188 lines
6.2 KiB
C
188 lines
6.2 KiB
C
/* wrnad_svconfig.h - 802.1ad VLAN stacking shell command header file */
|
|
|
|
/*
|
|
* Copyright (c) 2010 Wind River Systems, Inc.
|
|
*
|
|
* The right to copy, distribute or otherwise make use of this software
|
|
* may be licensed only pursuant to the terms of an applicable Wind River
|
|
* license agreement. No license to Wind River intellectual property rights
|
|
* is granted herein. All rights not licensed by Wind River are reserved
|
|
* by Wind River.
|
|
*/
|
|
|
|
/*
|
|
modification history
|
|
--------------------
|
|
01a,22jan10,tlu Created.
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 1 DESCRIPTION
|
|
****************************************************************************
|
|
* Configure 802.1ad VLAN stacking.
|
|
*/
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 2 CONFIGURATION
|
|
****************************************************************************
|
|
*/
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 3 INCLUDE FILES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <arpa/inet.h>
|
|
#include <linux/netlink.h>
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 4 DEFINES
|
|
****************************************************************************
|
|
*/
|
|
|
|
#define SVCONFIG_CMD_HELP 0 /* Display help message */
|
|
#define SVCONFIG_CMD_SHOW 1 /* Show service TPID */
|
|
#define SVCONFIG_CMD_SET_STPID 2 /* Set service TPID */
|
|
#define SVCONFIG_CMD_CONF 3 /* Configure VLAN stacking */
|
|
#define SVCONFIG_CMD_DEL 4 /* Delete VLAN stacking */
|
|
#define SVCONFIG_CMD_PVID_CONF 5 /* Configure PVID */
|
|
#define SVCONFIG_CMD_IN_CONF 6 /* Configure ingress rule */
|
|
#define SVCONFIG_CMD_OUT_CONF 7 /* Configure egress rule */
|
|
#define SVCONFIG_CMD_PRI_MAP_CONF 8 /* Configure priority mapping */
|
|
|
|
/* The maximum length of a network interface name */
|
|
#define IFNAMESIZE 16
|
|
|
|
/* VLAN stacking netlink msg types */
|
|
#define RTM_SET_SVLAN 120
|
|
#define RTM_DEL_SVLAN 121
|
|
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* 5 TYPES
|
|
****************************************************************************
|
|
*/
|
|
|
|
typedef struct cmd_int_str_map_struct
|
|
{
|
|
int key;
|
|
const char *str;
|
|
}
|
|
cmd_int_str_map;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* VLAN stacking cmd types
|
|
*===========================================================================
|
|
*/
|
|
typedef enum {
|
|
VLAN_SET_STPID = 1, /* Set service VLAN TPID */
|
|
VLAN_SET_SVLAN, /* Set VLAN stacking on an eth interface */
|
|
VLAN_SET_PVID, /* Set PVID */
|
|
VLAN_SET_PRI_MAP, /* Set VLAN priority map */
|
|
VLAN_SET_INGRESS, /* Set VLAN ingress rule */
|
|
VLAN_SET_EGRESS /* Set VLAN egress rule */
|
|
} vlan_cmd_type;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* VLAN stacking port types
|
|
*===========================================================================
|
|
*/
|
|
typedef enum {
|
|
VLAN_NOT_DEFINED = 0, /* VLAN stacking not defined */
|
|
VLAN_CS_VLAN, /* customer edge/network port */
|
|
VLAN_SC_VLAN, /* provider network port on provider edge */
|
|
VLAN_S_VLAN, /* provider network port on S-VLAN node */
|
|
} vlan_port_type;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Ingress rules
|
|
*===========================================================================
|
|
*/
|
|
typedef enum {
|
|
VLAN_INGRESS_ADMIT_ALL = 0, /* Admit all frames */
|
|
VLAN_INGRESS_ADMIT_TAG, /* Admit only VLAN-tagged frames */
|
|
VLAN_INGRESS_ADMIT_OTHER /* Admit only Untagged and
|
|
Prioirty-tagged frames */
|
|
} vlan_ingress_type;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* Egress rules
|
|
*===========================================================================
|
|
*/
|
|
typedef enum {
|
|
VLAN_EGRESS_TAGGED = 0,
|
|
VLAN_EGRESS_UNTAGGED
|
|
} vlan_egress_type;
|
|
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* vlannetreq - S-VLAN netlink config structure
|
|
*===========================================================================
|
|
* S-VLAN netlink config structure.
|
|
*/
|
|
typedef struct vlannetreq_struct
|
|
{
|
|
unsigned char family;
|
|
unsigned int ifindex;
|
|
vlan_cmd_type cmd; /* VLAN stacking configuration cmd */
|
|
vlan_port_type type; /* VLAN stacking port type */
|
|
unsigned short int tag; /* 12-bit C-VID, 1..4094, 0 for undefined, */
|
|
unsigned short int stag; /* 12-bit S-VID, 1..4094, 0 for undefined, */
|
|
vlan_ingress_type inrule; /* VLAN ingress rule */
|
|
vlan_egress_type outrule; /* VLAN egress rule */
|
|
unsigned char pri; /* 3-bit rcv VLAN priority, 0..7 */
|
|
unsigned char spri; /* 3-bit service pri mapped from rcv pri */
|
|
unsigned short int stpid; /* 16 bit service TPID */
|
|
}
|
|
vlannetreq;
|
|
|
|
|
|
/*
|
|
*===========================================================================
|
|
* vlannetlink - netlink msg
|
|
*===========================================================================
|
|
* Configuration structure for S-VLAN netlink msg.
|
|
*/
|
|
typedef struct vlannetlink_struct
|
|
{
|
|
struct nlmsghdr nlh;
|
|
vlannetreq vlan_conf;
|
|
}
|
|
vlannetlink;
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* Functions
|
|
****************************************************************************
|
|
*/
|
|
int wrnad_rtnl_svlan_handler(struct nlmsghdr *nlh);
|
|
|
|
|
|
/*
|
|
****************************************************************************
|
|
* END OF FILE
|
|
****************************************************************************
|
|
*/
|