diff --git a/sys/dev/wtap/if_medium.h b/sys/dev/wtap/if_medium.h --- a/sys/dev/wtap/if_medium.h +++ b/sys/dev/wtap/if_medium.h @@ -34,21 +34,21 @@ * $FreeBSD$ */ -#ifndef __DEV_WTAP_MEDIUM_H__ -#define __DEV_WTAP_MEDIUM_H__ +#ifndef __DEV_WTAP_MEDIUM_H__ +#define __DEV_WTAP_MEDIUM_H__ #include "if_wtapvar.h" #include "wtap_hal/handler.h" struct packet { - STAILQ_ENTRY(packet) pf_list; - struct mbuf * m; - int id; + STAILQ_ENTRY(packet) pf_list; + struct mbuf *m; + int id; }; typedef STAILQ_HEAD(, packet) md_pkthead; struct wtap_medium { - struct mtx md_mtx; + struct mtx md_mtx; #if 0 int visibility[MAX_NBR_WTAP]; struct stailhead *headp; @@ -58,17 +58,17 @@ /* = STAILQ_HEAD_INITIALIZER(head); */ #endif /* 0 means we drop packets, 1 we queue them */ - int open; - md_pkthead md_pktbuf; /* master queue */ - struct eventhandler *tx_handler; - struct timehandler *bc_handler; + int open; + md_pkthead md_pktbuf; /* master queue */ + struct eventhandler *tx_handler; + struct timehandler *bc_handler; }; -extern void init_medium(struct wtap_medium *); -extern void deinit_medium(struct wtap_medium *); -extern void medium_open(struct wtap_medium *); -extern void medium_close(struct wtap_medium *); -extern int medium_transmit(struct wtap_medium *, int id, struct mbuf*); -extern struct packet *medium_get_next_packet(struct wtap_medium *); +extern void init_medium(struct wtap_medium *); +extern void deinit_medium(struct wtap_medium *); +extern void medium_open(struct wtap_medium *); +extern void medium_close(struct wtap_medium *); +extern int medium_transmit(struct wtap_medium *, int id, struct mbuf *); +extern struct packet *medium_get_next_packet(struct wtap_medium *); -#endif /* __DEV_WTAP_MEDIUM_H__ */ +#endif /* __DEV_WTAP_MEDIUM_H__ */ diff --git a/sys/dev/wtap/if_medium.c b/sys/dev/wtap/if_medium.c --- a/sys/dev/wtap/if_medium.c +++ b/sys/dev/wtap/if_medium.c @@ -44,7 +44,7 @@ /* Event handler for sending packets between wtaps */ struct eventhandler *eh = (struct eventhandler *) malloc(sizeof(struct eventhandler), M_WTAP, M_NOWAIT | M_ZERO); - eh->tq = taskqueue_create("wtap_tx_taskq", M_NOWAIT | M_ZERO, + eh->tq = taskqueue_create("wtap_tx_taskq", M_NOWAIT | M_ZERO, taskqueue_thread_enqueue, &eh->tq); taskqueue_start_threads(&eh->tq, 1, PI_NET, "%s taskq", "wtap_medium"); md->tx_handler = eh; @@ -62,11 +62,11 @@ } int -medium_transmit(struct wtap_medium *md, int id, struct mbuf*m) +medium_transmit(struct wtap_medium *md, int id, struct mbuf *m) { mtx_lock(&md->md_mtx); - if (md->open == 0){ + if (md->open == 0) { DWTAP_PRINTF("[%d] dropping m=%p\n", id, m); m_free(m); mtx_unlock(&md->md_mtx); @@ -83,7 +83,7 @@ taskqueue_enqueue(md->tx_handler->tq, &md->tx_handler->proc); mtx_unlock(&md->md_mtx); - return 0; + return 0; } struct packet * @@ -93,7 +93,7 @@ mtx_lock(&md->md_mtx); p = STAILQ_FIRST(&md->md_pktbuf); - if (p == NULL){ + if (p == NULL) { mtx_unlock(&md->md_mtx); return NULL; } diff --git a/sys/dev/wtap/if_wtap.c b/sys/dev/wtap/if_wtap.c --- a/sys/dev/wtap/if_wtap.c +++ b/sys/dev/wtap/if_wtap.c @@ -34,7 +34,7 @@ * $FreeBSD$ */ #include "if_wtapvar.h" -#include /* uio struct */ +#include /* uio struct */ #include #include #include @@ -45,25 +45,25 @@ /* * This _requires_ vimage to be useful. */ -#ifndef VIMAGE -#error if_wtap requires VIMAGE. -#endif /* VIMAGE */ +#ifndef VIMAGE +#error if_wtap requires VIMAGE. +#endif /* VIMAGE */ /* device for IOCTL and read/write for debuggin purposes */ /* Function prototypes */ -static d_open_t wtap_node_open; -static d_close_t wtap_node_close; -static d_write_t wtap_node_write; -static d_ioctl_t wtap_node_ioctl; +static d_open_t wtap_node_open; +static d_close_t wtap_node_close; +static d_write_t wtap_node_write; +static d_ioctl_t wtap_node_ioctl; static struct cdevsw wtap_cdevsw = { - .d_version = D_VERSION, - .d_flags = 0, - .d_open = wtap_node_open, - .d_close = wtap_node_close, - .d_write = wtap_node_write, - .d_ioctl = wtap_node_ioctl, - .d_name = "wtapnode", + .d_version = D_VERSION, + .d_flags = 0, + .d_open = wtap_node_open, + .d_close = wtap_node_close, + .d_write = wtap_node_write, + .d_ioctl = wtap_node_ioctl, + .d_name = "wtapnode", }; static int @@ -72,7 +72,7 @@ int err = 0; uprintf("Opened device \"echo\" successfully.\n"); - return(err); + return (err); } static int @@ -80,7 +80,7 @@ { uprintf("Closing device \"echo.\"\n"); - return(0); + return (0); } static int @@ -109,9 +109,10 @@ CURVNET_SET(TD_TO_VNET(curthread)); NET_EPOCH_ENTER(et); - CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) { + CK_STAILQ_FOREACH(ifp, &V_ifnet, if_link) + { printf("ifp->if_xname = %s\n", ifp->if_xname); - if(strcmp(devtoname(dev), ifp->if_xname) == 0){ + 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; @@ -123,16 +124,16 @@ NET_EPOCH_EXIT(et); CURVNET_RESTORE(); - return(err); + return (err); } int -wtap_node_ioctl(struct cdev *dev, u_long cmd, caddr_t data, - int fflag, struct thread *td) +wtap_node_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, + struct thread *td) { int error = 0; - switch(cmd) { + switch (cmd) { default: DWTAP_PRINTF("Unknown WTAP IOCTL\n"); error = EINVAL; @@ -141,7 +142,7 @@ } static int wtap_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, - const struct ieee80211_bpf_params *params); + const struct ieee80211_bpf_params *params); static int wtap_medium_enqueue(struct wtap_vap *avp, struct mbuf *m) @@ -155,8 +156,8 @@ * and to do ibss merges. */ static void -wtap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, - int subtype, const struct ieee80211_rx_stats *stats, int rssi, int nf) +wtap_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype, + const struct ieee80211_rx_stats *stats, int rssi, int nf) { struct ieee80211vap *vap = ni->ni_vap; #if 0 @@ -224,10 +225,11 @@ struct mbuf *m; if (vap->iv_state < IEEE80211_S_RUN) { - DWTAP_PRINTF("Skip beacon, not running, state %d", vap->iv_state); - return ; + DWTAP_PRINTF("Skip beacon, not running, state %d", + vap->iv_state); + return; } - DWTAP_PRINTF("[%d] beacon intrp\n", avp->id); //burst mode + DWTAP_PRINTF("[%d] beacon intrp\n", avp->id); // burst mode /* * Update dynamic beacon contents. If this returns * non-zero then we need to remap the memory because @@ -237,11 +239,12 @@ m = m_dup(avp->beacon, M_NOWAIT); if (ieee80211_beacon_update(avp->bf_node, m, 0)) { printf("%s, need to remap the memory because the beacon frame" - " changed size.\n",__func__); + " changed size.\n", + __func__); } if (ieee80211_radiotap_active_vap(vap)) - ieee80211_radiotap_tx(vap, m); + ieee80211_radiotap_tx(vap, m); #if 0 medium_transmit(avp->av_md, avp->id, m); @@ -306,24 +309,24 @@ } static struct ieee80211vap * -wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], - int unit, enum ieee80211_opmode opmode, int flags, +wtap_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit, + enum ieee80211_opmode opmode, int flags, const uint8_t bssid[IEEE80211_ADDR_LEN], const uint8_t mac[IEEE80211_ADDR_LEN]) { - struct wtap_softc *sc = ic->ic_softc; - struct ieee80211vap *vap; - struct wtap_vap *avp; - int error; + struct wtap_softc *sc = ic->ic_softc; + struct ieee80211vap *vap; + struct wtap_vap *avp; + int error; struct ieee80211_node *ni; - DWTAP_PRINTF("%s\n", __func__); + DWTAP_PRINTF("%s\n", __func__); avp = malloc(sizeof(struct wtap_vap), M_80211_VAP, M_WAITOK | M_ZERO); avp->id = sc->id; avp->av_md = sc->sc_md; - avp->av_bcinterval = msecs_to_ticks(BEACON_INTRERVAL + 100*sc->id); - vap = (struct ieee80211vap *) avp; + avp->av_bcinterval = msecs_to_ticks(BEACON_INTRERVAL + 100 * sc->id); + vap = (struct ieee80211vap *)avp; error = ieee80211_vap_setup(ic, vap, name, unit, IEEE80211_M_MBSS, flags | IEEE80211_CLONE_NOBEACONS, bssid); if (error) { @@ -344,8 +347,8 @@ /* complete setup */ ieee80211_vap_attach(vap, ieee80211_media_change, ieee80211_media_status, mac); - avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, - "%s", (const char *)sc->name); + avp->av_dev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "%s", + (const char *)sc->name); /* TODO this is a hack to force it to choose the rate we want */ ni = ieee80211_ref_node(vap->iv_bss); @@ -407,13 +410,13 @@ static int wtap_raw_xmit(struct ieee80211_node *ni, struct mbuf *m, - const struct ieee80211_bpf_params *params) + const struct ieee80211_bpf_params *params) { #if 0 DWTAP_PRINTF("%s, %p\n", __func__, m); #endif - struct ieee80211vap *vap = ni->ni_vap; - struct wtap_vap *avp = WTAP_VAP(vap); + struct ieee80211vap *vap = ni->ni_vap; + struct wtap_vap *avp = WTAP_VAP(vap); if (ieee80211_radiotap_active_vap(vap)) { ieee80211_radiotap_tx(vap, m); @@ -427,15 +430,15 @@ void wtap_inject(struct wtap_softc *sc, struct mbuf *m) { - struct wtap_buf *bf = (struct wtap_buf *)malloc(sizeof(struct wtap_buf), - M_WTAP_RXBUF, M_NOWAIT | M_ZERO); - KASSERT(bf != NULL, ("could not allocated a new wtap_buf\n")); - bf->m = m; + struct wtap_buf *bf = (struct wtap_buf *)malloc(sizeof(struct wtap_buf), + M_WTAP_RXBUF, M_NOWAIT | M_ZERO); + KASSERT(bf != NULL, ("could not allocated a new wtap_buf\n")); + bf->m = m; - mtx_lock(&sc->sc_mtx); - STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); - taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); - mtx_unlock(&sc->sc_mtx); + mtx_lock(&sc->sc_mtx); + STAILQ_INSERT_TAIL(&sc->sc_rxbuf, bf, bf_list); + taskqueue_enqueue(sc->sc_tq, &sc->sc_rxtask); + mtx_unlock(&sc->sc_mtx); } static void @@ -446,14 +449,13 @@ struct ieee80211com *ic = &sc->sc_ic; struct mbuf *m; struct ieee80211_node *ni; - int type; struct wtap_buf *bf; #if 0 DWTAP_PRINTF("%s\n", __func__); #endif - for(;;) { + for (;;) { mtx_lock(&sc->sc_mtx); bf = STAILQ_FIRST(&sc->sc_rxbuf); if (bf == NULL) { @@ -465,7 +467,7 @@ KASSERT(bf != NULL, ("wtap_buf is NULL\n")); m = bf->m; DWTAP_PRINTF("[%d] receiving m=%p\n", sc->id, bf->m); - if (m == NULL) { /* NB: shouldn't happen */ + if (m == NULL) { /* NB: shouldn't happen */ ic_printf(ic, "%s: no mbuf!\n", __func__); free(bf, M_WTAP_RXBUF); return; @@ -487,10 +489,10 @@ /* * Sending station is known, dispatch directly. */ - type = ieee80211_input(ni, m, 1<<7, 10); + ieee80211_input(ni, m, 1 << 7, 10); ieee80211_free_node(ni); } else { - type = ieee80211_input_all(ic, m, 1<<7, 10); + ieee80211_input_all(ic, m, 1 << 7, 10); } NET_EPOCH_EXIT(et); @@ -534,14 +536,13 @@ static int wtap_transmit(struct ieee80211com *ic, struct mbuf *m) { - struct ieee80211_node *ni = - (struct ieee80211_node *) m->m_pkthdr.rcvif; + struct ieee80211_node *ni = (struct ieee80211_node *)m->m_pkthdr.rcvif; struct ieee80211vap *vap = ni->ni_vap; struct wtap_vap *avp = WTAP_VAP(vap); - if(ni == NULL){ + if (ni == NULL) { printf("m->m_pkthdr.rcvif is NULL we cant radiotap_tx\n"); - }else{ + } else { if (ieee80211_radiotap_active_vap(vap)) ieee80211_radiotap_tx(vap, m); } @@ -559,7 +560,7 @@ DWTAP_PRINTF("%s\n", __func__); ni = malloc(sizeof(struct ieee80211_node), M_80211_NODE, - M_NOWAIT|M_ZERO); + M_NOWAIT | M_ZERO); if (ni == NULL) return (NULL); @@ -632,9 +633,8 @@ ic->ic_scan_end = wtap_scan_end; ic->ic_set_channel = wtap_set_channel; - ieee80211_radiotap_attach(ic, - &sc->sc_tx_th.wt_ihdr, sizeof(sc->sc_tx_th), - WTAP_TX_RADIOTAP_PRESENT, + ieee80211_radiotap_attach(ic, &sc->sc_tx_th.wt_ihdr, + sizeof(sc->sc_tx_th), WTAP_TX_RADIOTAP_PRESENT, &sc->sc_rx_th.wr_ihdr, sizeof(sc->sc_rx_th), WTAP_RX_RADIOTAP_PRESENT); @@ -677,27 +677,23 @@ void wtap_resume(struct wtap_softc *sc) { - DWTAP_PRINTF("%s\n", __func__); } void wtap_suspend(struct wtap_softc *sc) { - DWTAP_PRINTF("%s\n", __func__); } void wtap_shutdown(struct wtap_softc *sc) { - DWTAP_PRINTF("%s\n", __func__); } void wtap_intr(struct wtap_softc *sc) { - DWTAP_PRINTF("%s\n", __func__); } diff --git a/sys/dev/wtap/if_wtap_module.c b/sys/dev/wtap/if_wtap_module.c --- a/sys/dev/wtap/if_wtap_module.c +++ b/sys/dev/wtap/if_wtap_module.c @@ -71,8 +71,8 @@ #include #include -#include /* cdevsw struct */ -#include /* uio struct */ +#include /* cdevsw struct */ +#include /* uio struct */ #include #include @@ -91,34 +91,34 @@ "wtap wireless simulator receive buffer"); MALLOC_DEFINE(M_WTAP_PLUGIN, "wtap plugin", "wtap wireless simulator plugin"); -static struct wtap_hal *hal; +static struct wtap_hal *hal; /* Function prototypes */ -static d_ioctl_t wtap_ioctl; +static d_ioctl_t wtap_ioctl; static struct cdev *sdev; static struct cdevsw wtap_cdevsw = { - .d_version = D_VERSION, - .d_flags = 0, - .d_ioctl = wtap_ioctl, - .d_name = "wtapctl", + .d_version = D_VERSION, + .d_flags = 0, + .d_ioctl = wtap_ioctl, + .d_name = "wtapctl", }; int -wtap_ioctl(struct cdev *dev, u_long cmd, caddr_t data, - int fflag, struct thread *td) +wtap_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int fflag, + struct thread *td) { int error = 0; CURVNET_SET(CRED_TO_VNET(curthread->td_ucred)); - switch(cmd) { + switch (cmd) { case WTAPIOCTLCRT: - if(new_wtap(hal, *(int *)data)) + if (new_wtap(hal, *(int *)data)) error = EINVAL; break; case WTAPIOCTLDEL: - if(free_wtap(hal, *(int *)data)) + if (free_wtap(hal, *(int *)data)) error = EINVAL; break; default: @@ -132,33 +132,32 @@ /* The function called at load/unload. */ static int -event_handler(module_t module, int event, void *arg) +event_handler(module_t module, int event, void *arg) { struct visibility_plugin *plugin; int e = 0; /* Error, 0 for normal return status */ switch (event) { case MOD_LOAD: - sdev = make_dev(&wtap_cdevsw,0,UID_ROOT, - GID_WHEEL,0600,(const char *)"wtapctl"); - hal = (struct wtap_hal *)malloc(sizeof(struct wtap_hal), - M_WTAP, M_NOWAIT | M_ZERO); - bzero(hal, sizeof(struct wtap_hal)); + sdev = make_dev(&wtap_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, + (const char *)"wtapctl"); + hal = (struct wtap_hal *)malloc(sizeof(struct wtap_hal), M_WTAP, + M_NOWAIT | M_ZERO); init_hal(hal); /* Setting up a simple plugin */ - plugin = (struct visibility_plugin *)malloc - (sizeof(struct visibility_plugin), M_WTAP_PLUGIN, - M_NOWAIT | M_ZERO); - plugin->base.wp_hal = hal; + plugin = (struct visibility_plugin *) + malloc(sizeof(struct visibility_plugin), M_WTAP_PLUGIN, + M_NOWAIT | M_ZERO); + plugin->base.wp_hal = hal; plugin->base.init = visibility_init; plugin->base.deinit = visibility_deinit; plugin->base.work = visibility_work; register_plugin(hal, (struct wtap_plugin *)plugin); - printf("Loaded wtap wireless simulator\n"); - break; + printf("Loaded wtap wireless simulator\n"); + break; case MOD_UNLOAD: destroy_dev(sdev); deregister_plugin(hal); @@ -171,15 +170,15 @@ break; } - return(e); + return (e); } /* The second argument of DECLARE_MODULE. */ static moduledata_t wtap_conf = { - "wtap", /* module name */ - event_handler, /* event handler */ - NULL /* extra data */ + "wtap", /* module name */ + event_handler, /* event handler */ + NULL /* extra data */ }; DECLARE_MODULE(wtap, wtap_conf, SI_SUB_DRIVERS, SI_ORDER_MIDDLE); -MODULE_DEPEND(wtap, wlan, 1, 1, 1); /* 802.11 media layer */ +MODULE_DEPEND(wtap, wlan, 1, 1, 1); /* 802.11 media layer */ diff --git a/sys/dev/wtap/if_wtapioctl.h b/sys/dev/wtap/if_wtapioctl.h --- a/sys/dev/wtap/if_wtapioctl.h +++ b/sys/dev/wtap/if_wtapioctl.h @@ -45,104 +45,103 @@ #include #include -#define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) -#define SIOCZATHSTATS _IOWR('i', 139, struct ifreq) +#define SIOCGATHSTATS _IOWR('i', 137, struct ifreq) +#define SIOCZATHSTATS _IOWR('i', 139, struct ifreq) -#define WTAPIOCTLCRT _IOW('W', 1, int) -#define WTAPIOCTLDEL _IOW('W', 2, int) +#define WTAPIOCTLCRT _IOW('W', 1, int) +#define WTAPIOCTLDEL _IOW('W', 2, int) struct wtap_stats { - u_int32_t ast_watchdog; /* device reset by watchdog */ - u_int32_t ast_hardware; /* fatal hardware error interrupts */ - u_int32_t ast_bmiss; /* beacon miss interrupts */ - u_int32_t ast_bmiss_phantom;/* beacon miss interrupts */ - u_int32_t ast_bstuck; /* beacon stuck interrupts */ - u_int32_t ast_rxorn; /* rx overrun interrupts */ - u_int32_t ast_rxeol; /* rx eol interrupts */ - u_int32_t ast_txurn; /* tx underrun interrupts */ - u_int32_t ast_mib; /* mib interrupts */ - u_int32_t ast_intrcoal; /* interrupts coalesced */ - u_int32_t ast_tx_packets; /* packet sent on the interface */ - u_int32_t ast_tx_mgmt; /* management frames transmitted */ - u_int32_t ast_tx_discard; /* frames discarded prior to assoc */ - u_int32_t ast_tx_qstop; /* output stopped 'cuz no buffer */ - u_int32_t ast_tx_encap; /* tx encapsulation failed */ - u_int32_t ast_tx_nonode; /* tx failed 'cuz no node */ - u_int32_t ast_tx_nombuf; /* tx failed 'cuz no mbuf */ - u_int32_t ast_tx_nomcl; /* tx failed 'cuz no cluster */ - u_int32_t ast_tx_linear; /* tx linearized to cluster */ - u_int32_t ast_tx_nodata; /* tx discarded empty frame */ - u_int32_t ast_tx_busdma; /* tx failed for dma resrcs */ - u_int32_t ast_tx_xretries;/* tx failed 'cuz too many retries */ - u_int32_t ast_tx_fifoerr; /* tx failed 'cuz FIFO underrun */ - u_int32_t ast_tx_filtered;/* tx failed 'cuz xmit filtered */ - u_int32_t ast_tx_shortretry;/* tx on-chip retries (short) */ - u_int32_t ast_tx_longretry;/* tx on-chip retries (long) */ - u_int32_t ast_tx_badrate; /* tx failed 'cuz bogus xmit rate */ - u_int32_t ast_tx_noack; /* tx frames with no ack marked */ - u_int32_t ast_tx_rts; /* tx frames with rts enabled */ - u_int32_t ast_tx_cts; /* tx frames with cts enabled */ - u_int32_t ast_tx_shortpre;/* tx frames with short preamble */ - u_int32_t ast_tx_altrate; /* tx frames with alternate rate */ - u_int32_t ast_tx_protect; /* tx frames with protection */ - u_int32_t ast_tx_ctsburst;/* tx frames with cts and bursting */ - u_int32_t ast_tx_ctsext; /* tx frames with cts extension */ - u_int32_t ast_rx_nombuf; /* rx setup failed 'cuz no mbuf */ - u_int32_t ast_rx_busdma; /* rx setup failed for dma resrcs */ - u_int32_t ast_rx_orn; /* rx failed 'cuz of desc overrun */ - u_int32_t ast_rx_crcerr; /* rx failed 'cuz of bad CRC */ - u_int32_t ast_rx_fifoerr; /* rx failed 'cuz of FIFO overrun */ - u_int32_t ast_rx_badcrypt;/* rx failed 'cuz decryption */ - u_int32_t ast_rx_badmic; /* rx failed 'cuz MIC failure */ - u_int32_t ast_rx_phyerr; /* rx failed 'cuz of PHY err */ - u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */ - u_int32_t ast_rx_tooshort;/* rx discarded 'cuz frame too short */ - u_int32_t ast_rx_toobig; /* rx discarded 'cuz frame too large */ - u_int32_t ast_rx_packets; /* packet recv on the interface */ - u_int32_t ast_rx_mgt; /* management frames received */ - u_int32_t ast_rx_ctl; /* rx discarded 'cuz ctl frame */ - int8_t ast_tx_rssi; /* tx rssi of last ack */ - int8_t ast_rx_rssi; /* rx rssi from histogram */ - u_int8_t ast_tx_rate; /* IEEE rate of last unicast tx */ - u_int32_t ast_be_xmit; /* beacons transmitted */ - u_int32_t ast_be_nombuf; /* beacon setup failed 'cuz no mbuf */ - u_int32_t ast_per_cal; /* periodic calibration calls */ - u_int32_t ast_per_calfail;/* periodic calibration failed */ - u_int32_t ast_per_rfgain; /* periodic calibration rfgain reset */ - u_int32_t ast_rate_calls; /* rate control checks */ - u_int32_t ast_rate_raise; /* rate control raised xmit rate */ - u_int32_t ast_rate_drop; /* rate control dropped xmit rate */ - u_int32_t ast_ant_defswitch;/* rx/default antenna switches */ - u_int32_t ast_ant_txswitch;/* tx antenna switches */ - u_int32_t ast_ant_rx[8]; /* rx frames with antenna */ - u_int32_t ast_ant_tx[8]; /* tx frames with antenna */ - u_int32_t ast_cabq_xmit; /* cabq frames transmitted */ - u_int32_t ast_cabq_busy; /* cabq found busy */ - u_int32_t ast_tx_raw; /* tx frames through raw api */ - u_int32_t ast_ff_txok; /* fast frames tx'd successfully */ - u_int32_t ast_ff_txerr; /* fast frames tx'd w/ error */ - u_int32_t ast_ff_rx; /* fast frames rx'd */ - u_int32_t ast_ff_flush; /* fast frames flushed from staging q */ - u_int32_t ast_tx_qfull; /* tx dropped 'cuz of queue limit */ - int8_t ast_rx_noise; /* rx noise floor */ - u_int32_t ast_tx_nobuf; /* tx dropped 'cuz no ath buffer */ - u_int32_t ast_tdma_update;/* TDMA slot timing updates */ - u_int32_t ast_tdma_timers;/* TDMA slot update set beacon timers */ - u_int32_t ast_tdma_tsf; /* TDMA slot update set TSF */ - u_int16_t ast_tdma_tsfadjp;/* TDMA slot adjust+ (usec, smoothed)*/ - u_int16_t ast_tdma_tsfadjm;/* TDMA slot adjust- (usec, smoothed)*/ - u_int32_t ast_tdma_ack; /* TDMA tx failed 'cuz ACK required */ - u_int32_t ast_tx_raw_fail;/* raw tx failed 'cuz h/w down */ - u_int32_t ast_tx_nofrag; /* tx dropped 'cuz no ath frag buffer */ - u_int32_t ast_be_missed; /* missed beacons */ - u_int32_t ast_pad[13]; + u_int32_t ast_watchdog; /* device reset by watchdog */ + u_int32_t ast_hardware; /* fatal hardware error interrupts */ + u_int32_t ast_bmiss; /* beacon miss interrupts */ + u_int32_t ast_bmiss_phantom; /* beacon miss interrupts */ + u_int32_t ast_bstuck; /* beacon stuck interrupts */ + u_int32_t ast_rxorn; /* rx overrun interrupts */ + u_int32_t ast_rxeol; /* rx eol interrupts */ + u_int32_t ast_txurn; /* tx underrun interrupts */ + u_int32_t ast_mib; /* mib interrupts */ + u_int32_t ast_intrcoal; /* interrupts coalesced */ + u_int32_t ast_tx_packets; /* packet sent on the interface */ + u_int32_t ast_tx_mgmt; /* management frames transmitted */ + u_int32_t ast_tx_discard; /* frames discarded prior to assoc */ + u_int32_t ast_tx_qstop; /* output stopped 'cuz no buffer */ + u_int32_t ast_tx_encap; /* tx encapsulation failed */ + u_int32_t ast_tx_nonode; /* tx failed 'cuz no node */ + u_int32_t ast_tx_nombuf; /* tx failed 'cuz no mbuf */ + u_int32_t ast_tx_nomcl; /* tx failed 'cuz no cluster */ + u_int32_t ast_tx_linear; /* tx linearized to cluster */ + u_int32_t ast_tx_nodata; /* tx discarded empty frame */ + u_int32_t ast_tx_busdma; /* tx failed for dma resrcs */ + u_int32_t ast_tx_xretries; /* tx failed 'cuz too many retries */ + u_int32_t ast_tx_fifoerr; /* tx failed 'cuz FIFO underrun */ + u_int32_t ast_tx_filtered; /* tx failed 'cuz xmit filtered */ + u_int32_t ast_tx_shortretry; /* tx on-chip retries (short) */ + u_int32_t ast_tx_longretry; /* tx on-chip retries (long) */ + u_int32_t ast_tx_badrate; /* tx failed 'cuz bogus xmit rate */ + u_int32_t ast_tx_noack; /* tx frames with no ack marked */ + u_int32_t ast_tx_rts; /* tx frames with rts enabled */ + u_int32_t ast_tx_cts; /* tx frames with cts enabled */ + u_int32_t ast_tx_shortpre; /* tx frames with short preamble */ + u_int32_t ast_tx_altrate; /* tx frames with alternate rate */ + u_int32_t ast_tx_protect; /* tx frames with protection */ + u_int32_t ast_tx_ctsburst; /* tx frames with cts and bursting */ + u_int32_t ast_tx_ctsext; /* tx frames with cts extension */ + u_int32_t ast_rx_nombuf; /* rx setup failed 'cuz no mbuf */ + u_int32_t ast_rx_busdma; /* rx setup failed for dma resrcs */ + u_int32_t ast_rx_orn; /* rx failed 'cuz of desc overrun */ + u_int32_t ast_rx_crcerr; /* rx failed 'cuz of bad CRC */ + u_int32_t ast_rx_fifoerr; /* rx failed 'cuz of FIFO overrun */ + u_int32_t ast_rx_badcrypt; /* rx failed 'cuz decryption */ + u_int32_t ast_rx_badmic; /* rx failed 'cuz MIC failure */ + u_int32_t ast_rx_phyerr; /* rx failed 'cuz of PHY err */ + u_int32_t ast_rx_phy[32]; /* rx PHY error per-code counts */ + u_int32_t ast_rx_tooshort; /* rx discarded 'cuz frame too short */ + u_int32_t ast_rx_toobig; /* rx discarded 'cuz frame too large */ + u_int32_t ast_rx_packets; /* packet recv on the interface */ + u_int32_t ast_rx_mgt; /* management frames received */ + u_int32_t ast_rx_ctl; /* rx discarded 'cuz ctl frame */ + int8_t ast_tx_rssi; /* tx rssi of last ack */ + int8_t ast_rx_rssi; /* rx rssi from histogram */ + u_int8_t ast_tx_rate; /* IEEE rate of last unicast tx */ + u_int32_t ast_be_xmit; /* beacons transmitted */ + u_int32_t ast_be_nombuf; /* beacon setup failed 'cuz no mbuf */ + u_int32_t ast_per_cal; /* periodic calibration calls */ + u_int32_t ast_per_calfail; /* periodic calibration failed */ + u_int32_t ast_per_rfgain; /* periodic calibration rfgain reset */ + u_int32_t ast_rate_calls; /* rate control checks */ + u_int32_t ast_rate_raise; /* rate control raised xmit rate */ + u_int32_t ast_rate_drop; /* rate control dropped xmit rate */ + u_int32_t ast_ant_defswitch; /* rx/default antenna switches */ + u_int32_t ast_ant_txswitch; /* tx antenna switches */ + u_int32_t ast_ant_rx[8]; /* rx frames with antenna */ + u_int32_t ast_ant_tx[8]; /* tx frames with antenna */ + u_int32_t ast_cabq_xmit; /* cabq frames transmitted */ + u_int32_t ast_cabq_busy; /* cabq found busy */ + u_int32_t ast_tx_raw; /* tx frames through raw api */ + u_int32_t ast_ff_txok; /* fast frames tx'd successfully */ + u_int32_t ast_ff_txerr; /* fast frames tx'd w/ error */ + u_int32_t ast_ff_rx; /* fast frames rx'd */ + u_int32_t ast_ff_flush; /* fast frames flushed from staging q */ + u_int32_t ast_tx_qfull; /* tx dropped 'cuz of queue limit */ + int8_t ast_rx_noise; /* rx noise floor */ + u_int32_t ast_tx_nobuf; /* tx dropped 'cuz no ath buffer */ + u_int32_t ast_tdma_update; /* TDMA slot timing updates */ + u_int32_t ast_tdma_timers; /* TDMA slot update set beacon timers */ + u_int32_t ast_tdma_tsf; /* TDMA slot update set TSF */ + u_int16_t ast_tdma_tsfadjp; /* TDMA slot adjust+ (usec, smoothed)*/ + u_int16_t ast_tdma_tsfadjm; /* TDMA slot adjust- (usec, smoothed)*/ + u_int32_t ast_tdma_ack; /* TDMA tx failed 'cuz ACK required */ + u_int32_t ast_tx_raw_fail; /* raw tx failed 'cuz h/w down */ + u_int32_t ast_tx_nofrag; /* tx dropped 'cuz no ath frag buffer */ + u_int32_t ast_be_missed; /* missed beacons */ + u_int32_t ast_pad[13]; }; /* * Radio capture format. */ -#define WTAP_RX_RADIOTAP_PRESENT ( \ - 0) +#define WTAP_RX_RADIOTAP_PRESENT (0) struct wtap_rx_radiotap_header { struct ieee80211_radiotap_header wr_ihdr; @@ -161,8 +160,7 @@ #endif } __packed __aligned(8); -#define WTAP_TX_RADIOTAP_PRESENT ( \ - 0) +#define WTAP_TX_RADIOTAP_PRESENT (0) struct wtap_tx_radiotap_header { struct ieee80211_radiotap_header wt_ihdr; diff --git a/sys/dev/wtap/if_wtapvar.h b/sys/dev/wtap/if_wtapvar.h --- a/sys/dev/wtap/if_wtapvar.h +++ b/sys/dev/wtap/if_wtapvar.h @@ -95,64 +95,63 @@ /* driver-specific node state */ struct wtap_node { - struct ieee80211_node an_node; /* base class */ - /* future addons */ + struct ieee80211_node an_node; /* base class */ + /* future addons */ }; -#define WTAP_NODE(ni) ((struct ath_node *)(ni)) -#define WTAP_NODE_CONST(ni) ((const struct ath_node *)(ni)) +#define WTAP_NODE(ni) ((struct ath_node *)(ni)) +#define WTAP_NODE_CONST(ni) ((const struct ath_node *)(ni)) struct wtap_buf { - STAILQ_ENTRY(wtap_buf) bf_list; - struct mbuf *m; /* mbuf for buf */ + STAILQ_ENTRY(wtap_buf) bf_list; + struct mbuf *m; /* mbuf for buf */ }; typedef STAILQ_HEAD(, wtap_buf) wtap_bufhead; -#define WTAP_BUF_BUSY 0x00000002 /* (tx) desc owned by h/w */ +#define WTAP_BUF_BUSY 0x00000002 /* (tx) desc owned by h/w */ struct wtap_vap { - struct ieee80211vap av_vap; /* base class */ - int32_t id; /* wtap id */ - struct cdev *av_dev; /* userspace injecting frames */ - struct wtap_medium *av_md; /* back pointer */ - struct mbuf *beacon; /* beacon */ - struct ieee80211_node *bf_node; /* pointer to the node */ - struct callout av_swba; /* software beacon alert */ - uint32_t av_bcinterval; /* beacon interval */ - void (*av_recv_mgmt)(struct ieee80211_node *, - struct mbuf *, int, const struct ieee80211_rx_stats *, int, int); - int (*av_newstate)(struct ieee80211vap *, - enum ieee80211_state, int); + struct ieee80211vap av_vap; /* base class */ + int32_t id; /* wtap id */ + struct cdev *av_dev; /* userspace injecting frames */ + struct wtap_medium *av_md; /* back pointer */ + struct mbuf *beacon; /* beacon */ + struct ieee80211_node *bf_node; /* pointer to the node */ + struct callout av_swba; /* software beacon alert */ + uint32_t av_bcinterval; /* beacon interval */ + void (*av_recv_mgmt)(struct ieee80211_node *, struct mbuf *, int, + const struct ieee80211_rx_stats *, int, int); + int (*av_newstate)(struct ieee80211vap *, enum ieee80211_state, int); void (*av_bmiss)(struct ieee80211vap *); }; -#define WTAP_VAP(vap) ((struct wtap_vap *)(vap)) +#define WTAP_VAP(vap) ((struct wtap_vap *)(vap)) struct taskqueue; struct wtap_softc { - struct ieee80211com sc_ic; - char name[7]; /* wtapXX\0 */ - int32_t id; - int32_t up; - struct wtap_medium *sc_md; /* interface medium */ - struct ieee80211_node* (* sc_node_alloc) - (struct ieee80211vap *, const uint8_t [IEEE80211_ADDR_LEN]); + struct ieee80211com sc_ic; + char name[7]; /* wtapXX\0 */ + int32_t id; + int32_t up; + struct wtap_medium *sc_md; /* interface medium */ + struct ieee80211_node *(*sc_node_alloc)(struct ieee80211vap *, + const uint8_t[IEEE80211_ADDR_LEN]); void (*sc_node_free)(struct ieee80211_node *); - struct mtx sc_mtx; /* master lock (recursive) */ - struct taskqueue *sc_tq; /* private task queue */ - wtap_bufhead sc_rxbuf; /* receive buffer */ - struct task sc_rxtask; /* rx int processing */ + struct mtx sc_mtx; /* master lock (recursive) */ + struct taskqueue *sc_tq; /* private task queue */ + wtap_bufhead sc_rxbuf; /* receive buffer */ + struct task sc_rxtask; /* rx int processing */ struct wtap_tx_radiotap_header sc_tx_th; - int sc_tx_th_len; + int sc_tx_th_len; struct wtap_rx_radiotap_header sc_rx_th; - int sc_rx_th_len; + int sc_rx_th_len; }; -int32_t wtap_attach(struct wtap_softc *, const uint8_t *macaddr); -int32_t wtap_detach(struct wtap_softc *); -void wtap_resume(struct wtap_softc *); -void wtap_suspend(struct wtap_softc *); -void wtap_shutdown(struct wtap_softc *); -void wtap_intr(struct wtap_softc *); -void wtap_inject(struct wtap_softc *, struct mbuf *); +int32_t wtap_attach(struct wtap_softc *, const uint8_t *macaddr); +int32_t wtap_detach(struct wtap_softc *); +void wtap_resume(struct wtap_softc *); +void wtap_suspend(struct wtap_softc *); +void wtap_shutdown(struct wtap_softc *); +void wtap_intr(struct wtap_softc *); +void wtap_inject(struct wtap_softc *, struct mbuf *); #endif diff --git a/sys/dev/wtap/plugins/visibility.h b/sys/dev/wtap/plugins/visibility.h --- a/sys/dev/wtap/plugins/visibility.h +++ b/sys/dev/wtap/plugins/visibility.h @@ -38,15 +38,15 @@ #define CDEV_GET_SOFTC(x) (x)->si_drv1 -#define ARRAY_SIZE (32) //We support a maximum of 1024 nodes for now +#define ARRAY_SIZE (32) // We support a maximum of 1024 nodes for now struct vis_map { - uint32_t map[ARRAY_SIZE]; + uint32_t map[ARRAY_SIZE]; }; struct visibility_plugin { - struct wtap_plugin base; - struct mtx pl_mtx; + struct wtap_plugin base; + struct mtx pl_mtx; struct vis_map pl_node[MAX_NBR_WTAP]; }; diff --git a/sys/dev/wtap/plugins/visibility.c b/sys/dev/wtap/plugins/visibility.c --- a/sys/dev/wtap/plugins/visibility.c +++ b/sys/dev/wtap/plugins/visibility.c @@ -71,8 +71,8 @@ #include #include -#include /* cdevsw struct */ -#include /* uio struct */ +#include /* cdevsw struct */ +#include /* uio struct */ #include #include @@ -80,13 +80,13 @@ #include "visibility.h" /* Function prototypes */ -static d_ioctl_t vis_ioctl; +static d_ioctl_t vis_ioctl; static struct cdevsw vis_cdevsw = { - .d_version = D_VERSION, - .d_flags = 0, - .d_ioctl = vis_ioctl, - .d_name = "visctl", + .d_version = D_VERSION, + .d_flags = 0, + .d_ioctl = vis_ioctl, + .d_name = "visctl", }; void @@ -94,12 +94,12 @@ { struct visibility_plugin *vis_plugin; - vis_plugin = (struct visibility_plugin *) plugin; - plugin->wp_sdev = make_dev(&vis_cdevsw,0,UID_ROOT,GID_WHEEL,0600, + vis_plugin = (struct visibility_plugin *)plugin; + plugin->wp_sdev = make_dev(&vis_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, (const char *)"visctl"); plugin->wp_sdev->si_drv1 = vis_plugin; - mtx_init(&vis_plugin->pl_mtx, "visibility_plugin mtx", - NULL, MTX_DEF | MTX_RECURSE); + mtx_init(&vis_plugin->pl_mtx, "visibility_plugin mtx", NULL, + MTX_DEF | MTX_RECURSE); printf("Using visibility wtap plugin...\n"); } @@ -108,7 +108,7 @@ { struct visibility_plugin *vis_plugin; - vis_plugin = (struct visibility_plugin *) plugin; + vis_plugin = (struct visibility_plugin *)plugin; destroy_dev(plugin->wp_sdev); mtx_destroy(&vis_plugin->pl_mtx); free(vis_plugin, M_WTAP_PLUGIN); @@ -121,15 +121,15 @@ void visibility_work(struct wtap_plugin *plugin, struct packet *p) { - struct visibility_plugin *vis_plugin = - (struct visibility_plugin *) plugin; + struct visibility_plugin *vis_plugin = (struct visibility_plugin *) + plugin; struct wtap_hal *hal = (struct wtap_hal *)vis_plugin->base.wp_hal; struct vis_map *map; - KASSERT(mtod(p->m, const char *) != (const char *) 0xdeadc0de || - mtod(p->m, const char *) != NULL, + KASSERT(mtod(p->m, const char *) != (const char *)0xdeadc0de || + mtod(p->m, const char *) != NULL, ("[%s] got a corrupt packet from master queue, p->m=%p, p->id=%d\n", - __func__, p->m, p->id)); + __func__, p->m, p->id)); DWTAP_PRINTF("[%d] BROADCASTING m=%p\n", p->id, p->m); mtx_lock(&vis_plugin->pl_mtx); map = &vis_plugin->pl_node[p->id]; @@ -140,20 +140,20 @@ * creating groups of nodes that hear each other. * Atleast for this simple static node plugin. */ - for(int i=0; imap[i]; - for(int j=0; j<32; ++j){ + for (int j = 0; j < 32; ++j) { int vis = index & 0x01; - if(vis){ - int k = i*ARRAY_SIZE + j; - if(hal->hal_devs[k] != NULL - && hal->hal_devs[k]->up == 1){ + if (vis) { + int k = i * ARRAY_SIZE + j; + if (hal->hal_devs[k] != NULL && + hal->hal_devs[k]->up == 1) { struct wtap_softc *sc = hal->hal_devs[k]; - struct mbuf *m = - m_dup(p->m, M_NOWAIT); + struct mbuf *m = m_dup(p->m, M_NOWAIT); DWTAP_PRINTF("[%d] duplicated old_m=%p" - "to new_m=%p\n", p->id, p->m, m); + "to new_m=%p\n", + p->id, p->m, m); #if 0 printf("[%d] sending to %d\n", p->id, k); @@ -172,7 +172,7 @@ mtx_lock(&vis_plugin->pl_mtx); struct vis_map *map = &vis_plugin->pl_node[l->id1]; - int index = l->id2/ARRAY_SIZE; + int index = l->id2 / ARRAY_SIZE; int bit = l->id2 % ARRAY_SIZE; uint32_t value = 1 << bit; map->map[index] = map->map[index] | value; @@ -189,7 +189,7 @@ mtx_lock(&vis_plugin->pl_mtx); struct vis_map *map = &vis_plugin->pl_node[l->id1]; - int index = l->id2/ARRAY_SIZE; + int index = l->id2 / ARRAY_SIZE; int bit = l->id2 % ARRAY_SIZE; uint32_t value = 1 << bit; map->map[index] = map->map[index] & ~value; @@ -200,28 +200,28 @@ } int -vis_ioctl(struct cdev *sdev, u_long cmd, caddr_t data, - int fflag, struct thread *td) +vis_ioctl(struct cdev *sdev, u_long cmd, caddr_t data, int fflag, + struct thread *td) { - struct visibility_plugin *vis_plugin = - (struct visibility_plugin *) sdev->si_drv1; + struct visibility_plugin *vis_plugin = (struct visibility_plugin *) + sdev->si_drv1; struct wtap_hal *hal = vis_plugin->base.wp_hal; struct link l; int op; int error = 0; CURVNET_SET(CRED_TO_VNET(curthread->td_ucred)); - switch(cmd) { + switch (cmd) { case VISIOCTLOPEN: - op = *(int *)data; - if(op == 0) + op = *(int *)data; + if (op == 0) medium_close(hal->hal_md); else medium_open(hal->hal_md); break; case VISIOCTLLINK: l = *(struct link *)data; - if(l.op == 0) + if (l.op == 0) del_link(vis_plugin, &l); else add_link(vis_plugin, &l); diff --git a/sys/dev/wtap/plugins/visibility_ioctl.h b/sys/dev/wtap/plugins/visibility_ioctl.h --- a/sys/dev/wtap/plugins/visibility_ioctl.h +++ b/sys/dev/wtap/plugins/visibility_ioctl.h @@ -41,12 +41,12 @@ #include struct link { - int op; //0 remove, 1 link - int id1; - int id2; + int op; // 0 remove, 1 link + int id1; + int id2; }; -#define VISIOCTLOPEN _IOW('W', 3, int) // 0 close, 1 open +#define VISIOCTLOPEN _IOW('W', 3, int) // 0 close, 1 open #define VISIOCTLLINK _IOW('W', 4, struct link) // #endif diff --git a/sys/dev/wtap/plugins/wtap_plugin.h b/sys/dev/wtap/plugins/wtap_plugin.h --- a/sys/dev/wtap/plugins/wtap_plugin.h +++ b/sys/dev/wtap/plugins/wtap_plugin.h @@ -38,8 +38,8 @@ #include "../wtap_hal/hal.h" struct wtap_plugin { - struct cdev *wp_sdev; - struct wtap_hal *wp_hal; + struct cdev *wp_sdev; + struct wtap_hal *wp_hal; void (*init)(struct wtap_plugin *); void (*deinit)(struct wtap_plugin *); void (*work)(struct wtap_plugin *, struct packet *p); diff --git a/sys/dev/wtap/wtap_hal/hal.h b/sys/dev/wtap/wtap_hal/hal.h --- a/sys/dev/wtap/wtap_hal/hal.h +++ b/sys/dev/wtap/wtap_hal/hal.h @@ -39,10 +39,10 @@ #include "handler.h" struct wtap_hal { - struct wtap_medium *hal_md; - struct mtx hal_mtx; - struct wtap_plugin *plugin; - struct wtap_softc *hal_devs[MAX_NBR_WTAP]; + struct wtap_medium *hal_md; + struct mtx hal_mtx; + struct wtap_plugin *plugin; + struct wtap_softc *hal_devs[MAX_NBR_WTAP]; }; void init_hal(struct wtap_hal *); diff --git a/sys/dev/wtap/wtap_hal/hal.c b/sys/dev/wtap/wtap_hal/hal.c --- a/sys/dev/wtap/wtap_hal/hal.c +++ b/sys/dev/wtap/wtap_hal/hal.c @@ -45,10 +45,10 @@ #endif hal = (struct wtap_hal *)arg; - for(;;){ + for (;;) { p = medium_get_next_packet(hal->hal_md); - if(p == NULL) - return; + if (p == NULL) + return; hal->plugin->work(hal->plugin, p); @@ -69,7 +69,6 @@ hal->hal_md = (struct wtap_medium *)malloc(sizeof(struct wtap_medium), M_WTAP, M_NOWAIT | M_ZERO); - bzero(hal->hal_md, sizeof(struct wtap_medium)); init_medium(hal->hal_md); /* register event handler for packets */ @@ -106,90 +105,58 @@ new_wtap(struct wtap_hal *hal, int32_t id) { static const uint8_t mac_pool[64][IEEE80211_ADDR_LEN] = { - {0,152,154,152,150,151}, - {0,152,154,152,150,152}, - {0,152,154,152,150,153}, - {0,152,154,152,150,154}, - {0,152,154,152,150,155}, - {0,152,154,152,150,156}, - {0,152,154,152,150,157}, - {0,152,154,152,150,158}, - {0,152,154,152,151,151}, - {0,152,154,152,151,152}, - {0,152,154,152,151,153}, - {0,152,154,152,151,154}, - {0,152,154,152,151,155}, - {0,152,154,152,151,156}, - {0,152,154,152,151,157}, - {0,152,154,152,151,158}, - {0,152,154,152,152,151}, - {0,152,154,152,152,152}, - {0,152,154,152,152,153}, - {0,152,154,152,152,154}, - {0,152,154,152,152,155}, - {0,152,154,152,152,156}, - {0,152,154,152,152,157}, - {0,152,154,152,152,158}, - {0,152,154,152,153,151}, - {0,152,154,152,153,152}, - {0,152,154,152,153,153}, - {0,152,154,152,153,154}, - {0,152,154,152,153,155}, - {0,152,154,152,153,156}, - {0,152,154,152,153,157}, - {0,152,154,152,153,158}, - {0,152,154,152,154,151}, - {0,152,154,152,154,152}, - {0,152,154,152,154,153}, - {0,152,154,152,154,154}, - {0,152,154,152,154,155}, - {0,152,154,152,154,156}, - {0,152,154,152,154,157}, - {0,152,154,152,154,158}, - {0,152,154,152,155,151}, - {0,152,154,152,155,152}, - {0,152,154,152,155,153}, - {0,152,154,152,155,154}, - {0,152,154,152,155,155}, - {0,152,154,152,155,156}, - {0,152,154,152,155,157}, - {0,152,154,152,155,158}, - {0,152,154,152,156,151}, - {0,152,154,152,156,152}, - {0,152,154,152,156,153}, - {0,152,154,152,156,154}, - {0,152,154,152,156,155}, - {0,152,154,152,156,156}, - {0,152,154,152,156,157}, - {0,152,154,152,156,158}, - {0,152,154,152,157,151}, - {0,152,154,152,157,152}, - {0,152,154,152,157,153}, - {0,152,154,152,157,154}, - {0,152,154,152,157,155}, - {0,152,154,152,157,156}, - {0,152,154,152,157,157}, - {0,152,154,152,157,158} - }; + { 0, 152, 154, 152, 150, 151 }, { 0, 152, 154, 152, 150, 152 }, + { 0, 152, 154, 152, 150, 153 }, { 0, 152, 154, 152, 150, 154 }, + { 0, 152, 154, 152, 150, 155 }, { 0, 152, 154, 152, 150, 156 }, + { 0, 152, 154, 152, 150, 157 }, { 0, 152, 154, 152, 150, 158 }, + { 0, 152, 154, 152, 151, 151 }, { 0, 152, 154, 152, 151, 152 }, + { 0, 152, 154, 152, 151, 153 }, { 0, 152, 154, 152, 151, 154 }, + { 0, 152, 154, 152, 151, 155 }, { 0, 152, 154, 152, 151, 156 }, + { 0, 152, 154, 152, 151, 157 }, { 0, 152, 154, 152, 151, 158 }, + { 0, 152, 154, 152, 152, 151 }, { 0, 152, 154, 152, 152, 152 }, + { 0, 152, 154, 152, 152, 153 }, { 0, 152, 154, 152, 152, 154 }, + { 0, 152, 154, 152, 152, 155 }, { 0, 152, 154, 152, 152, 156 }, + { 0, 152, 154, 152, 152, 157 }, { 0, 152, 154, 152, 152, 158 }, + { 0, 152, 154, 152, 153, 151 }, { 0, 152, 154, 152, 153, 152 }, + { 0, 152, 154, 152, 153, 153 }, { 0, 152, 154, 152, 153, 154 }, + { 0, 152, 154, 152, 153, 155 }, { 0, 152, 154, 152, 153, 156 }, + { 0, 152, 154, 152, 153, 157 }, { 0, 152, 154, 152, 153, 158 }, + { 0, 152, 154, 152, 154, 151 }, { 0, 152, 154, 152, 154, 152 }, + { 0, 152, 154, 152, 154, 153 }, { 0, 152, 154, 152, 154, 154 }, + { 0, 152, 154, 152, 154, 155 }, { 0, 152, 154, 152, 154, 156 }, + { 0, 152, 154, 152, 154, 157 }, { 0, 152, 154, 152, 154, 158 }, + { 0, 152, 154, 152, 155, 151 }, { 0, 152, 154, 152, 155, 152 }, + { 0, 152, 154, 152, 155, 153 }, { 0, 152, 154, 152, 155, 154 }, + { 0, 152, 154, 152, 155, 155 }, { 0, 152, 154, 152, 155, 156 }, + { 0, 152, 154, 152, 155, 157 }, { 0, 152, 154, 152, 155, 158 }, + { 0, 152, 154, 152, 156, 151 }, { 0, 152, 154, 152, 156, 152 }, + { 0, 152, 154, 152, 156, 153 }, { 0, 152, 154, 152, 156, 154 }, + { 0, 152, 154, 152, 156, 155 }, { 0, 152, 154, 152, 156, 156 }, + { 0, 152, 154, 152, 156, 157 }, { 0, 152, 154, 152, 156, 158 }, + { 0, 152, 154, 152, 157, 151 }, { 0, 152, 154, 152, 157, 152 }, + { 0, 152, 154, 152, 157, 153 }, { 0, 152, 154, 152, 157, 154 }, + { 0, 152, 154, 152, 157, 155 }, { 0, 152, 154, 152, 157, 156 }, + { 0, 152, 154, 152, 157, 157 }, { 0, 152, 154, 152, 157, 158 } + }; DWTAP_PRINTF("%s\n", __func__); uint8_t const *macaddr = mac_pool[id]; - if(hal->hal_devs[id] != NULL){ + if (hal->hal_devs[id] != NULL) { printf("error, wtap_id=%d already created\n", id); return -1; } - hal->hal_devs[id] = (struct wtap_softc *)malloc( - sizeof(struct wtap_softc), M_WTAP, M_NOWAIT | M_ZERO); - bzero(hal->hal_devs[id], sizeof(struct wtap_softc)); + hal->hal_devs[id] = (struct wtap_softc *)malloc(sizeof( + struct wtap_softc), + M_WTAP, M_NOWAIT | M_ZERO); hal->hal_devs[id]->sc_md = hal->hal_md; hal->hal_devs[id]->id = id; snprintf(hal->hal_devs[id]->name, sizeof(hal->hal_devs[id]->name), - "wlan%d", id); + "wtap%d", id); mtx_init(&hal->hal_devs[id]->sc_mtx, "wtap_softc mtx", NULL, MTX_DEF | MTX_RECURSE); - if(wtap_attach(hal->hal_devs[id], macaddr)){ + if (wtap_attach(hal->hal_devs[id], macaddr)) { printf("%s, cant alloc new wtap\n", __func__); return -1; } @@ -202,12 +169,12 @@ { DWTAP_PRINTF("%s\n", __func__); - if(hal->hal_devs[id] == NULL){ + if (hal->hal_devs[id] == NULL) { printf("error, wtap_id=%d never created\n", id); return -1; } - if(wtap_detach(hal->hal_devs[id])) + if (wtap_detach(hal->hal_devs[id])) printf("%s, cant alloc new wtap\n", __func__); mtx_destroy(&hal->hal_devs[id]->sc_mtx); free(hal->hal_devs[id], M_WTAP); diff --git a/sys/dev/wtap/wtap_hal/handler.h b/sys/dev/wtap/wtap_hal/handler.h --- a/sys/dev/wtap/wtap_hal/handler.h +++ b/sys/dev/wtap/wtap_hal/handler.h @@ -37,15 +37,15 @@ #include "../if_wtapvar.h" struct timehandler { - struct callout cb; + struct callout cb; void (*proc)(void *); }; struct taskqueue; struct eventhandler { - struct taskqueue *tq; - struct task proc; + struct taskqueue *tq; + struct task proc; }; #endif