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 format (s,
" (should be 0x%04x)",
159 s =
format (s,
" dscp %U ecn %U",
167 s =
format (s,
"\n%Ufragment id 0x%04x",
172 o = 8 * (f & 0x1fff);
175 s =
format (s,
" offset %d", o);
179 s =
format (s,
", flags ");
180 #define _(l) if (f & IP4_HEADER_FLAG_##l) s = format (s, #l); 192 if (max_header_bytes != 0 && header_bytes < max_header_bytes)
200 (
void *) ip + header_bytes,
201 max_header_bytes - header_bytes);
211 u8 **result = va_arg (*args,
u8 **);
219 old_length =
vec_len (*result);
227 if (!
unformat (input,
"%U: %U -> %U",
244 else if (
unformat (input,
"fragment id %U offset %U",
249 clib_host_to_net_u16 ((i / 8) & 0x1fff);
284 ip = (
void *) *result + old_length;
289 ip->
length = clib_host_to_net_u16 (
vec_len (*result) - old_length);
static ip_dscp_t ip4_header_get_dscp(const ip4_header_t *ip4)
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 uword ip4_header_checksum_is_valid(ip4_header_t *i)
description fragment has unexpected format
u8 * format_ip_dscp(u8 *s, va_list *va)
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
u8 * format_ip_ecn(u8 *s, va_list *va)
sll srl srl sll sra u16x4 i
unformat_function_t * unformat_header
#define IP4_HEADER_FLAG_CONGESTION
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static ip_ecn_t ip4_header_get_ecn(const ip4_header_t *ip4)
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static u16 ip4_header_checksum(ip4_header_t *i)