summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/if_cdce.c16
-rw-r--r--sys/dev/usb/if_cdcef.c14
-rw-r--r--sys/dev/usb/if_ugl.c14
3 files changed, 9 insertions, 35 deletions
diff --git a/sys/dev/usb/if_cdce.c b/sys/dev/usb/if_cdce.c
index 8bc98d8b629..c467e68a77e 100644
--- a/sys/dev/usb/if_cdce.c
+++ b/sys/dev/usb/if_cdce.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cdce.c,v 1.68 2015/11/25 03:10:00 dlg Exp $ */
+/* $OpenBSD: if_cdce.c,v 1.69 2016/04/12 10:15:25 mpi Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com>
@@ -151,7 +151,7 @@ cdce_attach(struct device *parent, struct device *self, void *aux)
struct cdce_softc *sc = (struct cdce_softc *)self;
struct usb_attach_arg *uaa = aux;
int s;
- struct ifnet *ifp;
+ struct ifnet *ifp = GET_IFP(sc);
struct usbd_device *dev = uaa->device;
const struct cdce_type *t;
usb_interface_descriptor_t *id;
@@ -162,9 +162,6 @@ cdce_attach(struct device *parent, struct device *self, void *aux)
const usb_descriptor_t *desc;
struct usbd_desc_iter iter;
usb_string_descriptor_t eaddr_str;
- struct timeval now;
- u_int32_t macaddr_lo;
- u_int16_t macaddr_hi;
int i, j, numalts, len;
int ctl_ifcno = -1;
int data_ifcno = -1;
@@ -310,13 +307,7 @@ found:
if (!ethd || usbd_get_string_desc(sc->cdce_udev, ethd->iMacAddress, 0,
&eaddr_str, &len)) {
- macaddr_hi = htons(0x2acb);
- bcopy(&macaddr_hi, &sc->cdce_arpcom.ac_enaddr[0],
- sizeof(u_int16_t));
- getmicrotime(&now);
- macaddr_lo = htonl(now.tv_usec << 8);
- bcopy(&macaddr_lo, &sc->cdce_arpcom.ac_enaddr[2], sizeof(u_int32_t));
- sc->cdce_arpcom.ac_enaddr[5] = (u_int8_t)(sc->cdce_dev.dv_unit);
+ ether_fakeaddr(ifp);
} else {
for (i = 0; i < ETHER_ADDR_LEN * 2; i++) {
int c = UGETW(eaddr_str.bString[i]);
@@ -337,7 +328,6 @@ found:
printf("%s: address %s\n", sc->cdce_dev.dv_xname,
ether_sprintf(sc->cdce_arpcom.ac_enaddr));
- ifp = GET_IFP(sc);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = cdce_ioctl;
diff --git a/sys/dev/usb/if_cdcef.c b/sys/dev/usb/if_cdcef.c
index 5496d9c1c4e..1221d71fdb0 100644
--- a/sys/dev/usb/if_cdcef.c
+++ b/sys/dev/usb/if_cdcef.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_cdcef.c,v 1.41 2015/11/25 03:10:00 dlg Exp $ */
+/* $OpenBSD: if_cdcef.c,v 1.42 2016/04/12 10:15:25 mpi Exp $ */
/*
* Copyright (c) 2007 Dale Rahn <drahn@openbsd.org>
@@ -121,8 +121,6 @@ struct usbf_function_methods cdcef_methods = {
#define DEVNAME(sc) ((sc)->sc_dev.bdev.dv_xname)
-extern int ticks;
-
/*
* USB function match/attach/detach
*/
@@ -139,11 +137,10 @@ cdcef_attach(struct device *parent, struct device *self, void *aux)
struct cdcef_softc *sc = (struct cdcef_softc *)self;
struct usbf_attach_arg *uaa = aux;
struct usbf_device *dev = uaa->device;
- struct ifnet *ifp;
+ struct ifnet *ifp = GET_IFP(sc);
usbf_status err;
struct usb_cdc_union_descriptor udesc;
int s;
- u_int16_t macaddr_hi;
/* Set the device identification according to the function. */
@@ -237,14 +234,9 @@ cdcef_attach(struct device *parent, struct device *self, void *aux)
s = splnet();
- macaddr_hi = htons(0x2acb);
- bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
- bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
- sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.bdev.dv_unit);
-
+ ether_fakeaddr(ifp);
printf(": address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr));
- ifp = GET_IFP(sc);
ifp->if_softc = sc;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
ifp->if_ioctl = cdcef_ioctl;
diff --git a/sys/dev/usb/if_ugl.c b/sys/dev/usb/if_ugl.c
index ba8490ba575..97448139211 100644
--- a/sys/dev/usb/if_ugl.c
+++ b/sys/dev/usb/if_ugl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ugl.c,v 1.18 2015/11/25 11:20:38 mpi Exp $ */
+/* $OpenBSD: if_ugl.c,v 1.19 2016/04/12 10:15:25 mpi Exp $ */
/* $NetBSD: if_upl.c,v 1.19 2002/07/11 21:14:26 augustss Exp $ */
/*
* Copyright (c) 2013 SASANO Takayoshi <uaa@uaa.org.uk>
@@ -152,8 +152,6 @@ int ugldebug = 0;
#define DPRINTFN(n,x)
#endif
-extern int ticks;
-
/*
* Various supported device vendors/products.
*/
@@ -210,11 +208,10 @@ ugl_attach(struct device *parent, struct device *self, void *aux)
int s;
struct usbd_device *dev = uaa->device;
struct usbd_interface *iface = uaa->iface;
- struct ifnet *ifp;
+ struct ifnet *ifp = GET_IFP(sc);
usb_interface_descriptor_t *id;
usb_endpoint_descriptor_t *ed;
int i;
- u_int16_t macaddr_hi;
DPRINTFN(5,(" : ugl_attach: sc=%p, dev=%p", sc, dev));
@@ -251,16 +248,11 @@ ugl_attach(struct device *parent, struct device *self, void *aux)
s = splnet();
- macaddr_hi = htons(0x2acb);
- bcopy(&macaddr_hi, &sc->sc_arpcom.ac_enaddr[0], sizeof(u_int16_t));
- bcopy(&ticks, &sc->sc_arpcom.ac_enaddr[2], sizeof(u_int32_t));
- sc->sc_arpcom.ac_enaddr[5] = (u_int8_t)(sc->sc_dev.dv_unit);
-
+ ether_fakeaddr(ifp);
printf("%s: address %s\n",
sc->sc_dev.dv_xname, ether_sprintf(sc->sc_arpcom.ac_enaddr));
/* Initialize interface info.*/
- ifp = GET_IFP(sc);
ifp->if_softc = sc;
ifp->if_hardmtu = UGL_MAX_MTU;
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;