diff --git a/src/include.new/netgraph/atm/ng_atm.h b/src/include.new/netgraph/atm/ng_atm.h new file mode 100644 index 0000000..4b40657 --- /dev/null +++ b/src/include.new/netgraph/atm/ng_atm.h @@ -0,0 +1,248 @@ +/*- + * Copyright (c) 2001-2003 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Harti Brandt + */ + +/* + * Netgraph module to connect NATM interfaces to netgraph. + * + * $FreeBSD: src/sys/netgraph/atm/ng_atm.h,v 1.5 2005/01/07 01:45:40 imp Exp $ + */ +#ifndef _NETGRAPH_ATM_NG_ATM_H_ +#define _NETGRAPH_ATM_NG_ATM_H_ + +#define NG_ATM_NODE_TYPE "atm" +#define NGM_ATM_COOKIE 960802260 + +/* Netgraph control messages */ +enum { + NGM_ATM_GET_IFNAME = 1, /* get the interface name */ + NGM_ATM_GET_CONFIG, /* get configuration */ + NGM_ATM_GET_VCCS, /* get a list of all active vccs */ + NGM_ATM_CPCS_INIT, /* start the channel */ + NGM_ATM_CPCS_TERM, /* stop the channel */ + NGM_ATM_GET_VCC, /* get VCC config */ + NGM_ATM_GET_VCCID, /* get VCC by VCI/VPI */ + NGM_ATM_GET_STATS, /* get global statistics */ + + /* messages from the node */ + NGM_ATM_CARRIER_CHANGE = 1000, /* UNUSED: carrier changed */ + NGM_ATM_VCC_CHANGE, /* permanent VCC changed */ + NGM_ATM_ACR_CHANGE, /* ABR ACR has changed */ + NGM_ATM_IF_CHANGE, /* interface state change */ +}; + +/* + * Hardware interface configuration + */ +struct ngm_atm_config { + uint32_t pcr; /* peak cell rate */ + uint32_t vpi_bits; /* number of active VPI bits */ + uint32_t vci_bits; /* number of active VCI bits */ + uint32_t max_vpcs; /* maximum number of VPCs */ + uint32_t max_vccs; /* maximum number of VCCs */ +}; +#define NGM_ATM_CONFIG_INFO \ + { \ + { "pcr", &ng_parse_uint32_type }, \ + { "vpi_bits", &ng_parse_uint32_type }, \ + { "vci_bits", &ng_parse_uint32_type }, \ + { "max_vpcs", &ng_parse_uint32_type }, \ + { "max_vccs", &ng_parse_uint32_type }, \ + { NULL } \ + } + +/* + * Information about an open VCC + * See net/if_atm.h. Keep in sync. + */ +#define NGM_ATM_TPARAM_INFO \ + { \ + { "pcr", &ng_parse_uint32_type }, \ + { "scr", &ng_parse_uint32_type }, \ + { "mbs", &ng_parse_uint32_type }, \ + { "mcr", &ng_parse_uint32_type }, \ + { "icr", &ng_parse_uint32_type }, \ + { "tbe", &ng_parse_uint32_type }, \ + { "nrm", &ng_parse_uint8_type }, \ + { "trm", &ng_parse_uint8_type }, \ + { "adtf", &ng_parse_uint16_type }, \ + { "rif", &ng_parse_uint8_type }, \ + { "rdf", &ng_parse_uint8_type }, \ + { "cdf", &ng_parse_uint8_type }, \ + { NULL } \ + } + +#define NGM_ATM_VCC_INFO \ + { \ + { "flags", &ng_parse_hint16_type }, \ + { "vpi", &ng_parse_uint16_type }, \ + { "vci", &ng_parse_uint16_type }, \ + { "rmtu", &ng_parse_uint16_type }, \ + { "tmtu", &ng_parse_uint16_type }, \ + { "aal", &ng_parse_uint8_type }, \ + { "traffic", &ng_parse_uint8_type }, \ + { "tparam", &ng_atm_tparam_type }, \ + { NULL } \ + } + +#define NGM_ATM_VCCARRAY_INFO \ + { \ + &ng_atm_vcc_type, \ + ng_atm_vccarray_getlen, \ + NULL \ + } + +#define NGM_ATM_VCCTABLE_INFO \ + { \ + { "count", &ng_parse_uint32_type }, \ + { "vccs", &ng_atm_vccarray_type }, \ + { NULL } \ + } + +/* + * Structure to open a VCC. + */ +struct ngm_atm_cpcs_init { + char name[NG_HOOKSIZ]; + uint32_t flags; /* flags. (if_atm.h) */ + uint16_t vci; /* VCI to open */ + uint16_t vpi; /* VPI to open */ + uint16_t rmtu; /* Receive maximum CPCS size */ + uint16_t tmtu; /* Transmit maximum CPCS size */ + uint8_t aal; /* AAL type (if_atm.h) */ + uint8_t traffic; /* traffic type (if_atm.h) */ + uint32_t pcr; /* Peak cell rate */ + uint32_t scr; /* VBR: Sustainable cell rate */ + uint32_t mbs; /* VBR: Maximum burst rate */ + uint32_t mcr; /* UBR+: Minimum cell rate */ + uint32_t icr; /* ABR: Initial cell rate */ + uint32_t tbe; /* ABR: Transmit buffer exposure */ + uint8_t nrm; /* ABR: Nrm */ + uint8_t trm; /* ABR: Trm */ + uint16_t adtf; /* ABR: ADTF */ + uint8_t rif; /* ABR: RIF */ + uint8_t rdf; /* ABR: RDF */ + uint8_t cdf; /* ABR: CDF */ +}; + +#define NGM_ATM_CPCS_INIT_INFO \ + { \ + { "name", &ng_parse_hookbuf_type }, \ + { "flags", &ng_parse_hint32_type }, \ + { "vci", &ng_parse_uint16_type }, \ + { "vpi", &ng_parse_uint16_type }, \ + { "rmtu", &ng_parse_uint16_type }, \ + { "tmtu", &ng_parse_uint16_type }, \ + { "aal", &ng_parse_uint8_type }, \ + { "traffic", &ng_parse_uint8_type }, \ + { "pcr", &ng_parse_uint32_type }, \ + { "scr", &ng_parse_uint32_type }, \ + { "mbs", &ng_parse_uint32_type }, \ + { "mcr", &ng_parse_uint32_type }, \ + { "icr", &ng_parse_uint32_type }, \ + { "tbe", &ng_parse_uint32_type }, \ + { "nrm", &ng_parse_uint8_type }, \ + { "trm", &ng_parse_uint8_type }, \ + { "adtf", &ng_parse_uint16_type }, \ + { "rif", &ng_parse_uint8_type }, \ + { "rdf", &ng_parse_uint8_type }, \ + { "cdf", &ng_parse_uint8_type }, \ + { NULL } \ + } + +/* + * Structure to close a VCI without disconnecting the hook + */ +struct ngm_atm_cpcs_term { + char name[NG_HOOKSIZ]; +}; +#define NGM_ATM_CPCS_TERM_INFO \ + { \ + { "name", &ng_parse_hookbuf_type }, \ + { NULL } \ + } + +struct ngm_atm_stats { + uint64_t in_packets; + uint64_t in_errors; + uint64_t out_packets; + uint64_t out_errors; +}; +#define NGM_ATM_STATS_INFO \ + { \ + { "in_packets", &ng_parse_uint64_type }, \ + { "in_errors", &ng_parse_uint64_type }, \ + { "out_packets", &ng_parse_uint64_type }, \ + { "out_errors", &ng_parse_uint64_type }, \ + { NULL } \ + } + +struct ngm_atm_if_change { + uint32_t node; + uint8_t carrier; + uint8_t running; +}; +#define NGM_ATM_IF_CHANGE_INFO \ + { \ + { "node", &ng_parse_hint32_type }, \ + { "carrier", &ng_parse_uint8_type }, \ + { "running", &ng_parse_uint8_type }, \ + { NULL } \ + } + +struct ngm_atm_vcc_change { + uint32_t node; + uint16_t vci; + uint8_t vpi; + uint8_t state; +}; +#define NGM_ATM_VCC_CHANGE_INFO \ + { \ + { "node", &ng_parse_hint32_type }, \ + { "vci", &ng_parse_uint16_type }, \ + { "vpi", &ng_parse_uint8_type }, \ + { "state", &ng_parse_uint8_type }, \ + { NULL } \ + } + +struct ngm_atm_acr_change { + uint32_t node; + uint16_t vci; + uint8_t vpi; + uint32_t acr; +}; +#define NGM_ATM_ACR_CHANGE_INFO \ + { \ + { "node", &ng_parse_hint32_type }, \ + { "vci", &ng_parse_uint16_type }, \ + { "vpi", &ng_parse_uint8_type }, \ + { "acr", &ng_parse_uint32_type }, \ + { NULL } \ + } + +#endif /* _NETGRAPH_ATM_NG_ATM_H */ diff --git a/src/include.new/netgraph/atm/ng_atmpif.h b/src/include.new/netgraph/atm/ng_atmpif.h new file mode 100644 index 0000000..70fb211 --- /dev/null +++ b/src/include.new/netgraph/atm/ng_atmpif.h @@ -0,0 +1,175 @@ +/*- + * Copyright (c) 2003 Harti Brandt. + * Copyright (c) 2003 Vincent Jardin. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ng_atmpif.h,v 1.2 2005/01/07 01:45:40 imp Exp $ + */ + +#ifndef _NETGRAPH_ATM_NG_ATMPIF_H_ +#define _NETGRAPH_ATM_NG_ATMPIF_H_ + +/* Node type name and magic cookie */ +#define NG_ATMPIF_NODE_TYPE "atmpif" +#define NGM_ATMPIF_COOKIE 967239456 + +/* + * Physical device name - used to configure HARP devices + */ +#ifndef VATMPIF_DEV_NAME +#define VATMPIF_DEV_NAME "hva" /* HARP Virtual ATM */ +#endif + +#define VATMPIF_MAX_VCI 65535 +#define VATMPIF_MAX_VPI 255 + +/* Hook name */ +#define NG_ATMPIF_HOOK_LINK "link" /* virtual link hook */ + +/* + * Node configuration structure + */ +struct ng_vatmpif_config { + uint8_t debug; /* debug bit field (see below) */ + uint32_t pcr; /* peak cell rate */ + Mac_addr macaddr; /* Mac Address */ +}; +/* Keep this in sync with the above structure definition */ +#define NG_ATMPIF_CONFIG_TYPE_INFO { \ + { "debug", &ng_parse_uint8_type }, \ + { "pcr", &ng_parse_uint32_type }, \ + { "macaddr", &ng_mac_addr_type }, \ + { NULL } \ +} + +/* + * Debug bit-fields + */ +#define VATMPIF_DEBUG_NONE 0x00 +#define VATMPIF_DEBUG_PACKET 0x01 /* enable ng_atmpif debugging */ + +#define IS_VATMPIF_DEBUG_PACKET(a) ( (a) \ + && ((a)->conf.debug & VATMPIF_DEBUG_PACKET) ) + +/* + * Statistics + */ +struct hva_stats_ng { + uint32_t ng_errseq; /* Duplicate or out of order */ + uint32_t ng_lostpdu; /* PDU lost detected */ + uint32_t ng_badpdu; /* Unknown PDU type */ + uint32_t ng_rx_novcc; /* Draining PDU on closed VCC */ + uint32_t ng_rx_iqfull; /* PDU drops, no room in atm_intrq */ + uint32_t ng_tx_rawcell; /* PDU raw cells transmitted */ + uint32_t ng_rx_rawcell; /* PDU raw cells received */ + uint64_t ng_tx_pdu; /* PDU transmitted */ + uint64_t ng_rx_pdu; /* PDU received */ +}; +typedef struct hva_stats_ng Hva_Stats_ng; +/* Keep this in sync with the above structure definition */ +#define HVA_STATS_NG_TYPE_INFO \ + { "errSeqOrder", &ng_parse_uint32_type }, \ + { "errLostPDU", &ng_parse_uint32_type }, \ + { "recvBadPDU", &ng_parse_uint32_type }, \ + { "ErrATMVC", &ng_parse_uint32_type }, \ + { "ErrQfull", &ng_parse_uint32_type }, \ + { "xmitRawCell", &ng_parse_uint32_type }, \ + { "recvRawCell", &ng_parse_uint32_type }, \ + { "xmitPDU", &ng_parse_uint64_type }, \ + { "recvPDU", &ng_parse_uint64_type }, + + +struct hva_stats_atm { + uint64_t atm_xmit; /* Cells transmitted */ + uint64_t atm_rcvd; /* Cells received */ +}; +typedef struct hva_stats_atm Hva_Stats_atm; +/* Keep this in sync with the above structure definition */ +#define HVA_STATS_ATM_NG_TYPE_INFO \ + { "xmitATMCells", &ng_parse_uint64_type }, \ + { "recvATMCells", &ng_parse_uint64_type }, + +struct hva_stats_aal5 { + uint64_t aal5_xmit; /* Cells transmitted */ + uint64_t aal5_rcvd; /* Cells received */ + uint32_t aal5_crc_len; /* Cells with CRC/length errors */ + uint32_t aal5_drops; /* Cell drops */ + uint64_t aal5_pdu_xmit; /* CS PDUs transmitted */ + uint64_t aal5_pdu_rcvd; /* CS PDUs received */ + uint32_t aal5_pdu_crc; /* CS PDUs with CRC errors */ + uint32_t aal5_pdu_errs; /* CS layer protocol errors */ + uint32_t aal5_pdu_drops; /* CS PDUs dropped */ +}; +typedef struct hva_stats_aal5 Hva_Stats_aal5; +/* Keep this in sync with the above structure definition */ +#define HVA_STATS_AAL5_NG_TYPE_INFO \ + { "xmitAAL5Cells", &ng_parse_uint64_type }, \ + { "recvAAL5Cells", &ng_parse_uint64_type }, \ + { "AAL5ErrCRCCells", &ng_parse_uint32_type }, \ + { "AAL5DropsCells", &ng_parse_uint32_type }, \ + { "xmitAAL5PDU", &ng_parse_uint64_type }, \ + { "recvAAL5PDU", &ng_parse_uint64_type }, \ + { "AAL5CRCPDU", &ng_parse_uint32_type }, \ + { "AAL5ErrPDU", &ng_parse_uint32_type }, \ + { "AAL5DropsPDU", &ng_parse_uint32_type }, + +struct vatmpif_stats { + Hva_Stats_ng hva_st_ng; /* Netgraph layer stats */ + Hva_Stats_atm hva_st_atm; /* ATM layer stats */ + Hva_Stats_aal5 hva_st_aal5; /* AAL5 layer stats */ +}; +typedef struct vatmpif_stats Vatmpif_stats; +/* Keep this in sync with the above structure definition */ +#define NG_ATMPIF_STATS_TYPE_INFO { \ + HVA_STATS_NG_TYPE_INFO \ + HVA_STATS_ATM_NG_TYPE_INFO \ + HVA_STATS_AAL5_NG_TYPE_INFO \ + { NULL } \ +} + +/* Structure returned by NGM_ATMPIF_GET_LINK_STATUS */ +struct ng_atmpif_link_status { + uint32_t InSeq; /* last received sequence number + 1 */ + uint32_t OutSeq; /* last sent sequence number */ + uint32_t cur_pcr; /* slot's reserved PCR */ +}; +/* Keep this in sync with the above structure definition */ +#define NG_ATMPIF_LINK_STATUS_TYPE_INFO { \ + { "InSeq", &ng_parse_uint32_type }, \ + { "OutSeq", &ng_parse_uint32_type }, \ + { "cur_pcr", &ng_parse_uint32_type }, \ + { NULL } \ +} + +/* Netgraph control messages */ +enum { + NGM_ATMPIF_SET_CONFIG = 1, /* set node configuration */ + NGM_ATMPIF_GET_CONFIG, /* get node configuration */ + NGM_ATMPIF_GET_LINK_STATUS, /* get link status */ + NGM_ATMPIF_GET_STATS, /* get link stats */ + NGM_ATMPIF_CLR_STATS, /* clear link stats */ + NGM_ATMPIF_GETCLR_STATS, /* atomically get & clear link stats */ +}; + +#endif /* _NETGRAPH_NG_ATMPIF_H_ */ diff --git a/src/include.new/netgraph/atm/ng_ccatm.h b/src/include.new/netgraph/atm/ng_ccatm.h new file mode 100644 index 0000000..b0ab97a --- /dev/null +++ b/src/include.new/netgraph/atm/ng_ccatm.h @@ -0,0 +1,172 @@ +/*- + * Copyright (c) 2001-2002 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * Copyright (c) 2003-2004 + * Hartmut Brandt + * All rights reserved. + * + * Author: Harti Brandt + * + * Redistribution of this software and documentation and use in source and + * binary forms, with or without modification, are permitted provided that + * the following conditions are met: + * + * 1. Redistributions of source code or documentation must retain the above + * copyright notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ng_ccatm.h,v 1.2 2005/01/07 01:45:40 imp Exp $ + */ + +/* + * Interface to ng_ccatm + */ +#ifndef _NETGRAPH_ATM_NG_CCATM_H_ +#define _NETGRAPH_ATM_NG_CCATM_H_ + +#define NG_CCATM_NODE_TYPE "ccatm" +#define NGM_CCATM_COOKIE 984046139 + +enum { + NGM_CCATM_DUMP, /* dump internal status */ + NGM_CCATM_STOP, /* stop all processing, close all */ + NGM_CCATM_START, /* start processing */ + NGM_CCATM_CLEAR, /* clear prefix/address table */ + NGM_CCATM_GET_ADDRESSES, /* get list of all addresses */ + NGM_CCATM_ADDRESS_REGISTERED, /* registration ok */ + NGM_CCATM_ADDRESS_UNREGISTERED, /* unregistration ok */ + NGM_CCATM_SET_PORT_PARAM, /* set port parameters */ + NGM_CCATM_GET_PORT_PARAM, /* get port parameters */ + NGM_CCATM_GET_PORTLIST, /* get list of port numbers */ + NGM_CCATM_GETSTATE, /* get port status */ + NGM_CCATM_SETLOG, /* set/get loglevel */ + NGM_CCATM_RESET, /* reset everything */ + NGM_CCATM_GET_EXSTAT, /* get extended status */ +}; + +/* + * This must be synchronized with unistruct.h::struct uni_addr + */ +#define NGM_CCATM_ADDR_ARRAY_INFO \ + { \ + &ng_parse_hint8_type, \ + UNI_ADDR_MAXLEN \ + } + +#define NGM_CCATM_UNI_ADDR_INFO \ + { \ + { "type", &ng_parse_uint32_type }, \ + { "plan", &ng_parse_uint32_type }, \ + { "len", &ng_parse_uint32_type }, \ + { "addr", &ng_ccatm_addr_array_type }, \ + { NULL } \ + } + +/* + * Address request + */ +struct ngm_ccatm_addr_req { + uint32_t port; + struct uni_addr addr; +}; +#define NGM_CCATM_ADDR_REQ_INFO \ + { \ + { "port", &ng_parse_uint32_type }, \ + { "addr", &ng_ccatm_uni_addr_type }, \ + { NULL }, \ + } + +/* + * Get current address list + */ +struct ngm_ccatm_get_addresses { + uint32_t count; + struct ngm_ccatm_addr_req addr[]; +}; +#define NGM_CCATM_ADDR_REQ_ARRAY_INFO \ + { \ + &ng_ccatm_addr_req_type, \ + ng_ccatm_addr_req_array_getlen \ + } +#define NGM_CCATM_GET_ADDRESSES_INFO \ + { \ + { "count", &ng_parse_uint32_type }, \ + { "addr", &ng_ccatm_addr_req_array_type }, \ + { NULL } \ + } + +/* + * Port as parameter + */ +struct ngm_ccatm_port { + uint32_t port; +}; +#define NGM_CCATM_PORT_INFO \ + { \ + { "port", &ng_parse_uint32_type }, \ + { NULL } \ + } + +/* + * Port parameters. + * This must be synchronized with atmapi.h::struct atm_port_info. + */ +#define NGM_CCATM_ESI_INFO \ + { \ + &ng_parse_hint8_type, \ + 6 \ + } +#define NGM_CCATM_ATM_PORT_INFO \ + { \ + { "port", &ng_parse_uint32_type }, \ + { "pcr", &ng_parse_uint32_type }, \ + { "max_vpi_bits", &ng_parse_uint32_type }, \ + { "max_vci_bits", &ng_parse_uint32_type }, \ + { "max_svpc_vpi", &ng_parse_uint32_type }, \ + { "max_svcc_vpi", &ng_parse_uint32_type }, \ + { "min_svcc_vci", &ng_parse_uint32_type }, \ + { "esi", &ng_ccatm_esi_type }, \ + { "num_addr", &ng_parse_uint32_type }, \ + { NULL } \ + } + +/* + * List of port numbers + */ +struct ngm_ccatm_portlist { + uint32_t nports; + uint32_t ports[]; +}; +#define NGM_CCATM_PORT_ARRAY_INFO \ + { \ + &ng_parse_uint32_type, \ + ng_ccatm_port_array_getlen \ + } +#define NGM_CCATM_PORTLIST_INFO \ + { \ + { "nports", &ng_parse_uint32_type }, \ + { "ports", &ng_ccatm_port_array_type }, \ + { NULL } \ + } + +struct ccatm_op { + uint32_t op; /* request code */ + u_char data[]; +}; + +#endif diff --git a/src/include.new/netgraph/atm/ng_sscfu.h b/src/include.new/netgraph/atm/ng_sscfu.h new file mode 100644 index 0000000..5a8950a --- /dev/null +++ b/src/include.new/netgraph/atm/ng_sscfu.h @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2001-2003 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * + * Author: Harti Brandt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ng_sscfu.h,v 1.2 2005/01/07 01:45:40 imp Exp $ + * + * Netgraph module for ITU-T Q.2120 UNI SSCF. + */ +#ifndef _NETGRAPH_ATM_NG_SSCFU_H_ +#define _NETGRAPH_ATM_NG_SSCFU_H_ + +#define NG_SSCFU_NODE_TYPE "sscfu" +#define NGM_SSCFU_COOKIE 980517963 + +/* Netgraph control messages */ +enum { + NGM_SSCFU_GETDEFPARAM = 1, /* get default SSCOP parameters */ + NGM_SSCFU_ENABLE, /* enable processing */ + NGM_SSCFU_DISABLE, /* disable processing */ + NGM_SSCFU_GETDEBUG, /* get debug flags */ + NGM_SSCFU_SETDEBUG, /* set debug flags */ + NGM_SSCFU_GETSTATE, /* get current state */ +}; + +/* getdefparam return */ +struct ng_sscfu_getdefparam { + struct sscop_param param; + uint32_t mask; +}; +#define NG_SSCFU_GETDEFPARAM_INFO \ + { \ + { "param", &ng_sscop_param_type }, \ + { "mask", &ng_parse_uint32_type }, \ + { NULL } \ + } + +/* + * Upper interface + */ +struct sscfu_arg { + uint32_t sig; + u_char data[]; +}; +#endif diff --git a/src/include.new/netgraph/atm/ng_sscop.h b/src/include.new/netgraph/atm/ng_sscop.h new file mode 100644 index 0000000..b4b2b3e --- /dev/null +++ b/src/include.new/netgraph/atm/ng_sscop.h @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2001-2003 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * + * Author: Harti Brandt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ng_sscop.h,v 1.3 2005/01/07 01:45:40 imp Exp $ + * + * Netgraph module for Q.2110 SSCOP + */ +#ifndef _NETGRAPH_ATM_NG_SSCOP_H_ +#define _NETGRAPH_ATM_NG_SSCOP_H_ + +#define NG_SSCOP_NODE_TYPE "sscop" +#define NGM_SSCOP_COOKIE 980175044 + +/* Netgraph control messages */ +enum { + NGM_SSCOP_GETPARAM = 1, /* get parameters */ + NGM_SSCOP_SETPARAM, /* set parameters */ + NGM_SSCOP_ENABLE, /* enable processing */ + NGM_SSCOP_DISABLE, /* disable and reset */ + NGM_SSCOP_GETDEBUG, /* get debugging flags */ + NGM_SSCOP_SETDEBUG, /* set debugging flags */ + NGM_SSCOP_GETSTATE, /* get current SSCOP state */ +}; + +/* This must be in-sync with the definition in sscopdef.h */ +#define NG_SSCOP_PARAM_INFO \ + { \ + { "timer_cc", &ng_parse_uint32_type }, \ + { "timer_poll", &ng_parse_uint32_type }, \ + { "timer_keep_alive", &ng_parse_uint32_type }, \ + { "timer_no_response",&ng_parse_uint32_type }, \ + { "timer_idle", &ng_parse_uint32_type }, \ + { "maxk", &ng_parse_uint32_type }, \ + { "maxj", &ng_parse_uint32_type }, \ + { "maxcc", &ng_parse_uint32_type }, \ + { "maxpd", &ng_parse_uint32_type }, \ + { "maxstat", &ng_parse_uint32_type }, \ + { "mr", &ng_parse_uint32_type }, \ + { "flags", &ng_parse_uint32_type }, \ + { NULL } \ + } + + +struct ng_sscop_setparam { + uint32_t mask; + struct sscop_param param; +}; +#define NG_SSCOP_SETPARAM_INFO \ + { \ + { "mask", &ng_parse_uint32_type }, \ + { "param", &ng_sscop_param_type }, \ + { NULL } \ + } + +struct ng_sscop_setparam_resp { + uint32_t mask; + int32_t error; +}; +#define NG_SSCOP_SETPARAM_RESP_INFO \ + { \ + { "mask", &ng_parse_uint32_type }, \ + { "error", &ng_parse_int32_type }, \ + { NULL } \ + } + +/* + * Upper interface + */ +struct sscop_arg { + uint32_t sig; + uint32_t arg; /* opt. sequence number or clear-buff */ + u_char data[]; +}; + +struct sscop_marg { + uint32_t sig; + u_char data[]; +}; +struct sscop_merr { + uint32_t sig; + uint32_t err; /* error code */ + uint32_t cnt; /* error count */ +}; + +#endif diff --git a/src/include.new/netgraph/atm/ng_uni.h b/src/include.new/netgraph/atm/ng_uni.h new file mode 100644 index 0000000..b2dc2c5 --- /dev/null +++ b/src/include.new/netgraph/atm/ng_uni.h @@ -0,0 +1,119 @@ +/*- + * Copyright (c) 2001-2003 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * + * Author: Hartmut Brandt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ng_uni.h,v 1.2 2005/01/07 01:45:40 imp Exp $ + * + * Netgraph module for UNI 4.0 + */ +#ifndef _NETGRAPH_ATM_NG_UNI_H_ +#define _NETGRAPH_ATM_NG_UNI_H_ + +#define NG_UNI_NODE_TYPE "uni" +#define NGM_UNI_COOKIE 981112392 + +enum { + NGM_UNI_GETDEBUG, /* get debug flags */ + NGM_UNI_SETDEBUG, /* set debug flags */ + NGM_UNI_GET_CONFIG, /* get configuration */ + NGM_UNI_SET_CONFIG, /* set configuration */ + NGM_UNI_ENABLE, /* enable processing */ + NGM_UNI_DISABLE, /* free resources and disable */ + NGM_UNI_GETSTATE, /* retrieve coord state */ +}; + +struct ngm_uni_debug { + uint32_t level[UNI_MAXFACILITY]; +}; +#define NGM_UNI_DEBUGLEVEL_INFO { \ + &ng_parse_uint32_type, \ + UNI_MAXFACILITY \ +} +#define NGM_UNI_DEBUG_INFO \ + { \ + { "level", &ng_uni_debuglevel_type }, \ + { NULL } \ + } + +#define NGM_UNI_CONFIG_INFO \ + { \ + { "proto", &ng_parse_uint32_type }, \ + { "popt", &ng_parse_uint32_type }, \ + { "option", &ng_parse_uint32_type }, \ + { "timer301", &ng_parse_uint32_type }, \ + { "timer303", &ng_parse_uint32_type }, \ + { "init303", &ng_parse_uint32_type }, \ + { "timer308", &ng_parse_uint32_type }, \ + { "init308", &ng_parse_uint32_type }, \ + { "timer309", &ng_parse_uint32_type }, \ + { "timer310", &ng_parse_uint32_type }, \ + { "timer313", &ng_parse_uint32_type }, \ + { "timer316", &ng_parse_uint32_type }, \ + { "init316", &ng_parse_uint32_type }, \ + { "timer317", &ng_parse_uint32_type }, \ + { "timer322", &ng_parse_uint32_type }, \ + { "init322", &ng_parse_uint32_type }, \ + { "timer397", &ng_parse_uint32_type }, \ + { "timer398", &ng_parse_uint32_type }, \ + { "timer399", &ng_parse_uint32_type }, \ + { NULL } \ + } + +struct ngm_uni_config_mask { + uint32_t mask; + uint32_t popt_mask; + uint32_t option_mask; +}; +#define NGM_UNI_CONFIG_MASK_INFO \ + { \ + { "mask", &ng_parse_hint32_type }, \ + { "popt_mask", &ng_parse_hint32_type }, \ + { "option_mask", &ng_parse_hint32_type }, \ + { NULL } \ + } + +struct ngm_uni_set_config { + struct uni_config config; + struct ngm_uni_config_mask mask; +}; +#define NGM_UNI_SET_CONFIG_INFO \ + { \ + { "config", &ng_uni_config_type }, \ + { "mask", &ng_uni_config_mask_type }, \ + { NULL } \ + } + +/* + * API message + */ +struct uni_arg { + uint32_t sig; + uint32_t cookie; + u_char data[]; +}; + +#endif diff --git a/src/include.new/netgraph/atm/ngatmbase.h b/src/include.new/netgraph/atm/ngatmbase.h new file mode 100644 index 0000000..126cb0b --- /dev/null +++ b/src/include.new/netgraph/atm/ngatmbase.h @@ -0,0 +1,64 @@ +/*- + * Copyright (c) 2001-2003 + * Fraunhofer Institute for Open Communication Systems (FhG Fokus). + * All rights reserved. + * + * Author: Harti Brandt + * + * Redistribution of this software and documentation and use in source and + * binary forms, with or without modification, are permitted provided that + * the following conditions are met: + * + * 1. Redistributions of source code or documentation must retain the above + * copyright notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE AND DOCUMENTATION IS PROVIDED BY FRAUNHOFER FOKUS + * AND ITS CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * FRAUNHOFER FOKUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD: src/sys/netgraph/atm/ngatmbase.h,v 1.3 2005/01/07 01:45:40 imp Exp $ + * + * In-kernel UNI stack message functions. + */ +#ifndef _NETGRAPH_ATM_NGATMBASE_H_ +#define _NETGRAPH_ATM_NGATMBASE_H_ + +/* forward declarations */ +struct mbuf; +struct uni_msg; + +struct mbuf *uni_msg_pack_mbuf(struct uni_msg *, void *, size_t); + +#ifdef NGATM_DEBUG + +struct uni_msg *_uni_msg_alloc(size_t, const char *, int); +struct uni_msg *_uni_msg_build(const char *, int, void *, ...); +void _uni_msg_destroy(struct uni_msg *, const char *, int); +int _uni_msg_unpack_mbuf(struct mbuf *, struct uni_msg **, const char *, int); + +#define uni_msg_alloc(S) _uni_msg_alloc((S), __FILE__, __LINE__) +#define uni_msg_build(P...) _uni_msg_build(__FILE__, __LINE__, P) +#define uni_msg_destroy(M) _uni_msg_destroy((M), __FILE__, __LINE__) +#define uni_msg_unpack_mbuf(M, PP) \ + _uni_msg_unpack_mbuf((M), (PP), __FILE__, __LINE__) + +#else /* !NGATM_DEBUG */ + +struct uni_msg *uni_msg_alloc(size_t); +struct uni_msg *uni_msg_build(void *, ...); +void uni_msg_destroy(struct uni_msg *); +int uni_msg_unpack_mbuf(struct mbuf *, struct uni_msg **); + +#endif +#endif diff --git a/src/include.new/netgraph/netflow/netflow.h b/src/include.new/netgraph/netflow/netflow.h new file mode 100644 index 0000000..594758e --- /dev/null +++ b/src/include.new/netgraph/netflow/netflow.h @@ -0,0 +1,129 @@ +/*- + * Copyright (c) 2004 Gleb Smirnoff + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $SourceForge: netflow.h,v 1.8 2004/09/16 17:05:11 glebius Exp $ + * $FreeBSD: src/sys/netgraph/netflow/netflow.h,v 1.3.2.1 2006/05/01 20:06:51 maxim Exp $ + */ + +/* netflow timeouts in seconds */ + +#define ACTIVE_TIMEOUT (30*60) /* maximum flow lifetime is 30 min */ +#define INACTIVE_TIMEOUT 15 + +/* + * More info can be found in these Cisco documents: + * + * Cisco IOS NetFlow, White Papers. + * http://www.cisco.com/en/US/products/ps6601/prod_white_papers_list.html + * + * Cisco CNS NetFlow Collection Engine User Guide, 5.0.2, NetFlow Export + * Datagram Formats. + * http://www.cisco.com/en/US/products/sw/netmgtsw/ps1964/products_user_guide_chapter09186a00803f3147.html#wp26453 + * + */ + +#define NETFLOW_V1 1 +#define NETFLOW_V5 5 + +struct netflow_v1_header +{ + uint16_t version; /* NetFlow version */ + uint16_t count; /* Number of records in flow */ + uint32_t sys_uptime; /* System uptime */ + uint32_t unix_secs; /* Current seconds since 0000 UTC 1970 */ + uint32_t unix_nsecs; /* Remaining nanoseconds since 0000 UTC 1970 */ +} __attribute__((__packed__)); + +struct netflow_v5_header +{ + uint16_t version; /* NetFlow version */ + uint16_t count; /* Number of records in flow */ + uint32_t sys_uptime; /* System uptime */ + uint32_t unix_secs; /* Current seconds since 0000 UTC 1970 */ + uint32_t unix_nsecs; /* Remaining nanoseconds since 0000 UTC 1970 */ + uint32_t flow_seq; /* Sequence number of the first record */ + uint8_t engine_type; /* Type of flow switching engine (RP,VIP,etc.) */ + uint8_t engine_id; /* Slot number of the flow switching engine */ + uint16_t pad; /* Pad to word boundary */ +} __attribute__((__packed__)); + +struct netflow_v1_record +{ + uint32_t src_addr; /* Source IP address */ + uint32_t dst_addr; /* Destination IP address */ + uint32_t next_hop; /* Next hop IP address */ + uint16_t in_ifx; /* Source interface index */ + uint16_t out_ifx; /* Destination interface index */ + uint32_t packets; /* Number of packets in a flow */ + uint32_t octets; /* Number of octets in a flow */ + uint32_t first; /* System uptime at start of a flow */ + uint32_t last; /* System uptime at end of a flow */ + uint16_t s_port; /* Source port */ + uint16_t d_port; /* Destination port */ + uint16_t pad1; /* Pad to word boundary */ + uint8_t prot; /* IP protocol */ + uint8_t tos; /* IP type of service */ + uint8_t flags; /* Cumulative OR of tcp flags */ + uint8_t pad2; /* Pad to word boundary */ + uint16_t pad3; /* Pad to word boundary */ + uint8_t reserved[5]; /* Reserved for future use */ +} __attribute__((__packed__)); + +struct netflow_v5_record +{ + uint32_t src_addr; /* Source IP address */ + uint32_t dst_addr; /* Destination IP address */ + uint32_t next_hop; /* Next hop IP address */ + uint16_t i_ifx; /* Source interface index */ + uint16_t o_ifx; /* Destination interface index */ + uint32_t packets; /* Number of packets in a flow */ + uint32_t octets; /* Number of octets in a flow */ + uint32_t first; /* System uptime at start of a flow */ + uint32_t last; /* System uptime at end of a flow */ + uint16_t s_port; /* Source port */ + uint16_t d_port; /* Destination port */ + uint8_t pad1; /* Pad to word boundary */ + uint8_t flags; /* Cumulative OR of tcp flags */ + uint8_t prot; /* IP protocol */ + uint8_t tos; /* IP type of service */ + uint16_t src_as; /* Src peer/origin Autonomous System */ + uint16_t dst_as; /* Dst peer/origin Autonomous System */ + uint8_t src_mask; /* Source route's mask bits */ + uint8_t dst_mask; /* Destination route's mask bits */ + uint16_t pad2; /* Pad to word boundary */ +} __attribute__((__packed__)); + +#define NETFLOW_V1_MAX_RECORDS 24 +#define NETFLOW_V5_MAX_RECORDS 30 + +#define NETFLOW_V1_MAX_SIZE (sizeof(netflow_v1_header)+ \ + sizeof(netflow_v1_record)*NETFLOW_V1_MAX_RECORDS) +#define NETFLOW_V5_MAX_SIZE (sizeof(netflow_v5_header)+ \ + sizeof(netflow_v5_record)*NETFLOW_V5_MAX_RECORDS) + +struct netflow_v5_export_dgram { + struct netflow_v5_header header; + struct netflow_v5_record r[NETFLOW_V5_MAX_RECORDS]; +} __attribute__((__packed__)); diff --git a/src/include.new/netgraph/netflow/ng_netflow.h b/src/include.new/netgraph/netflow/ng_netflow.h new file mode 100644 index 0000000..fc4f267 --- /dev/null +++ b/src/include.new/netgraph/netflow/ng_netflow.h @@ -0,0 +1,275 @@ +/*- + * Copyright (c) 2004-2005 Gleb Smirnoff + * Copyright (c) 2001-2003 Roman V. Palagin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $SourceForge: ng_netflow.h,v 1.26 2004/09/04 15:44:55 glebius Exp $ + * $FreeBSD: src/sys/netgraph/netflow/ng_netflow.h,v 1.7.2.2 2006/02/16 12:37:14 glebius Exp $ + */ + +#ifndef _NG_NETFLOW_H_ +#define _NG_NETFLOW_H_ + +#define NG_NETFLOW_NODE_TYPE "netflow" +#define NGM_NETFLOW_COOKIE 1137078102 + +#define NG_NETFLOW_MAXIFACES 2048 + +/* Hook names */ + +#define NG_NETFLOW_HOOK_DATA "iface" +#define NG_NETFLOW_HOOK_OUT "out" +#define NG_NETFLOW_HOOK_EXPORT "export" + +/* Netgraph commands understood by netflow node */ +enum { + NGM_NETFLOW_INFO = 1|NGM_READONLY|NGM_HASREPLY, /* get node info */ + NGM_NETFLOW_IFINFO = 2|NGM_READONLY|NGM_HASREPLY, /* get iface info */ + NGM_NETFLOW_SHOW = 3|NGM_READONLY|NGM_HASREPLY, /* show ip cache flow */ + NGM_NETFLOW_SETDLT = 4, /* set data-link type */ + NGM_NETFLOW_SETIFINDEX = 5, /* set interface index */ + NGM_NETFLOW_SETTIMEOUTS = 6, /* set active/inactive flow timeouts */ +}; + +/* This structure is returned by the NGM_NETFLOW_INFO message */ +struct ng_netflow_info { + uint64_t nfinfo_bytes; /* accounted bytes */ + uint32_t nfinfo_packets; /* accounted packets */ + uint32_t nfinfo_used; /* used cache records */ + uint32_t nfinfo_alloc_failed; /* failed allocations */ + uint32_t nfinfo_export_failed; /* failed exports */ + uint32_t nfinfo_act_exp; /* active expiries */ + uint32_t nfinfo_inact_exp; /* inactive expiries */ + uint32_t nfinfo_inact_t; /* flow inactive timeout */ + uint32_t nfinfo_act_t; /* flow active timeout */ +}; + +/* This structure is returned by the NGM_NETFLOW_IFINFO message */ +struct ng_netflow_ifinfo { + uint32_t ifinfo_packets; /* number of packets for this iface */ + uint8_t ifinfo_dlt; /* Data Link Type, DLT_XXX */ +#define MAXDLTNAMELEN 20 + u_int16_t ifinfo_index; /* connected iface index */ +}; + + +/* This structure is passed to NGM_NETFLOW_SETDLT message */ +struct ng_netflow_setdlt { + uint16_t iface; /* which iface dlt change */ + uint8_t dlt; /* DLT_XXX from bpf.h */ +}; + +/* This structure is passed to NGM_NETFLOW_SETIFINDEX */ +struct ng_netflow_setifindex { + u_int16_t iface; /* which iface index change */ + u_int16_t index; /* new index */ +}; + +/* This structure is passed to NGM_NETFLOW_SETTIMEOUTS */ +struct ng_netflow_settimeouts { + uint32_t inactive_timeout; /* flow inactive timeout */ + uint32_t active_timeout; /* flow active timeout */ +}; + +/* This is unique data, which identifies flow */ +struct flow_rec { + struct in_addr r_src; + struct in_addr r_dst; + union { + struct { + uint16_t s_port; /* source TCP/UDP port */ + uint16_t d_port; /* destination TCP/UDP port */ + } dir; + uint32_t both; + } ports; + union { + struct { + u_char prot; /* IP protocol */ + u_char tos; /* IP TOS */ + uint16_t i_ifx; /* input interface index */ + } i; + uint32_t all; + } misc; +}; + +#define r_ip_p misc.i.prot +#define r_tos misc.i.tos +#define r_i_ifx misc.i.i_ifx +#define r_misc misc.all +#define r_ports ports.both +#define r_sport ports.dir.s_port +#define r_dport ports.dir.d_port + +/* A flow entry which accumulates statistics */ +struct flow_entry_data { + struct flow_rec r; + struct in_addr next_hop; + uint16_t fle_o_ifx; /* output interface index */ +#define fle_i_ifx r.misc.i.i_ifx + uint8_t dst_mask; /* destination route mask bits */ + uint8_t src_mask; /* source route mask bits */ + u_long packets; + u_long bytes; + long first; /* uptime on first packet */ + long last; /* uptime on last packet */ + u_char tcp_flags; /* cumulative OR */ +}; + +/* + * How many flow records we will transfer at once + * without overflowing socket receive buffer + */ +#define NREC_AT_ONCE 1000 +#define NGRESP_SIZE (sizeof(struct ngnf_flows) + (NREC_AT_ONCE * \ + sizeof(struct flow_entry_data))) +#define SORCVBUF_SIZE (NGRESP_SIZE + 2 * sizeof(struct ng_mesg)) + +/* This struct is returned to userland, when "show cache ip flow" */ +struct ngnf_flows { + uint32_t nentries; + uint32_t last; + struct flow_entry_data entries[0]; +}; + +/* Everything below is for kernel */ + +#ifdef _KERNEL + +struct flow_entry { + struct flow_entry_data f; + TAILQ_ENTRY(flow_entry) fle_hash; /* entries in hash slot */ +}; + +/* Parsing declarations */ + +/* Parse the info structure */ +#define NG_NETFLOW_INFO_TYPE { \ + { "Bytes", &ng_parse_uint64_type }, \ + { "Packets", &ng_parse_uint32_type }, \ + { "Records used", &ng_parse_uint32_type },\ + { "Failed allocations", &ng_parse_uint32_type },\ + { "Failed exports", &ng_parse_uint32_type },\ + { "Active expiries", &ng_parse_uint32_type },\ + { "Inactive expiries", &ng_parse_uint32_type },\ + { "Inactive timeout", &ng_parse_uint32_type },\ + { "Active timeout", &ng_parse_uint32_type },\ + { NULL } \ +} + +/* Parse the ifinfo structure */ +#define NG_NETFLOW_IFINFO_TYPE { \ + { "packets", &ng_parse_uint32_type }, \ + { "data link type", &ng_parse_uint8_type }, \ + { "index", &ng_parse_uint16_type }, \ + { NULL } \ +} + +/* Parse the setdlt structure */ +#define NG_NETFLOW_SETDLT_TYPE { \ + { "iface", &ng_parse_uint16_type }, \ + { "dlt", &ng_parse_uint8_type }, \ + { NULL } \ +} + +/* Parse the setifindex structure */ +#define NG_NETFLOW_SETIFINDEX_TYPE { \ + { "iface", &ng_parse_uint16_type }, \ + { "index", &ng_parse_uint16_type }, \ + { NULL } \ +} + +/* Parse the settimeouts structure */ +#define NG_NETFLOW_SETTIMEOUTS_TYPE { \ + { "inactive", &ng_parse_uint32_type }, \ + { "active", &ng_parse_uint32_type }, \ + { NULL } \ +} + +/* Private hook data */ +struct ng_netflow_iface { + hook_p hook; /* NULL when disconnected */ + hook_p out; /* NULL when no bypass hook */ + struct ng_netflow_ifinfo info; +}; + +typedef struct ng_netflow_iface *iface_p; +typedef struct ng_netflow_ifinfo *ifinfo_p; + +/* Structure describing our flow engine */ +struct netflow { + node_p node; /* link to the node itself */ + hook_p export; /* export data goes there */ + + struct ng_netflow_info info; + struct callout exp_callout; /* expiry periodic job */ + + /* + * Flow entries are allocated in uma(9) zone zone. They are + * indexed by hash hash. Each hash element consist of tailqueue + * head and mutex to protect this element. + */ +#define CACHESIZE (65536*4) +#define CACHELOWAT (CACHESIZE * 3/4) +#define CACHEHIGHWAT (CACHESIZE * 9/10) + uma_zone_t zone; + struct flow_hash_entry *hash; + + /* + * NetFlow data export + * + * export_item is a data item, it has an mbuf with cluster + * attached to it. A thread detaches export_item from priv + * and works with it. If the export is full it is sent, and + * a new one is allocated. Before exiting thread re-attaches + * its current item back to priv. If there is item already, + * current incomplete datagram is sent. + * export_mtx is used for attaching/detaching. + */ + item_p export_item; + struct mtx export_mtx; + uint32_t flow_seq; /* current flow sequence */ + + struct ng_netflow_iface ifaces[NG_NETFLOW_MAXIFACES]; +}; + +typedef struct netflow *priv_p; + +/* Header of a small list in hash cell */ +struct flow_hash_entry { + struct mtx mtx; + TAILQ_HEAD(fhead, flow_entry) head; +}; + +#define ERROUT(x) { error = (x); goto done; } + +/* Prototypes for netflow.c */ +int ng_netflow_cache_init(priv_p); +void ng_netflow_cache_flush(priv_p); +void ng_netflow_copyinfo(priv_p, struct ng_netflow_info *); +timeout_t ng_netflow_expire; +int ng_netflow_flow_add(priv_p, struct ip *, iface_p, struct ifnet *); +int ng_netflow_flow_show(priv_p, uint32_t last, struct ng_mesg *); + +#endif /* _KERNEL */ +#endif /* _NG_NETFLOW_H_ */