BSD: Use correct ifindex from route messages
Use the interface index from the correct structure according to the message instead of assuming rtm_index is correct. Signed-off-by: Roy Marples <roy@marples.name>
This commit is contained in:
parent
5f17b2c60e
commit
dc0ad60314
1 changed files with 25 additions and 16 deletions
|
@ -773,12 +773,12 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
|
||||||
rtm->rtm_version);
|
rtm->rtm_version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drv = bsd_get_drvindex(global, rtm->rtm_index);
|
|
||||||
if (drv == NULL)
|
|
||||||
return;
|
|
||||||
switch (rtm->rtm_type) {
|
switch (rtm->rtm_type) {
|
||||||
case RTM_IEEE80211:
|
case RTM_IEEE80211:
|
||||||
ifan = (struct if_announcemsghdr *) rtm;
|
ifan = (struct if_announcemsghdr *) rtm;
|
||||||
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
||||||
|
if (drv == NULL)
|
||||||
|
return;
|
||||||
switch (ifan->ifan_what) {
|
switch (ifan->ifan_what) {
|
||||||
case RTM_IEEE80211_ASSOC:
|
case RTM_IEEE80211_ASSOC:
|
||||||
case RTM_IEEE80211_REASSOC:
|
case RTM_IEEE80211_REASSOC:
|
||||||
|
@ -1189,6 +1189,7 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
|
||||||
struct bsd_driver_global *global = sock_ctx;
|
struct bsd_driver_global *global = sock_ctx;
|
||||||
struct bsd_driver_data *drv;
|
struct bsd_driver_data *drv;
|
||||||
struct if_announcemsghdr *ifan;
|
struct if_announcemsghdr *ifan;
|
||||||
|
struct if_msghdr *ifm;
|
||||||
struct rt_msghdr *rtm;
|
struct rt_msghdr *rtm;
|
||||||
union wpa_event_data event;
|
union wpa_event_data event;
|
||||||
struct ieee80211_michael_event *mic;
|
struct ieee80211_michael_event *mic;
|
||||||
|
@ -1210,14 +1211,13 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
|
||||||
rtm->rtm_version);
|
rtm->rtm_version);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
drv = bsd_get_drvindex(global, rtm->rtm_index);
|
|
||||||
if (drv == NULL)
|
|
||||||
return;
|
|
||||||
ctx = drv->ctx;
|
|
||||||
os_memset(&event, 0, sizeof(event));
|
os_memset(&event, 0, sizeof(event));
|
||||||
switch (rtm->rtm_type) {
|
switch (rtm->rtm_type) {
|
||||||
case RTM_IFANNOUNCE:
|
case RTM_IFANNOUNCE:
|
||||||
ifan = (struct if_announcemsghdr *) rtm;
|
ifan = (struct if_announcemsghdr *) rtm;
|
||||||
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
||||||
|
if (drv == NULL)
|
||||||
|
return;
|
||||||
os_strlcpy(event.interface_status.ifname, drv->ifname,
|
os_strlcpy(event.interface_status.ifname, drv->ifname,
|
||||||
sizeof(event.interface_status.ifname));
|
sizeof(event.interface_status.ifname));
|
||||||
switch (ifan->ifan_what) {
|
switch (ifan->ifan_what) {
|
||||||
|
@ -1230,37 +1230,41 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
|
||||||
event.interface_status.ifname,
|
event.interface_status.ifname,
|
||||||
ifan->ifan_what == IFAN_DEPARTURE ?
|
ifan->ifan_what == IFAN_DEPARTURE ?
|
||||||
"removed" : "added");
|
"removed" : "added");
|
||||||
wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, &event);
|
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211:
|
case RTM_IEEE80211:
|
||||||
ifan = (struct if_announcemsghdr *) rtm;
|
ifan = (struct if_announcemsghdr *) rtm;
|
||||||
|
drv = bsd_get_drvindex(global, ifan->ifan_index);
|
||||||
|
if (drv == NULL)
|
||||||
|
return;
|
||||||
switch (ifan->ifan_what) {
|
switch (ifan->ifan_what) {
|
||||||
case RTM_IEEE80211_ASSOC:
|
case RTM_IEEE80211_ASSOC:
|
||||||
case RTM_IEEE80211_REASSOC:
|
case RTM_IEEE80211_REASSOC:
|
||||||
if (drv->is_ap)
|
if (drv->is_ap)
|
||||||
break;
|
break;
|
||||||
wpa_supplicant_event(ctx, EVENT_ASSOC, NULL);
|
wpa_supplicant_event(drv->ctx, EVENT_ASSOC, NULL);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211_DISASSOC:
|
case RTM_IEEE80211_DISASSOC:
|
||||||
if (drv->is_ap)
|
if (drv->is_ap)
|
||||||
break;
|
break;
|
||||||
wpa_supplicant_event(ctx, EVENT_DISASSOC, NULL);
|
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211_SCAN:
|
case RTM_IEEE80211_SCAN:
|
||||||
if (drv->is_ap)
|
if (drv->is_ap)
|
||||||
break;
|
break;
|
||||||
wpa_supplicant_event(ctx, EVENT_SCAN_RESULTS, NULL);
|
wpa_supplicant_event(drv->ctx, EVENT_SCAN_RESULTS,
|
||||||
|
NULL);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211_LEAVE:
|
case RTM_IEEE80211_LEAVE:
|
||||||
leave = (struct ieee80211_leave_event *) &ifan[1];
|
leave = (struct ieee80211_leave_event *) &ifan[1];
|
||||||
drv_event_disassoc(ctx, leave->iev_addr);
|
drv_event_disassoc(drv->ctx, leave->iev_addr);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211_JOIN:
|
case RTM_IEEE80211_JOIN:
|
||||||
#ifdef RTM_IEEE80211_REJOIN
|
#ifdef RTM_IEEE80211_REJOIN
|
||||||
case RTM_IEEE80211_REJOIN:
|
case RTM_IEEE80211_REJOIN:
|
||||||
#endif
|
#endif
|
||||||
join = (struct ieee80211_join_event *) &ifan[1];
|
join = (struct ieee80211_join_event *) &ifan[1];
|
||||||
bsd_new_sta(drv, ctx, join->iev_addr);
|
bsd_new_sta(drv, drv->ctx, join->iev_addr);
|
||||||
break;
|
break;
|
||||||
case RTM_IEEE80211_REPLAY:
|
case RTM_IEEE80211_REPLAY:
|
||||||
/* ignore */
|
/* ignore */
|
||||||
|
@ -1275,19 +1279,24 @@ wpa_driver_bsd_event_receive(int sock, void *ctx, void *sock_ctx)
|
||||||
os_memset(&event, 0, sizeof(event));
|
os_memset(&event, 0, sizeof(event));
|
||||||
event.michael_mic_failure.unicast =
|
event.michael_mic_failure.unicast =
|
||||||
!IEEE80211_IS_MULTICAST(mic->iev_dst);
|
!IEEE80211_IS_MULTICAST(mic->iev_dst);
|
||||||
wpa_supplicant_event(ctx, EVENT_MICHAEL_MIC_FAILURE,
|
wpa_supplicant_event(drv->ctx,
|
||||||
&event);
|
EVENT_MICHAEL_MIC_FAILURE, &event);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case RTM_IFINFO:
|
case RTM_IFINFO:
|
||||||
|
ifm = (struct if_msghdr *) rtm;
|
||||||
|
drv = bsd_get_drvindex(global, ifm->ifm_index);
|
||||||
|
if (drv == NULL)
|
||||||
|
return;
|
||||||
if ((rtm->rtm_flags & RTF_UP) == 0) {
|
if ((rtm->rtm_flags & RTF_UP) == 0) {
|
||||||
os_strlcpy(event.interface_status.ifname, drv->ifname,
|
os_strlcpy(event.interface_status.ifname, drv->ifname,
|
||||||
sizeof(event.interface_status.ifname));
|
sizeof(event.interface_status.ifname));
|
||||||
event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
|
event.interface_status.ievent = EVENT_INTERFACE_REMOVED;
|
||||||
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
|
wpa_printf(MSG_DEBUG, "RTM_IFINFO: Interface '%s' DOWN",
|
||||||
event.interface_status.ifname);
|
event.interface_status.ifname);
|
||||||
wpa_supplicant_event(ctx, EVENT_INTERFACE_STATUS, &event);
|
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS,
|
||||||
|
&event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue