From 33c22c64e90bb76e13d5cc546c25e3b52a6ac646 Mon Sep 17 00:00:00 2001 From: Archie Cobbs Date: Wed, 21 Jun 2000 23:01:07 +0000 Subject: [PATCH] - Make sure the message token returned by NgSendMsg() is non-negative - Have NgSendAsciiMsg() return the same token as NgSendMsg() - Document that NgSendMsg() and NgSendAsciiMsg() return the token - Add MLINKS for the functions defined in netgraph(3) --- lib/libnetgraph/Makefile | 12 ++++++++++++ lib/libnetgraph/msg.c | 15 +++++++++++---- lib/libnetgraph/netgraph.3 | 5 +++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/libnetgraph/Makefile b/lib/libnetgraph/Makefile index 39d9ad8e2657..04a917dc5e79 100644 --- a/lib/libnetgraph/Makefile +++ b/lib/libnetgraph/Makefile @@ -12,4 +12,16 @@ INCS= netgraph.h CFLAGS+= -Wall +MLINKS+= netgraph.3 NgMkSockNode.3 +MLINKS+= netgraph.3 NgNameNode.3 +MLINKS+= netgraph.3 NgSendMsg.3 +MLINKS+= netgraph.3 NgSendAsciiMsg.3 +MLINKS+= netgraph.3 NgSendMsgReply.3 +MLINKS+= netgraph.3 NgRecvMsg.3 +MLINKS+= netgraph.3 NgRecvAsciiMsg.3 +MLINKS+= netgraph.3 NgSendData.3 +MLINKS+= netgraph.3 NgRecvData.3 +MLINKS+= netgraph.3 NgSetDebug.3 +MLINKS+= netgraph.3 NgSetErrLog.3 + .include diff --git a/lib/libnetgraph/msg.c b/lib/libnetgraph/msg.c index bae4743e5a50..4cec810bc313 100644 --- a/lib/libnetgraph/msg.c +++ b/lib/libnetgraph/msg.c @@ -70,7 +70,9 @@ NgSendMsg(int cs, const char *path, memset(&msg, 0, sizeof(msg)); msg.header.version = NG_VERSION; msg.header.typecookie = cookie; - msg.header.token = ++gMsgId; + if (++gMsgId < 0) + gMsgId = 1; + msg.header.token = gMsgId; msg.header.flags = NGF_ORIG; msg.header.cmd = cmd; snprintf(msg.header.cmdstr, NG_CMDSTRLEN + 1, "cmd%d", cmd); @@ -78,7 +80,7 @@ NgSendMsg(int cs, const char *path, /* Deliver message */ if (NgDeliverMsg(cs, path, &msg, args, arglen) < 0) return (-1); - return(gMsgId); + return (gMsgId); } /* @@ -137,8 +139,13 @@ NgSendAsciiMsg(int cs, const char *path, const char *fmt, ...) return (-1); /* Now send binary version */ - return NgDeliverMsg(cs, - path, binary, binary->data, binary->header.arglen); + if (++gMsgId < 0) + gMsgId = 1; + binary->header.token = gMsgId; + if (NgDeliverMsg(cs, + path, binary, binary->data, binary->header.arglen) < 0) + return (-1); + return (gMsgId); } /* diff --git a/lib/libnetgraph/netgraph.3 b/lib/libnetgraph/netgraph.3 index f5df1744e9a4..67a037055b17 100644 --- a/lib/libnetgraph/netgraph.3 +++ b/lib/libnetgraph/netgraph.3 @@ -124,6 +124,8 @@ The .Fa cmd , and argument data are defined by the header file corresponding to the type of the node being addressed. +The unique, non-negative token value chosen for use in the message +header is returned. This value is typically used to associate replies. .Pp Use .Fn NgSendMsgReply @@ -147,6 +149,9 @@ string to the node in a control message. The node returns a binary version of the message, which is then sent back to the node just as with .Fn NgSendMsg . +As with +.Fn NgSendMsg , +the message token value is returned. Note that .Tn ASCII conversion may not be supported by all node types.