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);
78 u8 *result = va_arg (*args,
u8 *);
81 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
84 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
121 u32 max_header_bytes = va_arg (*args,
u32);
122 u32 ip_version, header_bytes;
126 if (max_header_bytes <
sizeof (ip[0]))
127 return format (s,
"IP header truncated");
135 s =
format (s,
"%U: %U -> %U",
141 if (ip_version != 4 || header_bytes !=
sizeof (
ip4_header_t))
142 s =
format (s,
"\n%Uversion %d, header length %d",
145 s =
format (s,
"\n%Utos 0x%02x, ttl %d, length %d, checksum 0x%04x",
148 clib_net_to_host_u16 (ip->
length),
149 clib_net_to_host_u16 (ip->
checksum));
155 s =
format (s,
" (should be 0x%04x)", clib_net_to_host_u16 (c));
162 s =
format (s,
"\n%Ufragment id 0x%04x",
167 o = 8 * (f & 0x1fff);
170 s =
format (s,
" offset %d", o);
174 s =
format (s,
", flags ");
175 #define _(l) if (f & IP4_HEADER_FLAG_##l) s = format (s, #l); 187 if (max_header_bytes != 0 && header_bytes < max_header_bytes)
195 (
void *) ip + header_bytes,
196 max_header_bytes - header_bytes);
206 u8 **result = va_arg (*args,
u8 **);
214 old_length =
vec_len (*result);
222 if (!
unformat (input,
"%U: %U -> %U",
239 else if (
unformat (input,
"fragment id %U offset %U",
244 clib_host_to_net_u16 ((i / 8) & 0x1fff);
279 ip = (
void *) *result + old_length;
284 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.
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
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)