Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/wtap/if_wtap.c
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | wtap_node_close(struct cdev *dev, int fflag, int devtype, struct thread *p) | ||||
return(0); | return(0); | ||||
} | } | ||||
static int | static int | ||||
wtap_node_write(struct cdev *dev, struct uio *uio, int ioflag) | wtap_node_write(struct cdev *dev, struct uio *uio, int ioflag) | ||||
{ | { | ||||
int err = 0; | int err = 0; | ||||
struct mbuf *m; | struct mbuf *m; | ||||
struct ifnet *ifp; | |||||
struct wtap_softc *sc; | struct wtap_softc *sc; | ||||
uint8_t buf[1024]; | uint8_t buf[1024]; | ||||
struct epoch_tracker et; | struct epoch_tracker et; | ||||
int buf_len; | int buf_len; | ||||
uprintf("write device %s \"echo.\"\n", devtoname(dev)); | uprintf("write device %s \"echo.\"\n", devtoname(dev)); | ||||
buf_len = MIN(uio->uio_iov->iov_len, 1024); | buf_len = MIN(uio->uio_iov->iov_len, 1024); | ||||
err = copyin(uio->uio_iov->iov_base, buf, buf_len); | err = copyin(uio->uio_iov->iov_base, buf, buf_len); | ||||
if (err != 0) { | if (err != 0) { | ||||
uprintf("Write failed: bad address!\n"); | uprintf("Write failed: bad address!\n"); | ||||
return (err); | return (err); | ||||
} | } | ||||
MGETHDR(m, M_NOWAIT, MT_DATA); | MGETHDR(m, M_NOWAIT, MT_DATA); | ||||
m_copyback(m, 0, buf_len, buf); | m_copyback(m, 0, buf_len, buf); | ||||
CURVNET_SET(TD_TO_VNET(curthread)); | |||||
NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||
bz: Do you still need to hold the epoch for wtap_inject here? | |||||
CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { | sc = (struct wtap_softc *)dev->si_drv1; | ||||
printf("ifp->if_xname = %s\n", ifp->if_xname); | |||||
if(strcmp(devtoname(dev), ifp->if_xname) == 0){ | |||||
printf("found match, correspoding wtap = %s\n", | |||||
ifp->if_xname); | |||||
sc = (struct wtap_softc *)ifp->if_softc; | |||||
printf("wtap id = %d\n", sc->id); | printf("wtap id = %d\n", sc->id); | ||||
bzUnsubmitted Not Done Inline ActionsAll the printfs in that code should eventually be changed into some kind of debug logging. But not in this change. bz: All the printfs in that code should eventually be changed into some kind of debug logging. But… | |||||
wtap_inject(sc, m); | wtap_inject(sc, m); | ||||
} | |||||
} | |||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
CURVNET_RESTORE(); | |||||
return(err); | return(err); | ||||
} | } | ||||
int | int | ||||
wtap_node_ioctl(struct cdev *dev, u_long cmd, caddr_t data, | wtap_node_ioctl(struct cdev *dev, u_long cmd, caddr_t data, | ||||
int fflag, struct thread *td) | int fflag, struct thread *td) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 207 Lines • ▼ Show 20 Lines | wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], | ||||
vap->iv_newstate = wtap_newstate; | vap->iv_newstate = wtap_newstate; | ||||
avp->av_bmiss = vap->iv_bmiss; | avp->av_bmiss = vap->iv_bmiss; | ||||
vap->iv_bmiss = wtap_bmiss; | vap->iv_bmiss = wtap_bmiss; | ||||
/* complete setup */ | /* complete setup */ | ||||
ieee80211_vap_attach(vap, ieee80211_media_change, | ieee80211_vap_attach(vap, ieee80211_media_change, | ||||
ieee80211_media_status, mac); | ieee80211_media_status, mac); | ||||
avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, | avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, | ||||
"%s", (const char *)sc->name); | "%s", (const char *)vap->iv_ifp->if_xname); | ||||
avp->av_dev->si_drv1 = sc; | |||||
/* TODO this is a hack to force it to choose the rate we want */ | /* TODO this is a hack to force it to choose the rate we want */ | ||||
ni = ieee80211_ref_node(vap->iv_bss); | ni = ieee80211_ref_node(vap->iv_bss); | ||||
ni->ni_txrate = 130; | ni->ni_txrate = 130; | ||||
ieee80211_free_node(ni); | ieee80211_free_node(ni); | ||||
return vap; | return vap; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 346 Lines • Show Last 20 Lines |
Do you still need to hold the epoch for wtap_inject here?