summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1996-01-24 21:12:23 +0000
committerphk <phk@FreeBSD.org>1996-01-24 21:12:23 +0000
commite7b9c377f822bc4d0b50421da4eccbe73e43678b (patch)
tree0421eea4b1ecfb759a27845bf2c1d67cdf1d79c3 /sys/net
parentdefff6cc5b2169d11d666f9ccd9d32a5719a8f28 (diff)
downloadFreeBSD-src-e7b9c377f822bc4d0b50421da4eccbe73e43678b.zip
FreeBSD-src-e7b9c377f822bc4d0b50421da4eccbe73e43678b.tar.gz
Use new printf features rather than local kludges.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c50
-rw-r--r--sys/net/if_ethersubr.c23
-rw-r--r--sys/net/if_ppp.c7
-rw-r--r--sys/net/ppp_tty.c30
4 files changed, 20 insertions, 90 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 4525600..62dc2fb 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
- * $Id: if.c,v 1.24 1995/12/09 20:47:08 phk Exp $
+ * $Id: if.c,v 1.25 1995/12/20 21:53:38 wollman Exp $
*/
#include <sys/param.h>
@@ -62,7 +62,6 @@ static void ifinit __P((void *));
static void if_qflush __P((struct ifqueue *));
static void if_slowtimo __P((void *));
static void link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
-static char *sprint_d __P((u_int, char *, int));
SYSINIT(interfaces, SI_SUB_PROTO_IF, SI_ORDER_FIRST, ifinit, NULL)
@@ -104,8 +103,8 @@ if_attach(ifp)
struct ifnet *ifp;
{
unsigned socksize, ifasize;
- int namelen, unitlen, masklen;
- char workbuf[12], *unitname;
+ int namelen, masklen;
+ char workbuf[64];
register struct ifnet **p = &ifnet;
register struct sockaddr_dl *sdl;
register struct ifaddr *ifa;
@@ -130,12 +129,9 @@ if_attach(ifp)
/*
* create a Link Level name for this device
*/
- unitname = sprint_d((u_int)ifp->if_unit, workbuf, sizeof(workbuf));
- namelen = strlen(ifp->if_name);
- unitlen = strlen(unitname);
+ namelen = sprintf(workbuf, "%s%d", ifp->if_name, ifp->if_unit);
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
- masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) +
- unitlen + namelen;
+ masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
socksize = masklen + ifp->if_addrlen;
#define ROUNDUP(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
socksize = ROUNDUP(socksize);
@@ -148,9 +144,8 @@ if_attach(ifp)
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
sdl->sdl_family = AF_LINK;
- bcopy(ifp->if_name, sdl->sdl_data, namelen);
- bcopy(unitname, namelen + (caddr_t)sdl->sdl_data, unitlen);
- sdl->sdl_nlen = (namelen += unitlen);
+ bcopy(workbuf, sdl->sdl_data, namelen);
+ sdl->sdl_nlen = namelen;
sdl->sdl_index = ifp->if_index;
sdl->sdl_type = ifp->if_type;
ifnet_addrs[if_index - 1] = ifa;
@@ -159,6 +154,7 @@ if_attach(ifp)
ifa->ifa_rtrequest = link_rtrequest;
ifp->if_addrlist = ifa;
ifa->ifa_addr = (struct sockaddr *)sdl;
+
sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
ifa->ifa_netmask = (struct sockaddr *)sdl;
sdl->sdl_len = masklen;
@@ -681,17 +677,14 @@ ifconf(cmd, data)
ifrp = ifc->ifc_req;
for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
- char workbuf[12], *unitname;
- int unitlen, ifnlen;
+ char workbuf[64];
+ int ifnlen;
- unitname = sprint_d(ifp->if_unit, workbuf, sizeof workbuf);
- unitlen = strlen(unitname);
- ifnlen = strlen(ifp->if_name);
- if(unitlen + ifnlen + 1 > sizeof ifr.ifr_name) {
+ ifnlen = sprintf(workbuf, "%s%d", ifp->if_name, ifp->if_unit);
+ if(ifnlen + 1 > sizeof ifr.ifr_name) {
error = ENAMETOOLONG;
} else {
- strcpy(ifr.ifr_name, ifp->if_name);
- strcpy(&ifr.ifr_name[ifnlen], unitname);
+ strcpy(ifr.ifr_name, workbuf);
}
if ((ifa = ifp->if_addrlist) == 0) {
@@ -741,21 +734,4 @@ ifconf(cmd, data)
return (error);
}
-static char *
-sprint_d(n, buf, buflen)
- u_int n;
- char *buf;
- int buflen;
-{
- register char *cp = buf + buflen - 1;
-
- *cp = 0;
- do {
- cp--;
- *cp = "0123456789"[n % 10];
- n /= 10;
- } while (n != 0);
- return (cp);
-}
-
SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index c4e5dbc..9adc8ef 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
- * $Id: if_ethersubr.c,v 1.12 1995/12/09 20:47:11 phk Exp $
+ * $Id: if_ethersubr.c,v 1.13 1995/12/20 21:53:40 wollman Exp $
*/
#include <sys/param.h>
@@ -487,27 +487,6 @@ ether_input(ifp, eh, m)
}
/*
- * Convert Ethernet address to printable (loggable) representation.
- */
-static char digits[] = "0123456789abcdef";
-char *
-ether_sprintf(ap)
- register u_char *ap;
-{
- register i;
- static char etherbuf[18];
- register char *cp = etherbuf;
-
- for (i = 0; i < 6; i++) {
- *cp++ = digits[*ap >> 4];
- *cp++ = digits[*ap++ & 0xf];
- *cp++ = ':';
- }
- *--cp = 0;
- return (etherbuf);
-}
-
-/*
* Perform common duties while attaching to interface list
*/
void
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 9c3d976..d059223 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -69,7 +69,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
-/* $Id: if_ppp.c,v 1.28 1995/11/13 22:09:39 peter Exp $ */
+/* $Id: if_ppp.c,v 1.29 1995/12/14 09:53:13 phk Exp $ */
/* from if_ppp.c,v 1.5 1995/08/16 01:36:38 paulus Exp */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
@@ -1413,7 +1413,6 @@ pppdumpm(m0)
char buf[3*MAX_DUMP_BYTES+4];
char *bp = buf;
struct mbuf *m;
- static char digits[] = "0123456789abcdef";
for (m = m0; m; m = m->m_next) {
int l = m->m_len;
@@ -1422,8 +1421,8 @@ pppdumpm(m0)
while (l--) {
if (bp > buf + sizeof(buf) - 4)
goto done;
- *bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
- *bp++ = digits[*rptr++ & 0xf];
+ *bp++ = hex2ascii(*rptr >> 4);
+ *bp++ = hex2ascii(*rptr++ & 0xf);
}
if (m->m_next) {
diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c
index 98b837d..cc46cf8 100644
--- a/sys/net/ppp_tty.c
+++ b/sys/net/ppp_tty.c
@@ -70,7 +70,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
-/* $Id: ppp_tty.c,v 1.3 1995/11/01 00:58:43 peter Exp $ */
+/* $Id: ppp_tty.c,v 1.4 1995/12/14 09:53:20 phk Exp $ */
/* from Id: ppp_tty.c,v 1.3 1995/08/16 01:36:40 paulus Exp */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
@@ -134,7 +134,6 @@ static void pppasyncrelinq __P((struct ppp_softc *));
static void pppasyncsetmtu __P((struct ppp_softc *));
static void ppp_timeout __P((void *));
static void pppgetm __P((struct ppp_softc *sc));
-static void pppdumpb __P((u_char *b, int l));
static void ppplogchar __P((struct ppp_softc *, int));
/*
@@ -1100,33 +1099,10 @@ ppplogchar(sc, c)
sc->sc_rawin[sc->sc_rawin_count++] = c;
if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
|| c < 0 && sc->sc_rawin_count > 0) {
- printf("ppp%d input: ", sc->sc_if.if_unit);
- pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
+ printf("ppp%d input: %*D", sc->sc_if.if_unit,
+ sc->sc_rawin_count, sc->sc_rawin, " ");
sc->sc_rawin_count = 0;
}
}
-static void
-pppdumpb(b, l)
- u_char *b;
- int l;
-{
- char buf[3*MAX_DUMP_BYTES+4];
- char *bp = buf;
- static char digits[] = "0123456789abcdef";
-
- while (l--) {
- if (bp >= buf + sizeof(buf) - 3) {
- *bp++ = '>';
- break;
- }
- *bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
- *bp++ = digits[*b++ & 0xf];
- *bp++ = ' ';
- }
-
- *bp = 0;
- printf("%s\n", buf);
-}
-
#endif /* NPPP > 0 */
OpenPOWER on IntegriCloud