46 u32 max_zero_run = 0, this_zero_run = 0;
47 int max_zero_run_index = -1, this_zero_run_index=0;
48 int in_zero_run = 0,
i;
49 int last_double_colon = 0;
62 this_zero_run_index =
i;
70 if (this_zero_run > max_zero_run && this_zero_run > 1)
72 max_zero_run_index = this_zero_run_index;
73 max_zero_run = this_zero_run;
83 if (this_zero_run > max_zero_run && this_zero_run > 1)
85 max_zero_run_index = this_zero_run_index;
86 max_zero_run = this_zero_run;
92 if (
i == max_zero_run_index)
95 i += max_zero_run - 1;
96 last_double_colon = 1;
101 (last_double_colon ||
i == 0) ?
"" :
":",
102 clib_net_to_host_u16 (a->
as_u16[
i]));
103 last_double_colon = 0;
114 u8 l = va_arg (*args,
u32);
123 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
124 uword c, n_colon, double_colon_index;
126 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
127 double_colon_index =
ARRAY_LEN (hex_quads);
131 if (c >=
'0' && c <=
'9')
133 else if (c >=
'a' && c <=
'f')
134 hex_digit = c + 10 -
'a';
135 else if (c >=
'A' && c <=
'F')
136 hex_digit = c + 10 -
'A';
137 else if (c ==
':' && n_colon < 2)
146 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
151 hex_quad = (hex_quad << 4) | hex_digit;
154 if (n_hex_digits >= 4)
165 if (double_colon_index <
ARRAY_LEN (hex_quads))
167 double_colon_index = n_hex_quads;
170 if (n_colon > 0 && n_hex_digits > 0)
172 hex_quads[n_hex_quads++] = hex_quad;
178 if (n_hex_digits > 0)
179 hex_quads[n_hex_quads++] = hex_quad;
185 if (double_colon_index <
ARRAY_LEN (hex_quads))
189 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
190 hex_quads[n_zero + i] = hex_quads[i];
192 for (i = 0; i < n_zero; i++)
195 hex_quads[double_colon_index +
i] = 0;
205 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
206 result->
as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
216 u32 max_header_bytes = va_arg (*args,
u32);
217 u32 i, ip_version, traffic_class, flow_label;
221 if (max_header_bytes <
sizeof (ip[0]))
222 return format (s,
"IP header truncated");
227 s =
format (s,
"%U: %U -> %U",
233 ip_version = (i >> 28);
234 traffic_class = (i >> 20) & 0xff;
238 s =
format (s,
"\n%Uversion %d",
241 s =
format (s,
"\n%Utos 0x%02x, flow label 0x%x, hop limit %d, payload length %d",
243 traffic_class, flow_label, ip->
hop_limit,
247 if (max_header_bytes != 0 &&
sizeof (ip[0]) < max_header_bytes)
257 max_header_bytes - sizeof (ip[0]));
266 u8 ** result = va_arg (*args,
u8 **);
274 old_length =
vec_len (*result);
275 vec_add2 (*result, p,
sizeof (ip[0]));
279 memset (ip, 0,
sizeof (ip[0]));
282 if (!
unformat (input,
"%U: %U -> %U",
315 ip = (
void *) *result + old_length;
327 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
343 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
sll srl srl sll sra u16x4 i
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static uword pow2_mask(uword x)
#define ip46_address_mask_ip4(ip46)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
#define ip46_address_is_ip4(ip46)
unformat_function_t * unformat_header
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)