Skip to content

Commit

Permalink
interfaces-plugin: add interfaces state context to the main context
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateo Cindrić committed Aug 23, 2022
1 parent ab4d5e8 commit c611bf7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/interfaces/src/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#include <srpc.h>
#include <sysrepo.h>

static int interfaces_init_state_changes_tracking(interfaces_state_changes_ctx_t* ctx);

int sr_plugin_init_cb(sr_session_ctx_t* running_session, void** private_data)
{
int error = 0;
Expand Down Expand Up @@ -259,6 +261,9 @@ int sr_plugin_init_cb(sr_session_ctx_t* running_session, void** private_data)
}
}

// tracking oper-status changes for interfaces
SRPC_SAFE_CALL_ERR(error, interfaces_init_state_changes_tracking(&ctx->state_ctx), error_out);

goto out;

error_out:
Expand Down Expand Up @@ -293,4 +298,11 @@ void sr_plugin_cleanup_cb(sr_session_ctx_t* running_session, void* private_data)
}

free(ctx);
}

static int interfaces_init_state_changes_tracking(interfaces_state_changes_ctx_t* ctx)
{
// setup threads to check every link state and write timestamps of changes
int error = 0;
return error;
}
9 changes: 9 additions & 0 deletions src/interfaces/src/plugin/context.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef INTERFACES_PLUGIN_CONTEXT_H
#define INTERFACES_PLUGIN_CONTEXT_H

#include "netlink/cache.h"
#include "plugin/types.h"
#include <sysrepo_types.h>

Expand All @@ -9,6 +10,13 @@
// typedefs
typedef struct interfaces_nl_ctx_s interfaces_nl_ctx_t;
typedef struct interfaces_ctx_s interfaces_ctx_t;
typedef struct interfaces_state_changes_ctx_s interfaces_state_changes_ctx_t;

struct interfaces_state_changes_ctx_s {
struct nl_sock* socket;
struct nl_cache* link_cache;
struct nl_cache_mngr* link_cache_manager;
};

struct interfaces_nl_ctx_s {
struct nl_sock* socket;
Expand All @@ -18,6 +26,7 @@ struct interfaces_nl_ctx_s {
struct interfaces_ctx_s {
sr_session_ctx_t* startup_session;
interfaces_nl_ctx_t nl_ctx;
interfaces_state_changes_ctx_t state_ctx;
};

#endif // INTERFACES_PLUGIN_CONTEXT_H

0 comments on commit c611bf7

Please sign in to comment.