summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/ietf/ietf_interface.c369
-rw-r--r--src/plugins/openconfig/openconfig_interfaces.c192
-rw-r--r--src/plugins/openconfig/openconfig_local_routing.c21
-rw-r--r--src/plugins/openconfig/sys_util.h1
-rw-r--r--src/plugins/sc_model.h4
-rw-r--r--src/plugins/sc_plugins.c30
-rw-r--r--src/plugins/sc_plugins.h26
7 files changed, 153 insertions, 490 deletions
diff --git a/src/plugins/ietf/ietf_interface.c b/src/plugins/ietf/ietf_interface.c
index 728d20e..922c84f 100644
--- a/src/plugins/ietf/ietf_interface.c
+++ b/src/plugins/ietf/ietf_interface.c
@@ -18,50 +18,14 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <sysrepo.h>
-#include <sysrepo/plugins.h>
-#include <sysrepo/values.h>
-#include <sysrepo/xpath.h>
-#include <vnet/interface.h>
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vapi/interface.api.vapi.h>
-
#include "ietf_interface.h"
-DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON;
-
-typedef struct _s_vpp_interface_
-{
- u32 sw_if_index;
- char interface_name[VPP_INTFC_NAME_LEN];
- u8 l2_address[VPP_MAC_ADDRESS_LEN];
- u32 l2_address_length;
- u64 link_speed;
- u16 link_mtu;
- u8 admin_up_down;
- u8 link_up_down;
-} scVppIntfc;
-
-typedef struct _ietf_sw_interface_dump_ctx
-{
- u8 last_called;
- int num_ifs;
- int capacity;
- scVppIntfc * intfcArray;
-} ietf_sw_interface_dump_ctx;
-
-static i32 ietf_setInterfaceFlags(u32 sw_if_index, u8 admin_up_down);
-static i32 ietf_interface_name2index(const char *name, u32* if_index);
-static i32 ietf_interface_add_del_addr(u32 sw_if_index, u8 is_add, u8 is_ipv6,
- u8 del_all, u8 address_length,
- u8 address[VPP_IP6_ADDRESS_LEN]);
-static int ietf_swInterfaceDump(ietf_sw_interface_dump_ctx * dctx);
-static int ietf_initSwInterfaceDumpCTX(ietf_sw_interface_dump_ctx * dctx);
-static int ietf_freeSwInterfaceDumpCTX(ietf_sw_interface_dump_ctx * dctx);
+#include "sc_vpp_interface.h"
+#include "sc_vpp_ip.h"
/**
- * @brief Helper function for converting netmask into prefix length.
+ * @brief Helper function for converting netmask (ex: 255.255.255.0)
+ * to prefix length (ex: 24).
*/
static uint8_t
netmask_to_prefix(const char *netmask)
@@ -80,65 +44,12 @@ netmask_to_prefix(const char *netmask)
}
/**
- * @brief Helper function for converting IPv4/IPv6 address string into binary representation.
+ * @brief Callback to be called by any config change of
+ * "/ietf-interfaces:interfaces/interface/enabled" leaf.
*/
static int
-ip_addr_str_to_binary(const char *ip_address_str, uint8_t *ip_address_bin, bool is_ipv6)
-{
- struct in6_addr addr6 = { 0, };
- struct in_addr addr4 = { 0, };
- int ret = 0;
-
- if (is_ipv6) {
- ret = inet_pton(AF_INET6, ip_address_str, &(addr6));
- if (1 == ret)
- {
- memcpy(ip_address_bin, &addr6, sizeof(addr6));
- }
- } else {
- ret = inet_pton(AF_INET, ip_address_str, &(addr4));
- if (1 == ret)
- {
- memcpy(ip_address_bin, &addr4, sizeof(addr4));
- }
- }
-
- return ret;
-}
-
-/**
- * @brief Enable or disable given interface.
- */
-static int
-interface_enable_disable(const char *if_name, bool enable)
-{
- uint32_t if_index = ~0;
- int rc = 0;
-
- SRP_LOG_DBG("%s interface '%s'", enable ? "Enabling" : "Disabling", if_name);
-
- /* get interface index */
- rc = ietf_interface_name2index(if_name, &if_index);
- if (0 != rc) {
- SRP_LOG_ERR("Invalid interface name: %s", if_name);
- return SR_ERR_INVAL_ARG;
- }
-
- /* enable/disable interface */
- rc = ietf_setInterfaceFlags(if_index, (uint8_t)enable);
- if (0 != rc) {
- SRP_LOG_ERR("Error by processing of the sw_interface_set_flags request, rc=%d", rc);
- return SR_ERR_OPERATION_FAILED;
- } else {
- return SR_ERR_OK;
- }
-}
-
-/**
- * @brief Callback to be called by any config change of "/ietf-interfaces:interfaces/interface/enabled" leaf.
- */
-static int
-ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_event_t event, void *private_ctx)
+ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath,
+ sr_notif_event_t event, void *private_ctx)
{
char *if_name = NULL;
sr_change_iter_t *iter = NULL;
@@ -148,6 +59,7 @@ ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, s
sr_xpath_ctx_t xpath_ctx = { 0, };
int rc = SR_ERR_OK, op_rc = SR_ERR_OK;
+ SRP_LOG_INF("In %s", __FUNCTION__);
/* no-op for apply, we only care about SR_EV_ENABLED, SR_EV_VERIFY, SR_EV_ABORT */
if (SR_EV_APPLY == event) {
return SR_ERR_OK;
@@ -170,10 +82,10 @@ ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, s
switch (op) {
case SR_OP_CREATED:
case SR_OP_MODIFIED:
- op_rc = interface_enable_disable(if_name, new_val->data.bool_val);
+ op_rc = interface_enable(if_name, new_val->data.bool_val);
break;
case SR_OP_DELETED:
- op_rc = interface_enable_disable(if_name, false /* !enable */);
+ op_rc = interface_enable(if_name, false /* !enable */);
break;
default:
break;
@@ -190,45 +102,7 @@ ietf_interface_enable_disable_cb(sr_session_ctx_t *session, const char *xpath, s
return op_rc;
}
-/**
- * @brief Add or remove IPv4/IPv6 address to/from an interface.
- */
-static int
-interface_ipv46_config_add_remove(const char *if_name, uint8_t *addr, uint8_t prefix, bool is_ipv6, bool add)
-{
- uint32_t if_index = ~0;
- int rc = 0;
-
- SRP_LOG_DBG("%s IP config on interface '%s'.", add ? "Adding" : "Removing", if_name);
-
- /* get interface index */
- rc = ietf_interface_name2index(if_name, &if_index);
- if (0 != rc) {
- SRP_LOG_ERR("Invalid interface name: %s", if_name);
- return SR_ERR_INVAL_ARG;
- }
-
- /* add del addr */
- rc = ietf_interface_add_del_addr(if_index, (uint8_t)add, (uint8_t)is_ipv6, 0, prefix, addr);
- if (0 != rc) {
- SRP_LOG_ERR("Error by processing of the sw_interface_set_flags request, rc=%d", rc);
- return SR_ERR_OPERATION_FAILED;
- } else {
- return SR_ERR_OK;
- }
-}
-int ietf_initSwInterfaceDumpCTX(ietf_sw_interface_dump_ctx * dctx)
-{
- if(dctx == NULL)
- return -1;
-
- dctx->intfcArray = NULL;
- dctx->last_called = false;
- dctx->capacity = 0;
- dctx->num_ifs = 0;
- return 0;
-}
-int ietf_freeSwInterfaceDumpCTX(ietf_sw_interface_dump_ctx * dctx)
+static int free_sw_interface_dump_ctx(dump_all_ctx * dctx)
{
if(dctx == NULL)
return -1;
@@ -238,167 +112,22 @@ int ietf_freeSwInterfaceDumpCTX(ietf_sw_interface_dump_ctx * dctx)
free(dctx->intfcArray);
}
- return ietf_initSwInterfaceDumpCTX(dctx);
-}
-vapi_error_e
-ietf_sw_interface_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_sw_interface_details * reply)
-{
- ietf_sw_interface_dump_ctx *dctx = callback_ctx;
- if (is_last)
- {
- dctx->last_called = true;
- }
- else
- {
- if(dctx->capacity == 0 && dctx->intfcArray == NULL)
- {
- dctx->capacity = 10;
- dctx->intfcArray = (scVppIntfc*)malloc( sizeof(scVppIntfc)*dctx->capacity );
- }
- if(dctx->num_ifs >= dctx->capacity-1)
- {
-
- dctx->capacity += 10;
- dctx->intfcArray = (scVppIntfc*)realloc(dctx->intfcArray, sizeof(scVppIntfc)*dctx->capacity );
- }
-
- scVppIntfc * thisIntfc = &dctx->intfcArray[dctx->num_ifs];
-
- thisIntfc->sw_if_index = reply->sw_if_index;
- strncpy(thisIntfc->interface_name, reply->interface_name, VPP_INTFC_NAME_LEN);
- thisIntfc->l2_address_length = reply->l2_address_length;
- memcpy(thisIntfc->l2_address, reply->l2_address, reply->l2_address_length );
- //thisIntfc->link_speed = reply->link_speed;
-#define ONE_MEGABIT (uint64_t)1000000
- switch (reply->link_speed << VNET_HW_INTERFACE_FLAG_SPEED_SHIFT)
- {
- default:
- thisIntfc->link_speed = 0;
- break;
- }
-
- thisIntfc->link_mtu = reply->link_mtu;
- thisIntfc->admin_up_down = reply->admin_up_down;
- thisIntfc->link_up_down = reply->link_up_down;
-
- dctx->num_ifs += 1;
- }
- return VAPI_OK;
-}
-
-static int ietf_swInterfaceDump(ietf_sw_interface_dump_ctx * dctx)
-{
- if(dctx == NULL)
- {
- return -1;
- }
-
- //ietf_sw_interface_dump_ctx dctx = { false, 0, 0, 0 };
- vapi_msg_sw_interface_dump *dump;
- vapi_error_e rv;
- // dctx->last_called = false;
- ietf_initSwInterfaceDumpCTX(dctx);
- dump = vapi_alloc_sw_interface_dump (g_vapi_ctx_instance);
- dump->payload.name_filter_valid = 0;
- memset (dump->payload.name_filter, 0, sizeof (dump->payload.name_filter));
- while (VAPI_EAGAIN ==
- (rv =
- vapi_sw_interface_dump (g_vapi_ctx_instance, dump, ietf_sw_interface_dump_cb,
- dctx)));
-
- return dctx->num_ifs;
-}
-
-static i32 ietf_interface_name2index(const char *name, u32* if_index)
-{
- ARG_CHECK2(-1, name, if_index);
-
- i32 ret = -1;
- ietf_sw_interface_dump_ctx dctx = {false, 0, 0, 0};
- vapi_msg_sw_interface_dump *dump;
- vapi_error_e rv;
- dctx.last_called = false;
-
- dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
- dump->payload.name_filter_valid = true;
- strncpy(dump->payload.name_filter, name, sizeof(dump->payload.name_filter));
-
- while (VAPI_EAGAIN == (rv = vapi_sw_interface_dump(g_vapi_ctx_instance, dump, ietf_sw_interface_dump_cb, &dctx)))
- ;
-
- int i = 0;
- for (; i < dctx.num_ifs; ++i)
- {
- if (strcmp(dctx.intfcArray[i].interface_name, name) == 0)
- {
- *if_index = dctx.intfcArray[i].sw_if_index;
- ret = 0;
- break;
- }
- }
- ietf_freeSwInterfaceDumpCTX(&dctx);
-
- return ret;
-}
-
-i32 ietf_interface_add_del_addr( u32 sw_if_index, u8 is_add, u8 is_ipv6, u8 del_all,
- u8 address_length, u8 address[VPP_IP6_ADDRESS_LEN] )
-{
- i32 ret = -1;
- vapi_msg_sw_interface_add_del_address *msg = vapi_alloc_sw_interface_add_del_address(g_vapi_ctx_instance);
- msg->payload.sw_if_index = sw_if_index;
- msg->payload.is_add = is_add;
- msg->payload.is_ipv6 = is_ipv6;
- msg->payload.del_all = del_all;
- msg->payload.address_length = address_length;
- memcpy(msg->payload.address, address, VPP_IP6_ADDRESS_LEN);
- vapi_msg_sw_interface_add_del_address_hton (msg);
-
- vapi_error_e rv = vapi_send (g_vapi_ctx_instance, msg);
-
- vapi_msg_sw_interface_add_del_address_reply *resp;
-
- SC_VPP_VAPI_RECV;
-
- vapi_msg_sw_interface_add_del_address_reply_hton(resp);
- ret = resp->payload.retval;
- vapi_msg_free (g_vapi_ctx_instance, resp);
- return ret;
-}
-
-i32 ietf_setInterfaceFlags(u32 sw_if_index, u8 admin_up_down)
-{
- i32 ret = -1;
- vapi_msg_sw_interface_set_flags *msg = vapi_alloc_sw_interface_set_flags(g_vapi_ctx_instance);
- msg->payload.sw_if_index = sw_if_index;
- msg->payload.admin_up_down = admin_up_down;
- vapi_msg_sw_interface_set_flags_hton (msg);
-
- vapi_error_e rv = vapi_send (g_vapi_ctx_instance, msg);
-
- vapi_msg_sw_interface_set_flags_reply *resp;
+ dctx->intfcArray = NULL;
+ dctx->capacity = 0;
+ dctx->num_ifs = 0;
- SC_VPP_VAPI_RECV;
-
- vapi_msg_sw_interface_set_flags_reply_ntoh(resp);
- ret = resp->payload.retval;
- vapi_msg_free (g_vapi_ctx_instance, resp);
- return ret;
+ return 0;
}
-
/**
* @brief Modify existing IPv4/IPv6 config on an interface.
*/
static int
-interface_ipv46_config_modify(sr_session_ctx_t *session, const char *if_name,
- sr_val_t *old_val, sr_val_t *new_val, bool is_ipv6)
+interface_ipv46_config_modify(const char *if_name, sr_val_t *old_val,
+ sr_val_t *new_val, bool is_ipv6)
{
sr_xpath_ctx_t xpath_ctx = { 0, };
- char *addr_str = NULL;
- uint8_t addr[16] = { 0, };
+ char *addr = NULL;
uint8_t prefix = 0;
int rc = SR_ERR_OK;
@@ -412,12 +141,11 @@ interface_ipv46_config_modify(sr_session_ctx_t *session, const char *if_name,
} else {
return SR_ERR_INVAL_ARG;
}
- addr_str = sr_xpath_key_value((char*)old_val->xpath, "address", "ip", &xpath_ctx);
- ip_addr_str_to_binary(addr_str, addr, is_ipv6);
+ addr = sr_xpath_key_value((char*)old_val->xpath, "address", "ip", &xpath_ctx);
sr_xpath_recover(&xpath_ctx);
/* delete old IP config */
- rc = interface_ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, false /* remove */);
+ rc = ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, false /* remove */);
if (SR_ERR_OK != rc) {
SRP_LOG_ERR("Unable to remove old IP address config, rc=%d", rc);
return rc;
@@ -431,7 +159,7 @@ interface_ipv46_config_modify(sr_session_ctx_t *session, const char *if_name,
}
/* set new IP config */
- rc = interface_ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, true /* add */);
+ rc = ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, true /* add */);
if (SR_ERR_OK != rc) {
SRP_LOG_ERR("Unable to remove old IP address config, rc=%d", rc);
return rc;
@@ -445,7 +173,10 @@ interface_ipv46_config_modify(sr_session_ctx_t *session, const char *if_name,
* or "/ietf-interfaces:interfaces/interface/ietf-ip:ipv6/address".
*/
static int
-ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_event_t event, void *private_ctx)
+ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session,
+ const char *xpath,
+ sr_notif_event_t event,
+ void *private_ctx)
{
sr_change_iter_t *iter = NULL;
sr_change_oper_t op = SR_OP_CREATED;
@@ -453,11 +184,13 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
sr_val_t *new_val = NULL;
sr_xpath_ctx_t xpath_ctx = { 0, };
bool is_ipv6 = false, has_addr = false, has_prefix = false;
- uint8_t addr[16] = { 0, };
+ char addr[VPP_IP6_ADDRESS_STRING_LEN] = {0};
uint8_t prefix = 0;
char *node_name = NULL, *if_name = NULL;
int rc = SR_ERR_OK, op_rc = SR_ERR_OK;
+ SRP_LOG_INF("In %s", __FUNCTION__);
+
/* no-op for apply, we only care about SR_EV_ENABLED, SR_EV_VERIFY, SR_EV_ABORT */
if (SR_EV_APPLY == event) {
return SR_ERR_OK;
@@ -493,7 +226,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
has_addr = has_prefix = false;
} else {
if (sr_xpath_node_name_eq(new_val->xpath, "ip")) {
- ip_addr_str_to_binary(new_val->data.string_val, addr, is_ipv6);
+ strncpy(addr, new_val->data.string_val, strlen(new_val->data.string_val));
has_addr = true;
} else if (sr_xpath_node_name_eq(new_val->xpath, "prefix-length")) {
prefix = new_val->data.uint8_val;
@@ -503,12 +236,13 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
has_prefix = true;
}
if (has_addr && has_prefix) {
- op_rc = interface_ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, true /* add */);
+ op_rc = ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, true /* add */);
}
}
break;
case SR_OP_MODIFIED:
- op_rc = interface_ipv46_config_modify(session, if_name, old_val, new_val, is_ipv6);
+ //TODO Why is it using old_val and new_val?
+ op_rc = interface_ipv46_config_modify(if_name, old_val, new_val, is_ipv6);
break;
case SR_OP_DELETED:
if (SR_LIST_T == old_val->type) {
@@ -516,7 +250,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
has_addr = has_prefix = false;
} else {
if (sr_xpath_node_name_eq(old_val->xpath, "ip")) {
- ip_addr_str_to_binary(old_val->data.string_val, addr, is_ipv6);
+ strncpy(addr, old_val->data.string_val, strlen(old_val->data.string_val));
has_addr = true;
} else if (sr_xpath_node_name_eq(old_val->xpath, "prefix-length")) {
prefix = old_val->data.uint8_val;
@@ -526,7 +260,7 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
has_prefix = true;
}
if (has_addr && has_prefix) {
- op_rc = interface_ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, false /* !add */);
+ op_rc = ipv46_config_add_remove(if_name, addr, prefix, is_ipv6, false /* !add */);
}
}
break;
@@ -550,8 +284,10 @@ ietf_interface_ipv46_address_change_cb(sr_session_ctx_t *session, const char *xp
* Does not provide any functionality, needed just to cover not supported config leaves.
*/
static int
-ietf_interface_change_cb(sr_session_ctx_t *session, const char *xpath, sr_notif_event_t event, void *private_ctx)
+ietf_interface_change_cb(sr_session_ctx_t *session, const char *xpath,
+ sr_notif_event_t event, void *private_ctx)
{
+ SRP_LOG_INF("In %s", __FUNCTION__);
SRP_LOG_DBG("'%s' modified, event=%d", xpath, event);
return SR_ERR_OK;
@@ -569,11 +305,12 @@ ietf_interface_state_cb(const char *xpath, sr_val_t **values,
{
sr_val_t *values_arr = NULL;
int values_arr_size = 0, values_arr_cnt = 0;
- ietf_sw_interface_dump_ctx dctx;
- scVppIntfc* if_details;
+ dump_all_ctx dctx;
+ int nb_iface;
+ vpp_interface_t* if_details;
int rc = 0;
- SRP_LOG_DBG("Requesting state data for '%s'", xpath);
+ SRP_LOG_INF("In %s", __FUNCTION__);
if (! sr_xpath_node_name_eq(xpath, "interface")) {
/* statistics, ipv4 and ipv6 state data not supported */
@@ -583,23 +320,23 @@ ietf_interface_state_cb(const char *xpath, sr_val_t **values,
}
/* dump interfaces */
- rc = ietf_swInterfaceDump(&dctx);
- if (rc <= 0) {
+ nb_iface = interface_dump_all(&dctx);
+ if (nb_iface <= 0) {
SRP_LOG_ERR_MSG("Error by processing of a interface dump request.");
- ietf_freeSwInterfaceDumpCTX(&dctx);
+ free_sw_interface_dump_ctx(&dctx);
return SR_ERR_INTERNAL;
}
/* allocate array of values to be returned */
- values_arr_size = dctx.num_ifs * 5;
+ values_arr_size = nb_iface * 5;
rc = sr_new_values(values_arr_size, &values_arr);
if (0 != rc) {
- ietf_freeSwInterfaceDumpCTX(&dctx);
+ free_sw_interface_dump_ctx(&dctx);
return rc;
}
int i = 0;
- for (; i < dctx.num_ifs; i++) {
+ for (; i < nb_iface; i++) {
if_details = dctx.intfcArray+i;
/* currently the only supported interface types are propVirtual / ethernetCsmacd */
@@ -623,10 +360,10 @@ ietf_interface_state_cb(const char *xpath, sr_val_t **values,
if_details->l2_address[3], if_details->l2_address[4], if_details->l2_address[5]);
values_arr_cnt++;
} else {
- sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/phys-address", xpath, if_details->interface_name);
- sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", 0,0,0,0,0,0);
- values_arr_cnt++;
- }
+ sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/phys-address", xpath, if_details->interface_name);
+ sr_val_build_str_data(&values_arr[values_arr_cnt], SR_STRING_T, "%02x:%02x:%02x:%02x:%02x:%02x", 0,0,0,0,0,0);
+ values_arr_cnt++;
+ }
sr_val_build_xpath(&values_arr[values_arr_cnt], "%s[name='%s']/speed", xpath, if_details->interface_name);
values_arr[values_arr_cnt].type = SR_UINT64_T;
@@ -639,7 +376,7 @@ ietf_interface_state_cb(const char *xpath, sr_val_t **values,
*values = values_arr;
*values_cnt = values_arr_cnt;
- ietf_freeSwInterfaceDumpCTX(&dctx);
+ free_sw_interface_dump_ctx(&dctx);
return SR_ERR_OK;
}
diff --git a/src/plugins/openconfig/openconfig_interfaces.c b/src/plugins/openconfig/openconfig_interfaces.c
index a1f66bb..85339af 100644
--- a/src/plugins/openconfig/openconfig_interfaces.c
+++ b/src/plugins/openconfig/openconfig_interfaces.c
@@ -14,43 +14,18 @@
* limitations under the License.
*/
+#include <assert.h>
+#include <string.h>
+
#include "openconfig_interfaces.h"
#include "sys_util.h"
+
#include "sc_vpp_comm.h"
#include "sc_vpp_interface.h"
#include "sc_vpp_ip.h"
-#include <assert.h>
-#include <string.h>
-#include <sysrepo/xpath.h>
-#include <sysrepo/values.h>
-#include <sysrepo.h>
-
#define XPATH_SIZE 2000
-static int oi_enable_interface(const char *interface_name,
- const bool enable)
-{
- ARG_CHECK(-1, interface_name);
-
- int rc = 0;
- sw_interface_details_query_t query = {0};
- sw_interface_details_query_set_name(&query, interface_name);
-
- if (false == get_interface_id(&query)) {
- return -1;
- }
-
- rc = bin_api_sw_interface_set_flags(query.sw_interface_details.sw_if_index,
- enable);
- if (VAPI_OK != rc) {
- SRP_LOG_ERR_MSG("Call bin_api_sw_interface_set_flags.");
- rc = -1;
- }
-
- return rc;
-}
-
// XPATH: /openconfig-interfaces:interfaces/interface[name='%s']/config/
int openconfig_interfaces_interfaces_interface_config_cb(
sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event,
@@ -64,6 +39,8 @@ int openconfig_interfaces_interfaces_interface_config_cb(
char interface_name[XPATH_SIZE] = {0};
int rc = 0;
+ SRP_LOG_INF_MSG("In openconfig_interfaces_interfaces_interface_config_cb");
+
ARG_CHECK2(SR_ERR_INVAL_ARG, ds, xpath);
// if we receive event SR_EV_APPLY - config has changed
@@ -128,7 +105,7 @@ int openconfig_interfaces_interfaces_interface_config_cb(
"description")) {
//TODO: LEAF: description, type: string
} else if(sr_xpath_node_name_eq(new_val->xpath, "enabled")) {
- rc = oi_enable_interface(interface_name,
+ rc = interface_enable(interface_name,
new_val->data.bool_val);
} else if(sr_xpath_node_name_eq(new_val->xpath,
"oc-vlan:tpid")) {
@@ -150,7 +127,7 @@ int openconfig_interfaces_interfaces_interface_config_cb(
"description")) {
//TODO: LEAF: description, type: string
} else if(sr_xpath_node_name_eq(new_val->xpath, "enabled")) {
- rc = oi_enable_interface(interface_name,
+ rc = interface_enable(interface_name,
new_val->data.bool_val);
} else if(sr_xpath_node_name_eq(new_val->xpath,
"oc-vlan:tpid")) {
@@ -175,7 +152,7 @@ int openconfig_interfaces_interfaces_interface_config_cb(
"description")) {
//TODO: LEAF: description, type: string
} else if(sr_xpath_node_name_eq(old_val->xpath, "enabled")) {
- rc = oi_enable_interface(interface_name, false);
+ rc = interface_enable(interface_name, false);
} else if(sr_xpath_node_name_eq(old_val->xpath,
"oc-vlan:tpid")) {
//TODO: LEAF: oc-vlan:tpid, type: identityref
@@ -204,13 +181,14 @@ int openconfig_interfaces_interfaces_interface_config_cb(
return SR_ERR_OK;
}
+// openconfig-interfaces
int openconfig_interface_mod_cb(
__attribute__((unused)) sr_session_ctx_t *session,
__attribute__((unused)) const char *module_name,
__attribute__((unused)) sr_notif_event_t event,
__attribute__((unused)) void *private_ctx)
{
- SRP_LOG_DBG("Interface module subscribe: %s", module_name);
+ SRP_LOG_INF_MSG("In openconfig_interface_mod_cb");
return SR_ERR_OK;
}
@@ -225,7 +203,6 @@ typedef struct
#define NOT_AVAL "NA"
-// XPATH: /openconfig-interfaces:interfaces/interface/state
static int sw_interface_dump_cb_inner(
vapi_payload_sw_interface_details * reply,
@@ -301,8 +278,6 @@ static int sw_interface_dump_cb_inner(
return SR_ERR_OK;
}
-
-// XPATH: /openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/state
static int sw_subinterface_dump_cb_inner(
vapi_payload_sw_interface_details *reply,
sys_sw_interface_dump_ctx *dctx)
@@ -367,9 +342,9 @@ static int sw_subinterface_dump_cb_inner(
return SR_ERR_OK;
}
-static
-bool is_subinterface(const char* subif_name, const char* base_name,
- const u32 subif_index)
+static bool
+is_subinterface(const char* subif_name, const char* base_name,
+ const u32 subif_index)
{
assert(subif_name && base_name);
@@ -434,10 +409,12 @@ sw_interface_dump_vapi_cb(struct vapi_ctx_s *ctx, void *callback_ctx,
static vapi_error_e sysr_sw_interface_dump(sys_sw_interface_dump_ctx * dctx)
{
+ vapi_msg_sw_interface_dump *dump;
+ vapi_error_e rv;
+
ARG_CHECK(VAPI_EINVAL, dctx);
- vapi_msg_sw_interface_dump *dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
- vapi_error_e rv;
+ dump = vapi_alloc_sw_interface_dump(g_vapi_ctx_instance);
dump->payload.name_filter_valid = true;
strcpy((char*)dump->payload.name_filter, (const char *)dctx->sw_interface_details_query.sw_interface_details.interface_name);
@@ -463,11 +440,13 @@ int openconfig_interfaces_interfaces_interface_state_cb(
char *tmp = NULL;
char interface_name[XPATH_SIZE] = {0};
+ SRP_LOG_INF_MSG("In openconfig_interfaces_interfaces_interface_state_cb");
+
ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt);
tmp = xpath_find_first_key(xpath, "name", &state);
if (NULL == tmp) {
- SRP_LOG_DBG_MSG("interface_name not found.");
+ SRP_LOG_ERR_MSG("Interface name not found in sysrepo database");
return SR_ERR_INVAL_ARG;
}
@@ -487,7 +466,7 @@ int openconfig_interfaces_interfaces_interface_state_cb(
sysr_sw_interface_dump(&dctx);
if (!dctx.sw_interface_details_query.interface_found) {
- SRP_LOG_DBG_MSG("interface not found");
+ SRP_LOG_ERR_MSG("interface not found");
return SR_ERR_NOT_FOUND;
}
@@ -498,16 +477,14 @@ int openconfig_interfaces_interfaces_interface_state_cb(
return SR_ERR_OK;
}
-// XPATH: /openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address/openconfig-if-ip:state
-int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_vapi_cb(
- vapi_payload_ip_address_details *reply,
- sysr_values_ctx_t *sysr_values_ctx)
+int oc_dump_ip_helper(char *address_ip, u8 prefix_len,
+ sysr_values_ctx_t *sysr_values_ctx)
{
sr_val_t *vals = NULL;
int rc = 0;
int vc = 0;
- ARG_CHECK2(SR_ERR_INVAL_ARG, reply, sysr_values_ctx);
+ ARG_CHECK2(SR_ERR_INVAL_ARG, address_ip, sysr_values_ctx);
vc = 3;
/* convenient functions such as this can be found in sysrepo/values.h */
@@ -516,8 +493,6 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
return rc;
}
- char * address_ip = sc_ntoa(reply->ip);
-
sr_val_build_xpath(&vals[0], "%s/openconfig-if-ip:ip",
sysr_values_ctx->xpath_root);
sr_val_set_str_data(&vals[0], SR_STRING_T, address_ip);
@@ -525,7 +500,7 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
sr_val_build_xpath(&vals[1], "%s/openconfig-if-ip:prefix-length",
sysr_values_ctx->xpath_root);
vals[1].type = SR_UINT8_T;
- vals[1].data.uint8_val = reply->prefix_length;
+ vals[1].data.uint8_val = prefix_len;
sr_val_build_xpath(&vals[2], "%s/openconfig-if-ip:origin",
sysr_values_ctx->xpath_root);
@@ -537,35 +512,6 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
return SR_ERR_OK;
}
-vapi_error_e
-ip_address_dump_cb (struct vapi_ctx_s *ctx, void *callback_ctx,
- vapi_error_e rv, bool is_last,
- vapi_payload_ip_address_details * reply)
-{
- ARG_CHECK2(VAPI_EINVAL, ctx, callback_ctx);
-
- sysr_values_ctx_t *dctx = callback_ctx;
-
- if (is_last)
- {
- assert (NULL == reply);
- }
- else
- {
- assert (NULL != reply);
-
- printf ("ip address dump entry:"
- "\tsw_if_index[%u]"
- "\tip[%s/%u]\n"
- , reply->sw_if_index, sc_ntoa(reply->ip),
- reply->prefix_length);
-
- openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_vapi_cb(reply, dctx);
- }
-
- return VAPI_OK;
-}
-
//TODO: for some arcane reason, this doesn't work
int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_cb(
const char *xpath, sr_val_t **values, size_t *values_cnt,
@@ -574,14 +520,17 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
__attribute__((unused)) void *private_ctx)
{
sr_xpath_ctx_t state = {0};
- vapi_error_e rv;
+ int rc;
char *tmp = NULL;
char interface_name[XPATH_SIZE] = {0};
char subinterface_index[XPATH_SIZE] = {0};
char address_ip[XPATH_SIZE] = {0};
+ u8 prefix_len;
ARG_CHECK3(SR_ERR_INVAL_ARG, xpath, values, values_cnt);
+ SRP_LOG_INF_MSG("In oc-interfaces oc-ip");
+
tmp = xpath_find_first_key(xpath, "name", &state);
if (NULL == tmp) {
SRP_LOG_ERR_MSG("interface_name not found.");
@@ -613,23 +562,16 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
snprintf(dctx.xpath_root, XPATH_SIZE, "/openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/openconfig-if-ip:ipv4/openconfig-if-ip:addresses/openconfig-if-ip:address[ip='%s']/openconfig-if-ip:state",
interface_name, subinterface_index, address_ip);
- sw_interface_details_query_t query = {0};
- sw_interface_details_query_set_name(&query, interface_name);
-
- if (!get_interface_id(&query))
- {
+ rc = ipv46_address_dump(interface_name, address_ip, &prefix_len, false);
+ if (!rc) {
+ SRP_LOG_ERR_MSG("ipv46_address_dump failed");
return SR_ERR_INVAL_ARG;
}
- vapi_msg_ip_address_dump *mp = vapi_alloc_ip_address_dump (g_vapi_ctx_instance);
- mp->payload.sw_if_index = query.sw_interface_details.sw_if_index;
- mp->payload.is_ipv6 = 0;
-
- rv = vapi_ip_address_dump(g_vapi_ctx_instance, mp, ip_address_dump_cb, &dctx);
- if (VAPI_OK != rv)
- {
- SRP_LOG_ERR_MSG("VAPI call failed");
- return SR_ERR_INVAL_ARG;
+ rc = oc_dump_ip_helper(address_ip, prefix_len, &dctx);
+ if (!rc) {
+ SRP_LOG_ERR_MSG("oc_dump_ip_helper failed");
+ return rc;
}
sr_xpath_recover(&state);
@@ -639,6 +581,7 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
return SR_ERR_OK;
}
+// openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/state
int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_cb(
const char *xpath, sr_val_t **values, size_t *values_cnt,
__attribute__((unused)) uint64_t request_id,
@@ -695,31 +638,7 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_
return SR_ERR_OK;
}
-// VAPI_RETVAL_CB(sw_interface_add_del_address);
-
-static int oi_int_ipv4_conf(const char *interface_name,
- const char *address_ip, u8 prefix_length,
- bool is_add)
-{
- ARG_CHECK2(-1, interface_name, address_ip);
-
- sw_interface_details_query_t query = {0};
- sw_interface_details_query_set_name(&query, interface_name);
- if (!get_interface_id(&query)) {
- return 0;
- }
-
- if (VAPI_OK != bin_api_sw_interface_add_del_address(query.sw_interface_details.sw_if_index,
- is_add, address_ip, prefix_length))
- {
- SRP_LOG_ERR_MSG("Call vapi_sw_interface_add_del_address.");
- return -1;
- }
-
- return 0;
-}
-
-// XPATH: /openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/oc-ip:ipv4/oc-ip:addresses/oc-ip:address[ip='%s']/oc-ip:config/
+// openconfig-interfaces:interfaces/interface[name='%s']/subinterfaces/subinterface[index='%s']/oc-ip:ipv4/oc-ip:addresses/oc-ip:address[ip='%s']/oc-ip:config/
int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_config_cb(
sr_session_ctx_t *ds, const char *xpath, sr_notif_event_t event,
__attribute__((unused)) void *private_ctx)
@@ -756,8 +675,7 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
return SR_ERR_OK;
}
- while (sr_get_change_next(ds, it, &oper,
- &old_val, &new_val) == SR_ERR_OK) {
+ while (sr_get_change_next(ds, it, &oper, &old_val, &new_val) == SR_ERR_OK) {
log_recv_oper(oper, "subtree_change_cb received");
@@ -795,8 +713,9 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
}
if (ip_set && prefix_len_set) {
- rc = oi_int_ipv4_conf(interface_name, address_ip,
- prefix_len, true);
+ //add ipv4
+ rc = ipv46_config_add_remove(interface_name, address_ip,
+ prefix_len, false , true);
}
break;
@@ -822,16 +741,18 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
}
if (old_ip_set && old_prefix_len_set) {
- rc = oi_int_ipv4_conf(interface_name, old_address_ip,
- old_prefix_len, false);
+ //remove ipv4
+ rc = ipv46_config_add_remove(interface_name, old_address_ip,
+ old_prefix_len, false, false);
if (0 != rc) {
break;
}
}
if (ip_set && prefix_len_set) {
- rc = oi_int_ipv4_conf(interface_name, address_ip,
- prefix_len, true);
+ //add ipv4
+ rc = ipv46_config_add_remove(interface_name, address_ip,
+ prefix_len, false, true);
}
break;
@@ -850,8 +771,9 @@ int openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_
}
if (old_ip_set && old_prefix_len_set) {
- rc = oi_int_ipv4_conf(interface_name, old_address_ip,
- old_prefix_len, false);
+ //remove ipv4
+ rc = ipv46_config_add_remove(interface_name, old_address_ip,
+ old_prefix_len, false, false);
}
break;
}
@@ -894,7 +816,7 @@ const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
.datastore = SR_DS_RUNNING,
.cb.scb = openconfig_interfaces_interfaces_interface_config_cb,
.private_ctx = NULL,
- .priority = 0,
+ .priority = 98,
//.opts = SR_SUBSCR_DEFAULT
.opts = SR_SUBSCR_CTX_REUSE
},
@@ -904,7 +826,7 @@ const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
.datastore = SR_DS_RUNNING,
.cb.gcb = openconfig_interfaces_interfaces_interface_state_cb,
.private_ctx = NULL,
- .priority = 0,
+ .priority = 98,
.opts = SR_SUBSCR_CTX_REUSE
},
{
@@ -913,7 +835,7 @@ const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
.datastore = SR_DS_RUNNING,
.cb.gcb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_state_cb,
.private_ctx = NULL,
- .priority = 0,
+ .priority = 99,
.opts = SR_SUBSCR_CTX_REUSE
},
{
@@ -922,7 +844,7 @@ const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
.datastore = SR_DS_RUNNING,
.cb.scb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_config_cb,
.private_ctx = NULL,
- .priority = 0,
+ .priority = 100,
//.opts = SR_SUBSCR_DEFAULT
.opts = SR_SUBSCR_CTX_REUSE
},
@@ -932,7 +854,7 @@ const xpath_t oc_interfaces_xpaths[OC_INTERFACES_SIZE] = {
.datastore = SR_DS_RUNNING,
.cb.gcb = openconfig_interfaces_interfaces_interface_subinterfaces_subinterface_oc_ip_ipv4_oc_ip_addresses_oc_ip_address_oc_ip_state_cb,
.private_ctx = NULL,
- .priority = 0,
+ .priority = 100,
.opts = SR_SUBSCR_CTX_REUSE
}
};
diff --git a/src/plugins/openconfig/openconfig_local_routing.c b/src/plugins/openconfig/openconfig_local_routing.c
index 59574a2..39481e1 100644
--- a/src/plugins/openconfig/openconfig_local_routing.c
+++ b/src/plugins/openconfig/openconfig_local_routing.c
@@ -14,18 +14,17 @@
* limitations under the License.
*/
+#include <assert.h>
+#include <string.h>
+
#include "openconfig_local_routing.h"
+
#include "sys_util.h"
+
#include "sc_vpp_comm.h"
#include "sc_vpp_interface.h"
#include "sc_vpp_ip.h"
-#include <assert.h>
-#include <string.h>
-#include <sysrepo.h>
-#include <sysrepo/xpath.h>
-#include <sysrepo/values.h>
-
#define XPATH_SIZE 2000
int openconfig_local_routing_mod_cb(
@@ -87,15 +86,13 @@ static int set_route(sr_session_ctx_t *sess, const char *index,
return SR_ERR_INVAL_ARG;
}
- vapi_payload_ip_add_del_route_reply reply = {0};
-
- vapi_error_e rv = bin_api_ip_add_del_route(&reply, prefix, mask,
- next_hop, is_add, 0, interface);
- if (VAPI_OK != rv || reply.retval > 0) {
+ rc = ipv46_config_add_del_route(prefix, mask, next_hop, is_add, 0,
+ interface);
+ if (!rc) {
return SR_ERR_INVAL_ARG;
}
- return VAPI_OK;
+ return SR_ERR_OK;
}
// XPATH: /openconfig-local-routing:local-routes/static-routes/static[prefix='%s']/next-hops/next-hop[index='%s']/config/
diff --git a/src/plugins/openconfig/sys_util.h b/src/plugins/openconfig/sys_util.h
index 6c227c3..d525066 100644
--- a/src/plugins/openconfig/sys_util.h
+++ b/src/plugins/openconfig/sys_util.h
@@ -19,6 +19,7 @@
#include <sysrepo.h>
#include <sysrepo/xpath.h>
+#include <sysrepo/plugins.h>
#define XPATH_SIZE 2000
diff --git a/src/plugins/sc_model.h b/src/plugins/sc_model.h
index ec4bff4..ad4055b 100644
--- a/src/plugins/sc_model.h
+++ b/src/plugins/sc_model.h
@@ -25,6 +25,10 @@
*/
#include <sysrepo.h>
+#include <sysrepo/xpath.h>
+#include <sysrepo/values.h>
+#include <sysrepo/plugins.h>
+
#include "sc_vpp_comm.h" //for ARG_CHECK only
typedef enum {
diff --git a/src/plugins/sc_plugins.c b/src/plugins/sc_plugins.c
index e0db8ed..093939c 100644
--- a/src/plugins/sc_plugins.c
+++ b/src/plugins/sc_plugins.c
@@ -12,25 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <vapi/vapi.h>
-#include <vapi/vpe.api.vapi.h>
-#include <vapi/interface.api.vapi.h>
-#include <vapi/l2.api.vapi.h>
-#include <vapi/ip.api.vapi.h>
-#include <vapi/tapv2.api.vapi.h>
-#include <vapi/ipsec.api.vapi.h>
-#include <vapi/vxlan.api.vapi.h>
-#include <vnet/interface.h>
-#include <vnet/mpls/mpls_types.h>
-
-// Use VAPI macros to define symbols
-DEFINE_VAPI_MSG_IDS_VPE_API_JSON;
-DEFINE_VAPI_MSG_IDS_INTERFACE_API_JSON;
-DEFINE_VAPI_MSG_IDS_L2_API_JSON;
-DEFINE_VAPI_MSG_IDS_IP_API_JSON;
-DEFINE_VAPI_MSG_IDS_TAPV2_API_JSON;
-DEFINE_VAPI_MSG_IDS_IPSEC_API_JSON;
-DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON;
#include "sc_plugins.h"
#include "sc_model.h"
@@ -41,13 +22,12 @@ DEFINE_VAPI_MSG_IDS_VXLAN_API_JSON;
int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
{
- SC_INVOKE_BEGIN;
plugin_main_t plugin_main;
int rc;
rc = sc_connect_vpp();
if (0 != rc) {
- SC_LOG_ERR("vpp connect error , with return %d.", rc);
+ SRP_LOG_ERR("vpp connect error , with return %d.", rc);
return SR_ERR_INTERNAL;
}
@@ -61,22 +41,18 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx)
/* set subscription as our private context */
*private_ctx = plugin_main.subscription;
- SC_INVOKE_END;
return SR_ERR_OK;
}
void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx)
{
- SC_INVOKE_BEGIN;
-
/* subscription was set as our private context */
if (private_ctx != NULL)
sr_unsubscribe(session, private_ctx);
- SC_LOG_DBG_MSG("unload plugin ok.");
+ SRP_LOG_DBG_MSG("unload plugin ok.");
sc_disconnect_vpp();
- SC_LOG_DBG_MSG("plugin disconnect vpp ok.");
- SC_INVOKE_END;
+ SRP_LOG_DBG_MSG("plugin disconnect vpp ok.");
}
diff --git a/src/plugins/sc_plugins.h b/src/plugins/sc_plugins.h
index bdf88d7..f405300 100644
--- a/src/plugins/sc_plugins.h
+++ b/src/plugins/sc_plugins.h
@@ -20,6 +20,32 @@
#include <sysrepo/values.h>
#include <sysrepo/plugins.h>
+#define ARG_CHECK(retval, arg) \
+ do \
+ { \
+ if (NULL == (arg)) \
+ { \
+ SRP_LOG_ERR_MSG(#arg ":NULL pointer passed."); \
+ return (retval); \
+ } \
+ } \
+ while (0)
+
+#define ARG_CHECK2(retval, arg1, arg2) \
+ ARG_CHECK(retval, arg1); \
+ ARG_CHECK(retval, arg2)
+
+#define ARG_CHECK3(retval, arg1, arg2, arg3) \
+ ARG_CHECK(retval, arg1); \
+ ARG_CHECK(retval, arg2); \
+ ARG_CHECK(retval, arg3)
+
+#define ARG_CHECK4(retval, arg1, arg2, arg3, arg4) \
+ ARG_CHECK(retval, arg1); \
+ ARG_CHECK(retval, arg2); \
+ ARG_CHECK(retval, arg3); \
+ ARG_CHECK(retval, arg4)
+
//functions that sysrepo-plugin need
int sr_plugin_init_cb(sr_session_ctx_t *session, void **private_ctx);
void sr_plugin_cleanup_cb(sr_session_ctx_t *session, void *private_ctx);