X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip6_format.c;h=1a1bef26aa62f49ec99a0525ec6970fc246ad38b;hb=2f4586d9b3507243918c11ce99b9d151d5bde7a0;hp=b7ae2ffae2986ab625e74463fec8d8403af85193;hpb=d3c008d108aa2187d1a2afe2833b4de25ca2c2ab;p=vpp.git diff --git a/src/vnet/ip/ip6_format.c b/src/vnet/ip/ip6_format.c index b7ae2ffae29..1a1bef26aa6 100644 --- a/src/vnet/ip/ip6_format.c +++ b/src/vnet/ip/ip6_format.c @@ -117,6 +117,22 @@ format_ip6_address_and_length (u8 * s, va_list * args) return format (s, "%U/%d", format_ip6_address, a, l); } +u8 * +format_ip6_address_and_mask (u8 * s, va_list * args) +{ + ip6_address_and_mask_t *am = va_arg (*args, ip6_address_and_mask_t *); + + if (am->addr.as_u64[0] == 0 && am->addr.as_u64[1] == 0 && + am->mask.as_u64[0] == 0 && am->mask.as_u64[1] == 0) + return format (s, "any"); + + if (am->mask.as_u64[0] == ~0 && am->mask.as_u64[1] == ~0) + return format (s, "%U", format_ip6_address, &am->addr); + + return format (s, "%U/%U", format_ip6_address, &am->addr, + format_ip6_address, &am->mask); +} + /* Parse an IP6 address. */ uword unformat_ip6_address (unformat_input_t * input, va_list * args) @@ -212,6 +228,32 @@ unformat_ip6_address (unformat_input_t * input, va_list * args) } } +uword +unformat_ip6_address_and_mask (unformat_input_t * input, va_list * args) +{ + ip6_address_and_mask_t *am = va_arg (*args, ip6_address_and_mask_t *); + ip6_address_t addr, mask; + + clib_memset (&addr, 0, sizeof (ip6_address_t)); + clib_memset (&mask, 0, sizeof (ip6_address_t)); + + if (unformat (input, "any")) + ; + else if (unformat (input, "%U/%U", unformat_ip6_address, &addr, + unformat_ip6_address, &mask)) + ; + else if (unformat (input, "%U", unformat_ip6_address, &addr)) + mask.as_u64[0] = mask.as_u64[1] = ~0; + else + return 0; + + am->addr.as_u64[0] = addr.as_u64[0]; + am->addr.as_u64[1] = addr.as_u64[1]; + am->mask.as_u64[0] = mask.as_u64[0]; + am->mask.as_u64[1] = mask.as_u64[1]; + return 1; +} + /* Format an IP6 header. */ u8 * format_ip6_header (u8 * s, va_list * args) @@ -246,7 +288,7 @@ format_ip6_header (u8 * s, va_list * args) "\n%Utos 0x%02x, flow label 0x%x, hop limit %d, payload length %d", format_white_space, indent, traffic_class, flow_label, ip->hop_limit, clib_net_to_host_u16 (ip->payload_length)); - +#if 0 /* Recurse into next protocol layer. */ if (max_header_bytes != 0 && sizeof (ip[0]) < max_header_bytes) { @@ -259,7 +301,7 @@ format_ip6_header (u8 * s, va_list * args) /* next protocol header */ (void *) (ip + 1), max_header_bytes - sizeof (ip[0])); } - +#endif return s; } @@ -280,7 +322,7 @@ unformat_ip6_header (unformat_input_t * input, va_list * args) ip = p; } - memset (ip, 0, sizeof (ip[0])); + clib_memset (ip, 0, sizeof (ip[0])); ip->ip_version_traffic_class_and_flow_label = clib_host_to_net_u32 (6 << 28); @@ -374,6 +416,25 @@ format_ip46_address (u8 * s, va_list * args) format (s, "%U", format_ip6_address, &ip46->ip6); } +u8 * +format_ip6_frag_hdr (u8 * s, va_list * args) +{ + ip6_frag_hdr_t *h = va_arg (*args, ip6_frag_hdr_t *); + u32 max_header_bytes = va_arg (*args, u32); + u32 header_bytes; + + header_bytes = sizeof (h[0]); + if (max_header_bytes != 0 && header_bytes > max_header_bytes) + return format (s, "ipv6 frag header truncated"); + + s = + format (s, + "IPV6_FRAG_HDR: next_hdr: %u, rsv: %u, frag_offset_and_more: %u, id: %u", + h->next_hdr, h->rsv, h->fragment_offset_and_more, + clib_net_to_host_u32 (h->identification)); + return s; +} + /* * fd.io coding-style-patch-verification: ON *