diff options
| author | 1996-05-10 12:31:01 +0000 | |
|---|---|---|
| committer | 1996-05-10 12:31:01 +0000 | |
| commit | 09d901c00137cd7253a32d0af99153adea6fb4cd (patch) | |
| tree | b102ded9a192d562503deea757f2b50fb5aef00c /sys/net | |
| parent | remove makelinks, when done. (diff) | |
| download | wireguard-openbsd-09d901c00137cd7253a32d0af99153adea6fb4cd.tar.xz wireguard-openbsd-09d901c00137cd7253a32d0af99153adea6fb4cd.zip | |
if_name/if_unit -> if_xname/if_softc
Diffstat (limited to 'sys/net')
| -rw-r--r-- | sys/net/bpf.c | 52 | ||||
| -rw-r--r-- | sys/net/if.c | 160 | ||||
| -rw-r--r-- | sys/net/if.h | 19 | ||||
| -rw-r--r-- | sys/net/if_arcsubr.c | 16 | ||||
| -rw-r--r-- | sys/net/if_ethersubr.c | 6 | ||||
| -rw-r--r-- | sys/net/if_fddisubr.c | 8 | ||||
| -rw-r--r-- | sys/net/if_loop.c | 10 | ||||
| -rw-r--r-- | sys/net/if_ppp.c | 49 | ||||
| -rw-r--r-- | sys/net/if_pppvar.h | 3 | ||||
| -rw-r--r-- | sys/net/if_sl.c | 15 | ||||
| -rw-r--r-- | sys/net/if_slvar.h | 3 | ||||
| -rw-r--r-- | sys/net/if_tun.c | 57 | ||||
| -rw-r--r-- | sys/net/ppp_tty.c | 28 |
13 files changed, 186 insertions, 240 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 9e390851c7d..de2153e75ed 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,5 +1,5 @@ -/* $OpenBSD: bpf.c,v 1.3 1996/04/21 22:28:27 deraadt Exp $ */ -/* $NetBSD: bpf.c,v 1.25 1996/03/30 21:57:30 christos Exp $ */ +/* $OpenBSD: bpf.c,v 1.4 1996/05/10 12:31:05 deraadt Exp $ */ +/* $NetBSD: bpf.c,v 1.27 1996/05/07 05:26:02 thorpej Exp $ */ /* * Copyright (c) 1990, 1991, 1993 @@ -899,34 +899,39 @@ bpf_setif(d, ifr) { struct bpf_if *bp; char *cp; - int unit, s, error; + int unit_seen, i, s, error; /* - * Separate string into name part and unit number. Put a null - * byte at the end of the name part, and compute the number. - * If the a unit number is unspecified, the default is 0, - * as initialized above. XXX This should be common code. + * Make sure the provided name has a unit number, and default + * it to '0' if not specified. + * XXX This is ugly ... do this differently? */ - unit = 0; + unit_seen = 0; cp = ifr->ifr_name; - cp[sizeof(ifr->ifr_name) - 1] = '\0'; - while (*cp++) { - if (*cp >= '0' && *cp <= '9') { - unit = *cp - '0'; - *cp++ = '\0'; - while (*cp) - unit = 10 * unit + *cp++ - '0'; - break; + cp[sizeof(ifr->ifr_name) - 1] = '\0'; /* sanity */ + while (*cp++) + if (*cp >= '0' && *cp <= '9') + unit_seen = 1; + if (!unit_seen) { + /* Make sure to leave room for the '\0'. */ + for (i = 0; i < (IFNAMSIZ - 1); ++i) { + if ((ifr->ifr_name[i] >= 'a' && + ifr->ifr_name[i] <= 'z') || + (ifr->ifr_name[i] >= 'A' && + ifr->ifr_name[i] <= 'Z')) + continue; + ifr->ifr_name[i] = '0'; } } + /* * Look through attached interfaces for the named one. */ for (bp = bpf_iflist; bp != 0; bp = bp->bif_next) { struct ifnet *ifp = bp->bif_ifp; - if (ifp == 0 || unit != ifp->if_unit - || strcmp(ifp->if_name, ifr->ifr_name) != 0) + if (ifp == 0 || + strcmp(ifp->if_xname, ifr->ifr_name) != 0) continue; /* * We found the requested interface. @@ -962,20 +967,15 @@ bpf_setif(d, ifr) } /* - * Convert an interface name plus unit number of an ifp to a single - * name which is returned in the ifr. + * Copy the interface name to the ifreq. */ static void bpf_ifname(ifp, ifr) struct ifnet *ifp; struct ifreq *ifr; { - char *s = ifp->if_name; - char *d = ifr->ifr_name; - while ((*d++ = *s++) != '\0') - continue; - sprintf(d, "%d", ifp->if_unit); + bcopy(ifp->if_xname, ifr->ifr_name, IFNAMSIZ); } /* @@ -1298,7 +1298,7 @@ bpfattach(driverp, ifp, dlt, hdrlen) D_MARKFREE(&bpf_dtab[i]); #if 0 - printf("bpf: %s%d attached\n", ifp->if_name, ifp->if_unit); + printf("bpf: %s attached\n", ifp->if_xname); #endif } diff --git a/sys/net/if.c b/sys/net/if.c index 426939ffdb7..b3da97849c1 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if.c,v 1.8 1996/05/09 11:10:28 deraadt Exp $ */ -/* $NetBSD: if.c,v 1.24 1996/02/13 22:00:09 christos Exp $ */ +/* $OpenBSD: if.c,v 1.9 1996/05/10 12:31:07 deraadt Exp $ */ +/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* * Copyright (c) 1980, 1986, 1993 @@ -73,7 +73,6 @@ ifinit() int if_index = 0; struct ifaddr **ifnet_addrs; -static char *sprint_d __P((u_int, char *, int)); /* * Attach an interface to the @@ -84,8 +83,7 @@ if_attach(ifp) struct ifnet *ifp; { unsigned socksize, ifasize; - int namelen, unitlen, masklen; - char workbuf[12], *unitname; + int namelen, masklen; register struct sockaddr_dl *sdl; register struct ifaddr *ifa; static int if_indexlim = 8; @@ -108,12 +106,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 = strlen(ifp->if_xname); #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))) if (socksize < sizeof(*sdl)) @@ -125,9 +120,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(ifp->if_xname, 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; @@ -394,7 +388,7 @@ if_slowtimo(arg) if (ifp->if_timer == 0 || --ifp->if_timer) continue; if (ifp->if_watchdog) - (*ifp->if_watchdog)(ifp->if_unit); + (*ifp->if_watchdog)(ifp); } splx(s); timeout(if_slowtimo, NULL, hz / IFNET_SLOWHZ); @@ -408,36 +402,13 @@ struct ifnet * ifunit(name) register char *name; { - register char *cp; register struct ifnet *ifp; - int unit; - unsigned len; - char *ep, c; - for (cp = name; cp < name + IFNAMSIZ && *cp; cp++) - if (*cp >= '0' && *cp <= '9') - break; - if (*cp == '\0' || cp == name + IFNAMSIZ) - return ((struct ifnet *)0); - /* - * Save first char of unit, and pointer to it, - * so we can put a null there to avoid matching - * initial substrings of interface names. - */ - len = cp - name + 1; - c = *cp; - ep = cp; - for (unit = 0; *cp >= '0' && *cp <= '9'; ) - unit = unit * 10 + *cp++ - '0'; - *ep = 0; - for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) { - if (bcmp(ifp->if_name, name, len)) - continue; - if (unit == ifp->if_unit) - break; - } - *ep = c; - return (ifp); + for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) + if (strcmp(ifp->if_xname, name) == 0) + return (ifp); + + return (NULL); } /* @@ -586,33 +557,13 @@ ifconf(cmd, data) register struct ifconf *ifc = (struct ifconf *)data; register struct ifnet *ifp; register struct ifaddr *ifa; - register char *cp, *ep; struct ifreq ifr, *ifrp; int space = ifc->ifc_len, error = 0; - int i, ndig; ifrp = ifc->ifc_req; - ep = ifr.ifr_name + sizeof (ifr.ifr_name); - for (ifp = ifnet.tqh_first; - space > sizeof (ifr) && ifp != 0; ifp = ifp->if_list.tqe_next) { - strncpy(ifr.ifr_name, ifp->if_name, sizeof(ifr.ifr_name) - 2); - for (cp = ifr.ifr_name; cp < ep && *cp; cp++) - continue; - i = ifp->if_unit; - ndig = 0; - do { - ndig++; - i /= 10; - } while (i); - cp += ndig; - if (cp >= ep) - continue; - *cp = '\0'; - i = ifp->if_unit; - do { - *--cp = '0' + i % 10; - i /= 10; - } while (i); + for (ifp = ifnet.tqh_first; space >= sizeof (ifr) && ifp != 0; + ifp = ifp->if_list.tqe_next) { + bcopy(ifp->if_xname, ifr.ifr_name, IFNAMSIZ); if ((ifa = ifp->if_addrlist.tqh_first) == 0) { bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr)); error = copyout((caddr_t)&ifr, (caddr_t)ifrp, @@ -621,58 +572,43 @@ ifconf(cmd, data) break; space -= sizeof (ifr), ifrp++; } else - for (; space > sizeof (ifr) && ifa != 0; ifa = ifa->ifa_list.tqe_next) { - register struct sockaddr *sa = ifa->ifa_addr; + for (; space >= sizeof (ifr) && ifa != 0; + ifa = ifa->ifa_list.tqe_next) { + register struct sockaddr *sa = ifa->ifa_addr; #if defined(COMPAT_43) || defined(COMPAT_LINUX) || defined(COMPAT_SVR4) - if (cmd == OSIOCGIFCONF) { - struct osockaddr *osa = - (struct osockaddr *)&ifr.ifr_addr; - ifr.ifr_addr = *sa; - osa->sa_family = sa->sa_family; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr)); - ifrp++; - } else + if (cmd == OSIOCGIFCONF) { + struct osockaddr *osa = + (struct osockaddr *)&ifr.ifr_addr; + ifr.ifr_addr = *sa; + osa->sa_family = sa->sa_family; + error = copyout((caddr_t)&ifr, (caddr_t)ifrp, + sizeof (ifr)); + ifrp++; + } else #endif - if (sa->sa_len <= sizeof(*sa)) { - ifr.ifr_addr = *sa; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr)); - ifrp++; - } else { - space -= sa->sa_len - sizeof(*sa); - if (space < sizeof (ifr)) + if (sa->sa_len <= sizeof(*sa)) { + ifr.ifr_addr = *sa; + error = copyout((caddr_t)&ifr, (caddr_t)ifrp, + sizeof (ifr)); + ifrp++; + } else { + space -= sa->sa_len - sizeof(*sa); + if (space < sizeof (ifr)) + break; + error = copyout((caddr_t)&ifr, (caddr_t)ifrp, + sizeof (ifr.ifr_name)); + if (error == 0) + error = copyout((caddr_t)sa, + (caddr_t)&ifrp->ifr_addr, + sa->sa_len); + ifrp = (struct ifreq *)(sa->sa_len + + (caddr_t)&ifrp->ifr_addr); + } + if (error) break; - error = copyout((caddr_t)&ifr, (caddr_t)ifrp, - sizeof (ifr.ifr_name)); - if (error == 0) - error = copyout((caddr_t)sa, - (caddr_t)&ifrp->ifr_addr, sa->sa_len); - ifrp = (struct ifreq *) - (sa->sa_len + (caddr_t)&ifrp->ifr_addr); + space -= sizeof (ifr); } - if (error) - break; - space -= sizeof (ifr); - } } ifc->ifc_len -= space; 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); -} diff --git a/sys/net/if.h b/sys/net/if.h index 404671ced18..db86882d94d 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,5 +1,5 @@ -/* $OpenBSD: if.h,v 1.4 1996/05/06 05:43:43 mickey Exp $ */ -/* $NetBSD: if.h,v 1.20 1996/02/13 22:00:12 christos Exp $ */ +/* $OpenBSD: if.h,v 1.5 1996/05/10 12:31:07 deraadt Exp $ */ +/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -106,14 +106,20 @@ struct if_data { */ TAILQ_HEAD(ifnet_head, ifnet); /* the actual queue head */ +/* + * Length of interface external name, including terminating '\0'. + * Note: this is the same size as a generic device's external name. + */ +#define IFNAMSIZ 16 + struct ifnet { /* and the entries */ - char *if_name; /* name, e.g. ``en'' or ``lo'' */ + void *if_softc; /* lower-level data for this if */ TAILQ_ENTRY(ifnet) if_list; /* all struct ifnets are chained */ TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */ + char if_xname[IFNAMSIZ]; /* external name (name + unit) */ int if_pcount; /* number of promiscuous listeners */ caddr_t if_bpf; /* packet filter structure */ u_short if_index; /* numeric abbreviation for this if */ - short if_unit; /* sub-unit for lower level driver */ short if_timer; /* time 'til if_watchdog called */ short if_flags; /* up/down, broadcast, etc. */ struct if_data if_data; /* statistics and other data about if */ @@ -126,9 +132,9 @@ struct ifnet { /* and the entries */ int (*if_ioctl) /* ioctl routine */ __P((struct ifnet *, u_long, caddr_t)); int (*if_reset) /* XXX bus reset routine */ - __P((int)); + __P((struct ifnet *)); void (*if_watchdog) /* timer routine */ - __P((int)); + __P((struct ifnet *)); struct ifqueue { struct mbuf *ifq_head; struct mbuf *ifq_tail; @@ -271,7 +277,6 @@ struct ifa_msghdr { * remainder may be interface specific. */ struct ifreq { -#define IFNAMSIZ 16 char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */ union { struct sockaddr ifru_addr; diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c index e10d561bf84..0b77b6ef8c0 100644 --- a/sys/net/if_arcsubr.c +++ b/sys/net/if_arcsubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_arcsubr.c,v 1.7 1996/04/15 14:01:25 is Exp $ */ +/* $NetBSD: if_arcsubr.c,v 1.8 1996/05/07 02:40:29 thorpej Exp $ */ /* * Copyright (c) 1994, 1995 Ignatios Souvatzis @@ -168,7 +168,7 @@ arc_output(ifp, m0, dst, rt0) break; default: - printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, + printf("%s: can't handle af%d\n", ifp->if_xname, dst->sa_family); senderr(EAFNOSUPPORT); } @@ -434,8 +434,8 @@ outofseq: if (m) m_freem(m); - log(LOG_INFO,"%s%d: got out of seq. packet: %s\n", - ifp->if_name, ifp->if_unit, s); + log(LOG_INFO,"%s: got out of seq. packet: %s\n", + ifp->if_xname, s); return NULL; } @@ -552,16 +552,16 @@ arc_ifattach(ifp) ifp->if_hdrlen = ARC_HDRLEN; if (ifp->if_flags & IFF_LINK0 && arc_phdsmtu > 60480) log(LOG_ERR, - "%s%d: arc_phdsmtu is %d, but must not exceed 60480", - ifp->if_name, ifp->if_unit, arc_phdsmtu); + "%s: arc_phdsmtu is %d, but must not exceed 60480", + ifp->if_xname, arc_phdsmtu); ifp->if_mtu = (ifp->if_flags & IFF_LINK0 ? arc_phdsmtu : ARCMTU); ac = (struct arccom *)ifp; ac->ac_seqid = (time.tv_sec) & 0xFFFF; /* try to make seqid unique */ if (ac->ac_anaddr == 0) { /* XXX this message isn't entirely clear, to me -- cgd */ - log(LOG_ERR,"%s%d: link address 0 reserved for broadcasts. Please change it and ifconfig %s%d down up\n", - ifp->if_name,ifp->if_unit,ifp->if_name,ifp->if_unit); + log(LOG_ERR,"%s: link address 0 reserved for broadcasts. Please change it and ifconfig %s down up\n", + ifp->if_xname, ifp->if_xname); } for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; ifa = ifa->ifa_list.tqe_next) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 2f1e87c6c38..88088654d62 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ethersubr.c,v 1.11 1996/05/06 14:13:53 mickey Exp $ */ -/* $NetBSD: if_ethersubr.c,v 1.18 1996/02/13 22:00:14 christos Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.12 1996/05/10 12:31:08 deraadt Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* * Copyright (c) 1982, 1989, 1993 @@ -333,7 +333,7 @@ ether_output(ifp, m0, dst, rt0) break; default: - printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, + printf("%s: can't handle af%d\n", ifp->if_xname, dst->sa_family); senderr(EAFNOSUPPORT); } diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c index 3e725b4dbe0..20ff08117e4 100644 --- a/sys/net/if_fddisubr.c +++ b/sys/net/if_fddisubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_fddisubr.c,v 1.3 1995/12/24 03:32:03 mycroft Exp $ */ +/* $NetBSD: if_fddisubr.c,v 1.4 1996/05/07 02:40:32 thorpej Exp $ */ /* * Copyright (c) 1995 @@ -234,6 +234,7 @@ fddi_output(ifp, m0, dst, rt0) l = mtod(m, struct llc *); l->llc_dsap = l->llc_ssap = LLC_ISO_LSAP; l->llc_control = LLC_UI; +#if defined(__FreeBSD__) IFDEBUG(D_ETHER) int i; printf("unoutput: sending pkt to: "); @@ -241,6 +242,7 @@ fddi_output(ifp, m0, dst, rt0) printf("%x ", edst[i] & 0xff); printf("\n"); ENDDEBUG +#endif } break; #endif /* ISO */ #ifdef LLC @@ -331,7 +333,7 @@ fddi_output(ifp, m0, dst, rt0) } #endif default: - printf("%s%d: can't handle af%d\n", ifp->if_name, ifp->if_unit, + printf("%s: can't handle af%d\n", ifp->if_xname, dst->sa_family); senderr(EAFNOSUPPORT); } @@ -484,9 +486,11 @@ fddi_input(ifp, fh, m) if (m == 0) return; *mtod(m, struct fddi_header *) = *fh; +#if defined(__FreeBSD__) IFDEBUG(D_ETHER) printf("clnp packet"); ENDDEBUG +#endif schednetisr(NETISR_ISO); inq = &clnlintrq; break; diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 4a2dd0f4684..a15519e3242 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_loop.c,v 1.4 1996/04/28 14:37:06 mickey Exp $ */ -/* $NetBSD: if_loop.c,v 1.14 1995/07/23 16:33:08 mycroft Exp $ */ +/* $OpenBSD: if_loop.c,v 1.5 1996/05/10 12:31:09 deraadt Exp $ */ +/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -98,8 +98,8 @@ loopattach(n) for (i = 0; i < NLOOP; i++) { ifp = &loif[i]; - ifp->if_unit = i; - ifp->if_name = "lo"; + sprintf(ifp->if_xname, "lo%d", i); + ifp->if_softc = NULL; ifp->if_mtu = LOMTU; ifp->if_flags = IFF_LOOPBACK | IFF_MULTICAST; ifp->if_ioctl = loioctl; @@ -187,7 +187,7 @@ looutput(ifp, m, dst, rt) break; #endif default: - printf("lo%d: can't handle af%d\n", ifp->if_unit, + printf("%s: can't handle af%d\n", ifp->if_xname, dst->sa_family); m_freem(m); return (EAFNOSUPPORT); diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 93b273aff9c..4e8dc87d27e 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_ppp.c,v 1.6 1996/04/21 22:28:32 deraadt Exp $ */ -/* $NetBSD: if_ppp.c,v 1.30 1996/03/19 01:00:49 paulus Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.7 1996/05/10 12:31:10 deraadt Exp $ */ +/* $NetBSD: if_ppp.c,v 1.31 1996/05/07 02:40:36 thorpej Exp $ */ /* * if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver. @@ -182,8 +182,9 @@ pppattach() register int i = 0; for (sc = ppp_softc; i < NPPP; sc++) { - sc->sc_if.if_name = "ppp"; - sc->sc_if.if_unit = i++; + sc->sc_unit = i; /* XXX */ + sprintf(sc->sc_if.if_xname, "ppp%d", i++); + sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; @@ -336,7 +337,7 @@ pppioctl(sc, cmd, data, flag, p) break; case PPPIOCGUNIT: - *(int *)data = sc->sc_if.if_unit; + *(int *)data = sc->sc_unit; /* XXX */ break; case PPPIOCGFLAGS: @@ -414,8 +415,8 @@ pppioctl(sc, cmd, data, flag, p) sc->sc_xc_state = (*cp)->comp_alloc(ccp_option, nb); if (sc->sc_xc_state == NULL) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: comp_alloc failed\n", - sc->sc_if.if_unit); + printf("%s: comp_alloc failed\n", + sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); @@ -429,8 +430,8 @@ pppioctl(sc, cmd, data, flag, p) sc->sc_rc_state = (*cp)->decomp_alloc(ccp_option, nb); if (sc->sc_rc_state == NULL) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: decomp_alloc failed\n", - sc->sc_if.if_unit); + printf("%s: decomp_alloc failed\n", + sc->sc_if.if_xname); error = ENOBUFS; } splhigh(); @@ -440,8 +441,8 @@ pppioctl(sc, cmd, data, flag, p) return (error); } if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: no compressor for [%x %x %x], %x\n", - sc->sc_if.if_unit, ccp_option[0], ccp_option[1], + printf("%s: no compressor for [%x %x %x], %x\n", + sc->sc_if.if_xname, ccp_option[0], ccp_option[1], ccp_option[2], nb); return (EINVAL); /* no handler found */ #endif /* PPP_COMPRESS */ @@ -529,7 +530,7 @@ pppsioctl(ifp, cmd, data) caddr_t data; { struct proc *p = curproc; /* XXX */ - register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; + register struct ppp_softc *sc = ifp->if_softc; register struct ifaddr *ifa = (struct ifaddr *)data; register struct ifreq *ifr = (struct ifreq *)data; struct ppp_stats *psp; @@ -628,7 +629,7 @@ pppoutput(ifp, m0, dst, rtp) struct sockaddr *dst; struct rtentry *rtp; { - register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; + register struct ppp_softc *sc = ifp->if_softc; int protocol, address, control; u_char *cp; int s, error; @@ -672,7 +673,7 @@ pppoutput(ifp, m0, dst, rtp) mode = NPMODE_PASS; break; default: - printf("ppp%d: af%d not supported\n", ifp->if_unit, dst->sa_family); + printf("%s: af%d not supported\n", ifp->if_xname, dst->sa_family); error = EAFNOSUPPORT; goto bad; } @@ -715,7 +716,7 @@ pppoutput(ifp, m0, dst, rtp) len += m->m_len; if (sc->sc_flags & SC_LOG_OUTPKT) { - printf("ppp%d output: ", ifp->if_unit); + printf("%s output: ", ifp->if_xname); pppdumpm(m0); } @@ -1082,7 +1083,7 @@ ppp_ccp(sc, m, rcvd) if (sc->sc_xc_state != NULL && (*sc->sc_xcomp->comp_init) (sc->sc_xc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, - sc->sc_if.if_unit, 0, sc->sc_flags & SC_DEBUG)) { + sc->sc_unit, 0, sc->sc_flags & SC_DEBUG)) { s = splhigh(); sc->sc_flags |= SC_COMP_RUN; splx(s); @@ -1092,7 +1093,7 @@ ppp_ccp(sc, m, rcvd) if (sc->sc_rc_state != NULL && (*sc->sc_rcomp->decomp_init) (sc->sc_rc_state, dp + CCP_HDRLEN, slen - CCP_HDRLEN, - sc->sc_if.if_unit, 0, sc->sc_mru, + sc->sc_unit, 0, sc->sc_mru, sc->sc_flags & SC_DEBUG)) { s = splhigh(); sc->sc_flags |= SC_DECOMP_RUN; @@ -1186,7 +1187,7 @@ ppp_inproc(sc, m) ilen = 0; for (mp = m; mp != NULL; mp = mp->m_next) ilen += mp->m_len; - printf("ppp%d: got %d bytes\n", ifp->if_unit, ilen); + printf("%s: got %d bytes\n", ifp->if_xname, ilen); pppdumpm(m); } @@ -1228,7 +1229,7 @@ ppp_inproc(sc, m) * CCP down or issue a Reset-Req. */ if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: decompress failed %d\n", ifp->if_unit, rv); + printf("%s: decompress failed %d\n", ifp->if_xname, rv); s = splhigh(); sc->sc_flags |= SC_VJ_RESET; if (rv == DECOMP_ERROR) @@ -1278,8 +1279,8 @@ ppp_inproc(sc, m) if (xlen <= 0) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: VJ uncompress failed on type comp\n", - ifp->if_unit); + printf("%s: VJ uncompress failed on type comp\n", + ifp->if_xname); goto bad; } @@ -1330,8 +1331,8 @@ ppp_inproc(sc, m) if (xlen < 0) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: VJ uncompress failed on type uncomp\n", - ifp->if_unit); + printf("%s: VJ uncompress failed on type uncomp\n", + ifp->if_xname); goto bad; } @@ -1421,7 +1422,7 @@ ppp_inproc(sc, m) IF_DROP(inq); splx(s); if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: input queue full\n", ifp->if_unit); + printf("%s: input queue full\n", ifp->if_xname); ifp->if_iqdrops++; goto bad; } diff --git a/sys/net/if_pppvar.h b/sys/net/if_pppvar.h index 8f7508912f2..eda2f6f468e 100644 --- a/sys/net/if_pppvar.h +++ b/sys/net/if_pppvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_pppvar.h,v 1.3 1996/03/15 02:28:06 paulus Exp $ */ +/* $NetBSD: if_pppvar.h,v 1.4 1996/05/07 02:40:39 thorpej Exp $ */ /* * if_pppvar.h - private structures and declarations for PPP. * @@ -53,6 +53,7 @@ */ struct ppp_softc { struct ifnet sc_if; /* network-visible interface */ + int sc_unit; /* XXX unit number */ u_int sc_flags; /* control/status bits; see if_ppp.h */ void *sc_devp; /* pointer to device-dep structure */ void (*sc_start) __P((struct ppp_softc *)); /* start output proc */ diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index c7f986732e8..99ff0783254 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_sl.c,v 1.3 1996/03/14 08:41:45 tholo Exp $ */ -/* $NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */ +/* $OpenBSD: if_sl.c,v 1.4 1996/05/10 12:31:11 deraadt Exp $ */ +/* $NetBSD: if_sl.c,v 1.39 1996/05/07 02:40:43 thorpej Exp $ */ /* * Copyright (c) 1987, 1989, 1992, 1993 @@ -202,8 +202,9 @@ slattach() register int i = 0; for (sc = sl_softc; i < NSL; sc++) { - sc->sc_if.if_name = "sl"; - sc->sc_if.if_unit = i++; + sprintf(sc->sc_if.if_xname, "sl%d", i++); + sc->sc_if.if_softc = sc; + sc->sc_unit = i; /* XXX */ sc->sc_if.if_mtu = SLMTU; sc->sc_if.if_flags = IFF_POINTOPOINT | SC_AUTOCOMP | IFF_MULTICAST; @@ -353,7 +354,7 @@ sltioctl(tp, cmd, data, flag) switch (cmd) { case SLIOCGUNIT: - *(int *)data = sc->sc_if.if_unit; + *(int *)data = sc->sc_unit; /* XXX */ break; default: @@ -375,7 +376,7 @@ sloutput(ifp, m, dst, rtp) struct sockaddr *dst; struct rtentry *rtp; { - register struct sl_softc *sc = &sl_softc[ifp->if_unit]; + register struct sl_softc *sc = ifp->if_softc; register struct ip *ip; register struct ifqueue *ifq; int s; @@ -385,7 +386,7 @@ sloutput(ifp, m, dst, rtp) * the line protocol to support other address families. */ if (dst->sa_family != AF_INET) { - printf("sl%d: af%d not supported\n", sc->sc_if.if_unit, + printf("%s: af%d not supported\n", sc->sc_if.if_xname, dst->sa_family); m_freem(m); sc->sc_if.if_noproto++; diff --git a/sys/net/if_slvar.h b/sys/net/if_slvar.h index 17cc730c162..ff24a932997 100644 --- a/sys/net/if_slvar.h +++ b/sys/net/if_slvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: if_slvar.h,v 1.15 1995/03/26 20:30:14 jtc Exp $ */ +/* $NetBSD: if_slvar.h,v 1.16 1996/05/07 02:40:46 thorpej Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -43,6 +43,7 @@ */ struct sl_softc { struct ifnet sc_if; /* network-visible interface */ + int sc_unit; /* XXX unit number */ struct ifqueue sc_fastq; /* interactive output queue */ struct tty *sc_ttyp; /* pointer to tty structure */ u_char *sc_mp; /* pointer to next available buf char */ diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 64b9dd9b0fe..31d1dbfad66 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,5 +1,5 @@ -/* $OpenBSD: if_tun.c,v 1.8 1996/04/24 06:43:51 mickey Exp $ */ -/* $NetBSD: if_tun.c,v 1.22 1996/02/13 22:00:26 christos Exp $ */ +/* $OpenBSD: if_tun.c,v 1.9 1996/05/10 12:31:13 deraadt Exp $ */ +/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* * Copyright (c) 1988, Julian Onions <jpo@cs.nott.ac.uk> @@ -99,7 +99,7 @@ int tunwrite __P((dev_t, struct uio *, int)); int tunselect __P((dev_t, int, struct proc *)); -static int tuninit __P((int)); +static int tuninit __P((struct tun_softc *)); void tunattach(unused) @@ -112,8 +112,8 @@ tunattach(unused) tunctl[i].tun_flags = TUN_INITED; ifp = &tunctl[i].tun_if; - ifp->if_unit = i; - ifp->if_name = "tun"; + sprintf(ifp->if_xname, "tun%d", i); + ifp->if_softc = &tunctl[i]; ifp->if_mtu = TUNMTU; ifp->if_ioctl = tun_ioctl; ifp->if_output = tun_output; @@ -158,7 +158,7 @@ tunopen(dev, flag, mode, p) return ENXIO; ifp = &tp->tun_if; tp->tun_flags |= TUN_OPEN; - TUNDEBUG(("%s%d: open\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: open\n", ifp->if_xname)); return (0); } @@ -210,19 +210,18 @@ tunclose(dev, flag, mode, p) tp->tun_pgrp = 0; selwakeup(&tp->tun_rsel); - TUNDEBUG(("%s%d: closed\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: closed\n", ifp->if_xname)); return (0); } static int -tuninit(unit) - int unit; +tuninit(tp) + struct tun_softc *tp; { - struct tun_softc *tp = &tunctl[unit]; struct ifnet *ifp = &tp->tun_if; register struct ifaddr *ifa; - TUNDEBUG(("%s%d: tuninit\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: tuninit\n", ifp->if_xname)); ifp->if_flags |= IFF_UP | IFF_RUNNING; @@ -258,13 +257,12 @@ tun_ioctl(ifp, cmd, data) s = splimp(); switch(cmd) { case SIOCSIFADDR: - tuninit(ifp->if_unit); - TUNDEBUG(("%s%d: address set\n", ifp->if_name, ifp->if_unit)); + tuninit((struct tun_softc *)(ifp->if_softc)); + TUNDEBUG(("%s: address set\n", ifp->if_xname)); break; case SIOCSIFDSTADDR: - tuninit(ifp->if_unit); - TUNDEBUG(("%s%d: destination address set\n", - ifp->if_name, ifp->if_unit)); + tuninit((struct tun_softc *)(ifp->if_softc)); + TUNDEBUG(("%s: destination address set\n", ifp->if_name)); break; default: error = EINVAL; @@ -283,15 +281,15 @@ tun_output(ifp, m0, dst, rt) struct sockaddr *dst; struct rtentry *rt; { - struct tun_softc *tp = &tunctl[ifp->if_unit]; + struct tun_softc *tp = ifp->if_softc; struct proc *p; int s; - TUNDEBUG(("%s%d: tun_output\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: tun_output\n", ifp->if_xname)); if ((tp->tun_flags & TUN_READY) != TUN_READY) { - TUNDEBUG(("%s%d: not ready 0%o\n", ifp->if_name, - ifp->if_unit, tp->tun_flags)); + TUNDEBUG(("%s: not ready 0%o\n", ifp->if_xname, + tp->tun_flags)); m_freem (m0); return EHOSTDOWN; } @@ -420,10 +418,10 @@ tunread(dev, uio, ioflag) struct mbuf *m, *m0; int error=0, len, s; - TUNDEBUG(("%s%d: read\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: read\n", ifp->if_xname)); if ((tp->tun_flags & TUN_READY) != TUN_READY) { - TUNDEBUG(("%s%d: not ready 0%o\n", ifp->if_name, - ifp->if_unit, tp->tun_flags)); + TUNDEBUG(("%s: not ready 0%o\n", ifp->if_xname, + tp->tun_flags)); return EHOSTDOWN; } @@ -479,11 +477,10 @@ tunwrite(dev, uio, ioflag) int isr; int error=0, s, tlen, mlen; - TUNDEBUG(("%s%d: tunwrite\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: tunwrite\n", ifp->if_xname)); if (uio->uio_resid < 0 || uio->uio_resid > TUNMTU) { - TUNDEBUG(("%s%d: len=%d!\n", ifp->if_name, ifp->if_unit, - uio->uio_resid)); + TUNDEBUG(("%s: len=%d!\n", ifp->if_xname, uio->uio_resid)); return EIO; } tlen = uio->uio_resid; @@ -596,14 +593,14 @@ tunselect(dev, rw, p) struct ifnet *ifp = &tp->tun_if; s = splimp(); - TUNDEBUG(("%s%d: tunselect\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: tunselect\n", ifp->if_xname)); switch (rw) { case FREAD: if (ifp->if_snd.ifq_len > 0) { splx(s); - TUNDEBUG(("%s%d: tunselect q=%d\n", ifp->if_name, - ifp->if_unit, ifp->if_snd.ifq_len)); + TUNDEBUG(("%s: tunselect q=%d\n", ifp->if_xname, + ifp->if_snd.ifq_len)); return 1; } selrecord(curproc, &tp->tun_rsel); @@ -613,7 +610,7 @@ tunselect(dev, rw, p) return 1; } splx(s); - TUNDEBUG(("%s%d: tunselect waiting\n", ifp->if_name, ifp->if_unit)); + TUNDEBUG(("%s: tunselect waiting\n", ifp->if_xname)); return 0; } diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 518d9ae5ec7..b46f96d2510 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ppp_tty.c,v 1.3 1996/04/21 22:28:42 deraadt Exp $ */ -/* $NetBSD: ppp_tty.c,v 1.5 1996/03/15 02:28:10 paulus Exp $ */ +/* $OpenBSD: ppp_tty.c,v 1.4 1996/05/10 12:31:13 deraadt Exp $ */ +/* $NetBSD: ppp_tty.c,v 1.6 1996/05/07 02:40:51 thorpej Exp $ */ /* * ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous @@ -784,7 +784,7 @@ pppinput(c, tp) if (c & TTY_FE) { /* framing error or overrun on this char - abort packet */ if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: bad char %x\n", sc->sc_if.if_unit, c); + printf("%s: bad char %x\n", sc->sc_if.if_xname, c); goto flush; } @@ -837,7 +837,7 @@ pppinput(c, tp) sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */ if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){ if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: bad fcs %x\n", sc->sc_if.if_unit, + printf("%s: bad fcs %x\n", sc->sc_if.if_xname, sc->sc_fcs); sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; @@ -850,7 +850,7 @@ pppinput(c, tp) if (ilen < PPP_HDRLEN + PPP_FCSLEN) { if (ilen) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: too short (%d)\n", sc->sc_if.if_unit, ilen); + printf("%s: too short (%d)\n", sc->sc_if.if_xname, ilen); sc->sc_if.if_ierrors++; sc->sc_stats.ppp_ierrors++; sc->sc_flags |= SC_PKTLOST; @@ -919,7 +919,7 @@ pppinput(c, tp) pppgetm(sc); if (sc->sc_m == NULL) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: no input mbufs!\n", sc->sc_if.if_unit); + printf("%s: no input mbufs!\n", sc->sc_if.if_xname); goto flush; } } @@ -932,8 +932,8 @@ pppinput(c, tp) if (c != PPP_ALLSTATIONS) { if (sc->sc_flags & SC_REJ_COMP_AC) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: garbage received: 0x%x (need 0xFF)\n", - sc->sc_if.if_unit, c); + printf("%s: garbage received: 0x%x (need 0xFF)\n", + sc->sc_if.if_xname, c); goto flush; } *sc->sc_mp++ = PPP_ALLSTATIONS; @@ -944,8 +944,8 @@ pppinput(c, tp) } if (sc->sc_ilen == 1 && c != PPP_UI) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: missing UI (0x3), got 0x%x\n", - sc->sc_if.if_unit, c); + printf("%s: missing UI (0x3), got 0x%x\n", + sc->sc_if.if_xname, c); goto flush; } if (sc->sc_ilen == 2 && (c & 1) == 1) { @@ -956,7 +956,7 @@ pppinput(c, tp) } if (sc->sc_ilen == 3 && (c & 1) == 0) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: bad protocol %x\n", sc->sc_if.if_unit, + printf("%s: bad protocol %x\n", sc->sc_if.if_xname, (sc->sc_mp[-1] << 8) + c); goto flush; } @@ -964,7 +964,7 @@ pppinput(c, tp) /* packet beyond configured mru? */ if (++sc->sc_ilen > sc->sc_mru + PPP_HDRLEN + PPP_FCSLEN) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: packet too big\n", sc->sc_if.if_unit); + printf("%s: packet too big\n", sc->sc_if.if_xname); goto flush; } @@ -975,7 +975,7 @@ pppinput(c, tp) pppgetm(sc); if (m->m_next == NULL) { if (sc->sc_flags & SC_DEBUG) - printf("ppp%d: too few input mbufs!\n", sc->sc_if.if_unit); + printf("%s: too few input mbufs!\n", sc->sc_if.if_xname); goto flush; } } @@ -1014,7 +1014,7 @@ 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); + printf("%s input: ", sc->sc_if.if_xname); pppdumpb(sc->sc_rawin, sc->sc_rawin_count); sc->sc_rawin_count = 0; } |
