X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fvnet%2Ffib%2Ffib_api.c;h=d46b9e23b04567f93ad4a695e938bc18b187136b;hb=e9cebdf4c12adf7962ab2a2053789c93d70c33d3;hp=cea54a20b3d0bdb4d481bd3263332e8f8d85a763;hpb=1f046dc117f10fe11d83bab0d61b29e6dcd035e3;p=vpp.git diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c index cea54a20b3d..d46b9e23b04 100644 --- a/src/vnet/fib/fib_api.c +++ b/src/vnet/fib/fib_api.c @@ -49,7 +49,7 @@ fib_path_api_parse (const vl_api_fib_path_t *in, path_flags = FIB_ROUTE_PATH_FLAG_NONE; next_hop_via_label = ntohl (in->via_label); - memset(out, 0, sizeof(*out)); + clib_memset(out, 0, sizeof(*out)); out->frp_sw_if_index = ~0; out->frp_proto = in->afi; @@ -207,7 +207,7 @@ void fib_api_path_encode (const fib_route_path_encode_t * api_rpath, vl_api_fib_path_t *out) { - memset (out, 0, sizeof (*out)); + clib_memset (out, 0, sizeof (*out)); switch (api_rpath->dpo.dpoi_type) { case DPO_RECEIVE: @@ -241,8 +241,7 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath, out->afi = api_rpath->rpath.frp_proto; fib_api_path_copy_next_hop (api_rpath, out); - if (~0 == api_rpath->rpath.frp_sw_if_index && - ip46_address_is_zero(&api_rpath->rpath.frp_addr)) + if (0 != api_rpath->rpath.frp_fib_index) { if ((DPO_PROTO_IP6 == api_rpath->rpath.frp_proto) || (DPO_PROTO_IP4 == api_rpath->rpath.frp_proto)) @@ -267,3 +266,34 @@ fib_api_path_encode (const fib_route_path_encode_t * api_rpath, } } +fib_protocol_t +fib_proto_from_api_address_family (int af) +{ + switch (clib_net_to_host_u32 (af)) + { + case ADDRESS_IP4: + return (FIB_PROTOCOL_IP4); + case ADDRESS_IP6: + return (FIB_PROTOCOL_IP6); + } + + ASSERT(0); + return (FIB_PROTOCOL_IP4); +} + +int +fib_proto_to_api_address_family (fib_protocol_t fproto) +{ + switch (fproto) + { + case FIB_PROTOCOL_IP4: + return (clib_net_to_host_u32 (ADDRESS_IP4)); + case FIB_PROTOCOL_IP6: + return (clib_net_to_host_u32 (ADDRESS_IP6)); + default: + break; + } + + ASSERT(0); + return (clib_net_to_host_u32 (ADDRESS_IP4)); +}