From c5b9ab990a7210961810d8e3ab7eb5268b1a00ea Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 9 Feb 2020 06:52:49 -0800 Subject: [PATCH] Move the network interface into its own header file. Up until now, the users of the interface data structure simply access its fields without restriction. This patch takes the first step towards abstracting this data structure by giving it a file of its very own. Signed-off-by: Richard Cochran Reviewed-by: Jacob Keller --- config.h | 15 +-------------- interface.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 interface.h diff --git a/config.h b/config.h index e27d3e2..14d2f64 100644 --- a/config.h +++ b/config.h @@ -26,25 +26,12 @@ #include "ds.h" #include "dm.h" #include "filter.h" +#include "interface.h" #include "mtab.h" #include "transport.h" #include "servo.h" #include "sk.h" -#define MAX_IFNAME_SIZE 108 /* = UNIX_PATH_MAX */ - -#if (IF_NAMESIZE > MAX_IFNAME_SIZE) -#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; -}; - struct config { /* configured interfaces */ STAILQ_HEAD(interfaces_head, interface) interfaces; diff --git a/interface.h b/interface.h new file mode 100644 index 0000000..61d53a2 --- /dev/null +++ b/interface.h @@ -0,0 +1,28 @@ +/** + * @file interface.h + * @brief Implements network interface data structures. + * @note Copyright (C) 2020 Richard Cochran + * @note SPDX-License-Identifier: GPL-2.0+ + */ +#ifndef HAVE_INTERFACE_H +#define HAVE_INTERFACE_H + +#include +#include "sk.h" + +#define MAX_IFNAME_SIZE 108 /* = UNIX_PATH_MAX */ + +#if (IF_NAMESIZE > MAX_IFNAME_SIZE) +#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; +}; + +#endif +