aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2016-03-26 09:19:49 (GMT)
committerJouni Malinen <j@w1.fi>2016-03-26 09:24:38 (GMT)
commitc815fab83a525f01019f2eae93c99f27a66d68a6 (patch)
tree4a1410a7a97484e23e275d38f0a2391cf16be18a
parent81606ab73bff3c402d03a60b590b4e723d8e12c1 (diff)
downloadhostap-c815fab83a525f01019f2eae93c99f27a66d68a6.zip
hostap-c815fab83a525f01019f2eae93c99f27a66d68a6.tar.gz
hostap-c815fab83a525f01019f2eae93c99f27a66d68a6.tar.bz2
Use own header file for defining Linux VLAN kernel interface
This gets rid of need to include linux/if_vlan.h and additional defines in vlan_ioctl.c to avoid issues with missing definitions in libc headers. Signed-off-by: Jouni Malinen <j@w1.fi>
-rw-r--r--src/ap/vlan_full.c2
-rw-r--r--src/ap/vlan_ioctl.c14
-rw-r--r--src/common/linux_vlan.h52
3 files changed, 56 insertions, 12 deletions
diff --git a/src/ap/vlan_full.c b/src/ap/vlan_full.c
index 0516523..e362e98 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 <sys/ioctl.h>
-#include <linux/if_vlan.h>
/* 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 97b9224..987b612 100644
--- a/src/ap/vlan_ioctl.c
+++ b/src/ap/vlan_ioctl.c
@@ -10,19 +10,11 @@
#include "utils/includes.h"
#include <sys/ioctl.h>
-#include <linux/sockios.h>
-#include <linux/if_vlan.h>
#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 0000000..8a1dd6e
--- /dev/null
+++ b/src/common/linux_vlan.h
@@ -0,0 +1,52 @@
+/*
+ * Linux VLAN configuration kernel interface
+ * Copyright (c) 2016, Jouni Malinen <j@w1.fi>
+ *
+ * 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 */