/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2005 Nuno Antunes <[email protected]>4* Copyright (c) 2007 Alexander Motin <[email protected]>5* All rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _NETGRAPH_NG_CAR_H_30#define _NETGRAPH_NG_CAR_H_3132#define NG_CAR_NODE_TYPE "car"33#define NGM_CAR_COOKIE 11736480343435/* Hook names */36#define NG_CAR_HOOK_UPPER "upper"37#define NG_CAR_HOOK_LOWER "lower"3839/* Per hook statistics counters */40struct ng_car_hookstats {41u_int64_t passed_pkts; /* Counter for passed packets */42u_int64_t dropped_pkts; /* Counter for dropped packets */43u_int64_t green_pkts; /* Counter for green packets */44u_int64_t yellow_pkts; /* Counter for yellow packets */45u_int64_t red_pkts; /* Counter for red packets */46u_int64_t errors; /* Counter for operation errors */47};48#define NG_CAR_HOOKSTATS { \49{ "passed", &ng_parse_uint64_type }, \50{ "dropped", &ng_parse_uint64_type }, \51{ "green", &ng_parse_uint64_type }, \52{ "yellow", &ng_parse_uint64_type }, \53{ "red", &ng_parse_uint64_type }, \54{ "errors", &ng_parse_uint64_type }, \55{ NULL } \56}5758/* Bulk statistics */59struct ng_car_bulkstats {60struct ng_car_hookstats upstream;61struct ng_car_hookstats downstream;62};63#define NG_CAR_BULKSTATS(hstatstype) { \64{ "upstream", (hstatstype) }, \65{ "downstream", (hstatstype) }, \66{ NULL } \67}6869/* Per hook configuration */70struct ng_car_hookconf {71u_int64_t cbs; /* Committed burst size (bytes) */72u_int64_t ebs; /* Exceeded/Peak burst size (bytes) */73u_int64_t cir; /* Committed information rate (bits/s) */74u_int64_t pir; /* Peak information rate (bits/s) */75u_int8_t green_action; /* Action for green packets */76u_int8_t yellow_action; /* Action for yellow packets */77u_int8_t red_action; /* Action for red packets */78u_int8_t mode; /* single/double rate, ... */79u_int8_t opt; /* color-aware or color-blind */80};81/* Keep this definition in sync with the above structure */82#define NG_CAR_HOOKCONF { \83{ "cbs", &ng_parse_uint64_type }, \84{ "ebs", &ng_parse_uint64_type }, \85{ "cir", &ng_parse_uint64_type }, \86{ "pir", &ng_parse_uint64_type }, \87{ "greenAction", &ng_parse_uint8_type }, \88{ "yellowAction", &ng_parse_uint8_type }, \89{ "redAction", &ng_parse_uint8_type }, \90{ "mode", &ng_parse_uint8_type }, \91{ "opt", &ng_parse_uint8_type }, \92{ NULL } \93}9495#define NG_CAR_CBS_MIN 819296#define NG_CAR_EBS_MIN 819297#define NG_CAR_CIR_DFLT 102409899/* possible actions (...Action) */100enum {101NG_CAR_ACTION_FORWARD = 1,102NG_CAR_ACTION_DROP,103NG_CAR_ACTION_MARK104};105106/* operation modes (mode) */107enum {108NG_CAR_SINGLE_RATE = 0,109NG_CAR_DOUBLE_RATE,110NG_CAR_RED,111NG_CAR_SHAPE112};113114/* mode options (bits in opt) */115#define NG_CAR_COLOR_AWARE 1116#define NG_CAR_COUNT_PACKETS 2117118/* Bulk config */119struct ng_car_bulkconf {120struct ng_car_hookconf upstream;121struct ng_car_hookconf downstream;122};123#define NG_CAR_BULKCONF(hconftype) { \124{ "upstream", (hconftype) }, \125{ "downstream", (hconftype) }, \126{ NULL } \127}128129/* Commands */130enum {131NGM_CAR_GET_STATS = 1, /* Get statistics */132NGM_CAR_CLR_STATS, /* Clear statistics */133NGM_CAR_GETCLR_STATS, /* Get and clear statistics */134NGM_CAR_GET_CONF, /* Get bulk configuration */135NGM_CAR_SET_CONF, /* Set bulk configuration */136};137138#endif /* _NETGRAPH_NG_CAR_H_ */139140141