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>
This commit is contained in:
parent
81606ab73b
commit
c815fab83a
3 changed files with 56 additions and 12 deletions
|
@ -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"
|
||||
|
|
|
@ -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,
|
||||
|
|
52
src/common/linux_vlan.h
Normal file
52
src/common/linux_vlan.h
Normal file
|
@ -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 */
|
Loading…
Reference in a new issue