]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
AP: Convert "dhcp_snoop" to use the generic "x_snoop"
authorKyeyoon Park <kyeyoonp@qca.qualcomm.com>
Sat, 1 Nov 2014 01:18:35 +0000 (18:18 -0700)
committerJouni Malinen <j@w1.fi>
Wed, 19 Nov 2014 14:14:15 +0000 (16:14 +0200)
Signed-off-by: Kyeyoon Park <kyeyoonp@qca.qualcomm.com>
src/ap/dhcp_snoop.c
src/ap/hostapd.c

index 1bd4ba4564bb7b1e41052c315f3aa714a3e82ade..24ac446d02d854d8c0875a494985f93235b72b8d 100644 (file)
@@ -7,7 +7,6 @@
  */
 
 #include "utils/includes.h"
-#include <linux/filter.h>
 #include <linux/ip.h>
 #include <linux/udp.h>
 
@@ -16,6 +15,7 @@
 #include "hostapd.h"
 #include "sta_info.h"
 #include "ap_drv_ops.h"
+#include "x_snoop.h"
 #include "dhcp_snoop.h"
 
 struct bootp_pkt {
@@ -132,22 +132,8 @@ static void handle_dhcp(void *ctx, const u8 *src_addr, const u8 *buf,
 
 int dhcp_snoop_init(struct hostapd_data *hapd)
 {
-       struct hostapd_bss_config *conf = hapd->conf;
-
-       if (!conf->isolate) {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: ap_isolate must be enabled for DHCP snooping");
-               return -1;
-       }
-
-       if (conf->bridge[0] == '\0') {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: Bridge must be configured for DHCP snooping");
-               return -1;
-       }
-
-       hapd->sock_dhcp = l2_packet_init(conf->bridge, NULL, ETH_P_ALL,
-                                        handle_dhcp, hapd, 1);
+       hapd->sock_dhcp = x_snoop_get_l2_packet(hapd, handle_dhcp,
+                                               L2_PACKET_FILTER_DHCP);
        if (hapd->sock_dhcp == NULL) {
                wpa_printf(MSG_DEBUG,
                           "dhcp_snoop: Failed to initialize L2 packet processing for DHCP packet: %s",
@@ -155,42 +141,11 @@ int dhcp_snoop_init(struct hostapd_data *hapd)
                return -1;
        }
 
-       if (l2_packet_set_packet_filter(hapd->sock_dhcp,
-                                       L2_PACKET_FILTER_DHCP)) {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: Failed to set L2 packet filter for DHCP: %s",
-                          strerror(errno));
-               return -1;
-       }
-
-       if (hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE,
-                                        1)) {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: Failed to enable hairpin_mode on the bridge port");
-               return -1;
-       }
-
-       if (hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_PROXYARP, 1)) {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: Failed to enable proxyarp on the bridge port");
-               return -1;
-       }
-
-       if (hostapd_drv_br_set_net_param(hapd, DRV_BR_NET_PARAM_GARP_ACCEPT,
-                                        1)) {
-               wpa_printf(MSG_DEBUG,
-                          "dhcp_snoop: Failed to enable accepting gratuitous ARP on the bridge");
-               return -1;
-       }
-
        return 0;
 }
 
 
 void dhcp_snoop_deinit(struct hostapd_data *hapd)
 {
-       hostapd_drv_br_set_net_param(hapd, DRV_BR_NET_PARAM_GARP_ACCEPT, 0);
-       hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_PROXYARP, 0);
-       hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, 0);
        l2_packet_deinit(hapd->sock_dhcp);
 }
index 2871b9b7621b4c84f7afc498c7d8464404c58c74..2ed16046ef164fc76821061d0946d1f9235c199e 100644 (file)
@@ -36,6 +36,7 @@
 #include "dfs.h"
 #include "ieee802_11.h"
 #include "bss_load.h"
+#include "x_snoop.h"
 #include "dhcp_snoop.h"
 
 
@@ -314,6 +315,7 @@ static void hostapd_free_hapd_data(struct hostapd_data *hapd)
 
        bss_load_update_deinit(hapd);
        dhcp_snoop_deinit(hapd);
+       x_snoop_deinit(hapd);
 
 #ifdef CONFIG_SQLITE
        bin_clear_free(hapd->tmp_eap_user.identity,
@@ -893,9 +895,18 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
                return -1;
        }
 
-       if (conf->proxy_arp && dhcp_snoop_init(hapd)) {
-               wpa_printf(MSG_ERROR, "DHCP snooping initialization failed");
-               return -1;
+       if (conf->proxy_arp) {
+               if (x_snoop_init(hapd)) {
+                       wpa_printf(MSG_ERROR,
+                                  "Generic snooping infrastructure initialization failed");
+                       return -1;
+               }
+
+               if (dhcp_snoop_init(hapd)) {
+                       wpa_printf(MSG_ERROR,
+                                  "DHCP snooping initialization failed");
+                       return -1;
+               }
        }
 
        if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {