Skip to content

Commit

Permalink
interface: Hide the implementation details.
Browse files Browse the repository at this point in the history
Now that a complete functional API is in place, there is no need to expose
the inner workings of the network interface data type.  This patch converts
it into an opaque type while leaving the list marker visible to users
through a simple form of "friendly exposition".

Signed-off-by: Richard Cochran <[email protected]>
  • Loading branch information
richardcochran committed Mar 4, 2020
1 parent 66dc316 commit a8f7425
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
4 changes: 4 additions & 0 deletions clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
#define N_CLOCK_PFD (N_POLLFD + 1) /* one extra per port, for the fault timer */
#define POW2_41 ((double)(1ULL << 41))

struct interface {
STAILQ_ENTRY(interface) list;
};

struct port {
LIST_ENTRY(port) list;
};
Expand Down
4 changes: 4 additions & 0 deletions config.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include "print.h"
#include "util.h"

struct interface {
STAILQ_ENTRY(interface) list;
};

enum config_section {
GLOBAL_SECTION,
UC_MTAB_SECTION,
Expand Down
7 changes: 7 additions & 0 deletions interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
#include <stdlib.h>
#include "interface.h"

struct interface {
STAILQ_ENTRY(interface) list;
char name[MAX_IFNAME_SIZE + 1];
char ts_label[MAX_IFNAME_SIZE + 1];
struct sk_ts_info ts_info;
};

struct interface *interface_create(const char *name)
{
struct interface *iface;
Expand Down
9 changes: 2 additions & 7 deletions interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@
#error if_namesize larger than expected.
#endif

/** Defines a network interface, with PTP options. */
struct interface {
STAILQ_ENTRY(interface) list;
char name[MAX_IFNAME_SIZE + 1];
char ts_label[MAX_IFNAME_SIZE + 1];
struct sk_ts_info ts_info;
};
/** Opaque type */
struct interface;

/**
* Creates an instance of an interface.
Expand Down
4 changes: 4 additions & 0 deletions nsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#define IFMT "\n\t\t"
#define NSM_NFD 3

struct interface {
STAILQ_ENTRY(interface) list;
};

struct nsm {
struct config *cfg;
struct fdarray fda;
Expand Down

0 comments on commit a8f7425

Please sign in to comment.