* limitations under the License.
*/
+#include <vlibapi/api_types.h>
#include <vnet/ip/ip_types_api.h>
#define vl_typedefs /* define message structures */
#include <vnet/vnet_all_api_h.h>
#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)
+{
+ ip_protocol_t ipp = clib_host_to_net_u32 (_ipp);
+
+ switch (ipp)
+ {
+#define ip_protocol(n,s) \
+ case IP_PROTOCOL_##s: \
+ *out = IP_PROTOCOL_##s; \
+ return (0);
+#include "protocols.def"
+#undef ip_protocol
+ }
+ return (-1);
+}
+
+int
+ip_proto_encode (ip_protocol_t ipp)
+{
+ switch (ipp)
+ {
+#define ip_protocol(n,s) \
+ case IP_PROTOCOL_##s: \
+ return (clib_host_to_net_u32 (IP_PROTOCOL_##s));
+#include "protocols.def"
+#undef ip_protocol
+ }
+
+ ASSERT (0);
+ return (clib_host_to_net_u32 (IP_API_PROTO_TCP));
+}
+
+ip_dscp_t
+ip_dscp_decode (u8 in)
+{
+ return ((ip_dscp_t) in);
+}
+
+u8
+ip_dscp_encode (ip_dscp_t dscp)
+{
+ return (dscp);
+}
+
void
ip6_address_encode (const ip6_address_t * in, vl_api_ip6_address_t out)
{
out->fp_proto = FIB_PROTOCOL_IP6;
break;
}
- out->fp_len = in->address_length;
+ out->fp_len = in->len;
out->___fp___pad = 0;
ip_address_decode (&in->address, &out->fp_addr);
}
void
ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out)
{
- out->address_length = in->fp_len;
+ out->len = in->fp_len;
ip_address_encode (&in->fp_addr,
fib_proto_to_ip46 (in->fp_proto), &out->address);
}
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);
+
+ if (!ip46_address_is_zero (&out->fp_src_addr))
+ out->fp_len = (out->fp_proto == FIB_PROTOCOL_IP6 ? 256 : 64);
}
/*