1126447Sru/*- 2126447Sru * Copyright (c) 2003 IPNET Internet Communication Company 3232825Sadrian * Copyright (c) 2011 - 2012 Rozhuk Ivan <rozhuk.im@gmail.com> 4126447Sru * All rights reserved. 5126447Sru * 6126447Sru * Redistribution and use in source and binary forms, with or without 7126447Sru * modification, are permitted provided that the following conditions 8126447Sru * are met: 9126447Sru * 1. Redistributions of source code must retain the above copyright 10126447Sru * notice, this list of conditions and the following disclaimer. 11126447Sru * 2. Redistributions in binary form must reproduce the above copyright 12126447Sru * notice, this list of conditions and the following disclaimer in the 13126447Sru * documentation and/or other materials provided with the distribution. 14126447Sru * 15126447Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16126447Sru * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17126447Sru * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18126447Sru * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19126447Sru * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20126447Sru * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21126447Sru * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22126447Sru * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23126447Sru * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24126447Sru * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25126447Sru * SUCH DAMAGE. 26126447Sru * 27126447Sru * Author: Ruslan Ermilov <ru@FreeBSD.org> 28126447Sru * 29126447Sru * $FreeBSD$ 30126447Sru */ 31126447Sru 32126447Sru#ifndef _NETGRAPH_NG_VLAN_H_ 33126447Sru#define _NETGRAPH_NG_VLAN_H_ 34126447Sru 35232825Sadrian/* Using "vlan" in addfilter and gettable messages. 2012.01 */ 36232825Sadrian#define NG_VLAN_USE_OLD_VLAN_NAME 1 37232825Sadrian 38126447Sru/* Node type name and magic cookie. */ 39126447Sru#define NG_VLAN_NODE_TYPE "vlan" 40126447Sru#define NGM_VLAN_COOKIE 1068486472 41126447Sru 42126447Sru/* Hook names. */ 43126447Sru#define NG_VLAN_HOOK_DOWNSTREAM "downstream" 44126447Sru#define NG_VLAN_HOOK_NOMATCH "nomatch" 45126447Sru 46126447Sru/* Netgraph commands. */ 47126447Sruenum { 48126447Sru NGM_VLAN_ADD_FILTER = 1, 49126447Sru NGM_VLAN_DEL_FILTER, 50232825Sadrian NGM_VLAN_GET_TABLE, 51232825Sadrian NGM_VLAN_DEL_VID_FLT, 52232825Sadrian NGM_VLAN_GET_DECAP, 53232825Sadrian NGM_VLAN_SET_DECAP, 54232825Sadrian NGM_VLAN_GET_ENCAP, 55232825Sadrian NGM_VLAN_SET_ENCAP, 56232825Sadrian NGM_VLAN_GET_ENCAP_PROTO, 57232825Sadrian NGM_VLAN_SET_ENCAP_PROTO, 58126447Sru}; 59126447Sru 60232825Sadrian#define VLAN_ENCAP_FROM_FILTER 0x00000001 61232825Sadrian#define VLAN_ENCAP_FROM_NOMATCH 0x00000002 62232825Sadrian 63126447Sru/* For NGM_VLAN_ADD_FILTER control message. */ 64126447Srustruct ng_vlan_filter { 65232825Sadrian char hook_name[NG_HOOKSIZ]; 66232825Sadrian#ifdef NG_VLAN_USE_OLD_VLAN_NAME 67232825Sadrian uint16_t vlan; /* VLAN - same as vid, oldname, deprecated. */ 68232825Sadrian#endif 69232825Sadrian uint16_t vid; /* VID - VLAN Identifier. */ 70232825Sadrian uint8_t pcp; /* PCP - Priority Code Point. */ 71232825Sadrian uint8_t cfi; /* CFI - Canonical Format Indicator. */ 72232825Sadrian}; 73126447Sru 74126447Sru/* Keep this in sync with the above structure definition. */ 75232825Sadrian#ifdef NG_VLAN_USE_OLD_VLAN_NAME 76126447Sru#define NG_VLAN_FILTER_FIELDS { \ 77232825Sadrian { "hook", &ng_parse_hookbuf_type }, \ 78232825Sadrian { "vlan", &ng_parse_uint16_type }, \ 79232825Sadrian { "vid", &ng_parse_uint16_type }, \ 80232825Sadrian { "pcp", &ng_parse_uint8_type }, \ 81232825Sadrian { "cfi", &ng_parse_uint8_type }, \ 82126447Sru { NULL } \ 83126447Sru} 84232825Sadrian#else 85232825Sadrian#define NG_VLAN_FILTER_FIELDS { \ 86232825Sadrian { "hook", &ng_parse_hookbuf_type }, \ 87232825Sadrian { "vid", &ng_parse_uint16_type }, \ 88232825Sadrian { "pcp", &ng_parse_uint8_type }, \ 89232825Sadrian { "cfi", &ng_parse_uint8_type }, \ 90232825Sadrian { NULL } \ 91232825Sadrian} 92232825Sadrian#endif 93126447Sru 94232825Sadrian 95126447Sru/* Structure returned by NGM_VLAN_GET_TABLE. */ 96126447Srustruct ng_vlan_table { 97126447Sru u_int32_t n; 98151800Sru struct ng_vlan_filter filter[]; 99126447Sru}; 100126447Sru 101126447Sru/* Keep this in sync with the above structure definition. */ 102126447Sru#define NG_VLAN_TABLE_FIELDS { \ 103126447Sru { "n", &ng_parse_uint32_type }, \ 104126447Sru { "filter", &ng_vlan_table_array_type }, \ 105126447Sru { NULL } \ 106126447Sru} 107126447Sru 108126447Sru#endif /* _NETGRAPH_NG_VLAN_H_ */ 109