1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* ng_message.h
|
2005-01-07 01:45:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*-
|
1999-10-21 09:06:11 +00:00
|
|
|
* Copyright (c) 1996-1999 Whistle Communications, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Subject to the following obligations and disclaimer of warranty, use and
|
|
|
|
* redistribution of this software, in source or object code forms, with or
|
|
|
|
* without modifications are expressly permitted by Whistle Communications;
|
|
|
|
* provided, however, that:
|
|
|
|
* 1. Any and all reproductions of the source or object code must include the
|
|
|
|
* copyright notice above and the following disclaimer of warranties; and
|
|
|
|
* 2. No rights are granted, in any manner or form, to use Whistle
|
|
|
|
* Communications, Inc. trademarks, including the mark "WHISTLE
|
|
|
|
* COMMUNICATIONS" on advertising, endorsements, or otherwise except as
|
|
|
|
* such appears in the above copyright notice or in the software.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS BEING PROVIDED BY WHISTLE COMMUNICATIONS "AS IS", AND
|
|
|
|
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, WHISTLE COMMUNICATIONS MAKES NO
|
|
|
|
* REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, REGARDING THIS SOFTWARE,
|
|
|
|
* INCLUDING WITHOUT LIMITATION, ANY AND ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
|
|
* WHISTLE COMMUNICATIONS DOES NOT WARRANT, GUARANTEE, OR MAKE ANY
|
|
|
|
* REPRESENTATIONS REGARDING THE USE OF, OR THE RESULTS OF THE USE OF THIS
|
|
|
|
* SOFTWARE IN TERMS OF ITS CORRECTNESS, ACCURACY, RELIABILITY OR OTHERWISE.
|
|
|
|
* IN NO EVENT SHALL WHISTLE COMMUNICATIONS BE LIABLE FOR ANY DAMAGES
|
|
|
|
* RESULTING FROM OR ARISING OUT OF ANY USE OF THIS SOFTWARE, INCLUDING
|
|
|
|
* WITHOUT LIMITATION, ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
|
|
* PUNITIVE, OR CONSEQUENTIAL DAMAGES, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES, LOSS OF USE, DATA OR PROFITS, HOWEVER CAUSED AND UNDER 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 WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
|
|
|
|
* OF SUCH DAMAGE.
|
|
|
|
*
|
2000-10-24 17:32:45 +00:00
|
|
|
* Author: Julian Elischer <julian@freebsd.org>
|
1999-10-21 09:06:11 +00:00
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
* $Whistle: ng_message.h,v 1.12 1999/01/25 01:17:44 archie Exp $
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETGRAPH_NG_MESSAGE_H_
|
2003-11-11 12:30:37 +00:00
|
|
|
#define _NETGRAPH_NG_MESSAGE_H_
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
/* ASCII string size limits */
|
2003-11-12 09:10:11 +00:00
|
|
|
#define NG_TYPESIZ 32 /* max type name len (including null) */
|
|
|
|
#define NG_HOOKSIZ 32 /* max hook name len (including null) */
|
|
|
|
#define NG_NODESIZ 32 /* max node name len (including null) */
|
|
|
|
#define NG_PATHSIZ 512 /* max path len (including null) */
|
|
|
|
#define NG_CMDSTRSIZ 32 /* max command string (including null) */
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
#define NG_TEXTRESPONSE 1024 /* allow this length for a text response */
|
|
|
|
|
|
|
|
/* A netgraph message */
|
|
|
|
struct ng_mesg {
|
|
|
|
struct ng_msghdr {
|
2000-12-18 20:03:32 +00:00
|
|
|
u_char version; /* == NGM_VERSION */
|
2005-02-05 23:23:14 +00:00
|
|
|
u_char spare; /* pad to 4 bytes */
|
|
|
|
u_int16_t spare2;
|
|
|
|
u_int32_t arglen; /* length of data */
|
2004-08-20 01:24:23 +00:00
|
|
|
u_int32_t cmd; /* command identifier */
|
1999-10-21 09:06:11 +00:00
|
|
|
u_int32_t flags; /* message status */
|
|
|
|
u_int32_t token; /* match with reply */
|
|
|
|
u_int32_t typecookie; /* node's type cookie */
|
2004-01-26 14:05:31 +00:00
|
|
|
u_char cmdstr[NG_CMDSTRSIZ]; /* cmd string + \0 */
|
1999-10-21 09:06:11 +00:00
|
|
|
} header;
|
2003-10-22 07:35:05 +00:00
|
|
|
char data[]; /* placeholder for actual data */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
1999-11-30 02:45:32 +00:00
|
|
|
|
2006-01-12 19:14:40 +00:00
|
|
|
/* This command is guaranteed to not alter data (or'd into the command). */
|
2001-01-06 00:46:47 +00:00
|
|
|
#define NGM_READONLY 0x10000000
|
2006-01-12 19:14:40 +00:00
|
|
|
/* This command is guaranteed to have a reply (or'd into the command). */
|
|
|
|
#define NGM_HASREPLY 0x20000000
|
2000-12-18 20:03:32 +00:00
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_NG_MESG_INFO(dtype) { \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "version", &ng_parse_uint8_type }, \
|
|
|
|
{ "spare", &ng_parse_uint8_type }, \
|
2005-02-05 23:23:14 +00:00
|
|
|
{ "spare2", &ng_parse_uint16_type }, \
|
|
|
|
{ "arglen", &ng_parse_uint32_type }, \
|
2004-08-20 01:24:23 +00:00
|
|
|
{ "cmd", &ng_parse_uint32_type }, \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "flags", &ng_parse_hint32_type }, \
|
|
|
|
{ "token", &ng_parse_uint32_type }, \
|
|
|
|
{ "typecookie", &ng_parse_uint32_type }, \
|
1999-11-30 02:45:32 +00:00
|
|
|
{ "cmdstr", &ng_parse_cmdbuf_type }, \
|
|
|
|
{ "data", (dtype) }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
2000-12-18 20:03:32 +00:00
|
|
|
/*
|
|
|
|
* Netgraph message header compatibility field
|
|
|
|
* Interfaces within the kernel are defined by a different
|
2005-02-05 23:23:14 +00:00
|
|
|
* value (see NG_ABI_VERSION in netgraph.h)
|
2000-12-18 20:03:32 +00:00
|
|
|
*/
|
2005-02-05 23:23:14 +00:00
|
|
|
#define NG_VERSION 8
|
1999-11-30 02:45:32 +00:00
|
|
|
|
|
|
|
/* Flags field flags */
|
2001-01-06 00:46:47 +00:00
|
|
|
#define NGF_ORIG 0x00000000 /* the msg is the original request */
|
|
|
|
#define NGF_RESP 0x00000001 /* the message is a response */
|
2001-01-30 20:51:52 +00:00
|
|
|
|
2006-10-17 11:01:20 +00:00
|
|
|
/* Type of a unique node ID. */
|
|
|
|
#define ng_ID_t uint32_t
|
1999-11-30 02:45:32 +00:00
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* Here we describe the "generic" messages that all nodes inherently
|
|
|
|
* understand. With the exception of NGM_TEXT_STATUS, these are handled
|
|
|
|
* automatically by the base netgraph code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Generic message type cookie */
|
2006-01-12 19:14:40 +00:00
|
|
|
#define NGM_GENERIC_COOKIE 1137070366
|
|
|
|
|
|
|
|
/* Generic messages defined for this type cookie. */
|
|
|
|
enum {
|
|
|
|
NGM_SHUTDOWN = 1, /* Shut down node. */
|
|
|
|
NGM_MKPEER = 2, /* Create and attach a peer node. */
|
|
|
|
NGM_CONNECT = 3, /* Connect two nodes. */
|
|
|
|
NGM_NAME = 4, /* Give a node a name. */
|
|
|
|
NGM_RMHOOK = 5, /* Break a connection between two nodes. */
|
|
|
|
|
|
|
|
/* Get nodeinfo for target. */
|
|
|
|
NGM_NODEINFO = (6|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* Get list of hooks on node. */
|
|
|
|
NGM_LISTHOOKS = (7|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* List globally named nodes. */
|
|
|
|
NGM_LISTNAMES = (8|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* List all nodes. */
|
|
|
|
NGM_LISTNODES = (9|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* List installed node types. */
|
|
|
|
NGM_LISTTYPES = (10|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* (optional) Get text status. */
|
|
|
|
NGM_TEXT_STATUS = (11|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* Convert struct ng_mesg to ASCII. */
|
|
|
|
NGM_BINARY2ASCII= (12|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* Convert ASCII to struct ng_mesg. */
|
|
|
|
NGM_ASCII2BINARY= (13|NGM_READONLY|NGM_HASREPLY),
|
|
|
|
/* (optional) Get/set text config. */
|
|
|
|
NGM_TEXT_CONFIG = 14,
|
|
|
|
};
|
1999-10-21 09:06:11 +00:00
|
|
|
|
2000-12-12 18:52:14 +00:00
|
|
|
/*
|
|
|
|
* Flow control and intra node control messages.
|
|
|
|
* These are routed between nodes to allow flow control and to allow
|
|
|
|
* events to be passed around the graph.
|
|
|
|
* There will be some form of default handling for these but I
|
|
|
|
* do not yet know what it is..
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Generic message type cookie */
|
|
|
|
#define NGM_FLOW_COOKIE 851672669 /* temp for debugging */
|
|
|
|
|
|
|
|
/* Upstream messages */
|
|
|
|
#define NGM_LINK_IS_UP 32 /* e.g. carrier found - no data */
|
|
|
|
#define NGM_LINK_IS_DOWN 33 /* carrier lost, includes queue state */
|
|
|
|
#define NGM_HIGH_WATER_PASSED 34 /* includes queue state */
|
|
|
|
#define NGM_LOW_WATER_PASSED 35 /* includes queue state */
|
|
|
|
#define NGM_SYNC_QUEUE_STATE 36 /* sync response from sending packet */
|
|
|
|
|
|
|
|
/* Downstream messages */
|
|
|
|
#define NGM_DROP_LINK 41 /* drop DTR, etc. - stay in the graph */
|
2001-02-01 20:51:23 +00:00
|
|
|
#define NGM_RAISE_LINK 42 /* if you previously dropped it */
|
|
|
|
#define NGM_FLUSH_QUEUE 43 /* no data */
|
2001-01-06 00:46:47 +00:00
|
|
|
#define NGM_GET_BANDWIDTH (44|NGM_READONLY) /* either real or measured */
|
2001-02-01 20:51:23 +00:00
|
|
|
#define NGM_SET_XMIT_Q_LIMITS 45 /* includes queue state */
|
2001-01-06 00:46:47 +00:00
|
|
|
#define NGM_GET_XMIT_Q_LIMITS (46|NGM_READONLY) /* returns queue state */
|
2001-02-01 20:51:23 +00:00
|
|
|
#define NGM_MICROMANAGE 47 /* We want sync. queue state
|
2001-01-06 00:46:47 +00:00
|
|
|
reply for each packet sent */
|
2001-02-01 20:51:23 +00:00
|
|
|
#define NGM_SET_FLOW_MANAGER 48 /* send flow control here */
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Structure used for NGM_MKPEER */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct ngm_mkpeer {
|
2004-01-26 14:05:31 +00:00
|
|
|
char type[NG_TYPESIZ]; /* peer type */
|
|
|
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
|
|
|
char peerhook[NG_HOOKSIZ]; /* peer hook name */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_MKPEER_INFO() { \
|
|
|
|
{ "type", &ng_parse_typebuf_type }, \
|
|
|
|
{ "ourhook", &ng_parse_hookbuf_type }, \
|
|
|
|
{ "peerhook", &ng_parse_hookbuf_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_CONNECT */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct ngm_connect {
|
2004-01-26 14:05:31 +00:00
|
|
|
char path[NG_PATHSIZ]; /* peer path */
|
|
|
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
|
|
|
char peerhook[NG_HOOKSIZ]; /* peer hook name */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_CONNECT_INFO() { \
|
|
|
|
{ "path", &ng_parse_pathbuf_type }, \
|
|
|
|
{ "ourhook", &ng_parse_hookbuf_type }, \
|
|
|
|
{ "peerhook", &ng_parse_hookbuf_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_NAME */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct ngm_name {
|
2004-01-26 14:05:31 +00:00
|
|
|
char name[NG_NODESIZ]; /* node name */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_NAME_INFO() { \
|
|
|
|
{ "name", &ng_parse_nodebuf_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_RMHOOK */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct ngm_rmhook {
|
2004-01-26 14:05:31 +00:00
|
|
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_RMHOOK_INFO() { \
|
|
|
|
{ "hook", &ng_parse_hookbuf_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_NODEINFO */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct nodeinfo {
|
2004-01-26 14:05:31 +00:00
|
|
|
char name[NG_NODESIZ]; /* node name (if any) */
|
|
|
|
char type[NG_TYPESIZ]; /* peer type */
|
1999-11-01 00:31:14 +00:00
|
|
|
ng_ID_t id; /* unique identifier */
|
1999-10-21 09:06:11 +00:00
|
|
|
u_int32_t hooks; /* number of active hooks */
|
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_NODEINFO_INFO() { \
|
|
|
|
{ "name", &ng_parse_nodebuf_type }, \
|
|
|
|
{ "type", &ng_parse_typebuf_type }, \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "id", &ng_parse_hint32_type }, \
|
|
|
|
{ "hooks", &ng_parse_uint32_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_LISTHOOKS */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct linkinfo {
|
2004-01-26 14:05:31 +00:00
|
|
|
char ourhook[NG_HOOKSIZ]; /* hook name */
|
|
|
|
char peerhook[NG_HOOKSIZ]; /* peer hook */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct nodeinfo nodeinfo;
|
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_LINKINFO_INFO(nitype) { \
|
|
|
|
{ "ourhook", &ng_parse_hookbuf_type }, \
|
|
|
|
{ "peerhook", &ng_parse_hookbuf_type }, \
|
|
|
|
{ "nodeinfo", (nitype) }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
struct hooklist {
|
|
|
|
struct nodeinfo nodeinfo; /* node information */
|
2003-10-22 07:35:05 +00:00
|
|
|
struct linkinfo link[]; /* info about each hook */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_HOOKLIST_INFO(nitype,litype) { \
|
|
|
|
{ "nodeinfo", (nitype) }, \
|
|
|
|
{ "linkinfo", (litype) }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_LISTNAMES/NGM_LISTNODES */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct namelist {
|
|
|
|
u_int32_t numnames;
|
2003-10-22 07:35:05 +00:00
|
|
|
struct nodeinfo nodeinfo[];
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_LISTNODES_INFO(niarraytype) { \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "numnames", &ng_parse_uint32_type }, \
|
1999-11-30 02:45:32 +00:00
|
|
|
{ "nodeinfo", (niarraytype) }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Structure used for NGM_LISTTYPES */
|
1999-10-21 09:06:11 +00:00
|
|
|
struct typeinfo {
|
2004-01-26 14:05:31 +00:00
|
|
|
char type_name[NG_TYPESIZ]; /* name of type */
|
|
|
|
u_int32_t numnodes; /* number alive */
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_TYPEINFO_INFO() { \
|
|
|
|
{ "typename", &ng_parse_typebuf_type }, \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "numnodes", &ng_parse_uint32_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
struct typelist {
|
|
|
|
u_int32_t numtypes;
|
2003-10-22 07:35:05 +00:00
|
|
|
struct typeinfo typeinfo[];
|
1999-10-21 09:06:11 +00:00
|
|
|
};
|
|
|
|
|
1999-11-30 02:45:32 +00:00
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_TYPELIST_INFO(tiarraytype) { \
|
2000-08-10 22:45:54 +00:00
|
|
|
{ "numtypes", &ng_parse_uint32_type }, \
|
1999-11-30 02:45:32 +00:00
|
|
|
{ "typeinfo", (tiarraytype) }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
1999-11-30 02:45:32 +00:00
|
|
|
}
|
|
|
|
|
2000-12-12 18:52:14 +00:00
|
|
|
struct ngm_bandwidth {
|
|
|
|
u_int64_t nominal_in;
|
|
|
|
u_int64_t seen_in;
|
|
|
|
u_int64_t nominal_out;
|
|
|
|
u_int64_t seen_out;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_BANDWIDTH_INFO() { \
|
|
|
|
{ "nominal_in", &ng_parse_uint64_type }, \
|
|
|
|
{ "seen_in", &ng_parse_uint64_type }, \
|
|
|
|
{ "nominal_out", &ng_parse_uint64_type }, \
|
|
|
|
{ "seen_out", &ng_parse_uint64_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
2000-12-12 18:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Information about a node's 'output' queue.
|
|
|
|
* This is NOT the netgraph input queueing mechanism,
|
|
|
|
* but rather any queue the node may implement internally
|
|
|
|
* This has to consider ALTQ if we are to work with it.
|
|
|
|
* As far as I can see, ALTQ counts PACKETS, not bytes.
|
|
|
|
* If ALTQ has several queues and one has passed a watermark
|
|
|
|
* we should have the priority of that queue be real (and not -1)
|
|
|
|
* XXX ALTQ stuff is just an idea.....
|
|
|
|
*/
|
|
|
|
struct ngm_queue_state {
|
|
|
|
u_int queue_priority; /* maybe only low-pri is full. -1 = all*/
|
|
|
|
u_int max_queuelen_bytes;
|
|
|
|
u_int max_queuelen_packets;
|
|
|
|
u_int low_watermark;
|
|
|
|
u_int high_watermark;
|
|
|
|
u_int current;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_QUEUE_INFO() { \
|
|
|
|
{ "max_queuelen_bytes", &ng_parse_uint_type }, \
|
|
|
|
{ "max_queuelen_packets", &ng_parse_uint_type }, \
|
|
|
|
{ "high_watermark", &ng_parse_uint_type }, \
|
|
|
|
{ "low_watermark", &ng_parse_uint_type }, \
|
|
|
|
{ "current", &ng_parse_uint_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
2000-12-12 18:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Tell a node who to send async flow control info to. */
|
|
|
|
struct flow_manager {
|
|
|
|
ng_ID_t id; /* unique identifier */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Keep this in sync with the above structure definition */
|
|
|
|
#define NG_GENERIC_FLOW_MANAGER_INFO() { \
|
|
|
|
{ "id", &ng_parse_hint32_type }, \
|
2002-05-31 23:48:03 +00:00
|
|
|
{ NULL } \
|
2000-12-12 18:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* For netgraph nodes that are somehow associated with file descriptors
|
|
|
|
* (e.g., a device that has a /dev entry and is also a netgraph node),
|
|
|
|
* we define a generic ioctl for requesting the corresponding nodeinfo
|
|
|
|
* structure and for assigning a name (if there isn't one already).
|
|
|
|
*
|
|
|
|
* For these to you need to also #include <sys/ioccom.h>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NGIOCGINFO _IOR('N', 40, struct nodeinfo) /* get node info */
|
|
|
|
#define NGIOCSETNAME _IOW('N', 41, struct ngm_name) /* set node name */
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1999-10-21 09:06:11 +00:00
|
|
|
/*
|
|
|
|
* Allocate and initialize a netgraph message "msg" with "len"
|
|
|
|
* extra bytes of argument. Sets "msg" to NULL if fails.
|
|
|
|
* Does not initialize token.
|
|
|
|
*/
|
|
|
|
#define NG_MKMESSAGE(msg, cookie, cmdid, len, how) \
|
|
|
|
do { \
|
2008-10-23 15:53:51 +00:00
|
|
|
(msg) = malloc(sizeof(struct ng_mesg) \
|
2001-01-06 00:46:47 +00:00
|
|
|
+ (len), M_NETGRAPH_MSG, (how) | M_ZERO); \
|
1999-10-21 09:06:11 +00:00
|
|
|
if ((msg) == NULL) \
|
|
|
|
break; \
|
|
|
|
(msg)->header.version = NG_VERSION; \
|
|
|
|
(msg)->header.typecookie = (cookie); \
|
|
|
|
(msg)->header.cmd = (cmdid); \
|
|
|
|
(msg)->header.arglen = (len); \
|
|
|
|
strncpy((msg)->header.cmdstr, #cmdid, \
|
|
|
|
sizeof((msg)->header.cmdstr) - 1); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate and initialize a response "rsp" to a message "msg"
|
|
|
|
* with "len" extra bytes of argument. Sets "rsp" to NULL if fails.
|
|
|
|
*/
|
|
|
|
#define NG_MKRESPONSE(rsp, msg, len, how) \
|
|
|
|
do { \
|
2008-10-23 15:53:51 +00:00
|
|
|
(rsp) = malloc(sizeof(struct ng_mesg) \
|
2001-01-06 00:46:47 +00:00
|
|
|
+ (len), M_NETGRAPH_MSG, (how) | M_ZERO); \
|
1999-10-21 09:06:11 +00:00
|
|
|
if ((rsp) == NULL) \
|
|
|
|
break; \
|
|
|
|
(rsp)->header.version = NG_VERSION; \
|
|
|
|
(rsp)->header.arglen = (len); \
|
|
|
|
(rsp)->header.token = (msg)->header.token; \
|
|
|
|
(rsp)->header.typecookie = (msg)->header.typecookie; \
|
|
|
|
(rsp)->header.cmd = (msg)->header.cmd; \
|
|
|
|
bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr, \
|
|
|
|
sizeof((rsp)->header.cmdstr)); \
|
|
|
|
(rsp)->header.flags |= NGF_RESP; \
|
|
|
|
} while (0)
|
2005-04-20 12:18:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make a copy of message. Sets "copy" to NULL if fails.
|
|
|
|
*/
|
|
|
|
#define NG_COPYMESSAGE(copy, msg, how) \
|
|
|
|
do { \
|
2008-10-23 15:53:51 +00:00
|
|
|
(copy) = malloc(sizeof(struct ng_mesg) \
|
|
|
|
+ (msg)->header.arglen, M_NETGRAPH_MSG, (how) | M_ZERO); \
|
2005-04-20 12:18:22 +00:00
|
|
|
if ((copy) == NULL) \
|
|
|
|
break; \
|
|
|
|
(copy)->header.version = NG_VERSION; \
|
|
|
|
(copy)->header.arglen = (msg)->header.arglen; \
|
|
|
|
(copy)->header.token = (msg)->header.token; \
|
|
|
|
(copy)->header.typecookie = (msg)->header.typecookie; \
|
|
|
|
(copy)->header.cmd = (msg)->header.cmd; \
|
|
|
|
(copy)->header.flags = (msg)->header.flags; \
|
|
|
|
bcopy((msg)->header.cmdstr, (copy)->header.cmdstr, \
|
|
|
|
sizeof((copy)->header.cmdstr)); \
|
|
|
|
if ((msg)->header.arglen > 0) \
|
|
|
|
bcopy((msg)->data, (copy)->data, (msg)->header.arglen); \
|
|
|
|
} while (0)
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1999-10-21 09:06:11 +00:00
|
|
|
|
|
|
|
#endif /* _NETGRAPH_NG_MESSAGE_H_ */
|