1/*- 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * Author: Harti Brandt <harti@freebsd.org> 28 */ 29 30/* 31 * Netgraph module to connect NATM interfaces to netgraph. 32 * 33 * $FreeBSD$ 34 */ 35#ifndef _NETGRAPH_ATM_NG_ATM_H_ 36#define _NETGRAPH_ATM_NG_ATM_H_ 37 38#define NG_ATM_NODE_TYPE "atm" 39#define NGM_ATM_COOKIE 960802260 40 41/* Netgraph control messages */ 42enum { 43 NGM_ATM_GET_IFNAME = 1, /* get the interface name */ 44 NGM_ATM_GET_CONFIG, /* get configuration */ 45 NGM_ATM_GET_VCCS, /* get a list of all active vccs */ 46 NGM_ATM_CPCS_INIT, /* start the channel */ 47 NGM_ATM_CPCS_TERM, /* stop the channel */ 48 NGM_ATM_GET_VCC, /* get VCC config */ 49 NGM_ATM_GET_VCCID, /* get VCC by VCI/VPI */ 50 NGM_ATM_GET_STATS, /* get global statistics */ 51 52 /* messages from the node */ 53 NGM_ATM_CARRIER_CHANGE = 1000, /* UNUSED: carrier changed */ 54 NGM_ATM_VCC_CHANGE, /* permanent VCC changed */ 55 NGM_ATM_ACR_CHANGE, /* ABR ACR has changed */ 56 NGM_ATM_IF_CHANGE, /* interface state change */ 57}; 58 59/* 60 * Hardware interface configuration 61 */ 62struct ngm_atm_config { 63 uint32_t pcr; /* peak cell rate */ 64 uint32_t vpi_bits; /* number of active VPI bits */ 65 uint32_t vci_bits; /* number of active VCI bits */ 66 uint32_t max_vpcs; /* maximum number of VPCs */ 67 uint32_t max_vccs; /* maximum number of VCCs */ 68}; 69#define NGM_ATM_CONFIG_INFO \ 70 { \ 71 { "pcr", &ng_parse_uint32_type }, \ 72 { "vpi_bits", &ng_parse_uint32_type }, \ 73 { "vci_bits", &ng_parse_uint32_type }, \ 74 { "max_vpcs", &ng_parse_uint32_type }, \ 75 { "max_vccs", &ng_parse_uint32_type }, \ 76 { NULL } \ 77 } 78 79/* 80 * Information about an open VCC 81 * See net/if_atm.h. Keep in sync. 82 */ 83#define NGM_ATM_TPARAM_INFO \ 84 { \ 85 { "pcr", &ng_parse_uint32_type }, \ 86 { "scr", &ng_parse_uint32_type }, \ 87 { "mbs", &ng_parse_uint32_type }, \ 88 { "mcr", &ng_parse_uint32_type }, \ 89 { "icr", &ng_parse_uint32_type }, \ 90 { "tbe", &ng_parse_uint32_type }, \ 91 { "nrm", &ng_parse_uint8_type }, \ 92 { "trm", &ng_parse_uint8_type }, \ 93 { "adtf", &ng_parse_uint16_type }, \ 94 { "rif", &ng_parse_uint8_type }, \ 95 { "rdf", &ng_parse_uint8_type }, \ 96 { "cdf", &ng_parse_uint8_type }, \ 97 { NULL } \ 98 } 99 100#define NGM_ATM_VCC_INFO \ 101 { \ 102 { "flags", &ng_parse_hint16_type }, \ 103 { "vpi", &ng_parse_uint16_type }, \ 104 { "vci", &ng_parse_uint16_type }, \ 105 { "rmtu", &ng_parse_uint16_type }, \ 106 { "tmtu", &ng_parse_uint16_type }, \ 107 { "aal", &ng_parse_uint8_type }, \ 108 { "traffic", &ng_parse_uint8_type }, \ 109 { "tparam", &ng_atm_tparam_type }, \ 110 { NULL } \ 111 } 112 113#define NGM_ATM_VCCARRAY_INFO \ 114 { \ 115 &ng_atm_vcc_type, \ 116 ng_atm_vccarray_getlen, \ 117 NULL \ 118 } 119 120#define NGM_ATM_VCCTABLE_INFO \ 121 { \ 122 { "count", &ng_parse_uint32_type }, \ 123 { "vccs", &ng_atm_vccarray_type }, \ 124 { NULL } \ 125 } 126 127/* 128 * Structure to open a VCC. 129 */ 130struct ngm_atm_cpcs_init { 131 char name[NG_HOOKSIZ]; 132 uint32_t flags; /* flags. (if_atm.h) */ 133 uint16_t vci; /* VCI to open */ 134 uint16_t vpi; /* VPI to open */ 135 uint16_t rmtu; /* Receive maximum CPCS size */ 136 uint16_t tmtu; /* Transmit maximum CPCS size */ 137 uint8_t aal; /* AAL type (if_atm.h) */ 138 uint8_t traffic; /* traffic type (if_atm.h) */ 139 uint32_t pcr; /* Peak cell rate */ 140 uint32_t scr; /* VBR: Sustainable cell rate */ 141 uint32_t mbs; /* VBR: Maximum burst rate */ 142 uint32_t mcr; /* UBR+: Minimum cell rate */ 143 uint32_t icr; /* ABR: Initial cell rate */ 144 uint32_t tbe; /* ABR: Transmit buffer exposure */ 145 uint8_t nrm; /* ABR: Nrm */ 146 uint8_t trm; /* ABR: Trm */ 147 uint16_t adtf; /* ABR: ADTF */ 148 uint8_t rif; /* ABR: RIF */ 149 uint8_t rdf; /* ABR: RDF */ 150 uint8_t cdf; /* ABR: CDF */ 151}; 152 153#define NGM_ATM_CPCS_INIT_INFO \ 154 { \ 155 { "name", &ng_parse_hookbuf_type }, \ 156 { "flags", &ng_parse_hint32_type }, \ 157 { "vci", &ng_parse_uint16_type }, \ 158 { "vpi", &ng_parse_uint16_type }, \ 159 { "rmtu", &ng_parse_uint16_type }, \ 160 { "tmtu", &ng_parse_uint16_type }, \ 161 { "aal", &ng_parse_uint8_type }, \ 162 { "traffic", &ng_parse_uint8_type }, \ 163 { "pcr", &ng_parse_uint32_type }, \ 164 { "scr", &ng_parse_uint32_type }, \ 165 { "mbs", &ng_parse_uint32_type }, \ 166 { "mcr", &ng_parse_uint32_type }, \ 167 { "icr", &ng_parse_uint32_type }, \ 168 { "tbe", &ng_parse_uint32_type }, \ 169 { "nrm", &ng_parse_uint8_type }, \ 170 { "trm", &ng_parse_uint8_type }, \ 171 { "adtf", &ng_parse_uint16_type }, \ 172 { "rif", &ng_parse_uint8_type }, \ 173 { "rdf", &ng_parse_uint8_type }, \ 174 { "cdf", &ng_parse_uint8_type }, \ 175 { NULL } \ 176 } 177 178/* 179 * Structure to close a VCI without disconnecting the hook 180 */ 181struct ngm_atm_cpcs_term { 182 char name[NG_HOOKSIZ]; 183}; 184#define NGM_ATM_CPCS_TERM_INFO \ 185 { \ 186 { "name", &ng_parse_hookbuf_type }, \ 187 { NULL } \ 188 } 189 190struct ngm_atm_stats { 191 uint64_t in_packets; 192 uint64_t in_errors; 193 uint64_t out_packets; 194 uint64_t out_errors; 195}; 196#define NGM_ATM_STATS_INFO \ 197 { \ 198 { "in_packets", &ng_parse_uint64_type }, \ 199 { "in_errors", &ng_parse_uint64_type }, \ 200 { "out_packets", &ng_parse_uint64_type }, \ 201 { "out_errors", &ng_parse_uint64_type }, \ 202 { NULL } \ 203 } 204 205struct ngm_atm_if_change { 206 uint32_t node; 207 uint8_t carrier; 208 uint8_t running; 209}; 210#define NGM_ATM_IF_CHANGE_INFO \ 211 { \ 212 { "node", &ng_parse_hint32_type }, \ 213 { "carrier", &ng_parse_uint8_type }, \ 214 { "running", &ng_parse_uint8_type }, \ 215 { NULL } \ 216 } 217 218struct ngm_atm_vcc_change { 219 uint32_t node; 220 uint16_t vci; 221 uint8_t vpi; 222 uint8_t state; 223}; 224#define NGM_ATM_VCC_CHANGE_INFO \ 225 { \ 226 { "node", &ng_parse_hint32_type }, \ 227 { "vci", &ng_parse_uint16_type }, \ 228 { "vpi", &ng_parse_uint8_type }, \ 229 { "state", &ng_parse_uint8_type }, \ 230 { NULL } \ 231 } 232 233struct ngm_atm_acr_change { 234 uint32_t node; 235 uint16_t vci; 236 uint8_t vpi; 237 uint32_t acr; 238}; 239#define NGM_ATM_ACR_CHANGE_INFO \ 240 { \ 241 { "node", &ng_parse_hint32_type }, \ 242 { "vci", &ng_parse_uint16_type }, \ 243 { "vpi", &ng_parse_uint8_type }, \ 244 { "acr", &ng_parse_uint32_type }, \ 245 { NULL } \ 246 } 247 248#endif /* _NETGRAPH_ATM_NG_ATM_H */ 249