1 /* SPDX-License-Identifier: Apache-2.0
2 * Copyright(c) 2022 Cisco Systems, Inc.
6 #include <vlibmemory/api.h>
7 #include <vnet/srv6/sr_pt.h>
9 #include <vnet/interface.h>
10 #include <vnet/api_errno.h>
12 #include <vnet/srv6/sr_pt.api_enum.h>
13 #include <vnet/srv6/sr_pt.api_types.h>
15 #define REPLY_MSG_ID_BASE sr_pt_main.msg_id_base
16 #include <vlibapi/api_helper_macros.h>
19 send_sr_pt_iface_details (sr_pt_iface_t *t, vl_api_registration_t *reg,
22 vl_api_sr_pt_iface_details_t *rmp;
24 rmp = vl_msg_api_alloc (sizeof (*rmp));
25 clib_memset (rmp, 0, sizeof (*rmp));
26 rmp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_SR_PT_IFACE_DETAILS);
28 rmp->sw_if_index = ntohl (t->iface);
29 rmp->id = ntohs (t->id);
30 rmp->ingress_load = t->ingress_load;
31 rmp->egress_load = t->egress_load;
32 rmp->tts_template = t->tts_template;
34 rmp->context = context;
36 vl_api_send_msg (reg, (u8 *) rmp);
40 vl_api_sr_pt_iface_dump_t_handler (vl_api_sr_pt_iface_dump_t *mp)
42 vl_api_registration_t *reg;
43 sr_pt_main_t *pt = &sr_pt_main;
46 reg = vl_api_client_index_to_registration (mp->client_index);
50 pool_foreach (t, pt->sr_pt_iface)
52 send_sr_pt_iface_details (t, reg, mp->context);
57 vl_api_sr_pt_iface_add_t_handler (vl_api_sr_pt_iface_add_t *mp)
59 vl_api_sr_pt_iface_add_reply_t *rmp;
62 VALIDATE_SW_IF_INDEX (mp);
64 rv = sr_pt_add_iface (ntohl (mp->sw_if_index), ntohs (mp->id),
65 mp->ingress_load, mp->egress_load, mp->tts_template);
67 BAD_SW_IF_INDEX_LABEL;
68 REPLY_MACRO (VL_API_SR_PT_IFACE_ADD_REPLY);
72 vl_api_sr_pt_iface_del_t_handler (vl_api_sr_pt_iface_del_t *mp)
74 vl_api_sr_pt_iface_del_reply_t *rmp;
77 VALIDATE_SW_IF_INDEX (mp);
79 rv = sr_pt_del_iface (ntohl (mp->sw_if_index));
81 BAD_SW_IF_INDEX_LABEL;
82 REPLY_MACRO (VL_API_SR_PT_IFACE_DEL_REPLY);
85 #include <vnet/srv6/sr_pt.api.c>
87 sr_pt_api_hookup (vlib_main_t *vm)
90 * Set up the (msg_name, crc, message-id) table
92 REPLY_MSG_ID_BASE = setup_message_id_table ();
97 VLIB_API_INIT_FUNCTION (sr_pt_api_hookup);