diff --git a/lib/libifconfig/Symbol.map b/lib/libifconfig/Symbol.map --- a/lib/libifconfig/Symbol.map +++ b/lib/libifconfig/Symbol.map @@ -31,6 +31,7 @@ ifconfig_media_get_status; ifconfig_media_get_subtype; ifconfig_media_get_type; + ifconfig_media_get_downreason; ifconfig_open; ifconfig_set_capability; ifconfig_set_description; diff --git a/lib/libifconfig/libifconfig.h b/lib/libifconfig/libifconfig.h --- a/lib/libifconfig/libifconfig.h +++ b/lib/libifconfig/libifconfig.h @@ -207,6 +207,15 @@ const char *ifconfig_media_get_status(const struct ifmediareq *ifmr); void ifconfig_media_get_options_string(int ifmw, char *buf, size_t buflen); +/** Retrieve the reason the interface is down + * @param h An open ifconfig state object + * @param name The interface name + * @param ifdr Return argument. + * @return 0 on success, nonzero on failure + */ +int ifconfig_media_get_downreason(ifconfig_handle_t *h, const char *name, + struct ifdownreason *ifdr); + int ifconfig_carp_get_info(ifconfig_handle_t *h, const char *name, struct carpreq *carpr, int ncarpr); diff --git a/lib/libifconfig/libifconfig_media.c b/lib/libifconfig/libifconfig_media.c --- a/lib/libifconfig/libifconfig_media.c +++ b/lib/libifconfig/libifconfig_media.c @@ -392,3 +392,13 @@ } } } + +int +ifconfig_media_get_downreason(ifconfig_handle_t *h, const char *name, + struct ifdownreason *ifdr) +{ + + (void)memset(ifdr, 0, sizeof(*ifdr)); + (void)strlcpy(ifdr->ifdr_name, name, sizeof(ifdr->ifdr_name)); + return (ifconfig_ioctlwrap(h, AF_LOCAL, SIOCGIFDOWNREASON, ifdr)); +}