aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip_types_api.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-06-07 23:48:20 -0700
committerFlorin Coras <florin.coras@gmail.com>2018-07-09 21:10:53 +0000
commit947ea6222dad1ef04595c34273e9231395aef443 (patch)
tree8990854b2901ff8cc2241b9abfc99b0b4b54d517 /src/vnet/ip/ip_types_api.c
parentdd47ecadcf63772a6037a1bb3715772d80e87f51 (diff)
IGMP improvements
- Enable/Disable an interface for IGMP - improve logging - refactor common code - no orphaned timers - IGMP state changes in main thread only - Large groups split over multiple state-change reports - SSM range configuration API. - more tests Change-Id: If5674f1044e7e97274a711f47807c9ba689d7b9a Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip/ip_types_api.c')
-rw-r--r--src/vnet/ip/ip_types_api.c105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/vnet/ip/ip_types_api.c b/src/vnet/ip/ip_types_api.c
new file mode 100644
index 00000000000..7fa8e404c78
--- /dev/null
+++ b/src/vnet/ip/ip_types_api.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2018 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vnet/ip/ip_types_api.h>
+
+#define vl_typedefs /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_typedefs
+
+#define vl_endianfun /* define message structures */
+#include <vnet/vnet_all_api_h.h>
+#undef vl_endianfun
+
+/* instantiate all the print functions we know about */
+#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
+#define vl_printfun
+#include <vnet/vnet_all_api_h.h>
+#undef vl_printfun
+
+
+void
+ip_address_decode (const vl_api_address_t * in, ip46_address_t * out)
+{
+ switch (in->af)
+ {
+ case ADDRESS_IP4:
+ memset (out, 0, sizeof (*out));
+ clib_memcpy (&out->ip4, &in->un.ip4, sizeof (out->ip4));
+ break;
+ case ADDRESS_IP6:
+ clib_memcpy (&out->ip6, &in->un.ip6, sizeof (out->ip6));
+ break;
+ }
+}
+
+void
+ip_address_encode (const ip46_address_t * in, vl_api_address_t * out)
+{
+ if (ip46_address_is_ip4 (in))
+ {
+ memset (out, 0, sizeof (*out));
+ out->af = ADDRESS_IP4;
+ clib_memcpy (&out->un.ip4, &in->ip4, sizeof (out->un.ip4));
+ }
+ else
+ {
+ out->af = ADDRESS_IP6;
+ clib_memcpy (&out->un.ip6, &in->ip6, sizeof (out->un.ip6));
+ }
+}
+
+void
+ip_prefix_decode (const vl_api_prefix_t * in, fib_prefix_t * out)
+{
+ switch (in->address.af)
+ {
+ case ADDRESS_IP4:
+ out->fp_proto = FIB_PROTOCOL_IP4;
+ break;
+ case ADDRESS_IP6:
+ out->fp_proto = FIB_PROTOCOL_IP6;
+ break;
+ }
+ out->fp_len = in->address_length;
+ ip_address_decode (&in->address, &out->fp_addr);
+}
+
+void
+ip_prefix_encode (const fib_prefix_t * in, vl_api_prefix_t * out)
+{
+ switch (in->fp_proto)
+ {
+ case FIB_PROTOCOL_IP4:
+ out->address.af = ADDRESS_IP4;
+ break;
+ case FIB_PROTOCOL_IP6:
+ out->address.af = ADDRESS_IP6;
+ break;
+ case FIB_PROTOCOL_MPLS:
+ ASSERT (0);
+ break;
+ }
+ out->address_length = in->fp_len;
+ ip_address_encode (&in->fp_addr, &out->address);
+}
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */