X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fip_types_api.c;h=d84c1ff912641b4e5f02eecf83a8951f24fd1a74;hb=50f0ac0f0;hp=b56101c355f5f517e9b5a8136c67e95e93936be2;hpb=37029305c671f4e2d091d6f6c22142634e409043;p=vpp.git 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 #include #define vl_typedefs /* define message structures */ @@ -29,6 +30,72 @@ #include #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) {