summaryrefslogtreecommitdiffstats
path: root/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'vnet')
-rw-r--r--vnet/Makefile.am21
l---------vnet/suffix-rules.mk1
-rw-r--r--vnet/vnet/interface.api31
-rw-r--r--vnet/vnet/interface_api.c122
-rw-r--r--vnet/vnet/vnet_all_api_h.h40
-rw-r--r--vnet/vnet/vnet_msg_enum.h37
6 files changed, 251 insertions, 1 deletions
diff --git a/vnet/Makefile.am b/vnet/Makefile.am
index d806785f6d7..a9481d11dc2 100644
--- a/vnet/Makefile.am
+++ b/vnet/Makefile.am
@@ -15,6 +15,8 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
AM_CFLAGS = -Wall -Werror @DPDK@ @DPDK_CRYPTO@ @IPSEC@ @IPV6SR@
+BUILT_SOURCES = vnet/interface.api.h
+
libvnet_la_SOURCES =
libvnetplugin_la_SOURCES =
nobase_include_HEADERS =
@@ -34,6 +36,7 @@ libvnet_la_SOURCES += \
vnet/devices/devices.c \
vnet/handoff.c \
vnet/interface.c \
+ vnet/interface_api.c \
vnet/interface_cli.c \
vnet/interface_format.c \
vnet/interface_output.c \
@@ -49,12 +52,15 @@ nobase_include_HEADERS += \
vnet/global_funcs.h \
vnet/handoff.h \
vnet/interface.h \
+ vnet/interface.api.h \
vnet/interface_funcs.h \
vnet/l3_types.h \
vnet/pipeline.h \
vnet/replication.h \
vnet/rewrite.h \
- vnet/vnet.h
+ vnet/vnet.h \
+ vnet/vnet_all_api_h.h \
+ vnet/vnet_msg_enum.h
########################################
# Policer infra
@@ -876,3 +882,16 @@ pcap2pg_LDFLAGS = -static
pcap2pg_LDADD = libvnet.la -l:libvppinfra.a -lpthread -lm -ldl
noinst_PROGRAMS += pcap2pg
+
+# Set the suffix list
+SUFFIXES = .api.h .api
+
+# install the API definition, so we can produce java bindings, etc.
+
+apidir = $(prefix)/vpp-api
+api_DATA = vnet/interface.api
+
+# 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
+
+include $(top_srcdir)/suffix-rules.mk
diff --git a/vnet/suffix-rules.mk b/vnet/suffix-rules.mk
new file mode 120000
index 00000000000..f609840001f
--- /dev/null
+++ b/vnet/suffix-rules.mk
@@ -0,0 +1 @@
+../build-data/suffix-rules.mk \ No newline at end of file
diff --git a/vnet/vnet/interface.api b/vnet/vnet/interface.api
new file mode 100644
index 00000000000..acc52a81724
--- /dev/null
+++ b/vnet/vnet/interface.api
@@ -0,0 +1,31 @@
+/* Hey Emacs use -*- mode: C -*- */
+
+/** \brief Set flags on the interface
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+ @param sw_if_index - index of the interface to set flags on
+ @param admin_up_down - set the admin state, 1 = up, 0 = down
+ @param link_up_down - Oper state sent on change event, not used in config.
+ @param deleted - interface was deleted
+*/
+define sw_interface_set_flags
+{
+ u32 client_index;
+ u32 context;
+ u32 sw_if_index;
+ /* 1 = up, 0 = down */
+ u8 admin_up_down;
+ u8 link_up_down;
+ u8 deleted;
+};
+
+/** \brief Reply to sw_interface_set_flags
+ @param context - sender context which was passed in the request
+ @param retval - return code of the set flags request
+*/
+define sw_interface_set_flags_reply
+{
+ u32 context;
+ i32 retval;
+};
+
diff --git a/vnet/vnet/interface_api.c b/vnet/vnet/interface_api.c
new file mode 100644
index 00000000000..eeb1d81d4d0
--- /dev/null
+++ b/vnet/vnet/interface_api.c
@@ -0,0 +1,122 @@
+/*
+ *------------------------------------------------------------------
+ * interface_api.c - vnet interface 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/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 \
+_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags)
+
+static void
+vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp)
+{
+ vl_api_sw_interface_set_flags_reply_t *rmp;
+ vnet_main_t *vnm = vnet_get_main ();
+ int rv = 0;
+ clib_error_t *error;
+ u16 flags;
+
+ VALIDATE_SW_IF_INDEX (mp);
+
+ flags = mp->admin_up_down ? VNET_SW_INTERFACE_FLAG_ADMIN_UP : 0;
+
+ error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
+ if (error)
+ {
+ rv = -1;
+ clib_error_report (error);
+ }
+
+ BAD_SW_IF_INDEX_LABEL;
+ REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
+}
+
+
+/*
+ * vpe_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_interface;
+#undef _
+}
+
+static clib_error_t *
+interface_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 (interface_api_hookup);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/vnet_all_api_h.h b/vnet/vnet/vnet_all_api_h.h
new file mode 100644
index 00000000000..0dacdc1f543
--- /dev/null
+++ b/vnet/vnet/vnet_all_api_h.h
@@ -0,0 +1,40 @@
+/*
+ *------------------------------------------------------------------
+ * vl_memory_api_h.h - memory API headers, in a specific order.
+ *
+ * Copyright (c) 2009-2010 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.
+ *------------------------------------------------------------------
+ */
+
+/*
+ * Add to the bottom of the #include list, or elves will steal your
+ * keyboard in the middle of the night!
+ *
+ * Include current layer (2) last, or an artistic disagreement
+ * about message numbering will occur
+ */
+
+#ifndef included_from_layer_3
+#include <vlibmemory/vl_memory_api_h.h>
+#endif /* included_from_layer_3 */
+
+#include <vnet/interface.api.h>
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
diff --git a/vnet/vnet/vnet_msg_enum.h b/vnet/vnet/vnet_msg_enum.h
new file mode 100644
index 00000000000..9899471ecd3
--- /dev/null
+++ b/vnet/vnet/vnet_msg_enum.h
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+#ifndef included_vnet_msg_enum_h
+#define included_vnet_msg_enum_h
+
+#include <vppinfra/byte_order.h>
+
+#define vl_msg_id(n,h) n,
+typedef enum
+{
+ VL_ILLEGAL_MESSAGE_ID = 0,
+#include <vnet/vnet_all_api_h.h>
+ VL_MSG_FIRST_AVAILABLE,
+} vl_msg_id_t;
+#undef vl_msg_id
+
+#endif /* included_vnet_msg_enum_h */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */