]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
vlan: Move if_nametoindex() use out of vlan_init.c
authorJouni Malinen <j@w1.fi>
Fri, 25 Mar 2016 16:00:44 +0000 (18:00 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 25 Mar 2016 16:00:44 +0000 (18:00 +0200)
With this, vlan_init.c does not need any special header files anymore
and vlan_ifconfig.c does not need hostapd-specific header files that
might conflict with net/if.h on NetBSD.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/vlan_ifconfig.c
src/ap/vlan_init.c
src/ap/vlan_util.h

index 6a4d10cd48655dfa43e67562ac2446979fd09ad5..ef953a5c4c95a083d3bdf64c54de5f02b4e00db0 100644 (file)
@@ -61,3 +61,9 @@ int ifconfig_up(const char *if_name)
        wpa_printf(MSG_DEBUG, "VLAN: Set interface %s up", if_name);
        return ifconfig_helper(if_name, 1);
 }
+
+
+int iface_exists(const char *ifname)
+{
+       return if_nametoindex(ifname);
+}
index b8ca4f7598e9d6c90f7948a9575bdb84e2364f92..31e4fc6b396a14de5b3bd1f7f4cc6e5eedcb8bcf 100644 (file)
@@ -9,9 +9,6 @@
  */
 
 #include "utils/includes.h"
-#include <net/if.h>
-/* Avoid conflicts due to NetBSD net/if.h if_type define with driver.h */
-#undef if_type
 
 #include "utils/common.h"
 #include "hostapd.h"
@@ -36,7 +33,7 @@ static int vlan_if_add(struct hostapd_data *hapd, struct hostapd_vlan *vlan,
                return -1;
        }
 
-       if (!if_nametoindex(vlan->ifname))
+       if (!iface_exists(vlan->ifname))
                ret = hostapd_vlan_if_add(hapd, vlan->ifname);
        else if (!existsok)
                return -1;
index 5e9e690c0f6618bb9f36ef8f96a9e3ec7b495918..244685975c0be1d4e3ddc55231b3dc53c281e093 100644 (file)
@@ -19,6 +19,7 @@ int vlan_set_name_type(unsigned int name_type);
 
 int ifconfig_helper(const char *if_name, int up);
 int ifconfig_up(const char *if_name);
+int iface_exists(const char *ifname);
 int vlan_if_remove(struct hostapd_data *hapd, struct hostapd_vlan *vlan);
 
 struct full_dynamic_vlan *