svn commit: r277115 - projects/ifnet/sys/net

Gleb Smirnoff glebius at FreeBSD.org
Tue Jan 13 07:46:22 UTC 2015


Author: glebius
Date: Tue Jan 13 07:46:21 2015
New Revision: 277115
URL: https://svnweb.freebsd.org/changeset/base/277115

Log:
  Provide ifmedia_link_state() that converts media status word
  to link state.
  
  Sponsored by:	Nginx, Inc.

Modified:
  projects/ifnet/sys/net/if_media.c
  projects/ifnet/sys/net/if_media.h

Modified: projects/ifnet/sys/net/if_media.c
==============================================================================
--- projects/ifnet/sys/net/if_media.c	Tue Jan 13 07:45:42 2015	(r277114)
+++ projects/ifnet/sys/net/if_media.c	Tue Jan 13 07:46:21 2015	(r277115)
@@ -406,6 +406,19 @@ ifmedia_baudrate(int mword)
 	/* Not known. */
 	return (0);
 }
+
+int
+ifmedia_link_state(u_int mstatus)
+{
+
+	if (mstatus & IFM_AVALID) {
+		if (mstatus & IFM_ACTIVE)
+			return (LINK_STATE_UP);
+		else
+			return (LINK_STATE_DOWN);
+	} else
+		return (LINK_STATE_UNKNOWN);
+}
  
 #ifdef IFMEDIA_DEBUG
 struct ifmedia_description ifm_type_descriptions[] =

Modified: projects/ifnet/sys/net/if_media.h
==============================================================================
--- projects/ifnet/sys/net/if_media.h	Tue Jan 13 07:45:42 2015	(r277114)
+++ projects/ifnet/sys/net/if_media.h	Tue Jan 13 07:46:21 2015	(r277115)
@@ -106,10 +106,12 @@ void	ifmedia_set(struct ifmedia *ifm, in
 int	ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr,
 	    struct ifmedia *ifm, u_long cmd);
 
-
 /* Compute baudrate for a given media. */
 uint64_t	ifmedia_baudrate(int);
 
+/* Convert media status to link state. */
+int	ifmedia_link_state(u_int);
+
 #endif /*_KERNEL */
 
 /*


More information about the svn-src-projects mailing list