Add hostapd configuration option to set VLAN naming scheme
Signed-hostap: M. Braun <michael-dev@fami-braun.de>
This commit is contained in:
parent
1d0c6fb1eb
commit
a00237ceb8
4 changed files with 46 additions and 6 deletions
|
@ -2133,6 +2133,15 @@ static int hostapd_config_fill(struct hostapd_config *conf,
|
||||||
"read VLAN file '%s'", line, pos);
|
"read VLAN file '%s'", line, pos);
|
||||||
errors++;
|
errors++;
|
||||||
}
|
}
|
||||||
|
} else if (os_strcmp(buf, "vlan_naming") == 0) {
|
||||||
|
bss->ssid.vlan_naming = atoi(pos);
|
||||||
|
if (bss->ssid.vlan_naming >= DYNAMIC_VLAN_NAMING_END ||
|
||||||
|
bss->ssid.vlan_naming < 0) {
|
||||||
|
wpa_printf(MSG_ERROR, "Line %d: invalid "
|
||||||
|
"naming scheme %d", line,
|
||||||
|
bss->ssid.vlan_naming);
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
||||||
} else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
|
} else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
|
||||||
bss->ssid.vlan_tagged_interface = os_strdup(pos);
|
bss->ssid.vlan_tagged_interface = os_strdup(pos);
|
||||||
|
|
|
@ -801,6 +801,12 @@ own_ip_addr=127.0.0.1
|
||||||
# to the bridge.
|
# to the bridge.
|
||||||
#vlan_tagged_interface=eth0
|
#vlan_tagged_interface=eth0
|
||||||
|
|
||||||
|
# When hostapd creates a VLAN interface on vlan_tagged_interfaces, it needs
|
||||||
|
# to know how to name it.
|
||||||
|
# 0 = vlan<XXX>, e.g., vlan1
|
||||||
|
# 1 = <vlan_tagged_interface>.<XXX>, e.g. eth0.1
|
||||||
|
#vlan_naming=0
|
||||||
|
|
||||||
# Arbitrary RADIUS attributes can be added into Access-Request and
|
# Arbitrary RADIUS attributes can be added into Access-Request and
|
||||||
# Accounting-Request packets by specifying the contents of the attributes with
|
# Accounting-Request packets by specifying the contents of the attributes with
|
||||||
# the following configuration parameters. There can be multiple of these to
|
# the following configuration parameters. There can be multiple of these to
|
||||||
|
|
|
@ -65,6 +65,10 @@ struct hostapd_ssid {
|
||||||
#define DYNAMIC_VLAN_OPTIONAL 1
|
#define DYNAMIC_VLAN_OPTIONAL 1
|
||||||
#define DYNAMIC_VLAN_REQUIRED 2
|
#define DYNAMIC_VLAN_REQUIRED 2
|
||||||
int dynamic_vlan;
|
int dynamic_vlan;
|
||||||
|
#define DYNAMIC_VLAN_NAMING_WITHOUT_DEVICE 0
|
||||||
|
#define DYNAMIC_VLAN_NAMING_WITH_DEVICE 1
|
||||||
|
#define DYNAMIC_VLAN_NAMING_END 2
|
||||||
|
int vlan_naming;
|
||||||
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
||||||
char *vlan_tagged_interface;
|
char *vlan_tagged_interface;
|
||||||
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
||||||
|
|
|
@ -481,6 +481,7 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
|
||||||
char br_name[IFNAMSIZ];
|
char br_name[IFNAMSIZ];
|
||||||
struct hostapd_vlan *vlan = hapd->conf->vlan;
|
struct hostapd_vlan *vlan = hapd->conf->vlan;
|
||||||
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
|
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
|
||||||
|
int vlan_naming = hapd->conf->ssid.vlan_naming;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "VLAN: vlan_newlink(%s)", ifname);
|
wpa_printf(MSG_DEBUG, "VLAN: vlan_newlink(%s)", ifname);
|
||||||
|
|
||||||
|
@ -496,13 +497,21 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
|
||||||
ifconfig_up(br_name);
|
ifconfig_up(br_name);
|
||||||
|
|
||||||
if (tagged_interface) {
|
if (tagged_interface) {
|
||||||
|
if (vlan_naming ==
|
||||||
|
DYNAMIC_VLAN_NAMING_WITH_DEVICE)
|
||||||
|
os_snprintf(vlan_ifname,
|
||||||
|
sizeof(vlan_ifname),
|
||||||
|
"%s.%d", tagged_interface,
|
||||||
|
vlan->vlan_id);
|
||||||
|
else
|
||||||
|
os_snprintf(vlan_ifname,
|
||||||
|
sizeof(vlan_ifname),
|
||||||
|
"vlan%d", vlan->vlan_id);
|
||||||
|
|
||||||
|
ifconfig_up(tagged_interface);
|
||||||
if (!vlan_add(tagged_interface, vlan->vlan_id))
|
if (!vlan_add(tagged_interface, vlan->vlan_id))
|
||||||
vlan->clean |= DVLAN_CLEAN_VLAN;
|
vlan->clean |= DVLAN_CLEAN_VLAN;
|
||||||
|
|
||||||
os_snprintf(vlan_ifname, sizeof(vlan_ifname),
|
|
||||||
"vlan%d", vlan->vlan_id);
|
|
||||||
|
|
||||||
if (!br_addif(br_name, vlan_ifname))
|
if (!br_addif(br_name, vlan_ifname))
|
||||||
vlan->clean |= DVLAN_CLEAN_VLAN_PORT;
|
vlan->clean |= DVLAN_CLEAN_VLAN_PORT;
|
||||||
|
|
||||||
|
@ -527,6 +536,7 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
|
||||||
char br_name[IFNAMSIZ];
|
char br_name[IFNAMSIZ];
|
||||||
struct hostapd_vlan *first, *prev, *vlan = hapd->conf->vlan;
|
struct hostapd_vlan *first, *prev, *vlan = hapd->conf->vlan;
|
||||||
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
|
char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
|
||||||
|
int vlan_naming = hapd->conf->ssid.vlan_naming;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "VLAN: vlan_dellink(%s)", ifname);
|
wpa_printf(MSG_DEBUG, "VLAN: vlan_dellink(%s)", ifname);
|
||||||
|
|
||||||
|
@ -541,8 +551,16 @@ static void vlan_dellink(char *ifname, struct hostapd_data *hapd)
|
||||||
br_delif(br_name, vlan->ifname);
|
br_delif(br_name, vlan->ifname);
|
||||||
|
|
||||||
if (tagged_interface) {
|
if (tagged_interface) {
|
||||||
os_snprintf(vlan_ifname, sizeof(vlan_ifname),
|
if (vlan_naming ==
|
||||||
"vlan%d", vlan->vlan_id);
|
DYNAMIC_VLAN_NAMING_WITH_DEVICE)
|
||||||
|
os_snprintf(vlan_ifname,
|
||||||
|
sizeof(vlan_ifname),
|
||||||
|
"%s.%d", tagged_interface,
|
||||||
|
vlan->vlan_id);
|
||||||
|
else
|
||||||
|
os_snprintf(vlan_ifname,
|
||||||
|
sizeof(vlan_ifname),
|
||||||
|
"vlan%d", vlan->vlan_id);
|
||||||
if (vlan->clean & DVLAN_CLEAN_VLAN_PORT)
|
if (vlan->clean & DVLAN_CLEAN_VLAN_PORT)
|
||||||
br_delif(br_name, vlan_ifname);
|
br_delif(br_name, vlan_ifname);
|
||||||
ifconfig_down(vlan_ifname);
|
ifconfig_down(vlan_ifname);
|
||||||
|
@ -682,7 +700,10 @@ full_dynamic_vlan_init(struct hostapd_data *hapd)
|
||||||
if (priv == NULL)
|
if (priv == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
vlan_set_name_type(VLAN_NAME_TYPE_PLUS_VID_NO_PAD);
|
vlan_set_name_type(hapd->conf->ssid.vlan_naming ==
|
||||||
|
DYNAMIC_VLAN_NAMING_WITH_DEVICE ?
|
||||||
|
VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD :
|
||||||
|
VLAN_NAME_TYPE_PLUS_VID_NO_PAD);
|
||||||
|
|
||||||
priv->s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
priv->s = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
|
||||||
if (priv->s < 0) {
|
if (priv->s < 0) {
|
||||||
|
|
Loading…
Reference in a new issue