|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
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);
64 if (
am->addr.as_u32 == 0 &&
am->mask.as_u32 == 0)
67 if (
am->mask.as_u32 == ~0)
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");
132 ip_version = (
ip->ip_version_and_header_length >> 4);
133 header_bytes = (
ip->ip_version_and_header_length & 0xf) *
sizeof (
u32);
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",
164 u32 f = clib_net_to_host_u16 (
ip->flags_and_fragment_offset);
167 s =
format (s,
"\n%Ufragment id 0x%04x",
169 clib_net_to_host_u16 (
ip->fragment_id));
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",
247 ip->fragment_id = clib_host_to_net_u16 (
i);
248 ip->flags_and_fragment_offset |=
249 clib_host_to_net_u16 ((
i / 8) & 0x1fff);
254 ip->flags_and_fragment_offset |=
258 ip->flags_and_fragment_offset |=
262 ip->flags_and_fragment_offset |=
284 ip = (
void *) *result + old_length;
289 ip->length = clib_host_to_net_u16 (
vec_len (*result) - old_length);
vnet_interface_main_t * im
#define IP4_HEADER_FLAG_DONT_FRAGMENT
static uword ip4_header_checksum_is_valid(ip4_header_t *i)
static ip_protocol_info_t * ip_get_protocol_info(ip_main_t *im, u32 protocol)
format_function_t * format_header
u8 * format_ip_ecn(u8 *s, va_list *va)
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
unformat_function_t * unformat_header
description fragment has unexpected format
static ip_dscp_t ip4_header_get_dscp(const ip4_header_t *ip4)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static ip_ecn_t ip4_header_get_ecn(const ip4_header_t *ip4)
static u16 ip4_header_checksum(ip4_header_t *i)
#define IP4_HEADER_FLAG_CONGESTION
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
u8 * format_ip_dscp(u8 *s, va_list *va)