libifconfig: Add a function to get down reason

For use in ifconfig.

Reviewed by:	kp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D28991
This commit is contained in:
Ryan Moeller 2021-02-28 09:34:30 +00:00
parent 64bacab177
commit b12a960e42
3 changed files with 20 additions and 0 deletions

View file

@ -31,6 +31,7 @@ FBSD_1.6 {
ifconfig_media_get_status;
ifconfig_media_get_subtype;
ifconfig_media_get_type;
ifconfig_media_get_downreason;
ifconfig_open;
ifconfig_set_capability;
ifconfig_set_description;

View file

@ -207,6 +207,15 @@ const char *ifconfig_media_get_subtype(int ifmw);
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);

View file

@ -392,3 +392,13 @@ ifconfig_media_get_options_string(int ifmw, char *buf, size_t buflen)
}
}
}
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));
}