diff options
author | Neale Ranns <nranns@cisco.com> | 2019-05-15 02:13:37 -0700 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-05-28 13:30:44 +0000 |
commit | 50f0ac0f097e5495da1f2b1816106e3d420ff34b (patch) | |
tree | d10ae0385fc10b7da97b2a24f8dea3882f6d702d /src/vnet/ip/ip_types_api.c | |
parent | 9080096f7c548415fc4d5354c7e582a3eda1a5ed (diff) |
Punt: socket register for exception dispatched/punted packets based on reason
- add to the Punt API to allow different descriptions of the desired packets: UDP or exceptions
- move the punt nodes into punt_node.c
- improve tests (test that the correct packets are punted to the registered socket)
Change-Id: I1a133dec88106874993cba1f5a439cd26b2fef72
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip_types_api.c')
-rw-r--r-- | src/vnet/ip/ip_types_api.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/vnet/ip/ip_types_api.c b/src/vnet/ip/ip_types_api.c index b56101c355f..d84c1ff9126 100644 --- a/src/vnet/ip/ip_types_api.c +++ b/src/vnet/ip/ip_types_api.c @@ -13,6 +13,7 @@ * limitations under the License. */ +#include <vlibapi/api_types.h> #include <vnet/ip/ip_types_api.h> #define vl_typedefs /* define message structures */ @@ -29,6 +30,72 @@ #include <vnet/vnet_all_api_h.h> #undef vl_printfun +int +ip_address_family_decode (int _af, ip_address_family_t * out) +{ + vl_api_address_family_t af = clib_host_to_net_u32 (_af); + + switch (af) + { + case ADDRESS_IP4: + *out = AF_IP4; + return (0); + case ADDRESS_IP6: + *out = AF_IP6; + return (0); + } + return (-1); +} + +int +ip_address_family_encode (ip_address_family_t af) +{ + switch (af) + { + case AF_IP4: + return (clib_host_to_net_u32 (ADDRESS_IP4)); + case AF_IP6: + return (clib_host_to_net_u32 (ADDRESS_IP6)); + } + + ASSERT (0); + return (clib_host_to_net_u32 (ADDRESS_IP4)); +} + +int +ip_proto_decode (int _ipp, ip_protocol_t * out) +{ + vl_api_ip_proto_t ipp = clib_host_to_net_u32 (_ipp); + + switch (ipp) + { + case IP_API_PROTO_TCP: + *out = IP_PROTOCOL_TCP; + return (0); + case IP_API_PROTO_UDP: + *out = IP_PROTOCOL_UDP; + return (0); + } + return (-1); +} + +int +ip_proto_encode (ip_protocol_t ipp) +{ + switch (ipp) + { + case IP_PROTOCOL_UDP: + return (clib_host_to_net_u32 (IP_API_PROTO_UDP)); + case IP_PROTOCOL_TCP: + return (clib_host_to_net_u32 (IP_API_PROTO_TCP)); + default: + break; + } + + ASSERT (0); + return (clib_host_to_net_u32 (IP_API_PROTO_TCP)); +} + void ip6_address_encode (const ip6_address_t * in, vl_api_ip6_address_t out) { |