diff options
author | Klement Sekera <ksekera@cisco.com> | 2019-10-10 09:46:06 +0000 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-01-03 10:10:15 +0000 |
commit | f126e746fc01c75bc99329d10ce9127b26b23814 (patch) | |
tree | faf9f09a363add6e140f30e25187b330843b3d21 /src/vnet/ip/ip6_packet.h | |
parent | 3535501b19aec95dfd32870c784f841f57b5c045 (diff) |
nat: use SVR
Remove NAT's implementation of shallow virtual reassembly with
corresponding CLIs, APIs & tests. Replace with standalone shallow
virtual reassembly provided by ipX-sv-reass* nodes.
Type: refactor
Change-Id: I7e6c7487a5a500d591f6871474a359e0993e59b6
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip6_packet.h')
-rw-r--r-- | src/vnet/ip/ip6_packet.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/vnet/ip/ip6_packet.h b/src/vnet/ip/ip6_packet.h index 2ba55b75e09..e823214dac9 100644 --- a/src/vnet/ip/ip6_packet.h +++ b/src/vnet/ip/ip6_packet.h @@ -579,6 +579,67 @@ ip6_ext_header_find (vlib_main_t * vm, vlib_buffer_t * b, return result; } +/* + * walk extension headers, looking for a specific extension header and last + * extension header, calculating length of all extension headers + * + * @param vm + * @param b buffer to limit search to + * @param ip6_header ipv6 header + * @param find_hdr extension header to look for (ignored if ext_hdr is NULL) + * @param length[out] length of all extension headers + * @param ext_hdr[out] extension header of type find_hdr (may be NULL) + * @param last_ext_hdr[out] last extension header (may be NULL) + * + * @return 0 on success, -1 on failure (ext headers crossing buffer boundary) + */ +always_inline int +ip6_walk_ext_hdr (vlib_main_t * vm, vlib_buffer_t * b, + const ip6_header_t * ip6_header, u8 find_hdr, u32 * length, + ip6_ext_header_t ** ext_hdr, + ip6_ext_header_t ** last_ext_hdr) +{ + if (!ip6_ext_hdr (ip6_header->protocol)) + { + *length = 0; + *ext_hdr = NULL; + *last_ext_hdr = NULL; + return 0; + } + *length = 0; + ip6_ext_header_t *h = (void *) (ip6_header + 1); + if (!vlib_object_within_buffer_data (vm, b, h, ip6_ext_header_len (h))) + { + return -1; + } + *length += ip6_ext_header_len (h); + *last_ext_hdr = h; + *ext_hdr = NULL; + if (ip6_header->protocol == find_hdr) + { + *ext_hdr = h; + } + while (ip6_ext_hdr (h->next_hdr)) + { + if (h->next_hdr == find_hdr) + { + h = ip6_ext_next_header (h); + *ext_hdr = h; + } + else + { + h = ip6_ext_next_header (h); + } + if (!vlib_object_within_buffer_data (vm, b, h, ip6_ext_header_len (h))) + { + return -1; + } + *length += ip6_ext_header_len (h); + *last_ext_hdr = h; + } + return 0; +} + /* *INDENT-OFF* */ typedef CLIB_PACKED (struct { u8 next_hdr; |