Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src From Steve Woodford (scw@): fix wi(4) and wiconfig(8) on big...



details:   https://anonhg.NetBSD.org/src/rev/28e5e4a4f76e
branches:  trunk
changeset: 555383:28e5e4a4f76e
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Sun Nov 16 09:41:01 2003 +0000

description:
>From Steve Woodford (scw@): fix wi(4) and wiconfig(8) on big-endian
machines.

diffstat:

 sys/dev/ic/wi.c              |  21 +++++++++++++--------
 usr.sbin/wiconfig/wiconfig.c |  14 +++++++-------
 2 files changed, 20 insertions(+), 15 deletions(-)

diffs (122 lines):

diff -r 83bc3bc75139 -r 28e5e4a4f76e sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c   Sun Nov 16 09:32:01 2003 +0000
+++ b/sys/dev/ic/wi.c   Sun Nov 16 09:41:01 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wi.c,v 1.145 2003/11/16 09:05:53 dyoung Exp $  */
+/*     $NetBSD: wi.c,v 1.146 2003/11/16 09:41:01 dyoung Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.145 2003/11/16 09:05:53 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.146 2003/11/16 09:41:01 dyoung Exp $");
 
 #define WI_HERMES_AUTOINC_WAR  /* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR    /* Work around stats counter bug. */
@@ -214,7 +214,10 @@
        struct ifnet *ifp = &ic->ic_if;
        int chan, nrate, buflen;
        u_int16_t val, chanavail;
-       u_int8_t ratebuf[2 + IEEE80211_RATE_SIZE];
+       struct {
+               u_int16_t nrates;
+               char rates[IEEE80211_RATE_SIZE];
+       } ratebuf;
        static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        };
@@ -353,12 +356,12 @@
 
        /* Find supported rates. */
        buflen = sizeof(ratebuf);
-       if (wi_read_rid(sc, WI_RID_DATA_RATES, ratebuf, &buflen) == 0) {
-               nrate = le16toh(*(u_int16_t *)ratebuf);
+       if (wi_read_rid(sc, WI_RID_DATA_RATES, &ratebuf, &buflen) == 0) {
+               nrate = le16toh(ratebuf.nrates);
                if (nrate > IEEE80211_RATE_SIZE)
                        nrate = IEEE80211_RATE_SIZE;
                memcpy(ic->ic_sup_rates[IEEE80211_MODE_11B].rs_rates,
-                   ratebuf + 2, nrate);
+                   &ratebuf.rates[0], nrate);
                ic->ic_sup_rates[IEEE80211_MODE_11B].rs_nrates = nrate;
        }
        buflen = sizeof(val);
@@ -1162,6 +1165,7 @@
                rate = 0;
        else {
                /* convert to 802.11 rate */
+               val = le16toh(val);
                rate = val * 2;
                if (sc->sc_firmware_type == WI_LUCENT) {
                        if (rate == 10)
@@ -1487,6 +1491,7 @@
                off = sizeof(ltbuf);
                for (i = 0; i < len; i++, off += 2, ptr++) {
                        wi_read_bap(sc, fid, off, &stat, sizeof(stat));
+                       stat = le16toh(stat);
 #ifdef WI_HERMES_STATS_WAR
                        if (stat & 0xf000)
                                stat = ~stat;
@@ -2446,8 +2451,8 @@
                (void)wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_SCAN_RESULTS, 0, 0);
                break;
        case WI_INTERSIL:
-               val[0] = chanmask;      /* channel */
-               val[1] = txrate;        /* tx rate */
+               val[0] = htole16(chanmask);     /* channel */
+               val[1] = htole16(txrate);       /* tx rate */
                error = wi_write_rid(sc, WI_RID_SCAN_REQ, val, sizeof(val));
                break;
        case WI_SYMBOL:
diff -r 83bc3bc75139 -r 28e5e4a4f76e usr.sbin/wiconfig/wiconfig.c
--- a/usr.sbin/wiconfig/wiconfig.c      Sun Nov 16 09:32:01 2003 +0000
+++ b/usr.sbin/wiconfig/wiconfig.c      Sun Nov 16 09:41:01 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wiconfig.c,v 1.31 2003/10/13 08:02:02 dyoung Exp $     */
+/*     $NetBSD: wiconfig.c,v 1.32 2003/11/16 09:41:01 dyoung Exp $     */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -70,7 +70,7 @@
 __COPYRIGHT(
 "@(#) Copyright (c) 1997, 1998, 1999\
        Bill Paul. All rights reserved.");
-__RCSID("$NetBSD: wiconfig.c,v 1.31 2003/10/13 08:02:02 dyoung Exp $");
+__RCSID("$NetBSD: wiconfig.c,v 1.32 2003/11/16 09:41:01 dyoung Exp $");
 #endif
 
 struct wi_table {
@@ -180,8 +180,8 @@
        wreq.wi_type = WI_RID_SCAN_APS;
        wreq.wi_len = 4;
        /* note chan. 1 is the least significant bit */
-       wreq.wi_val[0] = 0x3fff;        /* 1 bit per channel, 1-14 */
-       wreq.wi_val[1] = 0xf;           /* tx rate */
+       wreq.wi_val[0] = htole16(0x3fff);       /* 1 bit per channel, 1-14 */
+       wreq.wi_val[1] = htole16(0xf);          /* tx rate */
 
        /* write the request */
        wi_setval(iface, &wreq);
@@ -490,7 +490,7 @@
        if (wreq->wi_len < 4)
                return;
 
-       switch (wreq->wi_val[1]) {
+       switch (le16toh(wreq->wi_val[1])) {
        case WI_RID_STA_IDENTITY_LUCENT:
                vendor = "Lucent";
                break;
@@ -504,8 +504,8 @@
                vendor = "D-Link";
                break;
        }
-       printf("[ %s ID: %d version: %d.%d ]", vendor,
-              wreq->wi_val[0], wreq->wi_val[2], wreq->wi_val[3]);
+       printf("[ %s ID: %d version: %d.%d ]", vendor, le16toh(wreq->wi_val[0]),
+           le16toh(wreq->wi_val[2]), le16toh(wreq->wi_val[3]));
        return;
 }      
 



Home | Main Index | Thread Index | Old Index