diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/if.c | 16 | ||||
-rw-r--r-- | lib/if.h | 3 | ||||
-rw-r--r-- | lib/zclient.c | 2 |
3 files changed, 21 insertions, 0 deletions
@@ -270,6 +270,22 @@ if_is_up (struct interface *ifp) return ifp->flags & IFF_UP; } +/* Is interface running? */ +int +if_is_running (struct interface *ifp) +{ + return ifp->flags & IFF_RUNNING; +} + +/* Is the interface operative, eg. either UP & RUNNING + or UP & !ZEBRA_INTERFACE_LINK_DETECTION */ +int +if_is_operative (struct interface *ifp) +{ + return ((ifp->flags & IFF_UP) && + (ifp->flags & IFF_RUNNING || !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); +} + /* Is this loopback interface ? */ int if_is_loopback (struct interface *ifp) @@ -85,6 +85,7 @@ struct interface u_char status; #define ZEBRA_INTERFACE_ACTIVE (1 << 0) #define ZEBRA_INTERFACE_SUB (1 << 1) +#define ZEBRA_INTERFACE_LINKDETECTION (1 << 2) /* Interface flags. */ unsigned long flags; @@ -188,6 +189,8 @@ struct interface *if_lookup_address (struct in_addr); struct interface *if_get_by_name (char *); void if_delete (struct interface *); int if_is_up (struct interface *); +int if_is_running (struct interface *); +int if_is_operative (struct interface *); int if_is_loopback (struct interface *); int if_is_broadcast (struct interface *); int if_is_pointopoint (struct interface *); diff --git a/lib/zclient.c b/lib/zclient.c index 5e371546..c1b286f4 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -564,6 +564,7 @@ zebra_interface_add_read (struct stream *s) ifp->ifindex = stream_getl (s); /* Read interface's value. */ + ifp->status = stream_getc (s); ifp->flags = stream_getl (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); @@ -600,6 +601,7 @@ zebra_interface_state_read (struct stream *s) ifp->ifindex = stream_getl (s); /* Read interface's value. */ + ifp->status = stream_getc (s); ifp->flags = stream_getl (s); ifp->metric = stream_getl (s); ifp->mtu = stream_getl (s); |