summaryrefslogtreecommitdiffstats
path: root/lib/libnetgraph/msg.c
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-06-21 23:01:07 +0000
committerarchie <archie@FreeBSD.org>2000-06-21 23:01:07 +0000
commit8bd069edd69b70e3312829e2c8fc645c8f38ab51 (patch)
treec6e999b0c61eb91c640ef60b4e3313eefbfad299 /lib/libnetgraph/msg.c
parent369e860f9ccf2363276633699acfd47eb38cd964 (diff)
downloadFreeBSD-src-8bd069edd69b70e3312829e2c8fc645c8f38ab51.zip
FreeBSD-src-8bd069edd69b70e3312829e2c8fc645c8f38ab51.tar.gz
- 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)
Diffstat (limited to 'lib/libnetgraph/msg.c')
-rw-r--r--lib/libnetgraph/msg.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/libnetgraph/msg.c b/lib/libnetgraph/msg.c
index bae4743..4cec810 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);
}
/*
OpenPOWER on IntegriCloud