summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2002-09-24 17:35:08 +0000
committerbrooks <brooks@FreeBSD.org>2002-09-24 17:35:08 +0000
commitd039f38d0d117aa7a539cbc6c6b1fb592050eb12 (patch)
tree6bb2592d60be2179dc1f63ed27c053dfced72616 /sys/net/if.c
parentd73b1f9b7b8eb6c020851d65c60869d788e84828 (diff)
downloadFreeBSD-src-d039f38d0d117aa7a539cbc6c6b1fb592050eb12.zip
FreeBSD-src-d039f38d0d117aa7a539cbc6c6b1fb592050eb12.tar.gz
Add a new helper function if_printf() modeled on device_printf(). The
function takes a struct ifnet pointer followed by the usual printf arguments and prints "<interfacename>: " before the results of printf. Since this is the primary form of printf calls in network device drivers and accounts for most uses of the ifnet menber if_unit, this significantly simplifies many printf()s.
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 25b8dc8..699278b 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -55,6 +55,7 @@
#include <sys/syslog.h>
#include <sys/sysctl.h>
#include <sys/jail.h>
+#include <machine/stdarg.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -1972,5 +1973,18 @@ ifmaof_ifpforaddr(sa, ifp)
return ifma;
}
+int
+if_printf(struct ifnet *ifp, const char * fmt, ...)
+{
+ va_list ap;
+ int retval;
+
+ retval = printf("%s%d: ", ifp->if_name, ifp->if_unit);
+ va_start(ap, fmt);
+ retval += vprintf(fmt, ap);
+ va_end(ap);
+ return (retval);
+}
+
SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");
SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management");
OpenPOWER on IntegriCloud