summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2002-04-08 18:31:28 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2002-04-08 18:31:28 +0000
commite894090e857f9aa7417e2d9821e3b854df946835 (patch)
treed2f1405f2abdbcd6abc4a19cc602650a1d2825c2 /sys/dev
parenta8622545c362ee466406cd85a1a9ef5c3710e965 (diff)
make hostap work on other-endian machines; tested by drahn@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/if_wi.c26
-rw-r--r--sys/dev/ic/if_wi_hostap.c23
2 files changed, 27 insertions, 22 deletions
diff --git a/sys/dev/ic/if_wi.c b/sys/dev/ic/if_wi.c
index 570ec408666..1e41606be22 100644
--- a/sys/dev/ic/if_wi.c
+++ b/sys/dev/ic/if_wi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wi.c,v 1.49 2002/04/07 23:23:49 millert Exp $ */
+/* $OpenBSD: if_wi.c,v 1.50 2002/04/08 18:31:27 mickey Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
@@ -124,7 +124,7 @@ u_int32_t widebug = WIDEBUG;
#if !defined(lint) && !defined(__OpenBSD__)
static const char rcsid[] =
- "$OpenBSD: if_wi.c,v 1.49 2002/04/07 23:23:49 millert Exp $";
+ "$OpenBSD: if_wi.c,v 1.50 2002/04/08 18:31:27 mickey Exp $";
#endif /* lint */
#ifdef foo
@@ -436,15 +436,16 @@ wi_rxeof(sc)
eh = mtod(m, struct ether_header *);
m->m_pkthdr.rcvif = ifp;
- if (rx_frame.wi_status == WI_STAT_MGMT &&
+ if (rx_frame.wi_status == htole16(WI_STAT_MGMT) &&
sc->wi_ptype == WI_PORTTYPE_AP) {
- if ((WI_802_11_OFFSET_RAW + rx_frame.wi_dat_len + 2) >
- MCLBYTES) {
+ u_int16_t rxlen = letoh16(rx_frame.wi_dat_len);
+
+ if ((WI_802_11_OFFSET_RAW + rxlen + 2) > MCLBYTES) {
printf("%s: oversized mgmt packet received in "
"hostap mode (wi_dat_len=%d, wi_status=0x%x)\n",
sc->sc_dev.dv_xname,
- rx_frame.wi_dat_len, rx_frame.wi_status);
+ rxlen, letoh16(rx_frame.wi_status));
m_freem(m);
ifp->if_ierrors++;
return;
@@ -453,8 +454,7 @@ wi_rxeof(sc)
/* Put the whole header in there. */
bcopy(&rx_frame, mtod(m, void *), sizeof(struct wi_frame));
if (wi_read_data(sc, id, WI_802_11_OFFSET_RAW,
- mtod(m, caddr_t) + WI_802_11_OFFSET_RAW,
- rx_frame.wi_dat_len + 2)) {
+ mtod(m, caddr_t) + WI_802_11_OFFSET_RAW, rxlen + 2)) {
m_freem(m);
if (sc->arpcom.ac_if.if_flags & IFF_DEBUG)
printf("wihap: failed to copy header\n");
@@ -462,8 +462,7 @@ wi_rxeof(sc)
return;
}
- m->m_pkthdr.len = m->m_len =
- WI_802_11_OFFSET_RAW + rx_frame.wi_dat_len;
+ m->m_pkthdr.len = m->m_len = WI_802_11_OFFSET_RAW + rxlen;
/* XXX: consider giving packet to bhp? */
@@ -1775,7 +1774,7 @@ nextpkt:
bcopy((char *)&eh->ether_shost,
(char *)&tx_frame.wi_src_addr, ETHER_ADDR_LEN);
- tx_frame.wi_dat_len = htole16(m0->m_pkthdr.len - WI_SNAPHDR_LEN);
+ tx_frame.wi_dat_len = m0->m_pkthdr.len - WI_SNAPHDR_LEN;
tx_frame.wi_dat[0] = htons(WI_SNAP_WORD0);
tx_frame.wi_dat[1] = htons(WI_SNAP_WORD1);
tx_frame.wi_len = htons(m0->m_pkthdr.len - WI_SNAPHDR_LEN);
@@ -1796,6 +1795,7 @@ nextpkt:
tx_frame.wi_dat_len += IEEE80211_WEP_IVLEN +
IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN;
+ tx_frame.wi_dat_len = htole16(tx_frame.wi_dat_len);
wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
sizeof(struct wi_frame));
wi_write_data(sc, id, WI_802_11_OFFSET_RAW,
@@ -1807,6 +1807,7 @@ nextpkt:
m0->m_pkthdr.len - sizeof(struct ether_header),
(caddr_t)&sc->wi_txbuf);
+ tx_frame.wi_dat_len = htole16(tx_frame.wi_dat_len);
wi_write_data(sc, id, 0, (caddr_t)&tx_frame,
sizeof(struct wi_frame));
wi_write_data(sc, id, WI_802_11_OFFSET,
@@ -1885,6 +1886,7 @@ wi_mgmt_xmit(sc, data, len)
tx_frame.wi_dat_len = len - sizeof(struct wi_80211_hdr);
tx_frame.wi_len = htole16(tx_frame.wi_dat_len);
+ tx_frame.wi_dat_len = htole16(tx_frame.wi_dat_len);
wi_write_data(sc, id, 0, (caddr_t)&tx_frame, sizeof(struct wi_frame));
wi_write_data(sc, id, WI_802_11_OFFSET_RAW, dptr,
(len - sizeof(struct wi_80211_hdr)) + 2);
@@ -2008,7 +2010,7 @@ wi_get_id(sc)
sc->sc_firmware_type = WI_INTERSIL;
break;
default:
- if (letoh16(ver.wi_ver[0]) & 0x8000) {
+ if (ver.wi_ver[0] & htole16(0x8000)) {
p = "Unknown PRISM2 chip";
sc->sc_firmware_type = WI_INTERSIL;
} else {
diff --git a/sys/dev/ic/if_wi_hostap.c b/sys/dev/ic/if_wi_hostap.c
index e989e086aa8..1a568513920 100644
--- a/sys/dev/ic/if_wi_hostap.c
+++ b/sys/dev/ic/if_wi_hostap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wi_hostap.c,v 1.9 2002/04/07 23:23:49 millert Exp $ */
+/* $OpenBSD: if_wi_hostap.c,v 1.10 2002/04/08 18:31:27 mickey Exp $ */
/*
* Copyright (c) 2002
@@ -626,7 +626,8 @@ wihap_assoc_req(struct wi_softc *sc, struct wi_frame *rxfrm,
rates, sizeof(rates)))<0)
return;
- if ((rxfrm->wi_frame_ctl & WI_FCTL_STYPE) == WI_STYPE_MGMT_REASREQ) {
+ if ((rxfrm->wi_frame_ctl & htole16(WI_FCTL_STYPE)) ==
+ htole16(WI_STYPE_MGMT_REASREQ)) {
/* Reassociation Request-- * Current AP. (Ignore?) */
if (len < 6)
return;
@@ -702,7 +703,7 @@ fail:
/* Send response. */
resp_hdr = (struct wi_80211_hdr *) sc->wi_txbuf;
bzero(resp_hdr, sizeof(struct wi_80211_hdr));
- resp_hdr->frame_ctl = WI_FTYPE_MGMT | WI_STYPE_MGMT_ASRESP;
+ resp_hdr->frame_ctl = htole16(WI_FTYPE_MGMT | WI_STYPE_MGMT_ASRESP);
pkt = sc->wi_txbuf + sizeof(struct wi_80211_hdr);
bcopy(rxfrm->wi_addr2, resp_hdr->addr1, ETHER_ADDR_LEN);
@@ -712,10 +713,10 @@ fail:
put_hword(&pkt, capinfo);
put_hword(&pkt, status);
put_hword(&pkt, asid);
- rates_len=put_rates(&pkt, sc->wi_supprates);
+ rates_len = put_rates(&pkt, sc->wi_supprates);
wi_mgmt_xmit(sc, sc->wi_txbuf,
- 8 + rates_len+sizeof(struct wi_80211_hdr));
+ 8 + rates_len + sizeof(struct wi_80211_hdr));
}
/* wihap_deauth_req()
@@ -790,9 +791,10 @@ wihap_disassoc_req(struct wi_softc *sc, struct wi_frame *rxfrm,
static __inline void
wihap_debug_frame_type(struct wi_frame *rxfrm)
{
- printf("wihap_mgmt_input: len=%d ", rxfrm->wi_dat_len);
+ printf("wihap_mgmt_input: len=%d ", letoh16(rxfrm->wi_dat_len));
- if ((letoh16(rxfrm->wi_frame_ctl) & WI_FCTL_FTYPE) == WI_FTYPE_MGMT) {
+ if ((rxfrm->wi_frame_ctl & htole16(WI_FCTL_FTYPE)) ==
+ htole16(WI_FTYPE_MGMT)) {
printf("MGMT: ");
@@ -861,7 +863,8 @@ wihap_mgmt_input(struct wi_softc *sc, struct wi_frame *rxfrm, struct mbuf *m)
pkt = mtod(m, caddr_t) + WI_802_11_OFFSET_RAW;
len = m->m_len - WI_802_11_OFFSET_RAW;
- if ((rxfrm->wi_frame_ctl & WI_FCTL_FTYPE) == WI_FTYPE_MGMT) {
+ if ((rxfrm->wi_frame_ctl & htole16(WI_FCTL_FTYPE)) ==
+ htole16(WI_FTYPE_MGMT)) {
/* any of the following will mess w/ the station list */
s = splsoftclock();
@@ -970,7 +973,7 @@ wihap_data_input(struct wi_softc *sc, struct wi_frame *rxfrm, struct mbuf *m)
int mcast, s;
/* TODS flag must be set. */
- if (!(letoh16(rxfrm->wi_frame_ctl) & WI_FCTL_TODS)) {
+ if (!(rxfrm->wi_frame_ctl & htole16(WI_FCTL_TODS))) {
if (ifp->if_flags & IFF_DEBUG)
printf("wihap_data_input: no TODS src=%s\n",
ether_sprintf(rxfrm->wi_addr2));
@@ -1003,7 +1006,7 @@ wihap_data_input(struct wi_softc *sc, struct wi_frame *rxfrm, struct mbuf *m)
}
timeout_add(&sta->tmo, hz * whi->inactivity_time);
- sta->sig_info = rxfrm->wi_q_info;
+ sta->sig_info = letoh16(rxfrm->wi_q_info);
splx(s);