47 u32 max_zero_run = 0, this_zero_run = 0;
48 int max_zero_run_index = -1, this_zero_run_index = 0;
49 int in_zero_run = 0,
i;
50 int last_double_colon = 0;
63 this_zero_run_index =
i;
71 if (this_zero_run > max_zero_run && this_zero_run > 1)
73 max_zero_run_index = this_zero_run_index;
74 max_zero_run = this_zero_run;
84 if (this_zero_run > max_zero_run && this_zero_run > 1)
86 max_zero_run_index = this_zero_run_index;
87 max_zero_run = this_zero_run;
93 if (
i == max_zero_run_index)
96 i += max_zero_run - 1;
97 last_double_colon = 1;
102 (last_double_colon ||
i == 0) ?
"" :
":",
103 clib_net_to_host_u16 (a->
as_u16[
i]));
104 last_double_colon = 0;
116 u8 l = va_arg (*args,
u32);
143 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
144 uword c, n_colon, double_colon_index;
146 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
147 double_colon_index =
ARRAY_LEN (hex_quads);
151 if (c >=
'0' && c <=
'9')
153 else if (c >=
'a' && c <=
'f')
154 hex_digit = c + 10 -
'a';
155 else if (c >=
'A' && c <=
'F')
156 hex_digit = c + 10 -
'A';
157 else if (c ==
':' && n_colon < 2)
166 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
171 hex_quad = (hex_quad << 4) | hex_digit;
174 if (n_hex_digits >= 4)
185 if (double_colon_index <
ARRAY_LEN (hex_quads))
187 double_colon_index = n_hex_quads;
190 if (n_colon > 0 && n_hex_digits > 0)
192 hex_quads[n_hex_quads++] = hex_quad;
198 if (n_hex_digits > 0)
199 hex_quads[n_hex_quads++] = hex_quad;
205 if (double_colon_index <
ARRAY_LEN (hex_quads))
209 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
210 hex_quads[n_zero + i] = hex_quads[i];
212 for (i = 0; i < n_zero; i++)
215 hex_quads[double_colon_index +
i] = 0;
225 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
226 result->
as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
263 u32 max_header_bytes = va_arg (*args,
u32);
264 u32 i, ip_version, traffic_class, flow_label;
268 if (max_header_bytes <
sizeof (ip[0]))
269 return format (s,
"IP header truncated");
274 s =
format (s,
"%U: %U -> %U",
280 ip_version = (i >> 28);
281 traffic_class = (i >> 20) & 0xff;
289 "\n%Utos 0x%02x, flow label 0x%x, hop limit %d, payload length %d",
294 if (max_header_bytes != 0 &&
sizeof (ip[0]) < max_header_bytes)
303 max_header_bytes - sizeof (ip[0]));
313 u8 **result = va_arg (*args,
u8 **);
321 old_length =
vec_len (*result);
322 vec_add2 (*result, p,
sizeof (ip[0]));
328 clib_host_to_net_u32 (6 << 28);
330 if (!
unformat (input,
"%U: %U -> %U",
343 clib_host_to_net_u32 ((i & 0xff) << 20);
364 ip = (
void *) *result + old_length;
369 clib_host_to_net_u16 (
vec_len (*result) - (old_length +
sizeof (ip[0])));
378 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
398 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
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)