[PATCH] softmac: clean up event handling code

This patch cleans up the event handling code in ieee80211softmac_event.c and
makes the module slightly smaller by removing some strings that are not used
any more and consolidating some code.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
Johannes Berg 2006-04-20 20:02:04 +02:00 коммит произвёл John W. Linville
Родитель 9a1771e867
Коммит 921a91ef6a
1 изменённых файлов: 10 добавлений и 15 удалений

Просмотреть файл

@ -38,7 +38,8 @@
* The event context is private and can only be used from * The event context is private and can only be used from
* within this module. Its meaning varies with the event * within this module. Its meaning varies with the event
* type: * type:
* SCAN_FINISHED: no special meaning * SCAN_FINISHED,
* DISASSOCIATED: NULL
* ASSOCIATED, * ASSOCIATED,
* ASSOCIATE_FAILED, * ASSOCIATE_FAILED,
* ASSOCIATE_TIMEOUT, * ASSOCIATE_TIMEOUT,
@ -59,15 +60,15 @@
*/ */
static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = { static char *event_descriptions[IEEE80211SOFTMAC_EVENT_LAST+1] = {
"scan finished", NULL, /* scan finished */
"associated", NULL, /* associated */
"associating failed", "associating failed",
"associating timed out", "associating timed out",
"authenticated", "authenticated",
"authenticating failed", "authenticating failed",
"authenticating timed out", "authenticating timed out",
"associating failed because no suitable network was found", "associating failed because no suitable network was found",
"disassociated", NULL, /* disassociated */
}; };
@ -136,30 +137,24 @@ ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, int eve
int we_event; int we_event;
char *msg = NULL; char *msg = NULL;
memset(&wrqu, '\0', sizeof (union iwreq_data));
switch(event) { switch(event) {
case IEEE80211SOFTMAC_EVENT_ASSOCIATED: case IEEE80211SOFTMAC_EVENT_ASSOCIATED:
network = (struct ieee80211softmac_network *)event_ctx; network = (struct ieee80211softmac_network *)event_ctx;
wrqu.data.length = 0;
wrqu.data.flags = 0;
memcpy(wrqu.ap_addr.sa_data, &network->bssid[0], ETH_ALEN); memcpy(wrqu.ap_addr.sa_data, &network->bssid[0], ETH_ALEN);
wrqu.ap_addr.sa_family = ARPHRD_ETHER; /* fall through */
we_event = SIOCGIWAP;
break;
case IEEE80211SOFTMAC_EVENT_DISASSOCIATED: case IEEE80211SOFTMAC_EVENT_DISASSOCIATED:
wrqu.data.length = 0;
wrqu.data.flags = 0;
memset(&wrqu, '\0', sizeof (union iwreq_data));
wrqu.ap_addr.sa_family = ARPHRD_ETHER; wrqu.ap_addr.sa_family = ARPHRD_ETHER;
we_event = SIOCGIWAP; we_event = SIOCGIWAP;
break; break;
case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED: case IEEE80211SOFTMAC_EVENT_SCAN_FINISHED:
wrqu.data.length = 0;
wrqu.data.flags = 0;
memset(&wrqu, '\0', sizeof (union iwreq_data));
we_event = SIOCGIWSCAN; we_event = SIOCGIWSCAN;
break; break;
default: default:
msg = event_descriptions[event]; msg = event_descriptions[event];
if (!msg)
msg = "SOFTMAC EVENT BUG";
wrqu.data.length = strlen(msg); wrqu.data.length = strlen(msg);
we_event = IWEVCUSTOM; we_event = IWEVCUSTOM;
break; break;