aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/fib/fib_api.c31
-rw-r--r--src/vnet/fib/fib_api.h3
2 files changed, 34 insertions, 0 deletions
diff --git a/src/vnet/fib/fib_api.c b/src/vnet/fib/fib_api.c
index eca5e614531..3c832eb01fb 100644
--- a/src/vnet/fib/fib_api.c
+++ b/src/vnet/fib/fib_api.c
@@ -266,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));
+}
diff --git a/src/vnet/fib/fib_api.h b/src/vnet/fib/fib_api.h
index 66f0b51e891..041f962e3d7 100644
--- a/src/vnet/fib/fib_api.h
+++ b/src/vnet/fib/fib_api.h
@@ -73,4 +73,7 @@ struct _vl_api_fib_path;
extern int fib_path_api_parse(const struct _vl_api_fib_path *in,
fib_route_path_t *out);
+extern fib_protocol_t fib_proto_from_api_address_family (int af);
+extern int fib_proto_to_api_address_family (fib_protocol_t fproto);
+
#endif /* __FIB_API_H__ */