Skip to content

Commit

Permalink
interfaces-plugin: extract interface name when changing enabled IPv4 …
Browse files Browse the repository at this point in the history
…value
  • Loading branch information
zinccyy committed Oct 6, 2022
1 parent e2b4561 commit fbc1e3c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/interfaces/src/plugin/api/interfaces/interface/ipv4/change.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,25 @@ int interfaces_interface_ipv4_change_enabled_init(void* priv)
int interfaces_interface_ipv4_change_enabled(void* priv, sr_session_ctx_t* session, const srpc_change_ctx_t* change_ctx)
{
int error = 0;
void* error_ptr = NULL;
const char* node_name = LYD_NAME(change_ctx->node);
const char* node_value = lyd_get_value(change_ctx->node);

char path_buffer[PATH_MAX] = { 0 };
char interface_name_buffer[100] = { 0 };

// IPv4 can be disabled by deleting all IPv4 addresses associated with the interface

SRPLG_LOG_INF(PLUGIN_NAME, "Node Name: %s; Previous Value: %s, Value: %s; Operation: %d", node_name, change_ctx->previous_value, node_value, change_ctx->operation);

// get node path
SRPC_SAFE_CALL_PTR(error_ptr, lyd_path(change_ctx->node, LYD_PATH_STD, path_buffer, sizeof(path_buffer)), error_out);

// get interface name
SRPC_SAFE_CALL_ERR(error, srpc_extract_xpath_key_value(path_buffer, "interface", "name", interface_name_buffer, sizeof(interface_name_buffer)), error_out);

SRPLG_LOG_INF(PLUGIN_NAME, "Node Path: %s; Interface Name: %s", path_buffer, interface_name_buffer);

switch (change_ctx->operation) {
case SR_OP_CREATED:
break;
Expand All @@ -213,6 +225,12 @@ int interfaces_interface_ipv4_change_enabled(void* priv, sr_session_ctx_t* sessi
break;
}

goto out;

error_out:
error = -1;

out:
return -1;
}

Expand Down

0 comments on commit fbc1e3c

Please sign in to comment.