git: b12a960e4274 - main - libifconfig: Add a function to get down reason

Ryan Moeller freqlabs at FreeBSD.org
Sun Feb 28 21:47:06 UTC 2021


The branch main has been updated by freqlabs:

URL: https://cgit.FreeBSD.org/src/commit/?id=b12a960e4274926171dc7a4f9887a0d0a5195b44

commit b12a960e4274926171dc7a4f9887a0d0a5195b44
Author:     Ryan Moeller <freqlabs at FreeBSD.org>
AuthorDate: 2021-02-28 09:34:30 +0000
Commit:     Ryan Moeller <freqlabs at FreeBSD.org>
CommitDate: 2021-02-28 21:43:54 +0000

    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
---
 lib/libifconfig/Symbol.map          |  1 +
 lib/libifconfig/libifconfig.h       |  9 +++++++++
 lib/libifconfig/libifconfig_media.c | 10 ++++++++++
 3 files changed, 20 insertions(+)

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));
+}


More information about the dev-commits-src-all mailing list