14cf49a43SJulian Elischer 24cf49a43SJulian Elischer /* 34cf49a43SJulian Elischer * ng_message.h 44cf49a43SJulian Elischer * 54cf49a43SJulian Elischer * Copyright (c) 1996-1999 Whistle Communications, Inc. 64cf49a43SJulian Elischer * All rights reserved. 74cf49a43SJulian Elischer * 84cf49a43SJulian Elischer * Subject to the following obligations and disclaimer of warranty, use and 94cf49a43SJulian Elischer * redistribution of this software, in source or object code forms, with or 104cf49a43SJulian Elischer * without modifications are expressly permitted by Whistle Communications; 114cf49a43SJulian Elischer * provided, however, that: 124cf49a43SJulian Elischer * 1. Any and all reproductions of the source or object code must include the 134cf49a43SJulian Elischer * copyright notice above and the following disclaimer of warranties; and 144cf49a43SJulian Elischer * 2. No rights are granted, in any manner or form, to use Whistle 154cf49a43SJulian Elischer * Communications, Inc. trademarks, including the mark "WHISTLE 164cf49a43SJulian Elischer * COMMUNICATIONS" on advertising, endorsements, or otherwise except as 174cf49a43SJulian Elischer * such appears in the above copyright notice or in the software. 184cf49a43SJulian Elischer * 194cf49a43SJulian Elischer * THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND 204cf49a43SJulian Elischer * TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO 214cf49a43SJulian Elischer * REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE, 224cf49a43SJulian Elischer * INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF 234cf49a43SJulian Elischer * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. 244cf49a43SJulian Elischer * WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY 254cf49a43SJulian Elischer * REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS 264cf49a43SJulian Elischer * SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE. 274cf49a43SJulian Elischer * IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES 284cf49a43SJulian Elischer * RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING 294cf49a43SJulian Elischer * WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 304cf49a43SJulian Elischer * PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR 314cf49a43SJulian Elischer * SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER ANY 324cf49a43SJulian Elischer * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 334cf49a43SJulian Elischer * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 344cf49a43SJulian Elischer * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY 354cf49a43SJulian Elischer * OF SUCH DAMAGE. 364cf49a43SJulian Elischer * 37cc3bbd68SJulian Elischer * Author: Julian Elischer <julian@freebsd.org> 384cf49a43SJulian Elischer * 394cf49a43SJulian Elischer * $FreeBSD$ 404cf49a43SJulian Elischer * $Whistle: ng_message.h,v 1.12 1999/01/25 01:17:44 archie Exp $ 414cf49a43SJulian Elischer */ 424cf49a43SJulian Elischer 434cf49a43SJulian Elischer #ifndef _NETGRAPH_NG_MESSAGE_H_ 44e20480bfSRuslan Ermilov #define _NETGRAPH_NG_MESSAGE_H_ 454cf49a43SJulian Elischer 464cf49a43SJulian Elischer /* ASCII string size limits */ 47387ebc6dSHartmut Brandt #define NG_TYPESIZ 32 /* max type name len (including null) */ 48387ebc6dSHartmut Brandt #define NG_HOOKSIZ 32 /* max hook name len (including null) */ 49387ebc6dSHartmut Brandt #define NG_NODESIZ 32 /* max node name len (including null) */ 50387ebc6dSHartmut Brandt #define NG_PATHSIZ 512 /* max path len (including null) */ 51387ebc6dSHartmut Brandt #define NG_CMDSTRSIZ 32 /* max command string (including null) */ 52387ebc6dSHartmut Brandt 53387ebc6dSHartmut Brandt #ifndef BURN_BRIDGES 54387ebc6dSHartmut Brandt /* don't use these - they will go away */ 55387ebc6dSHartmut Brandt #define NG_TYPELEN (NG_TYPESIZ - 1) 56387ebc6dSHartmut Brandt #define NG_HOOKLEN (NG_HOOKSIZ - 1) 57387ebc6dSHartmut Brandt #define NG_NODELEN (NG_NODESIZ - 1) 58387ebc6dSHartmut Brandt #define NG_PATHLEN (NG_PATHSIZ - 1) 59387ebc6dSHartmut Brandt #define NG_CMDSTRLEN (NG_CMDSTRSIZ - 1) 60387ebc6dSHartmut Brandt #endif 61387ebc6dSHartmut Brandt 624cf49a43SJulian Elischer #define NG_TEXTRESPONSE 1024 /* allow this length for a text response */ 634cf49a43SJulian Elischer 644cf49a43SJulian Elischer /* A netgraph message */ 654cf49a43SJulian Elischer struct ng_mesg { 664cf49a43SJulian Elischer struct ng_msghdr { 67589f6ed8SJulian Elischer u_char version; /* == NGM_VERSION */ 684cf49a43SJulian Elischer u_char spare; /* pad to 2 bytes */ 694cf49a43SJulian Elischer u_int16_t arglen; /* length of data */ 704cf49a43SJulian Elischer u_int32_t flags; /* message status */ 714cf49a43SJulian Elischer u_int32_t token; /* match with reply */ 724cf49a43SJulian Elischer u_int32_t typecookie; /* node's type cookie */ 734cf49a43SJulian Elischer u_int32_t cmd; /* command identifier */ 7487e2c66aSHartmut Brandt u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string + \0 */ 754cf49a43SJulian Elischer } header; 760eecad8dSHartmut Brandt char data[]; /* placeholder for actual data */ 774cf49a43SJulian Elischer }; 78f8307e12SArchie Cobbs 79069154d5SJulian Elischer /* this command is guaranteed to not alter data or'd into the command */ 80069154d5SJulian Elischer #define NGM_READONLY 0x10000000 81589f6ed8SJulian Elischer 82f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 83f8307e12SArchie Cobbs #define NG_GENERIC_NG_MESG_INFO(dtype) { \ 8457b57be3SArchie Cobbs { "version", &ng_parse_uint8_type }, \ 8557b57be3SArchie Cobbs { "spare", &ng_parse_uint8_type }, \ 8657b57be3SArchie Cobbs { "arglen", &ng_parse_uint16_type }, \ 8757b57be3SArchie Cobbs { "flags", &ng_parse_hint32_type }, \ 8857b57be3SArchie Cobbs { "token", &ng_parse_uint32_type }, \ 8957b57be3SArchie Cobbs { "typecookie", &ng_parse_uint32_type }, \ 9057b57be3SArchie Cobbs { "cmd", &ng_parse_uint32_type }, \ 91f8307e12SArchie Cobbs { "cmdstr", &ng_parse_cmdbuf_type }, \ 92f8307e12SArchie Cobbs { "data", (dtype) }, \ 93f0184ff8SArchie Cobbs { NULL } \ 94f8307e12SArchie Cobbs } 95f8307e12SArchie Cobbs 96589f6ed8SJulian Elischer /* 97589f6ed8SJulian Elischer * Netgraph message header compatibility field 98589f6ed8SJulian Elischer * Interfaces within the kernel are defined by a different 99589f6ed8SJulian Elischer * value (see NG_ABI_VERSION in netgraph.g) 100589f6ed8SJulian Elischer */ 10167371b0fSHartmut Brandt #define NG_VERSION 6 102f8307e12SArchie Cobbs 103f8307e12SArchie Cobbs /* Flags field flags */ 104069154d5SJulian Elischer #define NGF_ORIG 0x00000000 /* the msg is the original request */ 105069154d5SJulian Elischer #define NGF_RESP 0x00000001 /* the message is a response */ 1061acb27c6SJulian Elischer 107f8307e12SArchie Cobbs /* Type of a unique node ID */ 108f8307e12SArchie Cobbs #define ng_ID_t unsigned int 109f8307e12SArchie Cobbs 1104cf49a43SJulian Elischer /* 1114cf49a43SJulian Elischer * Here we describe the "generic" messages that all nodes inherently 1124cf49a43SJulian Elischer * understand. With the exception of NGM_TEXT_STATUS, these are handled 1134cf49a43SJulian Elischer * automatically by the base netgraph code. 1144cf49a43SJulian Elischer */ 1154cf49a43SJulian Elischer 1164cf49a43SJulian Elischer /* Generic message type cookie */ 117069154d5SJulian Elischer #define NGM_GENERIC_COOKIE 977674408 1184cf49a43SJulian Elischer 1194cf49a43SJulian Elischer /* Generic messages defined for this type cookie */ 120f8307e12SArchie Cobbs #define NGM_SHUTDOWN 1 /* shut down node */ 121f8307e12SArchie Cobbs #define NGM_MKPEER 2 /* create and attach a peer node */ 122f8307e12SArchie Cobbs #define NGM_CONNECT 3 /* connect two nodes */ 123f8307e12SArchie Cobbs #define NGM_NAME 4 /* give a node a name */ 124f8307e12SArchie Cobbs #define NGM_RMHOOK 5 /* break a connection btw. two nodes */ 125069154d5SJulian Elischer #define NGM_NODEINFO (6|NGM_READONLY)/* get nodeinfo for target */ 126069154d5SJulian Elischer #define NGM_LISTHOOKS (7|NGM_READONLY)/* get list of hooks on node */ 127069154d5SJulian Elischer #define NGM_LISTNAMES (8|NGM_READONLY)/* list globally named nodes */ 128069154d5SJulian Elischer #define NGM_LISTNODES (9|NGM_READONLY)/* list nodes, named & not */ 129069154d5SJulian Elischer #define NGM_LISTTYPES (10|NGM_READONLY)/* list installed node types */ 130069154d5SJulian Elischer #define NGM_TEXT_STATUS (11|NGM_READONLY)/* (optional) get txt status */ 131069154d5SJulian Elischer #define NGM_BINARY2ASCII (12|NGM_READONLY)/* convert ng_mesg to ascii */ 132069154d5SJulian Elischer #define NGM_ASCII2BINARY (13|NGM_READONLY)/* convert ascii to ng_mesg */ 1337095e097SPoul-Henning Kamp #define NGM_TEXT_CONFIG 14 /* (optional) get/set text config */ 1344cf49a43SJulian Elischer 135859a4d16SJulian Elischer /* 136859a4d16SJulian Elischer * Flow control and intra node control messages. 137859a4d16SJulian Elischer * These are routed between nodes to allow flow control and to allow 138859a4d16SJulian Elischer * events to be passed around the graph. 139859a4d16SJulian Elischer * There will be some form of default handling for these but I 140859a4d16SJulian Elischer * do not yet know what it is.. 141859a4d16SJulian Elischer */ 142859a4d16SJulian Elischer 143859a4d16SJulian Elischer /* Generic message type cookie */ 144859a4d16SJulian Elischer #define NGM_FLOW_COOKIE 851672669 /* temp for debugging */ 145859a4d16SJulian Elischer 146859a4d16SJulian Elischer /* Upstream messages */ 147859a4d16SJulian Elischer #define NGM_LINK_IS_UP 32 /* e.g. carrier found - no data */ 148859a4d16SJulian Elischer #define NGM_LINK_IS_DOWN 33 /* carrier lost, includes queue state */ 149859a4d16SJulian Elischer #define NGM_HIGH_WATER_PASSED 34 /* includes queue state */ 150859a4d16SJulian Elischer #define NGM_LOW_WATER_PASSED 35 /* includes queue state */ 151859a4d16SJulian Elischer #define NGM_SYNC_QUEUE_STATE 36 /* sync response from sending packet */ 152859a4d16SJulian Elischer 153859a4d16SJulian Elischer /* Downstream messages */ 154859a4d16SJulian Elischer #define NGM_DROP_LINK 41 /* drop DTR, etc. - stay in the graph */ 155b57a7965SJulian Elischer #define NGM_RAISE_LINK 42 /* if you previously dropped it */ 156859a4d16SJulian Elischer #define NGM_FLUSH_QUEUE 43 /* no data */ 157069154d5SJulian Elischer #define NGM_GET_BANDWIDTH (44|NGM_READONLY) /* either real or measured */ 158859a4d16SJulian Elischer #define NGM_SET_XMIT_Q_LIMITS 45 /* includes queue state */ 159069154d5SJulian Elischer #define NGM_GET_XMIT_Q_LIMITS (46|NGM_READONLY) /* returns queue state */ 160069154d5SJulian Elischer #define NGM_MICROMANAGE 47 /* We want sync. queue state 161069154d5SJulian Elischer reply for each packet sent */ 162859a4d16SJulian Elischer #define NGM_SET_FLOW_MANAGER 48 /* send flow control here */ 163f8307e12SArchie Cobbs /* Structure used for NGM_MKPEER */ 1644cf49a43SJulian Elischer struct ngm_mkpeer { 16587e2c66aSHartmut Brandt char type[NG_TYPESIZ]; /* peer type */ 16687e2c66aSHartmut Brandt char ourhook[NG_HOOKSIZ]; /* hook name */ 16787e2c66aSHartmut Brandt char peerhook[NG_HOOKSIZ]; /* peer hook name */ 1684cf49a43SJulian Elischer }; 1694cf49a43SJulian Elischer 170f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 171f8307e12SArchie Cobbs #define NG_GENERIC_MKPEER_INFO() { \ 172f8307e12SArchie Cobbs { "type", &ng_parse_typebuf_type }, \ 173f8307e12SArchie Cobbs { "ourhook", &ng_parse_hookbuf_type }, \ 174f8307e12SArchie Cobbs { "peerhook", &ng_parse_hookbuf_type }, \ 175f0184ff8SArchie Cobbs { NULL } \ 176f8307e12SArchie Cobbs } 177f8307e12SArchie Cobbs 178f8307e12SArchie Cobbs /* Structure used for NGM_CONNECT */ 1794cf49a43SJulian Elischer struct ngm_connect { 18087e2c66aSHartmut Brandt char path[NG_PATHSIZ]; /* peer path */ 18187e2c66aSHartmut Brandt char ourhook[NG_HOOKSIZ]; /* hook name */ 18287e2c66aSHartmut Brandt char peerhook[NG_HOOKSIZ]; /* peer hook name */ 1834cf49a43SJulian Elischer }; 1844cf49a43SJulian Elischer 185f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 186f8307e12SArchie Cobbs #define NG_GENERIC_CONNECT_INFO() { \ 187f8307e12SArchie Cobbs { "path", &ng_parse_pathbuf_type }, \ 188f8307e12SArchie Cobbs { "ourhook", &ng_parse_hookbuf_type }, \ 189f8307e12SArchie Cobbs { "peerhook", &ng_parse_hookbuf_type }, \ 190f0184ff8SArchie Cobbs { NULL } \ 191f8307e12SArchie Cobbs } 192f8307e12SArchie Cobbs 193f8307e12SArchie Cobbs /* Structure used for NGM_NAME */ 1944cf49a43SJulian Elischer struct ngm_name { 19587e2c66aSHartmut Brandt char name[NG_NODESIZ]; /* node name */ 1964cf49a43SJulian Elischer }; 1974cf49a43SJulian Elischer 198f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 199f8307e12SArchie Cobbs #define NG_GENERIC_NAME_INFO() { \ 200f8307e12SArchie Cobbs { "name", &ng_parse_nodebuf_type }, \ 201f0184ff8SArchie Cobbs { NULL } \ 202f8307e12SArchie Cobbs } 203f8307e12SArchie Cobbs 204f8307e12SArchie Cobbs /* Structure used for NGM_RMHOOK */ 2054cf49a43SJulian Elischer struct ngm_rmhook { 20687e2c66aSHartmut Brandt char ourhook[NG_HOOKSIZ]; /* hook name */ 2074cf49a43SJulian Elischer }; 2084cf49a43SJulian Elischer 209f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 210f8307e12SArchie Cobbs #define NG_GENERIC_RMHOOK_INFO() { \ 211f8307e12SArchie Cobbs { "hook", &ng_parse_hookbuf_type }, \ 212f0184ff8SArchie Cobbs { NULL } \ 213f8307e12SArchie Cobbs } 214f8307e12SArchie Cobbs 215f8307e12SArchie Cobbs /* Structure used for NGM_NODEINFO */ 2164cf49a43SJulian Elischer struct nodeinfo { 21787e2c66aSHartmut Brandt char name[NG_NODESIZ]; /* node name (if any) */ 21887e2c66aSHartmut Brandt char type[NG_TYPESIZ]; /* peer type */ 219dc90cad9SJulian Elischer ng_ID_t id; /* unique identifier */ 2204cf49a43SJulian Elischer u_int32_t hooks; /* number of active hooks */ 2214cf49a43SJulian Elischer }; 2224cf49a43SJulian Elischer 223f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 224f8307e12SArchie Cobbs #define NG_GENERIC_NODEINFO_INFO() { \ 225f8307e12SArchie Cobbs { "name", &ng_parse_nodebuf_type }, \ 226f8307e12SArchie Cobbs { "type", &ng_parse_typebuf_type }, \ 22757b57be3SArchie Cobbs { "id", &ng_parse_hint32_type }, \ 22857b57be3SArchie Cobbs { "hooks", &ng_parse_uint32_type }, \ 229f0184ff8SArchie Cobbs { NULL } \ 230f8307e12SArchie Cobbs } 231f8307e12SArchie Cobbs 232f8307e12SArchie Cobbs /* Structure used for NGM_LISTHOOKS */ 2334cf49a43SJulian Elischer struct linkinfo { 23487e2c66aSHartmut Brandt char ourhook[NG_HOOKSIZ]; /* hook name */ 23587e2c66aSHartmut Brandt char peerhook[NG_HOOKSIZ]; /* peer hook */ 2364cf49a43SJulian Elischer struct nodeinfo nodeinfo; 2374cf49a43SJulian Elischer }; 2384cf49a43SJulian Elischer 239f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 240f8307e12SArchie Cobbs #define NG_GENERIC_LINKINFO_INFO(nitype) { \ 241f8307e12SArchie Cobbs { "ourhook", &ng_parse_hookbuf_type }, \ 242f8307e12SArchie Cobbs { "peerhook", &ng_parse_hookbuf_type }, \ 243f8307e12SArchie Cobbs { "nodeinfo", (nitype) }, \ 244f0184ff8SArchie Cobbs { NULL } \ 245f8307e12SArchie Cobbs } 246f8307e12SArchie Cobbs 2474cf49a43SJulian Elischer struct hooklist { 2484cf49a43SJulian Elischer struct nodeinfo nodeinfo; /* node information */ 2490eecad8dSHartmut Brandt struct linkinfo link[]; /* info about each hook */ 2504cf49a43SJulian Elischer }; 2514cf49a43SJulian Elischer 252f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 253f8307e12SArchie Cobbs #define NG_GENERIC_HOOKLIST_INFO(nitype,litype) { \ 254f8307e12SArchie Cobbs { "nodeinfo", (nitype) }, \ 255f8307e12SArchie Cobbs { "linkinfo", (litype) }, \ 256f0184ff8SArchie Cobbs { NULL } \ 257f8307e12SArchie Cobbs } 258f8307e12SArchie Cobbs 259f8307e12SArchie Cobbs /* Structure used for NGM_LISTNAMES/NGM_LISTNODES */ 2604cf49a43SJulian Elischer struct namelist { 2614cf49a43SJulian Elischer u_int32_t numnames; 2620eecad8dSHartmut Brandt struct nodeinfo nodeinfo[]; 2634cf49a43SJulian Elischer }; 2644cf49a43SJulian Elischer 265f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 266f8307e12SArchie Cobbs #define NG_GENERIC_LISTNODES_INFO(niarraytype) { \ 26757b57be3SArchie Cobbs { "numnames", &ng_parse_uint32_type }, \ 268f8307e12SArchie Cobbs { "nodeinfo", (niarraytype) }, \ 269f0184ff8SArchie Cobbs { NULL } \ 270f8307e12SArchie Cobbs } 271f8307e12SArchie Cobbs 272f8307e12SArchie Cobbs /* Structure used for NGM_LISTTYPES */ 2734cf49a43SJulian Elischer struct typeinfo { 27487e2c66aSHartmut Brandt char type_name[NG_TYPESIZ]; /* name of type */ 2754cf49a43SJulian Elischer u_int32_t numnodes; /* number alive */ 2764cf49a43SJulian Elischer }; 2774cf49a43SJulian Elischer 278f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 279f8307e12SArchie Cobbs #define NG_GENERIC_TYPEINFO_INFO() { \ 280f8307e12SArchie Cobbs { "typename", &ng_parse_typebuf_type }, \ 28157b57be3SArchie Cobbs { "numnodes", &ng_parse_uint32_type }, \ 282f0184ff8SArchie Cobbs { NULL } \ 283f8307e12SArchie Cobbs } 284f8307e12SArchie Cobbs 2854cf49a43SJulian Elischer struct typelist { 2864cf49a43SJulian Elischer u_int32_t numtypes; 2870eecad8dSHartmut Brandt struct typeinfo typeinfo[]; 2884cf49a43SJulian Elischer }; 2894cf49a43SJulian Elischer 290f8307e12SArchie Cobbs /* Keep this in sync with the above structure definition */ 291f8307e12SArchie Cobbs #define NG_GENERIC_TYPELIST_INFO(tiarraytype) { \ 29257b57be3SArchie Cobbs { "numtypes", &ng_parse_uint32_type }, \ 293f8307e12SArchie Cobbs { "typeinfo", (tiarraytype) }, \ 294f0184ff8SArchie Cobbs { NULL } \ 295f8307e12SArchie Cobbs } 296f8307e12SArchie Cobbs 297859a4d16SJulian Elischer struct ngm_bandwidth { 298859a4d16SJulian Elischer u_int64_t nominal_in; 299859a4d16SJulian Elischer u_int64_t seen_in; 300859a4d16SJulian Elischer u_int64_t nominal_out; 301859a4d16SJulian Elischer u_int64_t seen_out; 302859a4d16SJulian Elischer }; 303859a4d16SJulian Elischer 304859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */ 305859a4d16SJulian Elischer #define NG_GENERIC_BANDWIDTH_INFO() { \ 306859a4d16SJulian Elischer { "nominal_in", &ng_parse_uint64_type }, \ 307859a4d16SJulian Elischer { "seen_in", &ng_parse_uint64_type }, \ 308859a4d16SJulian Elischer { "nominal_out", &ng_parse_uint64_type }, \ 309859a4d16SJulian Elischer { "seen_out", &ng_parse_uint64_type }, \ 310f0184ff8SArchie Cobbs { NULL } \ 311859a4d16SJulian Elischer } 312859a4d16SJulian Elischer 313859a4d16SJulian Elischer /* 314859a4d16SJulian Elischer * Information about a node's 'output' queue. 315859a4d16SJulian Elischer * This is NOT the netgraph input queueing mechanism, 316859a4d16SJulian Elischer * but rather any queue the node may implement internally 317859a4d16SJulian Elischer * This has to consider ALTQ if we are to work with it. 318859a4d16SJulian Elischer * As far as I can see, ALTQ counts PACKETS, not bytes. 319859a4d16SJulian Elischer * If ALTQ has several queues and one has passed a watermark 320859a4d16SJulian Elischer * we should have the priority of that queue be real (and not -1) 321859a4d16SJulian Elischer * XXX ALTQ stuff is just an idea..... 322859a4d16SJulian Elischer */ 323859a4d16SJulian Elischer struct ngm_queue_state { 324859a4d16SJulian Elischer u_int queue_priority; /* maybe only low-pri is full. -1 = all*/ 325859a4d16SJulian Elischer u_int max_queuelen_bytes; 326859a4d16SJulian Elischer u_int max_queuelen_packets; 327859a4d16SJulian Elischer u_int low_watermark; 328859a4d16SJulian Elischer u_int high_watermark; 329859a4d16SJulian Elischer u_int current; 330859a4d16SJulian Elischer }; 331859a4d16SJulian Elischer 332859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */ 333859a4d16SJulian Elischer #define NG_GENERIC_QUEUE_INFO() { \ 334859a4d16SJulian Elischer { "max_queuelen_bytes", &ng_parse_uint_type }, \ 335859a4d16SJulian Elischer { "max_queuelen_packets", &ng_parse_uint_type }, \ 336859a4d16SJulian Elischer { "high_watermark", &ng_parse_uint_type }, \ 337859a4d16SJulian Elischer { "low_watermark", &ng_parse_uint_type }, \ 338859a4d16SJulian Elischer { "current", &ng_parse_uint_type }, \ 339f0184ff8SArchie Cobbs { NULL } \ 340859a4d16SJulian Elischer } 341859a4d16SJulian Elischer 342859a4d16SJulian Elischer /* Tell a node who to send async flow control info to. */ 343859a4d16SJulian Elischer struct flow_manager { 344859a4d16SJulian Elischer ng_ID_t id; /* unique identifier */ 345859a4d16SJulian Elischer }; 346859a4d16SJulian Elischer 347859a4d16SJulian Elischer /* Keep this in sync with the above structure definition */ 348859a4d16SJulian Elischer #define NG_GENERIC_FLOW_MANAGER_INFO() { \ 349859a4d16SJulian Elischer { "id", &ng_parse_hint32_type }, \ 350f0184ff8SArchie Cobbs { NULL } \ 351859a4d16SJulian Elischer } 352859a4d16SJulian Elischer 353859a4d16SJulian Elischer 3544cf49a43SJulian Elischer /* 3554cf49a43SJulian Elischer * For netgraph nodes that are somehow associated with file descriptors 3564cf49a43SJulian Elischer * (e.g., a device that has a /dev entry and is also a netgraph node), 3574cf49a43SJulian Elischer * we define a generic ioctl for requesting the corresponding nodeinfo 3584cf49a43SJulian Elischer * structure and for assigning a name (if there isn't one already). 3594cf49a43SJulian Elischer * 3604cf49a43SJulian Elischer * For these to you need to also #include <sys/ioccom.h>. 3614cf49a43SJulian Elischer */ 3624cf49a43SJulian Elischer 3634cf49a43SJulian Elischer #define NGIOCGINFO _IOR('N', 40, struct nodeinfo) /* get node info */ 3644cf49a43SJulian Elischer #define NGIOCSETNAME _IOW('N', 41, struct ngm_name) /* set node name */ 3654cf49a43SJulian Elischer 366664a31e4SPeter Wemm #ifdef _KERNEL 3674cf49a43SJulian Elischer /* 3684cf49a43SJulian Elischer * Allocate and initialize a netgraph message "msg" with "len" 3694cf49a43SJulian Elischer * extra bytes of argument. Sets "msg" to NULL if fails. 3704cf49a43SJulian Elischer * Does not initialize token. 3714cf49a43SJulian Elischer */ 3724cf49a43SJulian Elischer #define NG_MKMESSAGE(msg, cookie, cmdid, len, how) \ 3734cf49a43SJulian Elischer do { \ 37411589318SPoul-Henning Kamp KASSERT(!(how & M_DONTWAIT), \ 37511589318SPoul-Henning Kamp ("NG_MKMESSAGE() with how=M_DONTWAIT (%d)\n", how)); \ 37611589318SPoul-Henning Kamp KASSERT(!(how & M_TRYWAIT), \ 37711589318SPoul-Henning Kamp ("NG_MKMESSAGE() with how=M_TRYWAIT (%d)\n", how)); \ 3784cf49a43SJulian Elischer MALLOC((msg), struct ng_mesg *, sizeof(struct ng_mesg) \ 379069154d5SJulian Elischer + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \ 3804cf49a43SJulian Elischer if ((msg) == NULL) \ 3814cf49a43SJulian Elischer break; \ 3824cf49a43SJulian Elischer (msg)->header.version = NG_VERSION; \ 3834cf49a43SJulian Elischer (msg)->header.typecookie = (cookie); \ 3844cf49a43SJulian Elischer (msg)->header.cmd = (cmdid); \ 3854cf49a43SJulian Elischer (msg)->header.arglen = (len); \ 3864cf49a43SJulian Elischer strncpy((msg)->header.cmdstr, #cmdid, \ 3874cf49a43SJulian Elischer sizeof((msg)->header.cmdstr) - 1); \ 3884cf49a43SJulian Elischer } while (0) 3894cf49a43SJulian Elischer 3904cf49a43SJulian Elischer /* 3914cf49a43SJulian Elischer * Allocate and initialize a response "rsp" to a message "msg" 3924cf49a43SJulian Elischer * with "len" extra bytes of argument. Sets "rsp" to NULL if fails. 3934cf49a43SJulian Elischer */ 3944cf49a43SJulian Elischer #define NG_MKRESPONSE(rsp, msg, len, how) \ 3954cf49a43SJulian Elischer do { \ 3964cf49a43SJulian Elischer MALLOC((rsp), struct ng_mesg *, sizeof(struct ng_mesg) \ 397069154d5SJulian Elischer + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \ 3984cf49a43SJulian Elischer if ((rsp) == NULL) \ 3994cf49a43SJulian Elischer break; \ 4004cf49a43SJulian Elischer (rsp)->header.version = NG_VERSION; \ 4014cf49a43SJulian Elischer (rsp)->header.arglen = (len); \ 4024cf49a43SJulian Elischer (rsp)->header.token = (msg)->header.token; \ 4034cf49a43SJulian Elischer (rsp)->header.typecookie = (msg)->header.typecookie; \ 4044cf49a43SJulian Elischer (rsp)->header.cmd = (msg)->header.cmd; \ 4054cf49a43SJulian Elischer bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr, \ 4064cf49a43SJulian Elischer sizeof((rsp)->header.cmdstr)); \ 4074cf49a43SJulian Elischer (rsp)->header.flags |= NGF_RESP; \ 4084cf49a43SJulian Elischer } while (0) 409664a31e4SPeter Wemm #endif /* _KERNEL */ 4104cf49a43SJulian Elischer 4114cf49a43SJulian Elischer #endif /* _NETGRAPH_NG_MESSAGE_H_ */ 4124cf49a43SJulian Elischer 413