new file mode 100644
@@ -0,0 +1,53 @@
+/*
+ * hostapd / VLAN definitions and helpers functions
+ * Copyright (c) 2013, Michael Braun <michael-dev@fami-braun.de>
+ *
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
+ */
+
+#ifndef HOSTAPD_VLAN_H
+#define HOSTAPD_VLAN_H
+
+#define VLAN_NULL 0
+typedef uint16_t vlan_t;
+
+static inline void vlan_alloc(vlan_t *dst, const int untagged)
+{
+ *dst = untagged;
+}
+
+static inline void vlan_alloc_copy(vlan_t *dst, const vlan_t *src)
+{
+ *dst = *src;
+}
+
+static inline void vlan_free(vlan_t *dst)
+{
+ *dst = 0;
+}
+
+static inline int vlan_cmp(const vlan_t *a, const vlan_t *b)
+{
+ if (!a && !b)
+ return 1;
+ if (!a || !b)
+ return 0;
+ return (*a == *b);
+}
+
+static inline int vlan_untagged(const vlan_t *a)
+{
+ if (!a)
+ return 0;
+ return *a;
+}
+
+static inline int vlan_notempty(const vlan_t *a)
+{
+ if (!a)
+ return 0;
+ return *a;
+}
+
+#endif
@@ -20,6 +20,7 @@
#define WPA_SUPPLICANT_DRIVER_VERSION 4
#include "common/defs.h"
+#include "common/vlan.h"
#define HOSTAPD_CHAN_DISABLED 0x00000001
#define HOSTAPD_CHAN_PASSIVE_SCAN 0x00000002
@@ -1932,7 +1933,7 @@ struct wpa_driver_ops {
* domains to be used with a single BSS.
*/
int (*set_sta_vlan)(void *priv, const u8 *addr, const char *ifname,
- int vlan_id);
+ vlan_t vlan_id);
/**
* commit - Optional commit changes handler (AP only)
@@ -8149,7 +8149,7 @@ static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
static int i802_set_sta_vlan(struct i802_bss *bss, const u8 *addr,
- const char *ifname, int vlan_id)
+ const char *ifname, vlan_t vlan_id)
{
struct wpa_driver_nl80211_data *drv = bss->drv;
struct nl_msg *msg;
@@ -8172,7 +8172,7 @@ static int i802_set_sta_vlan(struct i802_bss *bss, const u8 *addr,
if (ret < 0) {
wpa_printf(MSG_ERROR, "nl80211: NL80211_ATTR_STA_VLAN (addr="
MACSTR " ifname=%s vlan_id=%d) failed: %d (%s)",
- MAC2STR(addr), ifname, vlan_id, ret,
+ MAC2STR(addr), ifname, vlan_untagged(&vlan_id), ret,
strerror(-ret));
}
nla_put_failure:
@@ -8342,13 +8342,13 @@ static int i802_set_wds_sta(void *priv, const u8 *addr, int aid, int val,
wpa_printf(MSG_ERROR, "nl80211: Failed to set WDS STA "
"interface %s up", name);
}
- return i802_set_sta_vlan(priv, addr, name, 0);
+ return i802_set_sta_vlan(priv, addr, name, VLAN_NULL);
} else {
if (bridge_ifname)
linux_br_del_if(drv->global->ioctl_sock, bridge_ifname,
name);
- i802_set_sta_vlan(priv, addr, bss->ifname, 0);
+ i802_set_sta_vlan(priv, addr, bss->ifname, VLAN_NULL);
return wpa_driver_nl80211_if_remove(priv, WPA_IF_AP_VLAN,
name);
}
@@ -9889,7 +9889,7 @@ static int driver_nl80211_sta_remove(void *priv, const u8 *addr)
#if defined(HOSTAPD) || defined(CONFIG_AP)
static int driver_nl80211_set_sta_vlan(void *priv, const u8 *addr,
- const char *ifname, int vlan_id)
+ const char *ifname, vlan_t vlan_id)
{
struct i802_bss *bss = priv;
return i802_set_sta_vlan(bss, addr, ifname, vlan_id);
@@ -1127,10 +1127,10 @@ static int test_driver_set_privacy(void *priv, int enabled)
static int test_driver_set_sta_vlan(void *priv, const u8 *addr,
- const char *ifname, int vlan_id)
+ const char *ifname, vlan_t vlan_id)
{
wpa_printf(MSG_DEBUG, "%s(addr=" MACSTR " ifname=%s vlan_id=%d)",
- __func__, MAC2STR(addr), ifname, vlan_id);
+ __func__, MAC2STR(addr), ifname, vlan_untagged(&vlan_id));
return 0;
}
@@ -261,7 +261,7 @@ static int auth_send_eapol(void *ctx, const u8 *addr, const u8 *data,
}
-static int auth_set_key(void *ctx, int vlan_id, enum wpa_alg alg,
+static int auth_set_key(void *ctx, vlan_t vlan_id, enum wpa_alg alg,
const u8 *addr, int idx, u8 *key, size_t key_len)
{
struct ibss_rsn *ibss_rsn = ctx;
@@ -40,7 +40,7 @@ void ap_sta_session_timeout(struct hostapd_data *hapd, struct sta_info *sta,
int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
- int old_vlanid)
+ vlan_t old_vlanid)
{
return 0;
}
@@ -77,7 +77,8 @@ hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
}
-const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
+const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan,
+ vlan_t vlan_id)
{
return NULL;
}