+int
+ip_address_family_decode (vl_api_address_family_t af,
+ ip_address_family_t * out)
+{
+ switch (af)
+ {
+ case ADDRESS_IP4:
+ *out = AF_IP4;
+ return (0);
+ case ADDRESS_IP6:
+ *out = AF_IP6;
+ return (0);
+ }
+ return (VNET_API_ERROR_INVALID_ADDRESS_FAMILY);
+}
+
+vl_api_address_family_t
+ip_address_family_encode (ip_address_family_t af)
+{
+ switch (af)
+ {
+ case AF_IP4:
+ return (ADDRESS_IP4);
+ case AF_IP6:
+ return (ADDRESS_IP6);
+ }
+
+ ASSERT (0);
+ return (ADDRESS_IP4);
+}
+
+int
+ip_proto_decode (vl_api_ip_proto_t ipp, ip_protocol_t * out)
+{
+ /* Not all protocol are defined in vl_api_ip_proto_t
+ * so we must cast to a different type.
+ */
+ switch ((u8) ipp)
+ {
+#define ip_protocol(n,s) \
+ case IP_PROTOCOL_##s: \
+ *out = IP_PROTOCOL_##s; \
+ return (0);
+#include "protocols.def"
+#undef ip_protocol
+ }
+ return (VNET_API_ERROR_INVALID_PROTOCOL);
+}
+
+vl_api_ip_proto_t
+ip_proto_encode (ip_protocol_t ipp)
+{
+ switch (ipp)
+ {
+#define ip_protocol(n,s) \
+ case IP_PROTOCOL_##s: \
+ return ((vl_api_ip_proto_t) IP_PROTOCOL_##s);
+#include "protocols.def"
+#undef ip_protocol
+ }
+
+ ASSERT (0);
+ return (IP_API_PROTO_TCP);
+}
+
+ip_dscp_t
+ip_dscp_decode (vl_api_ip_dscp_t in)
+{
+ return ((ip_dscp_t) in);
+}
+
+vl_api_ip_dscp_t
+ip_dscp_encode (ip_dscp_t dscp)
+{
+ return ((vl_api_ip_dscp_t) dscp);
+}
+
+int
+ip_feature_location_decode (vl_api_ip_feature_location_t loc,
+ ip_feature_location_t * out)
+{
+ /* Not all feature_locationcol are defined in vl_api_ip_feature_location_t
+ * so we must cast to a different type.
+ */
+ switch (loc)
+ {
+#define _(n,s) \
+ case IP_API_FEATURE_##n: \
+ *out = IP_FEATURE_##n; \
+ return (0);
+ foreach_ip_feature_location
+#undef _
+ }
+ return (VNET_API_ERROR_FEATURE_DISABLED);
+}
+
+vl_api_ip_feature_location_t
+ip_feature_location_encode (ip_feature_location_t loc)
+{
+ return ((vl_api_ip_feature_location_t) (loc));
+}
+
+
+void
+ip6_address_encode (const ip6_address_t * in, vl_api_ip6_address_t out)
+{
+ clib_memcpy (out, in, sizeof (*in));
+}
+
+void
+ip6_address_decode (const vl_api_ip6_address_t in, ip6_address_t * out)
+{
+ clib_memcpy (out, in, sizeof (*out));
+}
+
+void
+ip4_address_encode (const ip4_address_t * in, vl_api_ip4_address_t out)
+{
+ clib_memcpy (out, in, sizeof (*in));
+}
+
+void
+ip4_address_decode (const vl_api_ip4_address_t in, ip4_address_t * out)
+{
+ clib_memcpy (out, in, sizeof (*out));
+}
+