From owner-freebsd-net Thu Aug 15 13:33:23 2002 Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7F68037B400 for ; Thu, 15 Aug 2002 13:33:18 -0700 (PDT) Received: from odin.ac.hmc.edu (Odin.AC.HMC.Edu [134.173.32.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 060D043E65 for ; Thu, 15 Aug 2002 13:33:18 -0700 (PDT) (envelope-from brdavis@odin.ac.hmc.edu) Received: from odin.ac.hmc.edu (IDENT:brdavis@localhost.localdomain [127.0.0.1]) by odin.ac.hmc.edu (8.12.3/8.12.3) with ESMTP id g7FKXFwu007339 for ; Thu, 15 Aug 2002 13:33:15 -0700 Received: (from brdavis@localhost) by odin.ac.hmc.edu (8.12.3/8.12.3/Submit) id g7FKXFx4007338 for net@freebsd.org; Thu, 15 Aug 2002 13:33:15 -0700 Date: Thu, 15 Aug 2002 13:33:14 -0700 From: Brooks Davis To: net@freebsd.org Subject: adding if_printf() Message-ID: <20020815133314.A5037@Odin.AC.HMC.Edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="45Z9DzgjV8m4Oswq" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i X-Virus-Scanned: by amavisd-milter (http://amavis.org/) on odin.ac.hmc.edu Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --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 #include #include +#include =20 #include #include @@ -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