[PATCH]: madwifi filter netlink mesages
Gunter Burchardt
gbur
Fri Oct 8 04:58:09 PDT 2004
Hello
This patch filters netlink messages from madwifi driver. Only messages
from the right interface will pass.
regards
gunter
-------------- next part --------------
diff -Nur hostap.old/hostapd/driver_madwifi.c hostap/hostapd/driver_madwifi.c
--- hostap.old/hostapd/driver_madwifi.c 2004-09-21 05:37:27.000000000 +0200
+++ hostap/hostapd/driver_madwifi.c 2004-10-08 11:49:47.000000000 +0200
@@ -48,6 +48,7 @@
struct hostapd_data *hapd; /* back pointer */
char iface[IFNAMSIZ + 1];
+ int ifindex;
struct l2_packet_data *sock_xmit; /* raw packet xmit socket */
struct l2_packet_data *sock_recv; /* raw packet recv socket */
int ioctl_sock; /* socket for ioctl() use */
@@ -706,8 +707,8 @@
ifi = NLMSG_DATA(h);
- /* TODO: use ifi->ifi_index to filter out wireless events from other
- * interfaces */
+ if (ifi->ifi_index != drv->ifindex)
+ return;
nlmsg_len = NLMSG_ALIGN(sizeof(struct ifinfomsg));
@@ -886,6 +887,7 @@
madwifi_driver_init(struct hostapd_data *hapd)
{
struct madwifi_driver_data *drv;
+ struct ifreq ifr;
drv = malloc(sizeof(struct madwifi_driver_data));
if (drv == NULL) {
@@ -903,6 +905,14 @@
}
memcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
+ memset(&ifr, 0, sizeof(ifr));
+ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", drv->iface);
+ if (ioctl(drv->ioctl_sock, SIOCGIFINDEX, &ifr) != 0) {
+ perror("ioctl(SIOCGIFINDEX)");
+ return -1;
+ }
+ drv->ifindex = ifr.ifr_ifindex;
+
drv->sock_xmit = l2_packet_init(drv->iface, ETH_P_EAPOL,
handle_read, drv);
if (drv->sock_xmit == NULL)
More information about the Hostap
mailing list