- Add support for Cisco latest firmware RID sizes that supports 25 SSIDs!

- Fix up TX speed changes.
- Make mpi-350 cards sort-of work with new firmware.  It RXs okay but TXs
  only work for about 14 packets then fails to get an interrupt.  The
  TX watchdog fires.  It has been reported that my hack for now doesn't
  break cards with the older firmware.  It appears my card has lost
  the ability to RX or TX at all but other peoples cards work.  I assume
  it got damaged in tansport.

MFC:	1 week.
This commit is contained in:
Doug Ambrisko 2003-08-20 03:46:05 +00:00
parent a1c9e73ab8
commit e8ef0c2923
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119156
5 changed files with 215 additions and 138 deletions

View File

@ -63,7 +63,7 @@
* data, which is 240 words long, so 256 should be a safe
* value.
*/
#define AN_MAX_DATALEN 512
#define AN_MAX_DATALEN 4096
struct an_req {
u_int16_t an_len;
@ -261,7 +261,7 @@ struct an_ltv_stats {
u_int32_t an_uptime_usecs; /* 0x178 */
u_int32_t an_uptime_secs; /* 0x17C */
u_int32_t an_lostsync_better_ap; /* 0x180 */
u_int32_t an_rsvd[10];
u_int32_t an_rsvd[15];
};
/*
@ -337,6 +337,7 @@ struct an_ltv_genconfig {
u_int8_t an_magic_packet_action; /* 0x98 */
u_int8_t an_magic_packet_ctl; /* 0x99 */
u_int16_t an_rsvd9;
u_int16_t an_spare[13];
};
#define AN_OPMODE_IBSS_ADHOC 0x0000
@ -417,6 +418,18 @@ struct an_ltv_ssidlist {
char an_ssid3[32];
};
struct an_ltv_ssid_entry{
u_int16_t an_len;
char an_ssid[32];
};
#define MAX_SSIDS 25
struct an_ltv_ssidlist_new {
u_int16_t an_len;
u_int16_t an_type;
struct an_ltv_ssid_entry an_entry[MAX_SSIDS];
};
/*
* Valid AP list.
*/
@ -501,7 +514,7 @@ struct an_ltv_caps {
u_int16_t an_softcaps; /* 0x7C */
u_int16_t an_bootblockrev; /* 0x7E */
u_int16_t an_req_hw_support; /* 0x80 */
u_int16_t an_unknown; /* 0x82 */
u_int16_t an_unknown[31]; /* 0x82 */
};
/*
@ -580,7 +593,7 @@ struct an_ltv_status {
u_int8_t an_avg_noise_prev_min_db; /* 0x7D */
u_int8_t an_max_noise_prev_min_pc; /* 0x7E */
u_int8_t an_max_noise_prev_min_db; /* 0x7F */
u_int16_t an_spare[5];
u_int16_t an_spare[8];
};
#define AN_STATUS_OPMODE_CONFIGURED 0x0001

View File

@ -313,7 +313,7 @@ an_probe(dev)
device_t dev;
{
struct an_softc *sc = device_get_softc(dev);
struct an_ltv_ssidlist ssid;
struct an_ltv_ssidlist_new ssid;
int error;
bzero((char *)&ssid, sizeof(ssid));
@ -339,11 +339,11 @@ an_probe(dev)
ssid.an_type = AN_RID_SSIDLIST;
/* Make sure interrupts are disabled. */
sc->mpi350 = 0;
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), 0xFFFF);
an_reset(sc);
/* No need for an_init_mpi350_desc since it will be done in attach */
if (an_cmd(sc, AN_CMD_READCFG, 0))
return(0);
@ -352,7 +352,7 @@ an_probe(dev)
return(0);
/* See if the ssid matches what we expect ... but doesn't have to */
if (strcmp(ssid.an_ssid1, AN_DEF_SSID))
if (strcmp(ssid.an_entry[0].an_ssid, AN_DEF_SSID))
return(0);
return(AN_IOSIZ);
@ -715,7 +715,7 @@ an_attach(sc, unit, flags)
/* Read ssid list */
sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist);
sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
printf("an%d: read record failed\n", sc->an_unit);
goto fail;
@ -769,10 +769,11 @@ an_attach(sc, unit, flags)
bcopy(AN_DEFAULT_NODENAME, sc->an_config.an_nodename,
sizeof(AN_DEFAULT_NODENAME) - 1);
bzero(sc->an_ssidlist.an_ssid1, sizeof(sc->an_ssidlist.an_ssid1));
bcopy(AN_DEFAULT_NETNAME, sc->an_ssidlist.an_ssid1,
bzero(sc->an_ssidlist.an_entry[0].an_ssid,
sizeof(sc->an_ssidlist.an_entry[0].an_ssid));
bcopy(AN_DEFAULT_NETNAME, sc->an_ssidlist.an_entry[0].an_ssid,
sizeof(AN_DEFAULT_NETNAME) - 1);
sc->an_ssidlist.an_ssid1_len = strlen(AN_DEFAULT_NETNAME);
sc->an_ssidlist.an_entry[0].an_len = strlen(AN_DEFAULT_NETNAME);
sc->an_config.an_opmode =
AN_OPMODE_INFRASTRUCTURE_STATION;
@ -1088,7 +1089,7 @@ an_txeof(sc, status)
ifp->if_flags &= ~IFF_OACTIVE;
if (!sc->mpi350) {
id = CSR_READ_2(sc, AN_TX_CMP_FID);
id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
if (status & AN_EV_TX_EXC) {
ifp->if_oerrors++;
@ -1104,10 +1105,17 @@ an_txeof(sc, status)
AN_INC(sc->an_rdata.an_tx_cons, AN_TX_RING_CNT);
} else { /* MPI 350 */
AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC);
if (sc->an_rdata.an_tx_prod ==
sc->an_rdata.an_tx_cons)
sc->an_rdata.an_tx_empty = 1;
id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
if (!sc->an_rdata.an_tx_empty){
if (status & AN_EV_TX_EXC) {
ifp->if_oerrors++;
} else
ifp->if_opackets++;
AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC);
if (sc->an_rdata.an_tx_prod ==
sc->an_rdata.an_tx_cons)
sc->an_rdata.an_tx_empty = 1;
}
}
return;
@ -1179,10 +1187,10 @@ an_intr(xsc)
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
status = CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350));
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), ~AN_INTRS);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), ~AN_INTRS(sc->mpi350));
if (status & AN_EV_AWAKE) {
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_AWAKE);
if (status & AN_EV_MIC) {
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_MIC);
}
if (status & AN_EV_LINKSTAT) {
@ -1199,9 +1207,16 @@ an_intr(xsc)
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_RX);
}
if (sc->mpi350 && status & AN_EV_TX_CPY) {
an_txeof(sc, status);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
AN_EV_TX_CPY);
}
if (status & AN_EV_TX) {
an_txeof(sc, status);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_TX);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
AN_EV_TX);
}
if (status & AN_EV_TX_EXC) {
@ -1213,7 +1228,7 @@ an_intr(xsc)
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_ALLOC);
/* Re-enable interrupts. */
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS);
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
if ((ifp->if_flags & IFF_UP) && (ifp->if_snd.ifq_head != NULL))
an_start(ifp);
@ -1238,6 +1253,7 @@ an_cmd_struct(sc, cmd, reply)
} else
break;
}
if( i == AN_TIMEOUT) {
printf("BUSY\n");
return(ETIMEDOUT);
@ -1260,7 +1276,8 @@ an_cmd_struct(sc, cmd, reply)
reply->an_status = CSR_READ_2(sc, AN_STATUS(sc->mpi350));
if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY)
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_CLR_STUCK_BUSY);
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
AN_EV_CLR_STUCK_BUSY);
/* Ack the command */
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_CMD);
@ -1728,7 +1745,7 @@ an_setdef(sc, areq)
struct ifaddr *ifa;
struct ifnet *ifp;
struct an_ltv_genconfig *cfg;
struct an_ltv_ssidlist *ssid;
struct an_ltv_ssidlist_new *ssid;
struct an_ltv_aplist *ap;
struct an_ltv_gen *sp;
@ -1748,9 +1765,9 @@ an_setdef(sc, areq)
sizeof(struct an_ltv_genconfig));
break;
case AN_RID_SSIDLIST:
ssid = (struct an_ltv_ssidlist *)areq;
ssid = (struct an_ltv_ssidlist_new *)areq;
bcopy((char *)ssid, (char *)&sc->an_ssidlist,
sizeof(struct an_ltv_ssidlist));
sizeof(struct an_ltv_ssidlist_new));
break;
case AN_RID_APLIST:
ap = (struct an_ltv_aplist *)areq;
@ -1783,6 +1800,8 @@ an_setdef(sc, areq)
case AN_RID_WEP_PERM:
case AN_RID_LEAPUSERNAME:
case AN_RID_LEAPPASSWORD:
an_init(sc);
/* Disable the MAC. */
an_cmd(sc, AN_CMD_DISABLE, 0);
@ -1859,7 +1878,7 @@ an_ioctl(ifp, command, data)
{
int error = 0;
int len;
int i;
int i, max;
struct an_softc *sc;
struct ifreq *ifr;
struct thread *td = curthread;
@ -1869,7 +1888,7 @@ an_ioctl(ifp, command, data)
struct an_ltv_genconfig *config;
struct an_ltv_key *key;
struct an_ltv_status *status;
struct an_ltv_ssidlist *ssids;
struct an_ltv_ssidlist_new *ssids;
int mode;
struct aironet_ioctl l_ioctl;
@ -1881,7 +1900,7 @@ an_ioctl(ifp, command, data)
config = (struct an_ltv_genconfig *)&sc->areq;
key = (struct an_ltv_key *)&sc->areq;
status = (struct an_ltv_status *)&sc->areq;
ssids = (struct an_ltv_ssidlist *)&sc->areq;
ssids = (struct an_ltv_ssidlist_new *)&sc->areq;
if (sc->an_gone) {
error = ENODEV;
@ -2004,18 +2023,20 @@ an_ioctl(ifp, command, data)
error = EINVAL;
break;
}
if (ireq->i_val == 0) {
len = ssids->an_ssid1_len;
tmpptr = ssids->an_ssid1;
} else if (ireq->i_val == 1) {
len = ssids->an_ssid2_len;
tmpptr = ssids->an_ssid2;
} else if (ireq->i_val == 2) {
len = ssids->an_ssid3_len;
tmpptr = ssids->an_ssid3;
} else {
max = (sc->areq.an_len - 4)
/ sizeof(struct an_ltv_ssid_entry);
if ( max > MAX_SSIDS ) {
printf("To many SSIDs only using "
"%d of %d\n",
MAX_SSIDS, max);
max = MAX_SSIDS;
}
if (ireq->i_val > max) {
error = EINVAL;
break;
} else {
len = ssids->an_entry[ireq->i_val].an_len;
tmpptr = ssids->an_entry[ireq->i_val].an_ssid;
}
} else {
error = EINVAL;
@ -2032,7 +2053,22 @@ an_ioctl(ifp, command, data)
IEEE80211_NWID_LEN);
break;
case IEEE80211_IOC_NUMSSIDS:
ireq->i_val = 3;
sc->areq.an_len = sizeof(sc->areq);
sc->areq.an_type = AN_RID_SSIDLIST;
if (an_read_record(sc,
(struct an_ltv_gen *)&sc->areq)) {
error = EINVAL;
break;
}
max = (sc->areq.an_len - 4)
/ sizeof(struct an_ltv_ssid_entry);
if ( max > MAX_SSIDS ) {
printf("To many SSIDs only using "
"%d of %d\n",
MAX_SSIDS, max);
max = MAX_SSIDS;
}
ireq->i_val = max;
break;
case IEEE80211_IOC_WEP:
sc->areq.an_type = AN_RID_ACTUALCFG;
@ -2228,6 +2264,7 @@ an_ioctl(ifp, command, data)
}
switch (ireq->i_type) {
case IEEE80211_IOC_SSID:
sc->areq.an_len = sizeof(sc->areq);
sc->areq.an_type = AN_RID_SSIDLIST;
if (an_read_record(sc,
(struct an_ltv_gen *)&sc->areq)) {
@ -2238,25 +2275,24 @@ an_ioctl(ifp, command, data)
error = EINVAL;
break;
}
switch (ireq->i_val) {
case 0:
error = copyin(ireq->i_data,
ssids->an_ssid1, ireq->i_len);
ssids->an_ssid1_len = ireq->i_len;
break;
case 1:
error = copyin(ireq->i_data,
ssids->an_ssid2, ireq->i_len);
ssids->an_ssid2_len = ireq->i_len;
break;
case 2:
error = copyin(ireq->i_data,
ssids->an_ssid3, ireq->i_len);
ssids->an_ssid3_len = ireq->i_len;
break;
default:
max = (sc->areq.an_len - 4)
/ sizeof(struct an_ltv_ssid_entry);
if ( max > MAX_SSIDS ) {
printf("To many SSIDs only using "
"%d of %d\n",
MAX_SSIDS, max);
max = MAX_SSIDS;
}
if (ireq->i_val > max) {
error = EINVAL;
break;
} else {
error = copyin(ireq->i_data,
ssids->an_entry[ireq->i_val].an_ssid,
ireq->i_len);
ssids->an_entry[ireq->i_val].an_len
= ireq->i_len;
break;
}
break;
case IEEE80211_IOC_WEP:
@ -2512,7 +2548,7 @@ an_init(xsc)
/* Set the ssid list */
sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist);
sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
printf("an%d: failed to set ssid list\n", sc->an_unit);
AN_UNLOCK(sc);
@ -2548,7 +2584,7 @@ an_init(xsc)
an_cmd(sc, AN_CMD_SET_MODE, 0xffff);
/* enable interrupts */
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS);
CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
ifp->if_flags |= IFF_RUNNING;
ifp->if_flags &= ~IFF_OACTIVE;
@ -2570,7 +2606,6 @@ an_start(ifp)
int id, idx, i;
unsigned char txcontrol;
struct an_card_tx_desc an_tx_desc;
u_int8_t *ptr;
u_int8_t *buf;
sc = ifp->if_softc;
@ -2650,8 +2685,34 @@ an_start(ifp)
printf("an%d: xmit failed\n", sc->an_unit);
AN_INC(idx, AN_TX_RING_CNT);
/*
* Set a timeout in case the chip goes out to lunch.
*/
ifp->if_timer = 5;
}
} else { /* MPI-350 */
/* HACK */
{
struct an_command cmd_struct;
struct an_reply reply;
/*
* Allocate TX descriptor
*/
bzero(&reply,sizeof(reply));
cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
cmd_struct.an_parm0 = AN_DESCRIPTOR_TX;
cmd_struct.an_parm1 = AN_TX_DESC_OFFSET;
cmd_struct.an_parm2 = AN_MAX_TX_DESC;
if (an_cmd_struct(sc, &cmd_struct, &reply)) {
printf("an%d: failed to allocate TX "
"descriptor\n",
sc->an_unit);
return;
}
}
/* HACK */
while (sc->an_rdata.an_tx_empty ||
idx != sc->an_rdata.an_tx_cons) {
IF_DEQUEUE(&ifp->if_snd, m0);
@ -2697,12 +2758,15 @@ an_start(ifp)
an_tx_desc.an_eoc = 1;
an_tx_desc.an_valid = 1;
an_tx_desc.an_len = 0x44 +
tx_frame_802_3.an_tx_802_3_payload_len;
an_tx_desc.an_phys = sc->an_tx_buffer[idx].an_dma_paddr;
ptr = (u_int8_t*)&an_tx_desc;
for (i = 0; i < sizeof(an_tx_desc); i++) {
CSR_MEM_AUX_WRITE_1(sc, AN_TX_DESC_OFFSET + i,
ptr[i]);
tx_frame_802_3.an_tx_802_3_payload_len;
an_tx_desc.an_phys
= sc->an_tx_buffer[idx].an_dma_paddr;
for (i = 0; i < sizeof(an_tx_desc) / 4 ; i++) {
CSR_MEM_AUX_WRITE_4(sc, AN_TX_DESC_OFFSET
/* zero for now */
+ (0 * sizeof(an_tx_desc))
+ (i * 4),
((u_int32_t*)&an_tx_desc)[i]);
}
/*
@ -2713,11 +2777,14 @@ an_start(ifp)
m_freem(m0);
m0 = NULL;
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_ALLOC);
AN_INC(idx, AN_MAX_TX_DESC);
sc->an_rdata.an_tx_empty = 0;
CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_ALLOC);
/*
* Set a timeout in case the chip goes out to lunch.
*/
ifp->if_timer = 5;
}
}
@ -2726,11 +2793,6 @@ an_start(ifp)
sc->an_rdata.an_tx_prod = idx;
/*
* Set a timeout in case the chip goes out to lunch.
*/
ifp->if_timer = 5;
return;
}
@ -3069,13 +3131,10 @@ an_media_change(ifp)
int otype = sc->an_config.an_opmode;
int orate = sc->an_tx_rate;
if ((sc->an_ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
sc->an_config.an_opmode = AN_OPMODE_IBSS_ADHOC;
else
sc->an_config.an_opmode = AN_OPMODE_INFRASTRUCTURE_STATION;
sc->an_tx_rate = ieee80211_media2rate(
IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media));
if (sc->an_tx_rate < 0)
sc->an_tx_rate = 0;
if (orate != sc->an_tx_rate) {
/* Read the current configuration */
@ -3093,6 +3152,11 @@ an_media_change(ifp)
sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
}
if ((sc->an_ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
sc->an_config.an_opmode &= ~AN_OPMODE_INFRASTRUCTURE_STATION;
else
sc->an_config.an_opmode |= AN_OPMODE_INFRASTRUCTURE_STATION;
if (otype != sc->an_config.an_opmode ||
orate != sc->an_tx_rate)
an_init(sc);

View File

@ -198,7 +198,7 @@ an_attach_pci(dev)
/* Allocate aux. memory */
sc->mem_aux_rid = PCIR_MAPS + 8;
error = an_alloc_aux_memory(dev, sc->mem_aux_rid,
AN_AUXMEMSIZE);
AN_AUX_MEM_SIZE);
if (error) {
printf("an%d: couldn't map aux memory\n", unit);
goto fail;

View File

@ -95,7 +95,7 @@
/*
* Size of aux. memory space ... probably not needed DJA
*/
#define AN_AUXMEMSIZE (256 * 1024)
#define AN_AUX_MEM_SIZE (256 * 1024)
/*
* Hermes register definitions and what little I know about them.
@ -181,10 +181,11 @@ struct an_card_tx_desc
u_int64_t an_phys;
};
#define AN_RID_BUFFER_SIZE 2048
#define AN_RX_BUFFER_SIZE 1840
#define AN_TX_BUFFER_SIZE 1840
#define AN_HOST_DESC_OFFSET 0x8
#define AN_RID_BUFFER_SIZE AN_MAX_DATALEN
#define AN_RX_BUFFER_SIZE AN_HOSTBUFSIZ
#define AN_TX_BUFFER_SIZE AN_HOSTBUFSIZ
/*#define AN_HOST_DESC_OFFSET 0xC sort of works */
#define AN_HOST_DESC_OFFSET 0x800
#define AN_RX_DESC_OFFSET (AN_HOST_DESC_OFFSET + \
sizeof(struct an_card_rid_desc))
#define AN_TX_DESC_OFFSET (AN_RX_DESC_OFFSET + \
@ -243,7 +244,7 @@ struct an_reply {
/* memory handle management registers */
#define AN_RX_FID 0x20
#define AN_ALLOC_FID 0x22
#define AN_TX_CMP_FID 0x24
#define AN_TX_CMP_FID(x) (x ? 0x1a : 0x24)
/*
* Buffer Access Path (BAP) registers.
@ -276,16 +277,23 @@ struct an_reply {
/* Events */
#define AN_EV_CLR_STUCK_BUSY 0x4000 /* clear stuck busy bit */
#define AN_EV_WAKEREQUEST 0x2000 /* awaken from PSP mode */
#define AN_EV_MIC 0x1000 /* Message Integrity Check*/
#define AN_EV_AWAKE 0x0100 /* station woke up from PSP mode*/
#define AN_EV_LINKSTAT 0x0080 /* link status available */
#define AN_EV_CMD 0x0010 /* command completed */
#define AN_EV_ALLOC 0x0008 /* async alloc/reclaim completed */
#define AN_EV_TX_CPY 0x0400
#define AN_EV_TX_EXC 0x0004 /* async xmit completed with failure */
#define AN_EV_TX 0x0002 /* async xmit completed succesfully */
#define AN_EV_RX 0x0001 /* async rx completed */
#define AN_INTRS \
(AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC|AN_EV_LINKSTAT)
#define AN_INTRS(x) \
( x ? (AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_TX_CPY|AN_EV_ALLOC \
|AN_EV_LINKSTAT|AN_EV_MIC) \
: \
(AN_EV_RX|AN_EV_TX|AN_EV_TX_EXC|AN_EV_ALLOC \
|AN_EV_LINKSTAT|AN_EV_MIC) \
)
/* Host software registers */
#define AN_SW0(x) (x ? 0x50 : 0x28)
@ -458,7 +466,7 @@ struct an_softc {
bus_dma_tag_t an_dtag;
struct an_ltv_genconfig an_config;
struct an_ltv_caps an_caps;
struct an_ltv_ssidlist an_ssidlist;
struct an_ltv_ssidlist_new an_ssidlist;
struct an_ltv_aplist an_aplist;
struct an_ltv_key an_temp_keys[4];
int an_tx_rate;

View File

@ -101,9 +101,7 @@ int main(int, char **);
#define ACT_DUMPAP 6
#define ACT_SET_OPMODE 7
#define ACT_SET_SSID1 8
#define ACT_SET_SSID2 9
#define ACT_SET_SSID3 10
#define ACT_SET_SSID 8
#define ACT_SET_FREQ 11
#define ACT_SET_AP1 12
#define ACT_SET_AP2 13
@ -185,6 +183,7 @@ static void an_setval(iface, areq)
err(1, "SIOCSAIRONET");
close(s);
printf("Hello %s %s %d\n",__FILE__,__FUNCTION__,__LINE__);
return;
}
@ -648,18 +647,26 @@ static void an_dumpap(iface)
static void an_dumpssid(iface)
const char *iface;
{
struct an_ltv_ssidlist *ssid;
struct an_ltv_ssidlist_new *ssid;
struct an_req areq;
int i, max;
areq.an_len = sizeof(areq);
areq.an_type = AN_RID_SSIDLIST;
an_getval(iface, &areq);
ssid = (struct an_ltv_ssidlist *)&areq;
printf("SSID 1:\t\t\t[ %.*s ]\n", ssid->an_ssid1_len, ssid->an_ssid1);
printf("SSID 2:\t\t\t[ %.*s ]\n", ssid->an_ssid2_len, ssid->an_ssid2);
printf("SSID 3:\t\t\t[ %.*s ]\n", ssid->an_ssid3_len, ssid->an_ssid3);
max = (areq.an_len - 4) / sizeof(struct an_ltv_ssid_entry);
if ( max > MAX_SSIDS ) {
printf("To many SSIDs only printing %d of %d\n",
MAX_SSIDS, max);
max = MAX_SSIDS;
}
ssid = (struct an_ltv_ssidlist_new *)&areq;
for (i = 0; i < max; i++)
printf("SSID %2d:\t\t\t[ %.*s ]\n", i + 1,
ssid->an_entry[i].an_len,
ssid->an_entry[i].an_ssid);
return;
}
@ -1182,37 +1189,38 @@ static void an_setssid(iface, act, arg)
int act;
void *arg;
{
struct an_ltv_ssidlist *ssid;
struct an_ltv_ssidlist_new *ssid;
struct an_req areq;
int max;
areq.an_len = sizeof(areq);
areq.an_type = AN_RID_SSIDLIST;
an_getval(iface, &areq);
ssid = (struct an_ltv_ssidlist *)&areq;
ssid = (struct an_ltv_ssidlist_new *)&areq;
switch (act) {
case ACT_SET_SSID1:
bzero(ssid->an_ssid1, sizeof(ssid->an_ssid1));
strlcpy(ssid->an_ssid1, (char *)arg, sizeof(ssid->an_ssid1));
ssid->an_ssid1_len = strlen(ssid->an_ssid1);
break;
case ACT_SET_SSID2:
bzero(ssid->an_ssid2, sizeof(ssid->an_ssid2));
strlcpy(ssid->an_ssid2, (char *)arg, sizeof(ssid->an_ssid2));
ssid->an_ssid2_len = strlen(ssid->an_ssid2);
break;
case ACT_SET_SSID3:
bzero(ssid->an_ssid3, sizeof(ssid->an_ssid3));
strlcpy(ssid->an_ssid3, (char *)arg, sizeof(ssid->an_ssid3));
ssid->an_ssid3_len = strlen(ssid->an_ssid3);
break;
default:
errx(1, "unknown action");
break;
max = (areq.an_len - 4) / sizeof(struct an_ltv_ssid_entry);
if ( max > MAX_SSIDS ) {
printf("To many SSIDs only printing %d of %d\n",
MAX_SSIDS, max);
max = MAX_SSIDS;
}
if ( act > max ) {
errx(1, "bad modifier %d: there "
"are only %d SSID settings", act, max);
exit(1);
}
bzero(ssid->an_entry[act-1].an_ssid,
sizeof(ssid->an_entry[act-1].an_ssid));
strlcpy(ssid->an_entry[act-1].an_ssid, (char *)arg,
sizeof(ssid->an_entry[act-1].an_ssid));
ssid->an_entry[act-1].an_len
= strlen(ssid->an_entry[act-1].an_ssid);
an_setval(iface, &areq);
exit(0);
}
@ -1702,23 +1710,9 @@ int main(argc, argv)
arg = optarg;
break;
case 'n':
switch(modifier) {
case 0:
case 1:
act = ACT_SET_SSID1;
break;
case 2:
act = ACT_SET_SSID2;
break;
case 3:
act = ACT_SET_SSID3;
break;
default:
errx(1, "bad modifier %d: there"
"are only 3 SSID settings", modifier);
usage(p);
break;
}
if (modifier == 0)
modifier = 1;
act = ACT_SET_SSID;
arg = optarg;
break;
case 'o':
@ -1800,10 +1794,8 @@ int main(argc, argv)
case ACT_DUMPRSSIMAP:
an_dumprssimap(iface);
break;
case ACT_SET_SSID1:
case ACT_SET_SSID2:
case ACT_SET_SSID3:
an_setssid(iface, act, arg);
case ACT_SET_SSID:
an_setssid(iface, modifier, arg);
break;
case ACT_SET_AP1:
case ACT_SET_AP2: