Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/sys/net/if_tap.c,v rcsdiff: /ftp/cvs/cvsroot/src/sys/net/if_tap.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.21.2.2 retrieving revision 1.22 diff -u -p -r1.21.2.2 -r1.22 --- src/sys/net/if_tap.c 2007/01/12 01:04:12 1.21.2.2 +++ src/sys/net/if_tap.c 2006/10/12 01:32:28 1.22 @@ -1,4 +1,4 @@ -/* $NetBSD: if_tap.c,v 1.21.2.2 2007/01/12 01:04:12 ad Exp $ */ +/* $NetBSD: if_tap.c,v 1.22 2006/10/12 01:32:28 christos Exp $ */ /* * Copyright (c) 2003, 2004 The NetBSD Foundation. @@ -43,7 +43,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.21.2.2 2007/01/12 01:04:12 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_tap.c,v 1.22 2006/10/12 01:32:28 christos Exp $"); #if defined(_KERNEL_OPT) #include "bpfilter.h" @@ -122,6 +122,10 @@ static int tap_match(struct device *, st static void tap_attach(struct device *, struct device *, void *); static int tap_detach(struct device*, int); +/* Ethernet address helper functions */ + +static int tap_ether_aton(u_char *, char *); + CFATTACH_DECL(tap, sizeof(struct tap_softc), tap_match, tap_attach, tap_detach, NULL); extern struct cfdriver tap_cd; @@ -222,7 +226,7 @@ static struct tap_softc * tap_clone_crea int tap_clone_destroyer(struct device *); void -tapattach(int n) +tapattach(int n __unused) { int error; @@ -239,15 +243,15 @@ tapattach(int n) /* Pretty much useless for a pseudo-device */ static int -tap_match(struct device *self, struct cfdata *cfdata, - void *arg) +tap_match(struct device *self __unused, struct cfdata *cfdata __unused, + void *arg __unused) { return (1); } void -tap_attach(struct device *parent, struct device *self, - void *aux) +tap_attach(struct device *parent __unused, struct device *self, + void *aux __unused) { struct tap_softc *sc = (struct tap_softc *)self; struct ifnet *ifp; @@ -361,7 +365,7 @@ tap_attach(struct device *parent, struct * routine, in reversed order. */ static int -tap_detach(struct device* self, int flags) +tap_detach(struct device* self, int flags __unused) { struct tap_softc *sc = (struct tap_softc *)self; struct ifnet *ifp = &sc->sc_ec.ec_if; @@ -403,7 +407,7 @@ tap_detach(struct device* self, int flag * reconfigure the hardware. */ static int -tap_mediachange(struct ifnet *ifp) +tap_mediachange(struct ifnet *ifp __unused) { return (0); } @@ -519,7 +523,7 @@ tap_ioctl(struct ifnet *ifp, u_long cmd, * and should actually be available to all Ethernet drivers, real or not. */ static int -tap_lifaddr(struct ifnet *ifp, u_long cmd, struct ifaliasreq *ifra) +tap_lifaddr(struct ifnet *ifp, u_long cmd __unused, struct ifaliasreq *ifra) { struct sockaddr *sa = (struct sockaddr *)&ifra->ifra_addr; @@ -555,7 +559,7 @@ tap_init(struct ifnet *ifp) * read requests cancelled. */ static void -tap_stop(struct ifnet *ifp, int disable) +tap_stop(struct ifnet *ifp, int disable __unused) { struct tap_softc *sc = (struct tap_softc *)ifp->if_softc; @@ -574,7 +578,7 @@ tap_stop(struct ifnet *ifp, int disable) * for us. */ static int -tap_clone_create(struct if_clone *ifc, int unit) +tap_clone_create(struct if_clone *ifc __unused, int unit) { if (tap_clone_creator(unit) == NULL) { aprint_error("%s%d: unable to attach an instance\n", @@ -659,7 +663,7 @@ tap_clone_destroyer(struct device *dev) */ static int -tap_cdev_open(dev_t dev, int flags, int fmt, struct lwp *l) +tap_cdev_open(dev_t dev, int flags __unused, int fmt __unused, struct lwp *l) { struct tap_softc *sc; @@ -732,8 +736,8 @@ tap_dev_cloner(struct lwp *l) * created it closes it. */ static int -tap_cdev_close(dev_t dev, int flags, int fmt, - struct lwp *l) +tap_cdev_close(dev_t dev, int flags __unused, int fmt __unused, + struct lwp *l __unused) { struct tap_softc *sc = (struct tap_softc *)device_lookup(&tap_cd, minor(dev)); @@ -751,7 +755,7 @@ tap_cdev_close(dev_t dev, int flags, int * would dead lock. TAP_GOING ensures that this situation doesn't happen. */ static int -tap_fops_close(struct file *fp, struct lwp *l) +tap_fops_close(struct file *fp, struct lwp *l __unused) { int unit = (intptr_t)fp->f_data; struct tap_softc *sc; @@ -815,14 +819,14 @@ tap_cdev_read(dev_t dev, struct uio *uio } static int -tap_fops_read(struct file *fp, off_t *offp, struct uio *uio, - kauth_cred_t cred, int flags) +tap_fops_read(struct file *fp, off_t *offp __unused, struct uio *uio, + kauth_cred_t cred __unused, int flags) { return tap_dev_read((intptr_t)fp->f_data, uio, flags); } static int -tap_dev_read(int unit, struct uio *uio, int flags) +tap_dev_read(int unit, struct uio *uio, int flags __unused) { struct tap_softc *sc = (struct tap_softc *)device_lookup(&tap_cd, unit); @@ -914,14 +918,14 @@ tap_cdev_write(dev_t dev, struct uio *ui } static int -tap_fops_write(struct file *fp, off_t *offp, struct uio *uio, - kauth_cred_t cred, int flags) +tap_fops_write(struct file *fp, off_t *offp __unused, struct uio *uio, + kauth_cred_t cred __unused, int flags) { return tap_dev_write((intptr_t)fp->f_data, uio, flags); } static int -tap_dev_write(int unit, struct uio *uio, int flags) +tap_dev_write(int unit, struct uio *uio, int flags __unused) { struct tap_softc *sc = (struct tap_softc *)device_lookup(&tap_cd, unit); @@ -977,7 +981,7 @@ tap_dev_write(int unit, struct uio *uio, } static int -tap_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags, +tap_cdev_ioctl(dev_t dev, u_long cmd, caddr_t data, int flags __unused, struct lwp *l) { return tap_dev_ioctl(minor(dev), cmd, data, l); @@ -1149,7 +1153,7 @@ tap_kqdetach(struct knote *kn) } static int -tap_kqread(struct knote *kn, long hint) +tap_kqread(struct knote *kn, long hint __unused) { struct tap_softc *sc = (struct tap_softc *)kn->kn_hook; struct ifnet *ifp = &sc->sc_ec.ec_if; @@ -1291,7 +1295,44 @@ tap_sysctl_handler(SYSCTLFN_ARGS) return (EINVAL); /* Commit change */ - if (ether_nonstatic_aton(LLADDR(ifp->if_sadl), addr) != 0) + if (tap_ether_aton(LLADDR(ifp->if_sadl), addr) != 0) return (EINVAL); return (error); } + +/* + * ether_aton implementation, not using a static buffer. + */ +static int +tap_ether_aton(u_char *dest, char *str) +{ + int i; + char *cp = str; + u_char val[6]; + +#define set_value \ + if (*cp > '9' && *cp < 'a') \ + *cp -= 'A' - 10; \ + else if (*cp > '9') \ + *cp -= 'a' - 10; \ + else \ + *cp -= '0' + + for (i = 0; i < 6; i++, cp++) { + if (!isxdigit(*cp)) + return (1); + set_value; + val[i] = *cp++; + if (isxdigit(*cp)) { + set_value; + val[i] *= 16; + val[i] += *cp++; + } + if (*cp == ':' || i == 5) + continue; + else + return (1); + } + memcpy(dest, val, 6); + return (0); +}