44#ifndef _NETGRAPH_NG_MESSAGE_H_
45#define _NETGRAPH_NG_MESSAGE_H_
52#define NG_CMDSTRSIZ 32
54#define NG_TEXTRESPONSE 1024
73#define NGM_READONLY 0x10000000
75#define NGM_HASREPLY 0x20000000
78#define NG_GENERIC_NG_MESG_INFO(dtype) { \
79 { "version", &ng_parse_uint8_type }, \
80 { "spare", &ng_parse_uint8_type }, \
81 { "spare2", &ng_parse_uint16_type }, \
82 { "arglen", &ng_parse_uint32_type }, \
83 { "cmd", &ng_parse_uint32_type }, \
84 { "flags", &ng_parse_hint32_type }, \
85 { "token", &ng_parse_uint32_type }, \
86 { "typecookie", &ng_parse_uint32_type }, \
87 { "cmdstr", &ng_parse_cmdbuf_type }, \
88 { "data", (dtype) }, \
100#define NGF_ORIG 0x00000000
101#define NGF_RESP 0x00000001
104#define ng_ID_t uint32_t
113#define NGM_GENERIC_COOKIE 1137070366
152#define NGM_FLOW_COOKIE 851672669
155#define NGM_LINK_IS_UP 32
156#define NGM_LINK_IS_DOWN 33
157#define NGM_HIGH_WATER_PASSED 34
158#define NGM_LOW_WATER_PASSED 35
159#define NGM_SYNC_QUEUE_STATE 36
162#define NGM_DROP_LINK 41
163#define NGM_RAISE_LINK 42
164#define NGM_FLUSH_QUEUE 43
165#define NGM_GET_BANDWIDTH (44|NGM_READONLY)
166#define NGM_SET_XMIT_Q_LIMITS 45
167#define NGM_GET_XMIT_Q_LIMITS (46|NGM_READONLY)
168#define NGM_MICROMANAGE 47
170#define NGM_SET_FLOW_MANAGER 48
179#define NG_GENERIC_MKPEER_INFO() { \
180 { "type", &ng_parse_typebuf_type }, \
181 { "ourhook", &ng_parse_hookbuf_type }, \
182 { "peerhook", &ng_parse_hookbuf_type }, \
194#define NG_GENERIC_CONNECT_INFO() { \
195 { "path", &ng_parse_pathbuf_type }, \
196 { "ourhook", &ng_parse_hookbuf_type }, \
197 { "peerhook", &ng_parse_hookbuf_type }, \
207#define NG_GENERIC_NAME_INFO() { \
208 { "name", &ng_parse_nodebuf_type }, \
218#define NG_GENERIC_RMHOOK_INFO() { \
219 { "hook", &ng_parse_hookbuf_type }, \
232#define NG_GENERIC_NODEINFO_INFO() { \
233 { "name", &ng_parse_nodebuf_type }, \
234 { "type", &ng_parse_typebuf_type }, \
235 { "id", &ng_parse_hint32_type }, \
236 { "hooks", &ng_parse_uint32_type }, \
248#define NG_GENERIC_LINKINFO_INFO(nitype) { \
249 { "ourhook", &ng_parse_hookbuf_type }, \
250 { "peerhook", &ng_parse_hookbuf_type }, \
251 { "nodeinfo", (nitype) }, \
261#define NG_GENERIC_HOOKLIST_INFO(nitype,litype) { \
262 { "nodeinfo", (nitype) }, \
263 { "linkinfo", (litype) }, \
274#define NG_GENERIC_LISTNODES_INFO(niarraytype) { \
275 { "numnames", &ng_parse_uint32_type }, \
276 { "nodeinfo", (niarraytype) }, \
287#define NG_GENERIC_TYPEINFO_INFO() { \
288 { "typename", &ng_parse_typebuf_type }, \
289 { "numnodes", &ng_parse_uint32_type }, \
299#define NG_GENERIC_TYPELIST_INFO(tiarraytype) { \
300 { "numtypes", &ng_parse_uint32_type }, \
301 { "typeinfo", (tiarraytype) }, \
313#define NG_GENERIC_BANDWIDTH_INFO() { \
314 { "nominal_in", &ng_parse_uint64_type }, \
315 { "seen_in", &ng_parse_uint64_type }, \
316 { "nominal_out", &ng_parse_uint64_type }, \
317 { "seen_out", &ng_parse_uint64_type }, \
341#define NG_GENERIC_QUEUE_INFO() { \
342 { "max_queuelen_bytes", &ng_parse_uint_type }, \
343 { "max_queuelen_packets", &ng_parse_uint_type }, \
344 { "high_watermark", &ng_parse_uint_type }, \
345 { "low_watermark", &ng_parse_uint_type }, \
346 { "current", &ng_parse_uint_type }, \
356#define NG_GENERIC_FLOW_MANAGER_INFO() { \
357 { "id", &ng_parse_hint32_type }, \
370#define NGIOCGINFO _IOR('N', 40, struct nodeinfo)
371#define NGIOCSETNAME _IOW('N', 41, struct ngm_name)
379#define NG_MKMESSAGE(msg, cookie, cmdid, len, how) \
381 (msg) = malloc(sizeof(struct ng_mesg) \
382 + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \
385 (msg)->header.version = NG_VERSION; \
386 (msg)->header.typecookie = (cookie); \
387 (msg)->header.cmd = (cmdid); \
388 (msg)->header.arglen = (len); \
389 strncpy((msg)->header.cmdstr, #cmdid, \
390 sizeof((msg)->header.cmdstr) - 1); \
397#define NG_MKRESPONSE(rsp, msg, len, how) \
399 (rsp) = malloc(sizeof(struct ng_mesg) \
400 + (len), M_NETGRAPH_MSG, (how) | M_ZERO); \
403 (rsp)->header.version = NG_VERSION; \
404 (rsp)->header.arglen = (len); \
405 (rsp)->header.token = (msg)->header.token; \
406 (rsp)->header.typecookie = (msg)->header.typecookie; \
407 (rsp)->header.cmd = (msg)->header.cmd; \
408 bcopy((msg)->header.cmdstr, (rsp)->header.cmdstr, \
409 sizeof((rsp)->header.cmdstr)); \
410 (rsp)->header.flags |= NGF_RESP; \
416#define NG_COPYMESSAGE(copy, msg, how) \
418 (copy) = malloc(sizeof(struct ng_mesg) \
419 + (msg)->header.arglen, M_NETGRAPH_MSG, (how) | M_ZERO); \
420 if ((copy) == NULL) \
422 (copy)->header.version = NG_VERSION; \
423 (copy)->header.arglen = (msg)->header.arglen; \
424 (copy)->header.token = (msg)->header.token; \
425 (copy)->header.typecookie = (msg)->header.typecookie; \
426 (copy)->header.cmd = (msg)->header.cmd; \
427 (copy)->header.flags = (msg)->header.flags; \
428 bcopy((msg)->header.cmdstr, (copy)->header.cmdstr, \
429 sizeof((copy)->header.cmdstr)); \
430 if ((msg)->header.arglen > 0) \
431 bcopy((msg)->data, (copy)->data, (msg)->header.arglen); \
char peerhook[NG_HOOKSIZ]
u_char cmdstr[NG_CMDSTRSIZ]
struct ng_mesg::ng_msghdr header
char peerhook[NG_HOOKSIZ]
char peerhook[NG_HOOKSIZ]
u_int max_queuelen_packets
char type_name[NG_TYPESIZ]