46 u8 *
a = va_arg (*args,
u8 *);
47 return format (s,
"%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
54 u8 *
a = va_arg (*args,
u8 *);
55 u8 l = va_arg (*args,
u32);
63 u8 *result = va_arg (*args,
u8 *);
66 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
69 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
85 u32 max_header_bytes = va_arg (*args,
u32);
86 u32 ip_version, header_bytes;
90 if (max_header_bytes <
sizeof (ip[0]))
91 return format (s,
"IP header truncated");
99 s =
format (s,
"%U: %U -> %U",
105 if (ip_version != 4 || header_bytes !=
sizeof (
ip4_header_t))
106 s =
format (s,
"\n%Uversion %d, header length %d",
109 s =
format (s,
"\n%Utos 0x%02x, ttl %d, length %d, checksum 0x%04x",
112 clib_net_to_host_u16 (ip->
length),
113 clib_net_to_host_u16 (ip->
checksum));
119 s =
format (s,
" (should be 0x%04x)", clib_net_to_host_u16 (c));
126 s =
format (s,
"\n%Ufragment id 0x%04x",
131 o = 8 * (f & 0x1fff);
134 s =
format (s,
" offset %d", o);
138 s =
format (s,
", flags ");
139 #define _(l) if (f & IP4_HEADER_FLAG_##l) s = format (s, #l); 148 if (max_header_bytes != 0 && header_bytes < max_header_bytes)
156 (
void *) ip + header_bytes,
157 max_header_bytes - header_bytes);
167 u8 **result = va_arg (*args,
u8 **);
175 old_length =
vec_len (*result);
180 memset (ip, 0,
sizeof (ip[0]));
183 if (!
unformat (input,
"%U: %U -> %U",
200 else if (
unformat (input,
"fragment id %U offset %U",
205 clib_host_to_net_u16 ((i / 8) & 0x1fff);
240 ip = (
void *) *result + old_length;
245 ip->
length = clib_host_to_net_u16 (
vec_len (*result) - old_length);
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
unformat_function_t * unformat_header
#define IP4_HEADER_FLAG_CONGESTION
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static u16 ip4_header_checksum(ip4_header_t *i)