diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-11 16:12:10 -0700 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2008-07-11 19:01:09 -0700 |
commit | 775e09c69825718c8d24d193e86c826cb0bf8f68 (patch) | |
tree | 3c78f1f5bcf67f71f2ee7fa96697d20f41f649ae /lib/if.h | |
parent | d6dc4ba487f79ba79e5fb02f4c3e978fa1edeee5 (diff) | |
download | quagga-775e09c69825718c8d24d193e86c826cb0bf8f68.tar.bz2 quagga-775e09c69825718c8d24d193e86c826cb0bf8f68.tar.xz |
Make some trivial functions on interfaces inline
Make the trivial boolean functions inline to help performance
and code size.
Diffstat (limited to 'lib/if.h')
-rw-r--r-- | lib/if.h | 63 |
1 files changed, 56 insertions, 7 deletions
@@ -257,13 +257,62 @@ extern void if_delete_retain (struct interface *); deletes it from the interface list and frees the structure. */ extern void if_delete (struct interface *); -extern int if_is_up (struct interface *); -extern int if_is_running (struct interface *); -extern int if_is_operative (struct interface *); -extern int if_is_loopback (struct interface *); -extern int if_is_broadcast (struct interface *); -extern int if_is_pointopoint (struct interface *); -extern int if_is_multicast (struct interface *); +/* Does interface up ? */ +static inline int +if_is_up (const struct interface *ifp) +{ + return ifp->flags & IFF_UP; +} + +/* Is interface running? */ +static inline int +if_is_running (const struct interface *ifp) +{ + return ifp->flags & IFF_RUNNING; +} + +/* Is the interface operative, eg. either UP & RUNNING + or UP & !ZEBRA_INTERFACE_LINK_DETECTION */ +static inline int +if_is_operative (const struct interface *ifp) +{ + return ((ifp->flags & IFF_UP) && + (ifp->flags & IFF_RUNNING || + !CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_LINKDETECTION))); +} + +/* Is this loopback interface ? */ +static inline int +if_is_loopback (const struct interface *ifp) +{ + /* XXX: Do this better, eg what if IFF_WHATEVER means X on platform M + * but Y on platform N? + */ + return (ifp->flags & (IFF_LOOPBACK|IFF_NOXMIT|IFF_VIRTUAL)); +} + +/* Does this interface support broadcast ? */ +static inline int +if_is_broadcast (const struct interface *ifp) +{ + return ifp->flags & IFF_BROADCAST; +} + +/* Does this interface support broadcast ? */ +static inline int +if_is_pointopoint (const struct interface *ifp) +{ + return ifp->flags & IFF_POINTOPOINT; +} + +/* Does this interface support multicast ? */ +static inline int +if_is_multicast (const struct interface *ifp) +{ + return ifp->flags & IFF_MULTICAST; +} + + extern void if_add_hook (int, int (*)(struct interface *)); extern void if_init (void); extern void if_dump_all (void); |