API refactoring : l2tp 26/4426/4
authorPavel Kotucek <pkotucek@cisco.com>
Tue, 20 Dec 2016 09:01:20 +0000 (10:01 +0100)
committerDamjan Marion <dmarion.lists@gmail.com>
Wed, 21 Dec 2016 22:47:32 +0000 (22:47 +0000)
Change-Id: I30d2785ceaf304b245192f9bce60e37e9da69023
Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
vnet/Makefile.am
vnet/vnet/l2tp/l2tp.api [new file with mode: 0644]
vnet/vnet/l2tp/l2tp_api.c [new file with mode: 0644]
vnet/vnet/vnet_all_api_h.h
vpp-api/java/Makefile.am
vpp/vpp-api/api.c
vpp/vpp-api/vpe.api

index 4425171..37798c9 100644 (file)
@@ -30,6 +30,8 @@ BUILT_SOURCES =                               \
  vnet/ip/ip.api.json                           \
  vnet/l2/l2.api.h                              \
  vnet/l2/l2.api.json                           \
+ vnet/l2tp/l2tp.api.h                          \
+ vnet/l2tp/l2tp.api.json                       \
  vnet/map/map.api.h                            \
  vnet/map/map.api.json                         \
  vnet/span/span.api.h                          \
@@ -487,11 +489,13 @@ libvnet_la_SOURCES +=                             \
  vnet/l2tp/l2tp.c                              \
  vnet/l2tp/encap.c                             \
  vnet/l2tp/decap.c                             \
- vnet/l2tp/pg.c
+ vnet/l2tp/pg.c                                        \
+ vnet/l2tp/l2tp_api.c
  
 nobase_include_HEADERS +=                      \
  vnet/l2tp/l2tp.h                              \
- vnet/l2tp/packet.h                            
+ vnet/l2tp/packet.h                            \
+ vnet/l2tp/l2tp.api.h  
 
 ########################################
 # Tunnel protocol: gre+mpls
@@ -964,12 +968,13 @@ api_DATA =                                        \
  vnet/interface.api.json                       \
  vnet/ip/ip.api.json                           \
  vnet/l2/l2.api.json                           \
+ vnet/l2tp/l2tp.api.json                       \
  vnet/map/map.api.json                         \
  vnet/span/span.api.json                       \
  vnet/unix/tap.api.json                                \
  vnet/vxlan/vxlan.api.json                     \
  vnet/vxlan-gpe/vxlan_gpe.api.json
+
 # The actual %.api.h rule is in .../build-data/packages/suffix-rules.mk
 # and requires a symbolic link at the top of the vnet source tree
 
diff --git a/vnet/vnet/l2tp/l2tp.api b/vnet/vnet/l2tp/l2tp.api
new file mode 100644 (file)
index 0000000..5a5a5a4
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2015-2016 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.
+ */
+
+/** \brief l2tpv3 tunnel interface create request
+    @param client_index - opaque cookie to identify the sender
+    @param context - sender context, to match reply w/ request
+    @param client_address - remote client tunnel ip address
+    @param client_address - local tunnel ip address
+    @param is_ipv6 - ipv6 if non-zero, else ipv4
+    @param local_session_id - local tunnel session id
+    @param remote_session_id - remote tunnel session id
+    @param local_cookie - local tunnel cookie
+    @param l2_sublayer_present - l2 sublayer is present in packets if non-zero
+    @param encap_vrf_id - fib identifier used for outgoing encapsulated packets
+*/
+define l2tpv3_create_tunnel
+{
+  u32 client_index;
+  u32 context;
+  u8 client_address[16];
+  u8 our_address[16];
+  u8 is_ipv6;
+  u32 local_session_id;
+  u32 remote_session_id;
+  u64 local_cookie;
+  u64 remote_cookie;
+  u8 l2_sublayer_present;
+  u32 encap_vrf_id;
+};
+
+/** \brief l2tpv3 tunnel interface create response
+    @param context - sender context, to match reply w/ request
+    @param retval - return code for the request
+    @param sw_if_index - index of the new tunnel interface
+*/
+define l2tpv3_create_tunnel_reply
+{
+  u32 context;
+  i32 retval;
+  u32 sw_if_index;
+};
+
+define l2tpv3_set_tunnel_cookies
+{
+  u32 client_index;
+  u32 context;
+  u32 sw_if_index;
+  u64 new_local_cookie;
+  u64 new_remote_cookie;
+};
+
+/** \brief L2TP tunnel set cookies response
+    @param context - sender context, to match reply w/ request
+    @param retval - return code for the request
+*/
+define l2tpv3_set_tunnel_cookies_reply
+{
+  u32 context;
+  i32 retval;
+};
+
+define sw_if_l2tpv3_tunnel_details
+{
+  u32 context;
+  u32 sw_if_index;
+  u8 interface_name[64];
+  u8 client_address[16];
+  u8 our_address[16];
+  u32 local_session_id;
+  u32 remote_session_id;
+  u64 local_cookie[2];
+  u64 remote_cookie;
+  u8 l2_sublayer_present;
+};
+
+define sw_if_l2tpv3_tunnel_dump
+{
+  u32 client_index;
+  u32 context;
+};
+
+define l2tpv3_interface_enable_disable
+{
+  u32 client_index;
+  u32 context;
+  u8 enable_disable;
+  u32 sw_if_index;
+};
+
+define l2tpv3_interface_enable_disable_reply
+{
+  u32 context;
+  i32 retval;
+};
+
+define l2tpv3_set_lookup_key
+{
+  u32 client_index;
+  u32 context;
+  /* 0 = ip6 src_address, 1 = ip6 dst_address, 2 = session_id */
+  u8 key;
+};
+
+define l2tpv3_set_lookup_key_reply
+{
+  u32 context;
+  i32 retval;
+};
+
+/*
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/l2tp/l2tp_api.c b/vnet/vnet/l2tp/l2tp_api.c
new file mode 100644 (file)
index 0000000..88d758c
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+ *------------------------------------------------------------------
+ * l2tp_api.c - l2tpv3 api
+ *
+ * Copyright (c) 2016 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/vnet.h>
+#include <vlibmemory/api.h>
+
+#include <vnet/interface.h>
+#include <vnet/api_errno.h>
+#include <vnet/l2tp/l2tp.h>
+
+#include <vnet/vnet_msg_enum.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
+
+#include <vlibapi/api_helper_macros.h>
+
+#define foreach_vpe_api_msg                             \
+_(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel)                           \
+_(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies)                 \
+_(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable)     \
+_(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
+_(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)
+
+static void
+send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
+                                 unix_shared_memory_queue_t * q,
+                                 l2t_session_t * s,
+                                 l2t_main_t * lm, u32 context)
+{
+  vl_api_sw_if_l2tpv3_tunnel_details_t *mp;
+  u8 *if_name = NULL;
+  vnet_sw_interface_t *si = NULL;
+
+  si = vnet_get_hw_sw_interface (lm->vnet_main, s->hw_if_index);
+
+  if_name = format (if_name, "%U",
+                   format_vnet_sw_interface_name, lm->vnet_main, si);
+
+  mp = vl_msg_api_alloc (sizeof (*mp));
+  memset (mp, 0, sizeof (*mp));
+  mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
+  strncpy ((char *) mp->interface_name,
+          (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
+  mp->sw_if_index = ntohl (si->sw_if_index);
+  mp->local_session_id = s->local_session_id;
+  mp->remote_session_id = s->remote_session_id;
+  mp->local_cookie[0] = s->local_cookie[0];
+  mp->local_cookie[1] = s->local_cookie[1];
+  mp->remote_cookie = s->remote_cookie;
+  clib_memcpy (mp->client_address, &s->client_address,
+              sizeof (s->client_address));
+  clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
+  mp->l2_sublayer_present = s->l2_sublayer_present;
+  mp->context = context;
+
+  vl_msg_api_send_shmem (q, (u8 *) & mp);
+}
+
+
+static void
+vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t *
+                                          mp)
+{
+  vpe_api_main_t *am = &vpe_api_main;
+  l2t_main_t *lm = &l2t_main;
+  unix_shared_memory_queue_t *q;
+  l2t_session_t *session;
+
+  q = vl_api_client_index_to_input_queue (mp->client_index);
+  if (q == 0)
+    return;
+
+  /* *INDENT-OFF* */
+  pool_foreach (session, lm->sessions,
+  ({
+    send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
+  }));
+  /* *INDENT-ON* */
+}
+
+static void vl_api_l2tpv3_create_tunnel_t_handler
+  (vl_api_l2tpv3_create_tunnel_t * mp)
+{
+  vl_api_l2tpv3_create_tunnel_reply_t *rmp;
+  l2t_main_t *lm = &l2t_main;
+  u32 sw_if_index = (u32) ~ 0;
+  int rv;
+
+  if (mp->is_ipv6 != 1)
+    {
+      rv = VNET_API_ERROR_UNIMPLEMENTED;
+      goto out;
+    }
+
+  u32 encap_fib_index;
+
+  if (mp->encap_vrf_id != ~0)
+    {
+      uword *p;
+      ip6_main_t *im = &ip6_main;
+      if (!
+         (p =
+          hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id))))
+       {
+         rv = VNET_API_ERROR_NO_SUCH_FIB;
+         goto out;
+       }
+      encap_fib_index = p[0];
+    }
+  else
+    {
+      encap_fib_index = ~0;
+    }
+
+  rv = create_l2tpv3_ipv6_tunnel (lm,
+                                 (ip6_address_t *) mp->client_address,
+                                 (ip6_address_t *) mp->our_address,
+                                 ntohl (mp->local_session_id),
+                                 ntohl (mp->remote_session_id),
+                                 clib_net_to_host_u64 (mp->local_cookie),
+                                 clib_net_to_host_u64 (mp->remote_cookie),
+                                 mp->l2_sublayer_present,
+                                 encap_fib_index, &sw_if_index);
+
+out:
+  /* *INDENT-OFF* */
+  REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
+  ({
+    rmp->sw_if_index = ntohl (sw_if_index);
+  }));
+  /* *INDENT-ON* */
+}
+
+static void vl_api_l2tpv3_set_tunnel_cookies_t_handler
+  (vl_api_l2tpv3_set_tunnel_cookies_t * mp)
+{
+  vl_api_l2tpv3_set_tunnel_cookies_reply_t *rmp;
+  l2t_main_t *lm = &l2t_main;
+  int rv;
+
+  VALIDATE_SW_IF_INDEX (mp);
+
+  rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index),
+                                 clib_net_to_host_u64 (mp->new_local_cookie),
+                                 clib_net_to_host_u64
+                                 (mp->new_remote_cookie));
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
+}
+
+static void vl_api_l2tpv3_interface_enable_disable_t_handler
+  (vl_api_l2tpv3_interface_enable_disable_t * mp)
+{
+  int rv;
+  vnet_main_t *vnm = vnet_get_main ();
+  vl_api_l2tpv3_interface_enable_disable_reply_t *rmp;
+
+  VALIDATE_SW_IF_INDEX (mp);
+
+  rv = l2tpv3_interface_enable_disable
+    (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
+}
+
+static void vl_api_l2tpv3_set_lookup_key_t_handler
+  (vl_api_l2tpv3_set_lookup_key_t * mp)
+{
+  int rv = 0;
+  l2t_main_t *lm = &l2t_main;
+  vl_api_l2tpv3_set_lookup_key_reply_t *rmp;
+
+  if (mp->key > L2T_LOOKUP_SESSION_ID)
+    {
+      rv = VNET_API_ERROR_INVALID_VALUE;
+      goto out;
+    }
+
+  lm->lookup_type = mp->key;
+
+out:
+  REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
+}
+
+/*
+ * l2tp_api_hookup
+ * Add vpe's API message handlers to the table.
+ * vlib has alread mapped shared memory and
+ * added the client registration handlers.
+ * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
+ */
+#define vl_msg_name_crc_list
+#include <vnet/vnet_all_api_h.h>
+#undef vl_msg_name_crc_list
+
+static void
+setup_message_id_table (api_main_t * am)
+{
+#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
+  foreach_vl_msg_name_crc_l2tp;
+#undef _
+}
+
+static clib_error_t *
+l2tp_api_hookup (vlib_main_t * vm)
+{
+  api_main_t *am = &api_main;
+
+#define _(N,n)                                                  \
+    vl_msg_api_set_handlers(VL_API_##N, #n,                     \
+                           vl_api_##n##_t_handler,              \
+                           vl_noop_handler,                     \
+                           vl_api_##n##_t_endian,               \
+                           vl_api_##n##_t_print,                \
+                           sizeof(vl_api_##n##_t), 1);
+  foreach_vpe_api_msg;
+#undef _
+
+  /*
+   * Set up the (msg_name, crc, message-id) table
+   */
+  setup_message_id_table (am);
+
+  return 0;
+}
+
+VLIB_API_INIT_FUNCTION (l2tp_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
index 379f6b0..7acbf28 100644 (file)
@@ -36,6 +36,7 @@
 #include <vnet/interface.api.h>
 #include <vnet/map/map.api.h>
 #include <vnet/l2/l2.api.h>
+#include <vnet/l2tp/l2tp.api.h>
 #include <vnet/span/span.api.h>
 #include <vnet/ip/ip.api.h>
 #include <vnet/unix/tap.api.h>
index 8a2d039..4542f41 100644 (file)
@@ -91,6 +91,7 @@ jvpp-core/io_fd_vpp_jvpp_core_JVppCoreImpl.h:         \
     $(prefix)/../vpp/vpp-api/vpe.api.json              \
     $(prefix)/../vnet/vnet/gre.api.json                        \
     $(prefix)/../vnet/vnet/ip.api.json                         \
+    $(prefix)/../vnet/vnet/l2tp.api.json               \
     $(prefix)/../vnet/vnet/tap.api.json                \
     $(prefix)/../vnet/vnet/vxlan.api.json              \
     $(prefix)/../vnet/vnet/vxlan_gpe.api.json
@@ -106,6 +107,7 @@ jvpp-core/io_fd_vpp_jvpp_core_JVppCoreImpl.h:               \
                    $(prefix)/../vnet/vnet/gre.api.json \
                    $(prefix)/../vnet/vnet/interface.api.json \
                    $(prefix)/../vnet/vnet/l2.api.json \
+                   $(prefix)/../vnet/vnet/l2tp.api.json \
                    $(prefix)/../vnet/vnet/map.api.json \
                    $(prefix)/../vnet/vnet/ip.api.json \
                    $(prefix)/../vnet/vnet/span.api.json \
index 69f3af6..8a05e0d 100644 (file)
@@ -49,7 +49,6 @@
 #include <vnet/vnet.h>
 #include <vnet/l2/l2_input.h>
 #include <vnet/l2/l2_bd.h>
-#include <vnet/l2tp/l2tp.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ip/ip6.h>
 #include <vnet/ip/ip6_neighbor.h>
@@ -184,11 +183,6 @@ _(CLASSIFY_SET_INTERFACE_IP_TABLE, classify_set_interface_ip_table)     \
 _(CLASSIFY_SET_INTERFACE_L2_TABLES, classify_set_interface_l2_tables)   \
 _(GET_NODE_INDEX, get_node_index)                                       \
 _(ADD_NODE_NEXT, add_node_next)                                                \
-_(L2TPV3_CREATE_TUNNEL, l2tpv3_create_tunnel)                           \
-_(L2TPV3_SET_TUNNEL_COOKIES, l2tpv3_set_tunnel_cookies)                 \
-_(L2TPV3_INTERFACE_ENABLE_DISABLE, l2tpv3_interface_enable_disable)     \
-_(L2TPV3_SET_LOOKUP_KEY, l2tpv3_set_lookup_key)                         \
-_(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump)                   \
 _(VXLAN_ADD_DEL_TUNNEL, vxlan_add_del_tunnel)                           \
 _(VXLAN_TUNNEL_DUMP, vxlan_tunnel_dump)                                 \
 _(L2_FIB_CLEAR_TABLE, l2_fib_clear_table)                               \
@@ -2552,63 +2546,6 @@ static void
   REPLY_MACRO (VL_API_L2_INTERFACE_VLAN_TAG_REWRITE_REPLY);
 }
 
-static void
-send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am,
-                                 unix_shared_memory_queue_t * q,
-                                 l2t_session_t * s,
-                                 l2t_main_t * lm, u32 context)
-{
-  vl_api_sw_if_l2tpv3_tunnel_details_t *mp;
-  u8 *if_name = NULL;
-  vnet_sw_interface_t *si = NULL;
-
-  si = vnet_get_hw_sw_interface (lm->vnet_main, s->hw_if_index);
-
-  if_name = format (if_name, "%U",
-                   format_vnet_sw_interface_name, lm->vnet_main, si);
-
-  mp = vl_msg_api_alloc (sizeof (*mp));
-  memset (mp, 0, sizeof (*mp));
-  mp->_vl_msg_id = ntohs (VL_API_SW_IF_L2TPV3_TUNNEL_DETAILS);
-  strncpy ((char *) mp->interface_name,
-          (char *) if_name, ARRAY_LEN (mp->interface_name) - 1);
-  mp->sw_if_index = ntohl (si->sw_if_index);
-  mp->local_session_id = s->local_session_id;
-  mp->remote_session_id = s->remote_session_id;
-  mp->local_cookie[0] = s->local_cookie[0];
-  mp->local_cookie[1] = s->local_cookie[1];
-  mp->remote_cookie = s->remote_cookie;
-  clib_memcpy (mp->client_address, &s->client_address,
-              sizeof (s->client_address));
-  clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address));
-  mp->l2_sublayer_present = s->l2_sublayer_present;
-  mp->context = context;
-
-  vl_msg_api_send_shmem (q, (u8 *) & mp);
-}
-
-
-static void
-vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t *
-                                          mp)
-{
-  vpe_api_main_t *am = &vpe_api_main;
-  l2t_main_t *lm = &l2t_main;
-  unix_shared_memory_queue_t *q;
-  l2t_session_t *session;
-
-  q = vl_api_client_index_to_input_queue (mp->client_index);
-  if (q == 0)
-    return;
-
-  /* *INDENT-OFF* */
-  pool_foreach (session, lm->sessions,
-  ({
-    send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context);
-  }));
-  /* *INDENT-ON* */
-}
-
 static void
 vl_api_l2_fib_table_entry_t_handler (vl_api_l2_fib_table_entry_t * mp)
 {
@@ -2812,114 +2749,6 @@ out:
   /* *INDENT-ON* */
 }
 
-static void vl_api_l2tpv3_create_tunnel_t_handler
-  (vl_api_l2tpv3_create_tunnel_t * mp)
-{
-  vl_api_l2tpv3_create_tunnel_reply_t *rmp;
-  l2t_main_t *lm = &l2t_main;
-  u32 sw_if_index = (u32) ~ 0;
-  int rv;
-
-  if (mp->is_ipv6 != 1)
-    {
-      rv = VNET_API_ERROR_UNIMPLEMENTED;
-      goto out;
-    }
-
-  u32 encap_fib_index;
-
-  if (mp->encap_vrf_id != ~0)
-    {
-      uword *p;
-      ip6_main_t *im = &ip6_main;
-      if (!
-         (p =
-          hash_get (im->fib_index_by_table_id, ntohl (mp->encap_vrf_id))))
-       {
-         rv = VNET_API_ERROR_NO_SUCH_FIB;
-         goto out;
-       }
-      encap_fib_index = p[0];
-    }
-  else
-    {
-      encap_fib_index = ~0;
-    }
-
-  rv = create_l2tpv3_ipv6_tunnel (lm,
-                                 (ip6_address_t *) mp->client_address,
-                                 (ip6_address_t *) mp->our_address,
-                                 ntohl (mp->local_session_id),
-                                 ntohl (mp->remote_session_id),
-                                 clib_net_to_host_u64 (mp->local_cookie),
-                                 clib_net_to_host_u64 (mp->remote_cookie),
-                                 mp->l2_sublayer_present,
-                                 encap_fib_index, &sw_if_index);
-
-out:
-  /* *INDENT-OFF* */
-  REPLY_MACRO2(VL_API_L2TPV3_CREATE_TUNNEL_REPLY,
-  ({
-    rmp->sw_if_index = ntohl (sw_if_index);
-  }));
-  /* *INDENT-ON* */
-}
-
-static void vl_api_l2tpv3_set_tunnel_cookies_t_handler
-  (vl_api_l2tpv3_set_tunnel_cookies_t * mp)
-{
-  vl_api_l2tpv3_set_tunnel_cookies_reply_t *rmp;
-  l2t_main_t *lm = &l2t_main;
-  int rv;
-
-  VALIDATE_SW_IF_INDEX (mp);
-
-  rv = l2tpv3_set_tunnel_cookies (lm, ntohl (mp->sw_if_index),
-                                 clib_net_to_host_u64 (mp->new_local_cookie),
-                                 clib_net_to_host_u64
-                                 (mp->new_remote_cookie));
-
-  BAD_SW_IF_INDEX_LABEL;
-
-  REPLY_MACRO (VL_API_L2TPV3_SET_TUNNEL_COOKIES_REPLY);
-}
-
-static void vl_api_l2tpv3_interface_enable_disable_t_handler
-  (vl_api_l2tpv3_interface_enable_disable_t * mp)
-{
-  int rv;
-  vnet_main_t *vnm = vnet_get_main ();
-  vl_api_l2tpv3_interface_enable_disable_reply_t *rmp;
-
-  VALIDATE_SW_IF_INDEX (mp);
-
-  rv = l2tpv3_interface_enable_disable
-    (vnm, ntohl (mp->sw_if_index), mp->enable_disable);
-
-  BAD_SW_IF_INDEX_LABEL;
-
-  REPLY_MACRO (VL_API_L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY);
-}
-
-static void vl_api_l2tpv3_set_lookup_key_t_handler
-  (vl_api_l2tpv3_set_lookup_key_t * mp)
-{
-  int rv = 0;
-  l2t_main_t *lm = &l2t_main;
-  vl_api_l2tpv3_set_lookup_key_reply_t *rmp;
-
-  if (mp->key > L2T_LOOKUP_SESSION_ID)
-    {
-      rv = VNET_API_ERROR_INVALID_VALUE;
-      goto out;
-    }
-
-  lm->lookup_type = mp->key;
-
-out:
-  REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY);
-}
-
 static void vl_api_vxlan_add_del_tunnel_t_handler
   (vl_api_vxlan_add_del_tunnel_t * mp)
 {
index 7a43090..aea080f 100644 (file)
@@ -31,6 +31,7 @@
  * VHOST-USER APIs: see .../vnet/devices/virtio/{vhost_user.api, vhost_user_api.c}
  * VXLAN GPE APIs: see .../vnet/vnet/vxlan-gpe/{vxlan_gpe.api, vxlan_gpe_api.c}
  * GRE APIs: see .../vnet/vnet/gre/{gre.api, gre_api.c}
+ * L2TP APIs: see .../vnet/vnet/l2tp/{l2tp.api, l2tp_api.c}
  */
 
 /** \brief Create a new subinterface with the given vlan id
@@ -1328,84 +1329,6 @@ define dhcp_proxy_config_2_reply
   i32 retval;
 };
 
-/** \brief l2tpv3 tunnel interface create request
-    @param client_index - opaque cookie to identify the sender
-    @param context - sender context, to match reply w/ request
-    @param client_address - remote client tunnel ip address
-    @param client_address - local tunnel ip address
-    @param is_ipv6 - ipv6 if non-zero, else ipv4
-    @param local_session_id - local tunnel session id
-    @param remote_session_id - remote tunnel session id
-    @param local_cookie - local tunnel cookie
-    @param l2_sublayer_present - l2 sublayer is present in packets if non-zero
-    @param encap_vrf_id - fib identifier used for outgoing encapsulated packets
-*/
-define l2tpv3_create_tunnel
-{
-  u32 client_index;
-  u32 context;
-  u8 client_address[16];
-  u8 our_address[16];
-  u8 is_ipv6;
-  u32 local_session_id;
-  u32 remote_session_id;
-  u64 local_cookie;
-  u64 remote_cookie;
-  u8 l2_sublayer_present;
-  u32 encap_vrf_id;
-};
-
-/** \brief l2tpv3 tunnel interface create response
-    @param context - sender context, to match reply w/ request
-    @param retval - return code for the request
-    @param sw_if_index - index of the new tunnel interface
-*/
-define l2tpv3_create_tunnel_reply
-{
-  u32 context;
-  i32 retval;
-  u32 sw_if_index;
-};
-
-define l2tpv3_set_tunnel_cookies
-{
-  u32 client_index;
-  u32 context;
-  u32 sw_if_index;
-  u64 new_local_cookie;
-  u64 new_remote_cookie;
-};
-
-/** \brief L2TP tunnel set cookies response
-    @param context - sender context, to match reply w/ request
-    @param retval - return code for the request
-*/
-define l2tpv3_set_tunnel_cookies_reply
-{
-  u32 context;
-  i32 retval;
-};
-
-define sw_if_l2tpv3_tunnel_details
-{
-  u32 context;
-  u32 sw_if_index;
-  u8 interface_name[64];
-  u8 client_address[16];
-  u8 our_address[16];
-  u32 local_session_id;
-  u32 remote_session_id;
-  u64 local_cookie[2];
-  u64 remote_cookie;
-  u8 l2_sublayer_present;
-};
-
-define sw_if_l2tpv3_tunnel_dump
-{
-  u32 client_index;
-  u32 context;
-};
-
 /** \brief L2 fib clear table request, clear all mac entries in the l2 fib
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request
@@ -1450,34 +1373,6 @@ define l2_interface_efp_filter_reply
   i32 retval;
 };
 
-define l2tpv3_interface_enable_disable
-{
-  u32 client_index;
-  u32 context;
-  u8 enable_disable;
-  u32 sw_if_index;
-};
-
-define l2tpv3_interface_enable_disable_reply
-{
-  u32 context;
-  i32 retval;
-};
-
-define l2tpv3_set_lookup_key
-{
-  u32 client_index;
-  u32 context;
-  /* 0 = ip6 src_address, 1 = ip6 dst_address, 2 = session_id */
-  u8 key;
-};
-
-define l2tpv3_set_lookup_key_reply
-{
-  u32 context;
-  i32 retval;
-};
-
 /** \brief L2 interface vlan tag rewrite configure request
     @param client_index - opaque cookie to identify the sender
     @param context - sender context, to match reply w/ request