summaryrefslogtreecommitdiff
path: root/sys/net/if.h
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-09-14 11:42:53 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-09-14 11:42:53 +0000
commit1bd24efb29758e44a531fee3a46f16571b662fe3 (patch)
tree7a9039919d15972babebc144c02747351dfcc4e1 /sys/net/if.h
parent9f00fc89d906c5a6addde7e01fc0ebd2b46d7927 (diff)
Add a way to convert the ifi_link_state to a string without the use of
if_media. This makes link state tracking a lot easier as there is no need to convert if types to if_media types, etc. Additionally this allows us to extend the link states to include states tracked on higher protocol layers. gre(4) keepalives packets, bfd and udld can be implemented without ugly hacks. OK henning, michele, sthen, deraadt
Diffstat (limited to 'sys/net/if.h')
-rw-r--r--sys/net/if.h53
1 files changed, 47 insertions, 6 deletions
diff --git a/sys/net/if.h b/sys/net/if.h
index e4c78fa5213..dcd904397a2 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.108 2009/08/10 11:22:10 deraadt Exp $ */
+/* $OpenBSD: if.h,v 1.109 2009/09/14 11:42:52 claudio Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -161,14 +161,55 @@ struct ifqueue {
/*
* Values for if_link_state.
*/
-#define LINK_STATE_UNKNOWN 0 /* link invalid/unknown */
-#define LINK_STATE_DOWN 1 /* link is down */
-#define LINK_STATE_UP 2 /* link is up */
-#define LINK_STATE_HALF_DUPLEX 3 /* link is up and half duplex */
-#define LINK_STATE_FULL_DUPLEX 4 /* link is up and full duplex */
+#define LINK_STATE_UNKNOWN 0 /* link unknown */
+#define LINK_STATE_INVALID 1 /* link invalid */
+#define LINK_STATE_DOWN 2 /* link is down */
+#define LINK_STATE_KALIVE_DOWN 3 /* keepalive reports down */
+#define LINK_STATE_UP 4 /* link is up */
+#define LINK_STATE_HALF_DUPLEX 5 /* link is up and half duplex */
+#define LINK_STATE_FULL_DUPLEX 6 /* link is up and full duplex */
+
#define LINK_STATE_IS_UP(_s) ((_s) >= LINK_STATE_UP)
/*
+ * Status bit descriptions for the various interface types.
+ */
+struct if_status_description {
+ u_char ifs_type;
+ u_char ifs_state;
+ const char *ifs_string;
+};
+
+#define LINK_STATE_DESC_MATCH(_ifs, _t, _s) \
+ (((_ifs)->ifs_type == (_t) || (_ifs)->ifs_type == 0) && \
+ (_ifs)->ifs_state == (_s))
+
+
+
+#define LINK_STATE_DESCRIPTIONS { \
+ { IFT_ETHER, LINK_STATE_DOWN, "no carrier" }, \
+ \
+ { IFT_IEEE80211, LINK_STATE_DOWN, "no network" }, \
+ \
+ { IFT_PPP, LINK_STATE_DOWN, "no carrier" }, \
+ \
+ { IFT_CARP, LINK_STATE_DOWN, "backup" }, \
+ { IFT_CARP, LINK_STATE_UP, "master" }, \
+ { IFT_CARP, LINK_STATE_HALF_DUPLEX, "master" }, \
+ { IFT_CARP, LINK_STATE_FULL_DUPLEX, "master" }, \
+ \
+ { 0, LINK_STATE_UP, "active" }, \
+ { 0, LINK_STATE_HALF_DUPLEX, "active" }, \
+ { 0, LINK_STATE_FULL_DUPLEX, "active" }, \
+ \
+ { 0, LINK_STATE_UNKNOWN, "unknown" }, \
+ { 0, LINK_STATE_INVALID, "invalid" }, \
+ { 0, LINK_STATE_DOWN, "down" }, \
+ { 0, LINK_STATE_KALIVE_DOWN, "keepalive down" }, \
+ { 0, 0, NULL } \
+}
+
+/*
* Structure defining a queue for a network interface.
*
* (Would like to call this struct ``if'', but C isn't PL/1.)