Save stack space by converting areq in sc->areq.

Reviewed by:	Brooks Davis <brooks@freebsd.org>
		Warner Losh <imp@freebsd.org>
Approved by:	Brooks Davis <brooks@freebsd.org>
		Warner Losh <imp@freebsd.org>
This commit is contained in:
Doug Ambrisko 2001-12-31 22:12:42 +00:00
parent 0d6fcb5c0e
commit 9598826172

View File

@ -1267,7 +1267,6 @@ an_ioctl(ifp, command, data)
int len; int len;
int i; int i;
struct an_softc *sc; struct an_softc *sc;
struct an_req areq;
struct ifreq *ifr; struct ifreq *ifr;
struct proc *p = curproc; struct proc *p = curproc;
struct ieee80211req *ireq; struct ieee80211req *ireq;
@ -1285,10 +1284,10 @@ an_ioctl(ifp, command, data)
ifr = (struct ifreq *)data; ifr = (struct ifreq *)data;
ireq = (struct ieee80211req *)data; ireq = (struct ieee80211req *)data;
config = (struct an_ltv_genconfig *)&areq; config = (struct an_ltv_genconfig *)&sc->areq;
key = (struct an_ltv_key *)&areq; key = (struct an_ltv_key *)&sc->areq;
status = (struct an_ltv_status *)&areq; status = (struct an_ltv_status *)&sc->areq;
ssids = (struct an_ltv_ssidlist *)&areq; ssids = (struct an_ltv_ssidlist *)&sc->areq;
if (sc->an_gone) { if (sc->an_gone) {
error = ENODEV; error = ENODEV;
@ -1330,38 +1329,38 @@ an_ioctl(ifp, command, data)
error = 0; error = 0;
break; break;
case SIOCGAIRONET: case SIOCGAIRONET:
error = copyin(ifr->ifr_data, &areq, sizeof(areq)); error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
if (error != 0) if (error != 0)
break; break;
#ifdef ANCACHE #ifdef ANCACHE
if (areq.an_type == AN_RID_ZERO_CACHE) { if (sc->areq.an_type == AN_RID_ZERO_CACHE) {
sc->an_sigitems = sc->an_nextitem = 0; sc->an_sigitems = sc->an_nextitem = 0;
break; break;
} else if (areq.an_type == AN_RID_READ_CACHE) { } else if (sc->areq.an_type == AN_RID_READ_CACHE) {
char *pt = (char *)&areq.an_val; char *pt = (char *)&sc->areq.an_val;
bcopy((char *)&sc->an_sigitems, (char *)pt, bcopy((char *)&sc->an_sigitems, (char *)pt,
sizeof(int)); sizeof(int));
pt += sizeof(int); pt += sizeof(int);
areq.an_len = sizeof(int) / 2; sc->areq.an_len = sizeof(int) / 2;
bcopy((char *)&sc->an_sigcache, (char *)pt, bcopy((char *)&sc->an_sigcache, (char *)pt,
sizeof(struct an_sigcache) * sc->an_sigitems); sizeof(struct an_sigcache) * sc->an_sigitems);
areq.an_len += ((sizeof(struct an_sigcache) * sc->areq.an_len += ((sizeof(struct an_sigcache) *
sc->an_sigitems) / 2) + 1; sc->an_sigitems) / 2) + 1;
} else } else
#endif #endif
if (an_read_record(sc, (struct an_ltv_gen *)&areq)) { if (an_read_record(sc, (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
error = copyout(&areq, ifr->ifr_data, sizeof(areq)); error = copyout(&sc->areq, ifr->ifr_data, sizeof(sc->areq));
break; break;
case SIOCSAIRONET: case SIOCSAIRONET:
if ((error = suser(p))) if ((error = suser(p)))
goto out; goto out;
error = copyin(ifr->ifr_data, &areq, sizeof(areq)); error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
if (error != 0) if (error != 0)
break; break;
an_setdef(sc, &areq); an_setdef(sc, &sc->areq);
break; break;
case SIOCGPRIVATE_0: /* used by Cisco client utility */ case SIOCGPRIVATE_0: /* used by Cisco client utility */
copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl)); copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
@ -1389,23 +1388,23 @@ an_ioctl(ifp, command, data)
error = 0; error = 0;
break; break;
case SIOCG80211: case SIOCG80211:
areq.an_len = sizeof(areq); sc->areq.an_len = sizeof(sc->areq);
/* was that a good idea DJA we are doing a short-cut */ /* was that a good idea DJA we are doing a short-cut */
switch (ireq->i_type) { switch (ireq->i_type) {
case IEEE80211_IOC_SSID: case IEEE80211_IOC_SSID:
if (ireq->i_val == -1) { if (ireq->i_val == -1) {
areq.an_type = AN_RID_STATUS; sc->areq.an_type = AN_RID_STATUS;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
len = status->an_ssidlen; len = status->an_ssidlen;
tmpptr = status->an_ssid; tmpptr = status->an_ssid;
} else if (ireq->i_val >= 0) { } else if (ireq->i_val >= 0) {
areq.an_type = AN_RID_SSIDLIST; sc->areq.an_type = AN_RID_SSIDLIST;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1440,9 +1439,9 @@ an_ioctl(ifp, command, data)
ireq->i_val = 3; ireq->i_val = 3;
break; break;
case IEEE80211_IOC_WEP: case IEEE80211_IOC_WEP:
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1469,10 +1468,10 @@ an_ioctl(ifp, command, data)
} }
len = 0; len = 0;
if (ireq->i_val < 5) { if (ireq->i_val < 5) {
areq.an_type = AN_RID_WEP_TEMP; sc->areq.an_type = AN_RID_WEP_TEMP;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1481,7 +1480,7 @@ an_ioctl(ifp, command, data)
if (key->kindex == ireq->i_val) if (key->kindex == ireq->i_val)
len = key->klen; len = key->klen;
/* Required to get next entry */ /* Required to get next entry */
areq.an_type = AN_RID_WEP_PERM; sc->areq.an_type = AN_RID_WEP_PERM;
} }
if (error != 0) if (error != 0)
break; break;
@ -1503,25 +1502,25 @@ an_ioctl(ifp, command, data)
* For some strange reason, you have to read all * For some strange reason, you have to read all
* keys before you can read the txkey. * keys before you can read the txkey.
*/ */
areq.an_type = AN_RID_WEP_TEMP; sc->areq.an_type = AN_RID_WEP_TEMP;
for (i = 0; i < 5; i++) { for (i = 0; i < 5; i++) {
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *) &areq)) { (struct an_ltv_gen *) &sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
if (key->kindex == 0xffff) if (key->kindex == 0xffff)
break; break;
/* Required to get next entry */ /* Required to get next entry */
areq.an_type = AN_RID_WEP_PERM; sc->areq.an_type = AN_RID_WEP_PERM;
} }
if (error != 0) if (error != 0)
break; break;
areq.an_type = AN_RID_WEP_PERM; sc->areq.an_type = AN_RID_WEP_PERM;
key->kindex = 0xffff; key->kindex = 0xffff;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1531,10 +1530,10 @@ an_ioctl(ifp, command, data)
* 5th key since that is how it is stored on * 5th key since that is how it is stored on
* the card * the card
*/ */
areq.an_len = sizeof(struct an_ltv_genconfig); sc->areq.an_len = sizeof(struct an_ltv_genconfig);
areq.an_type = AN_RID_GENCONFIG; sc->areq.an_type = AN_RID_GENCONFIG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1542,9 +1541,9 @@ an_ioctl(ifp, command, data)
ireq->i_val = 4; ireq->i_val = 4;
break; break;
case IEEE80211_IOC_AUTHMODE: case IEEE80211_IOC_AUTHMODE:
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1561,9 +1560,9 @@ an_ioctl(ifp, command, data)
error = EINVAL; error = EINVAL;
break; break;
case IEEE80211_IOC_STATIONNAME: case IEEE80211_IOC_STATIONNAME:
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1575,18 +1574,18 @@ an_ioctl(ifp, command, data)
IEEE80211_NWID_LEN); IEEE80211_NWID_LEN);
break; break;
case IEEE80211_IOC_CHANNEL: case IEEE80211_IOC_CHANNEL:
areq.an_type = AN_RID_STATUS; sc->areq.an_type = AN_RID_STATUS;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
ireq->i_val = status->an_cur_channel; ireq->i_val = status->an_cur_channel;
break; break;
case IEEE80211_IOC_POWERSAVE: case IEEE80211_IOC_POWERSAVE:
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1602,9 +1601,9 @@ an_ioctl(ifp, command, data)
error = EINVAL; error = EINVAL;
break; break;
case IEEE80211_IOC_POWERSAVESLEEP: case IEEE80211_IOC_POWERSAVESLEEP:
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1615,7 +1614,7 @@ an_ioctl(ifp, command, data)
case SIOCS80211: case SIOCS80211:
if ((error = suser(p))) if ((error = suser(p)))
goto out; goto out;
areq.an_len = sizeof(areq); sc->areq.an_len = sizeof(sc->areq);
/* /*
* We need a config structure for everything but the WEP * We need a config structure for everything but the WEP
* key management and SSIDs so we get it now so avoid * key management and SSIDs so we get it now so avoid
@ -1624,18 +1623,18 @@ an_ioctl(ifp, command, data)
if (ireq->i_type != IEEE80211_IOC_SSID && if (ireq->i_type != IEEE80211_IOC_SSID &&
ireq->i_type != IEEE80211_IOC_WEPKEY && ireq->i_type != IEEE80211_IOC_WEPKEY &&
ireq->i_type != IEEE80211_IOC_WEPTXKEY) { ireq->i_type != IEEE80211_IOC_WEPTXKEY) {
areq.an_type = AN_RID_GENCONFIG; sc->areq.an_type = AN_RID_GENCONFIG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
} }
switch (ireq->i_type) { switch (ireq->i_type) {
case IEEE80211_IOC_SSID: case IEEE80211_IOC_SSID:
areq.an_type = AN_RID_SSIDLIST; sc->areq.an_type = AN_RID_SSIDLIST;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1696,14 +1695,14 @@ an_ioctl(ifp, command, data)
error = copyin(ireq->i_data, tmpstr, 13); error = copyin(ireq->i_data, tmpstr, 13);
if (error != 0) if (error != 0)
break; break;
bzero(&areq, sizeof(struct an_ltv_key)); bzero(&sc->areq, sizeof(struct an_ltv_key));
areq.an_len = sizeof(struct an_ltv_key); sc->areq.an_len = sizeof(struct an_ltv_key);
key->mac[0] = 1; /* The others are 0. */ key->mac[0] = 1; /* The others are 0. */
key->kindex = ireq->i_val % 4; key->kindex = ireq->i_val % 4;
if (ireq->i_val < 4) if (ireq->i_val < 4)
areq.an_type = AN_RID_WEP_TEMP; sc->areq.an_type = AN_RID_WEP_TEMP;
else else
areq.an_type = AN_RID_WEP_PERM; sc->areq.an_type = AN_RID_WEP_PERM;
key->klen = ireq->i_len; key->klen = ireq->i_len;
bcopy(tmpstr, key->key, key->klen); bcopy(tmpstr, key->key, key->klen);
break; break;
@ -1717,10 +1716,10 @@ an_ioctl(ifp, command, data)
error = EINVAL; error = EINVAL;
break; break;
} }
areq.an_len = sizeof(struct an_ltv_genconfig); sc->areq.an_len = sizeof(struct an_ltv_genconfig);
areq.an_type = AN_RID_ACTUALCFG; sc->areq.an_type = AN_RID_ACTUALCFG;
if (an_read_record(sc, if (an_read_record(sc,
(struct an_ltv_gen *)&areq)) { (struct an_ltv_gen *)&sc->areq)) {
error = EINVAL; error = EINVAL;
break; break;
} }
@ -1733,11 +1732,11 @@ an_ioctl(ifp, command, data)
sc->an_config.an_home_product sc->an_config.an_home_product
= config->an_home_product; = config->an_home_product;
an_write_record(sc, (struct an_ltv_gen *)&areq); an_write_record(sc, (struct an_ltv_gen *)&sc->areq);
bzero(&areq, sizeof(struct an_ltv_key)); bzero(&sc->areq, sizeof(struct an_ltv_key));
areq.an_len = sizeof(struct an_ltv_key); sc->areq.an_len = sizeof(struct an_ltv_key);
areq.an_type = AN_RID_WEP_PERM; sc->areq.an_type = AN_RID_WEP_PERM;
key->kindex = 0xffff; key->kindex = 0xffff;
key->mac[0] = ireq->i_val; key->mac[0] = ireq->i_val;
break; break;
@ -1805,7 +1804,7 @@ an_ioctl(ifp, command, data)
} }
if (!error) if (!error)
an_setdef(sc, &areq); an_setdef(sc, &sc->areq);
break; break;
default: default:
error = EINVAL; error = EINVAL;
@ -2388,9 +2387,8 @@ readrids(ifp, l_ioctl)
struct ifnet *ifp; struct ifnet *ifp;
struct aironet_ioctl *l_ioctl; struct aironet_ioctl *l_ioctl;
{ {
unsigned short rid; unsigned short rid;
struct an_softc *sc; struct an_softc *sc;
struct an_req areq;
switch (l_ioctl->command) { switch (l_ioctl->command) {
case AIROGCAP: case AIROGCAP:
@ -2435,20 +2433,20 @@ readrids(ifp, l_ioctl)
return -EINVAL; return -EINVAL;
sc = ifp->if_softc; sc = ifp->if_softc;
areq.an_len = AN_MAX_DATALEN; sc->areq.an_len = AN_MAX_DATALEN;
areq.an_type = rid; sc->areq.an_type = rid;
an_read_record(sc, (struct an_ltv_gen *)&areq); an_read_record(sc, (struct an_ltv_gen *)&sc->areq);
l_ioctl->len = areq.an_len - 4; /* just data */ l_ioctl->len = sc->areq.an_len - 4; /* just data */
/* the data contains the length at first */ /* the data contains the length at first */
if (copyout(&(areq.an_len), l_ioctl->data, if (copyout(&(sc->areq.an_len), l_ioctl->data,
sizeof(areq.an_len))) { sizeof(sc->areq.an_len))) {
return -EFAULT; return -EFAULT;
} }
/* Just copy the data back */ /* Just copy the data back */
if (copyout(&(areq.an_val), l_ioctl->data + 2, if (copyout(&(sc->areq.an_val), l_ioctl->data + 2,
l_ioctl->len)) { l_ioctl->len)) {
return -EFAULT; return -EFAULT;
} }
@ -2461,7 +2459,6 @@ writerids(ifp, l_ioctl)
struct aironet_ioctl *l_ioctl; struct aironet_ioctl *l_ioctl;
{ {
struct an_softc *sc; struct an_softc *sc;
struct an_req areq;
int rid, command; int rid, command;
sc = ifp->if_softc; sc = ifp->if_softc;
@ -2498,19 +2495,19 @@ writerids(ifp, l_ioctl)
rid = AN_RID_32BITS_DELTACLR; rid = AN_RID_32BITS_DELTACLR;
sc = ifp->if_softc; sc = ifp->if_softc;
areq.an_len = AN_MAX_DATALEN; sc->areq.an_len = AN_MAX_DATALEN;
areq.an_type = rid; sc->areq.an_type = rid;
an_read_record(sc, (struct an_ltv_gen *)&areq); an_read_record(sc, (struct an_ltv_gen *)&sc->areq);
l_ioctl->len = areq.an_len - 4; /* just data */ l_ioctl->len = sc->areq.an_len - 4; /* just data */
/* the data contains the length at first */ /* the data contains the length at first */
if (copyout(&(areq.an_len), l_ioctl->data, if (copyout(&(sc->areq.an_len), l_ioctl->data,
sizeof(areq.an_len))) { sizeof(sc->areq.an_len))) {
return -EFAULT; return -EFAULT;
} }
/* Just copy the data */ /* Just copy the data */
if (copyout(&(areq.an_val), l_ioctl->data + 2, if (copyout(&(sc->areq.an_val), l_ioctl->data + 2,
l_ioctl->len)) { l_ioctl->len)) {
return -EFAULT; return -EFAULT;
} }
@ -2533,17 +2530,17 @@ writerids(ifp, l_ioctl)
} }
if (rid) { if (rid) {
if (l_ioctl->len > sizeof(areq.an_val) + 4) if (l_ioctl->len > sizeof(sc->areq.an_val) + 4)
return -EINVAL; return -EINVAL;
areq.an_len = l_ioctl->len + 4; /* add type & length */ sc->areq.an_len = l_ioctl->len + 4; /* add type & length */
areq.an_type = rid; sc->areq.an_type = rid;
/* Just copy the data back */ /* Just copy the data back */
copyin((l_ioctl->data) + 2, &areq.an_val, copyin((l_ioctl->data) + 2, &sc->areq.an_val,
l_ioctl->len); l_ioctl->len);
an_cmd(sc, AN_CMD_DISABLE, 0); an_cmd(sc, AN_CMD_DISABLE, 0);
an_write_record(sc, (struct an_ltv_gen *)&areq); an_write_record(sc, (struct an_ltv_gen *)&sc->areq);
an_cmd(sc, AN_CMD_ENABLE, 0); an_cmd(sc, AN_CMD_ENABLE, 0);
return 0; return 0;
} }
@ -2818,9 +2815,8 @@ flashcard(ifp, l_ioctl)
struct ifnet *ifp; struct ifnet *ifp;
struct aironet_ioctl *l_ioctl; struct aironet_ioctl *l_ioctl;
{ {
struct an_softc *sc;
struct an_req areq;
int z = 0, status; int z = 0, status;
struct an_softc *sc;
sc = ifp->if_softc; sc = ifp->if_softc;
status = l_ioctl->command; status = l_ioctl->command;
@ -2833,16 +2829,16 @@ flashcard(ifp, l_ioctl)
return setflashmode(ifp); return setflashmode(ifp);
break; break;
case AIROFLSHGCHR: /* Get char from aux */ case AIROFLSHGCHR: /* Get char from aux */
copyin(l_ioctl->data, &areq, l_ioctl->len); copyin(l_ioctl->data, &sc->areq, l_ioctl->len);
z = *(int *)&areq; z = *(int *)&sc->areq;
if ((status = flashgchar(ifp, z, 8000)) == 1) if ((status = flashgchar(ifp, z, 8000)) == 1)
return 0; return 0;
else else
return -1; return -1;
break; break;
case AIROFLSHPCHR: /* Send char to card. */ case AIROFLSHPCHR: /* Send char to card. */
copyin(l_ioctl->data, &areq, l_ioctl->len); copyin(l_ioctl->data, &sc->areq, l_ioctl->len);
z = *(int *)&areq; z = *(int *)&sc->areq;
if ((status = flashpchar(ifp, z, 8000)) == -1) if ((status = flashpchar(ifp, z, 8000)) == -1)
return -EIO; return -EIO;
else else