46 ip6_address_t *
a = va_arg (*args, ip6_address_t *);
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;
55 if (a->as_u16[
i] == 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;
115 ip6_address_t *
a = va_arg (*args, ip6_address_t *);
116 u8 l = va_arg (*args,
u32);
125 if (am->
addr.as_u64[0] == 0 && am->
addr.as_u64[1] == 0 &&
126 am->
mask.as_u64[0] == 0 && am->
mask.as_u64[1] == 0)
129 if (am->
mask.as_u64[0] == ~0 && am->
mask.as_u64[1] == ~0)
140 ip6_address_t *result = va_arg (*args, ip6_address_t *);
142 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
143 uword c, n_colon, double_colon_index;
145 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
146 double_colon_index =
ARRAY_LEN (hex_quads);
150 if (c >=
'0' && c <=
'9')
152 else if (c >=
'a' && c <=
'f')
153 hex_digit = c + 10 -
'a';
154 else if (c >=
'A' && c <=
'F')
155 hex_digit = c + 10 -
'A';
156 else if (c ==
':' && n_colon < 2)
165 if (n_hex_quads >=
ARRAY_LEN (hex_quads))
170 hex_quad = (hex_quad << 4) | hex_digit;
173 if (n_hex_digits >= 4)
184 if (double_colon_index <
ARRAY_LEN (hex_quads))
186 double_colon_index = n_hex_quads;
189 if (n_colon > 0 && n_hex_digits > 0)
191 hex_quads[n_hex_quads++] = hex_quad;
197 if (n_hex_digits > 0)
198 hex_quads[n_hex_quads++] = hex_quad;
204 if (double_colon_index <
ARRAY_LEN (hex_quads))
208 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
209 hex_quads[n_zero + i] = hex_quads[i];
211 for (i = 0; i < n_zero; i++)
214 hex_quads[double_colon_index +
i] = 0;
224 for (i = 0; i <
ARRAY_LEN (hex_quads); i++)
225 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
246 mask.as_u64[0] = mask.as_u64[1] = ~0;
250 am->
addr.as_u64[0] = addr.as_u64[0];
251 am->
addr.as_u64[1] = addr.as_u64[1];
252 am->
mask.as_u64[0] = mask.as_u64[0];
253 am->
mask.as_u64[1] = mask.as_u64[1];
262 u32 max_header_bytes = va_arg (*args,
u32);
263 u32 i, ip_version, traffic_class, flow_label;
267 if (max_header_bytes <
sizeof (ip[0]))
268 return format (s,
"IP header truncated");
273 s =
format (s,
"%U: %U -> %U",
279 ip_version = (i >> 28);
280 traffic_class = (i >> 20) & 0xff;
288 "\n%Utos 0x%02x, flow label 0x%x, hop limit %d, payload length %d",
293 if (max_header_bytes != 0 &&
sizeof (ip[0]) < max_header_bytes)
302 max_header_bytes - sizeof (ip[0]));
312 u8 **result = va_arg (*args,
u8 **);
320 old_length =
vec_len (*result);
321 vec_add2 (*result, p,
sizeof (ip[0]));
327 clib_host_to_net_u32 (6 << 28);
329 if (!
unformat (input,
"%U: %U -> %U",
342 clib_host_to_net_u32 ((i & 0xff) << 20);
363 ip = (
void *) *result + old_length;
368 clib_host_to_net_u16 (
vec_len (*result) - (old_length +
sizeof (ip[0])));
377 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
397 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
422 ip6_frag_hdr_t *
h = va_arg (*args, ip6_frag_hdr_t *);
423 u32 max_header_bytes = va_arg (*args,
u32);
426 header_bytes =
sizeof (h[0]);
427 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
428 return format (s,
"ipv6 frag header truncated");
432 "IPV6_FRAG_HDR: next_hdr: %u, rsv: %u, frag_offset_and_more: %u, id: %u",
433 h->next_hdr, h->rsv, h->fragment_offset_and_more,
434 clib_net_to_host_u32 (h->identification));
static void ip46_address_mask_ip4(ip46_address_t *ip46)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
static uword pow2_mask(uword x)
vl_api_fib_path_type_t type
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
sll srl srl sll sra u16x4 i
unformat_function_t * unformat_header
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)