Skip to content

Commit

Permalink
mctp-link: move the netlink structs to header file
Browse files Browse the repository at this point in the history
Move the `linkmap_entry` and `linkmap_entry` struct definition to header
file. This helps others source files can include and use those structs
easily.

Signed-off-by: Thu Nguyen <[email protected]>
  • Loading branch information
ThuBaNguyen committed Jun 7, 2024
1 parent 61b7e03 commit 46a169f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 29 deletions.
28 changes: 0 additions & 28 deletions src/mctp-netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <sys/socket.h>

#include <linux/if.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <linux/netdevice.h>
Expand All @@ -20,33 +19,6 @@
#include "mctp-util.h"
#include "mctp-ops.h"

struct linkmap_entry {
int ifindex;
char ifname[IFNAMSIZ+1];
int net;
bool up;

mctp_eid_t *local_eids;
size_t num_local;
};

struct mctp_nl {
// socket for queries
int sd;
// socket for monitor
int sd_monitor;

struct linkmap_entry *linkmap;
size_t linkmap_count;
size_t linkmap_alloc;
bool verbose;

// allows callers to silence printf of EEXIST returns.
// TODO: this is a workaround, if more are required we should
// rework how error messages are returned to callers.
bool quiet_eexist;
};

static int fill_local_addrs(mctp_nl *nl);
static int fill_linkmap(mctp_nl *nl);
static void sort_linkmap(mctp_nl *nl);
Expand Down
29 changes: 28 additions & 1 deletion src/mctp-netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,39 @@
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <linux/if.h>
#include <linux/rtnetlink.h>

#include "mctp.h"

struct mctp_nl;
struct linkmap_entry {
int ifindex;
char ifname[IFNAMSIZ+1];
int net;
bool up;

mctp_eid_t *local_eids;
size_t num_local;
};

struct mctp_nl {
// socket for queries
int sd;
// socket for monitor
int sd_monitor;

struct linkmap_entry *linkmap;
size_t linkmap_count;
size_t linkmap_alloc;
bool verbose;

// allows callers to silence printf of EEXIST returns.
// TODO: this is a workaround, if more are required we should
// rework how error messages are returned to callers.
bool quiet_eexist;
};
typedef struct mctp_nl mctp_nl;
typedef struct linkmap_entry linkmap_entry;

struct mctp_nl_change {
#define MCTP_NL_OP_COUNT 6
Expand Down

0 comments on commit 46a169f

Please sign in to comment.