diff --git a/src/ap/vlan_full.c b/src/ap/vlan_full.c index 0516523c7..e362e987f 100644 --- a/src/ap/vlan_full.c +++ b/src/ap/vlan_full.c @@ -13,7 +13,6 @@ /* Avoid conflicts due to NetBSD net/if.h if_type define with driver.h */ #undef if_type #include -#include /* From linux/if_bridge.h that can conflict with C library headers for IPv6 */ #define BRCTL_GET_VERSION 0 #define BRCTL_GET_BRIDGES 1 @@ -27,6 +26,7 @@ #include "utils/common.h" #include "drivers/priv_netlink.h" +#include "common/linux_vlan.h" #include "utils/eloop.h" #include "hostapd.h" #include "ap_config.h" diff --git a/src/ap/vlan_ioctl.c b/src/ap/vlan_ioctl.c index 97b922453..987b612e1 100644 --- a/src/ap/vlan_ioctl.c +++ b/src/ap/vlan_ioctl.c @@ -10,19 +10,11 @@ #include "utils/includes.h" #include -#include -#include #include "utils/common.h" +#include "common/linux_vlan.h" #include "vlan_util.h" -/* - * These are only available in recent linux headers (without the leading - * underscore). - */ -#define _GET_VLAN_REALDEV_NAME_CMD 8 -#define _GET_VLAN_VID_CMD 9 - int vlan_rem(const char *if_name) { @@ -95,11 +87,11 @@ int vlan_add(const char *if_name, int vid, const char *vlan_if_name) os_snprintf(if_request.device1, sizeof(if_request.device1), "vlan%d", vid); - if_request.cmd = _GET_VLAN_VID_CMD; + if_request.cmd = GET_VLAN_VID_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) == 0 && if_request.u.VID == vid) { - if_request.cmd = _GET_VLAN_REALDEV_NAME_CMD; + if_request.cmd = GET_VLAN_REALDEV_NAME_CMD; if (ioctl(fd, SIOCSIFVLAN, &if_request) == 0 && os_strncmp(if_request.u.device2, if_name, diff --git a/src/common/linux_vlan.h b/src/common/linux_vlan.h new file mode 100644 index 000000000..8a1dd6e46 --- /dev/null +++ b/src/common/linux_vlan.h @@ -0,0 +1,52 @@ +/* + * Linux VLAN configuration kernel interface + * Copyright (c) 2016, Jouni Malinen + * + * This software may be distributed under the terms of the BSD license. + * See README for more details. + */ + +#ifndef LINUX_VLAN_H +#define LINUX_VLAN_H + +/* This ioctl is defined in linux/sockios.h */ + +#ifndef SIOCSIFVLAN +#define SIOCSIFVLAN 0x8983 +#endif /* SIOCSIFVLAN */ + +/* This interface is defined in linux/if_vlan.h */ + +#define ADD_VLAN_CMD 0 +#define DEL_VLAN_CMD 1 +#define SET_VLAN_INGRESS_PRIORITY_CMD 2 +#define SET_VLAN_EGRESS_PRIORITY_CMD 3 +#define GET_VLAN_INGRESS_PRIORITY_CMD 4 +#define GET_VLAN_EGRESS_PRIORITY_CMD 5 +#define SET_VLAN_NAME_TYPE_CMD 6 +#define SET_VLAN_FLAG_CMD 7 +#define GET_VLAN_REALDEV_NAME_CMD 8 +#define GET_VLAN_VID_CMD 9 + +#define VLAN_NAME_TYPE_PLUS_VID 0 +#define VLAN_NAME_TYPE_RAW_PLUS_VID 1 +#define VLAN_NAME_TYPE_PLUS_VID_NO_PAD 2 +#define VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD 3 + +struct vlan_ioctl_args { + int cmd; + char device1[24]; + + union { + char device2[24]; + int VID; + unsigned int skb_priority; + unsigned int name_type; + unsigned int bind_type; + unsigned int flag; + } u; + + short vlan_qos; +}; + +#endif /* LINUX_VLAN_H */