Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Aug 2002 13:33:14 -0700
From:      Brooks Davis <brooks@one-eyed-alien.net>
To:        net@freebsd.org
Subject:   adding if_printf()
Message-ID:  <20020815133314.A5037@Odin.AC.HMC.Edu>

next in thread | raw e-mail | index | archive | help

--45Z9DzgjV8m4Oswq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

I propose we create a new function if_printf() which is just like
device_printf() except that it takes a (struct ifnet *) instead of a
device_t.  It prints things like:

an0: message

Since this is what the vast majority of printfs in interface code, using
this function would be cleaner and easier.  Additionaly, it potentialy
gives driver authors a say to keep their source more compatable between
4.x and 5.x after the if_xname conversion.

A patch to add if_printf is below.

Does this seem like a good idea to other people?

-- Brooks

Index: if.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/net/if.c,v
retrieving revision 1.144
diff -u -p -r1.144 if.c
--- if.c	1 Aug 2002 21:15:53 -0000	1.144
+++ if.c	15 Aug 2002 19:40:57 -0000
@@ -55,6 +55,7 @@
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
 #include <sys/jail.h>
+#include <machine/stdarg.h>
=20
 #include <net/if.h>
 #include <net/if_arp.h>
@@ -1951,6 +1952,19 @@ ifmaof_ifpforaddr(sa, ifp)
 			break;
=20
 	return ifma;
+}
+
+int
+if_printf(struct ifnet *ifp, const char * fmt, ...)
+{
+	va_list ap;
+	int retval;
+
+	retval =3D printf("%s%d: ", ifp->if_name, ifp->if_unit);
+	va_start(ap, fmt);
+	retval +=3D vprintf(fmt, ap);
+	va_end(ap);
+	return (retval);
 }
=20
 SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");
Index: if_var.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /usr/cvs/src/sys/net/if_var.h,v
retrieving revision 1.48
diff -u -p -r1.48 if_var.h
--- if_var.h	14 Aug 2002 01:37:22 -0000	1.48
+++ if_var.h	15 Aug 2002 20:14:00 -0000
@@ -422,6 +422,7 @@ void	if_attach(struct ifnet *);
 int	if_delmulti(struct ifnet *, struct sockaddr *);
 void	if_detach(struct ifnet *);
 void	if_down(struct ifnet *);
+int	if_printf(struct ifnet *, const char *, ...) __printflike(2, 3);
 void	if_route(struct ifnet *, int flag, int fam);
 int	if_setlladdr(struct ifnet *, const u_char *, int);
 void	if_unroute(struct ifnet *, int flag, int fam);

--=20
Any statement of the form "X is the one, true Y" is FALSE.
PGP fingerprint 655D 519C 26A7 82E7 2529  9BF0 5D8E 8BE9 F238 1AD4

--45Z9DzgjV8m4Oswq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9XBAKXY6L6fI4GtQRAszrAJ9VRVhfV908nkgwA9gBqXJeFDcdFwCgm2er
1YMdwVcQAabGdlMPgokXzM0=
=+Ok6
-----END PGP SIGNATURE-----

--45Z9DzgjV8m4Oswq--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020815133314.A5037>