aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Moeller <freqlabs@FreeBSD.org>2021-02-28 09:34:30 +0000
committerRyan Moeller <freqlabs@FreeBSD.org>2021-02-28 21:43:54 +0000
commitb12a960e4274926171dc7a4f9887a0d0a5195b44 (patch)
tree3ff1fcfdeb174c7f28ea0228d7051624ddfd655a
parent64bacab177f7c743af3268a3e1ffcddaf77a68d0 (diff)
downloadsrc-b12a960e4274926171dc7a4f9887a0d0a5195b44.tar.gz
src-b12a960e4274926171dc7a4f9887a0d0a5195b44.zip
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
-rw-r--r--lib/libifconfig/Symbol.map1
-rw-r--r--lib/libifconfig/libifconfig.h9
-rw-r--r--lib/libifconfig/libifconfig_media.c10
3 files changed, 20 insertions, 0 deletions
diff --git a/lib/libifconfig/Symbol.map b/lib/libifconfig/Symbol.map
index 4f82c8185d0b..b3e81d6ee497 100644
--- a/lib/libifconfig/Symbol.map
+++ b/lib/libifconfig/Symbol.map
@@ -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;
diff --git a/lib/libifconfig/libifconfig.h b/lib/libifconfig/libifconfig.h
index 46a13ae27d69..d8245ea13b23 100644
--- a/lib/libifconfig/libifconfig.h
+++ b/lib/libifconfig/libifconfig.h
@@ -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);
diff --git a/lib/libifconfig/libifconfig_media.c b/lib/libifconfig/libifconfig_media.c
index f7302d8a9b24..d7ef507604be 100644
--- a/lib/libifconfig/libifconfig_media.c
+++ b/lib/libifconfig/libifconfig_media.c
@@ -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));
+}