aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/srv6
diff options
context:
space:
mode:
authorFilip Tehlar <ftehlar@cisco.com>2021-09-02 10:32:40 +0000
committerOle Tr�an <otroan@employees.org>2021-09-28 10:01:49 +0000
commit850024bb846c193ada01f7237b3cfcd998e67d9c (patch)
treee44dc300aa752a376b2cd7af893a95978f7fed85 /src/vnet/srv6
parenta427690b80003303d2cf6278f512a027ec430d6d (diff)
sr: add API test files
Type: improvement Signed-off-by: Filip Tehlar <ftehlar@cisco.com> Change-Id: Iefc88107ae96915570ae425a527c3969f7ce7b1d
Diffstat (limited to 'src/vnet/srv6')
-rw-r--r--src/vnet/srv6/sr_test.c195
1 files changed, 195 insertions, 0 deletions
diff --git a/src/vnet/srv6/sr_test.c b/src/vnet/srv6/sr_test.c
new file mode 100644
index 00000000000..85f64e1e230
--- /dev/null
+++ b/src/vnet/srv6/sr_test.c
@@ -0,0 +1,195 @@
+/*
+ *------------------------------------------------------------------
+ * Copyright (c) 2021 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 <vat/vat.h>
+#include <vlibapi/api.h>
+#include <vlibmemory/api.h>
+#include <vppinfra/error.h>
+#include <vpp/api/types.h>
+#include <vnet/ip/ip_types_api.h>
+
+#define __plugin_msg_base sr_test_main.msg_id_base
+#include <vlibapi/vat_helper_macros.h>
+
+/* Declare message IDs */
+#include <vnet/format_fns.h>
+#include <vnet/srv6/sr.api_enum.h>
+#include <vnet/srv6/sr.api_types.h>
+
+#define vl_endianfun /* define message structures */
+#include <vnet/srv6/sr.api.h>
+#undef vl_endianfun
+
+typedef struct
+{
+ /* API message ID base */
+ u16 msg_id_base;
+ u32 ping_id;
+ vat_main_t *vat_main;
+} sr_test_main_t;
+
+static sr_test_main_t sr_test_main;
+
+static int
+api_sr_steering_add_del (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_set_encap_hop_limit (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_set_encap_source (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_policy_del (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_policy_mod (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_policy_add (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_localsids_dump (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_policies_dump (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_policies_with_sl_index_dump (vat_main_t *vam)
+{
+ return -1;
+}
+
+static int
+api_sr_steering_pol_dump (vat_main_t *vam)
+{
+ return -1;
+}
+
+static void
+vl_api_sr_policies_details_t_handler (vl_api_sr_policies_details_t *mp)
+{
+}
+
+static void
+vl_api_sr_localsids_details_t_handler (vl_api_sr_localsids_details_t *mp)
+{
+}
+
+static void
+vl_api_sr_policies_with_sl_index_details_t_handler (
+ vl_api_sr_policies_with_sl_index_details_t *mp)
+{
+}
+
+static void
+vl_api_sr_steering_pol_details_t_handler (vl_api_sr_steering_pol_details_t *mp)
+{
+}
+
+static int
+api_sr_localsid_add_del (vat_main_t *vam)
+{
+ unformat_input_t *i = vam->input;
+ vl_api_sr_localsid_add_del_t *mp;
+
+ u8 is_del;
+ ip6_address_t localsid;
+ u8 end_psp = 0;
+ u8 behavior = ~0;
+ u32 sw_if_index;
+ u32 fib_table = ~(u32) 0;
+ ip46_address_t nh_addr;
+ clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
+
+ bool nexthop_set = 0;
+
+ int ret;
+
+ while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (i, "del"))
+ is_del = 1;
+ else if (unformat (i, "address %U", unformat_ip6_address, &localsid))
+ ;
+ else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
+ nexthop_set = 1;
+ else if (unformat (i, "behavior %u", &behavior))
+ ;
+ else if (unformat (i, "sw_if_index %u", &sw_if_index))
+ ;
+ else if (unformat (i, "fib-table %u", &fib_table))
+ ;
+ else if (unformat (i, "end.psp %u", &behavior))
+ ;
+ else
+ break;
+ }
+
+ M (SR_LOCALSID_ADD_DEL, mp);
+
+ clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
+
+ if (nexthop_set)
+ {
+ clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
+ }
+ mp->behavior = behavior;
+ mp->sw_if_index = ntohl (sw_if_index);
+ mp->fib_table = ntohl (fib_table);
+ mp->end_psp = end_psp;
+ mp->is_del = is_del;
+
+ S (mp);
+ W (ret);
+ return ret;
+}
+
+#include <vnet/srv6/sr.api_test.c>
+
+VAT_REGISTER_FEATURE_FUNCTION (vat_sr_plugin_register);
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */