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)
141 ip6_address_t *result = va_arg (*args, ip6_address_t *);
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]);
236 ip6_address_t
addr, mask;
247 mask.as_u64[0] = mask.as_u64[1] = ~0;
251 am->
addr.as_u64[0] = addr.as_u64[0];
252 am->
addr.as_u64[1] = addr.as_u64[1];
253 am->
mask.as_u64[0] = mask.as_u64[0];
254 am->
mask.as_u64[1] = mask.as_u64[1];
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 *);
423 ip6_frag_hdr_t *
h = va_arg (*args, ip6_frag_hdr_t *);
424 u32 max_header_bytes = va_arg (*args,
u32);
427 header_bytes =
sizeof (h[0]);
428 if (max_header_bytes != 0 && header_bytes > max_header_bytes)
429 return format (s,
"ipv6 frag header truncated");
433 "IPV6_FRAG_HDR: next_hdr: %u, rsv: %u, frag_offset_and_more: %u, id: %u",
434 h->next_hdr, h->rsv, h->fragment_offset_and_more,
435 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)