return (ip_address_union_decode (&in->un, in->af, out));
}
+void
+ip_address_decode2 (const vl_api_address_t * in, ip_address_t * out)
+{
+ switch (ip_address_union_decode (&in->un, in->af, &out->ip))
+ {
+ case IP46_TYPE_IP4:
+ out->version = AF_IP4;
+ break;
+ case IP46_TYPE_IP6:
+ out->version = AF_IP6;
+ break;
+ default:
+ break;
+ }
+}
+
static void
ip_address_union_encode (const ip46_address_t * in,
vl_api_address_family_t af,
ip_address_union_encode (in, out->af, &out->un);
}
+void
+ip_address_encode2 (const ip_address_t * in, vl_api_address_t * out)
+{
+ switch (in->version)
+ {
+ case AF_IP4:
+ out->af = clib_net_to_host_u32 (ADDRESS_IP4);
+ break;
+ case AF_IP6:
+ out->af = clib_net_to_host_u32 (ADDRESS_IP6);
+ break;
+ }
+ ip_address_union_encode (&in->ip, out->af, &out->un);
+}
+
void
ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out)
{
ip_address_decode (&in->address, &out->fp_addr);
}
+int
+ip_prefix_decode2 (const vl_api_prefix_t * in, ip_prefix_t * out)
+{
+ out->len = in->len;
+ ip_address_decode2 (&in->address, &out->addr);
+
+ if (!ip_prefix_validate (out))
+ return (VNET_API_ERROR_IP_PREFIX_INVALID);
+ return (0);
+}
+
void
ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out)
{
out->len = in->fp_len;
- ip_address_encode (&in->fp_addr,
- fib_proto_to_ip46 (in->fp_proto), &out->address);
+ ip46_type_t ip46_type;
+
+ switch (in->fp_proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ ip46_type = (IP46_TYPE_IP4);
+ break;
+ case FIB_PROTOCOL_IP6:
+ ip46_type = (IP46_TYPE_IP6);
+ break;
+ case FIB_PROTOCOL_MPLS:
+ ip46_type = (IP46_TYPE_ANY);
+ break;
+ default:
+ ip46_type = (IP46_TYPE_ANY);
+ }
+
+ ip_address_encode (&in->fp_addr, ip46_type, &out->address);
+}
+
+void
+ip_prefix_encode2 (const ip_prefix_t * in, vl_api_prefix_t * out)
+{
+ out->len = in->len;
+ ip_address_encode2 (&in->addr, &out->address);
}
void
out->fp_proto = (ADDRESS_IP6 == clib_net_to_host_u32 (in->af) ?
FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4);
out->fp_len = clib_net_to_host_u16 (in->grp_address_length);
+ out->___fp___pad = 0;
ip_address_union_decode (&in->grp_address, in->af, &out->fp_grp_addr);
ip_address_union_decode (&in->src_address, in->af, &out->fp_src_addr);