45 u8 *
a = va_arg (*args,
u8 *);
46 return format (s,
"%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
52 u8 *
a = va_arg (*args,
u8 *);
53 u8 l = va_arg (*args,
u32);
60 u8 * result = va_arg (*args,
u8 *);
63 if (!
unformat (input,
"%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
66 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
81 u32 max_header_bytes = va_arg (*args,
u32);
82 u32 ip_version, header_bytes;
86 if (max_header_bytes <
sizeof (ip[0]))
87 return format (s,
"IP header truncated");
95 s =
format (s,
"%U: %U -> %U",
101 if (ip_version != 4 || header_bytes !=
sizeof (
ip4_header_t))
102 s =
format (s,
"\n%Uversion %d, header length %d",
104 ip_version, header_bytes);
106 s =
format (s,
"\n%Utos 0x%02x, ttl %d, length %d, checksum 0x%04x",
109 clib_net_to_host_u16 (ip->
length),
110 clib_net_to_host_u16 (ip->
checksum));
116 s =
format (s,
" (should be 0x%04x)", clib_net_to_host_u16 (c));
123 s =
format (s,
"\n%Ufragment id 0x%04x",
128 o = 8 * (f & 0x1fff);
131 s =
format (s,
" offset %d", o);
135 s =
format (s,
", flags ");
136 #define _(l) if (f & IP4_HEADER_FLAG_##l) s = format (s, #l); 145 if (max_header_bytes != 0 && header_bytes < max_header_bytes)
154 (
void*) ip + header_bytes,
155 max_header_bytes - header_bytes);
164 u8 ** result = va_arg (*args,
u8 **);
172 old_length =
vec_len (*result);
177 memset (ip, 0,
sizeof (ip[0]));
180 if (!
unformat (input,
"%U: %U -> %U",
197 else if (
unformat (input,
"fragment id %U offset %U",
203 clib_host_to_net_u16 ((i / 8) & 0x1fff);
235 ip = (
void *) *result + old_length;
240 ip->
length = clib_host_to_net_u16 (
vec_len (*result) - old_length);
sll srl srl sll sra u16x4 i
#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)