MCPcopy Create free account
hub / github.com/F-Stack/f-stack / NgSendMsg

Function NgSendMsg

tools/libnetgraph/msg.c:90–109  ·  view source on GitHub ↗

* Send a message to a node using control socket node "cs". * Returns -1 if error and sets errno appropriately. * If successful, returns the message ID (token) used. */

Source from the content-addressed store, hash-verified

88 * If successful, returns the message ID (token) used.
89 */
90int
91NgSendMsg(int cs, const char *path,
92 int cookie, int cmd, const void *args, size_t arglen)
93{
94 struct ng_mesg msg;
95
96 /* Prepare message header */
97 memset(&msg, 0, sizeof(msg));
98 msg.header.version = NG_VERSION;
99 msg.header.typecookie = cookie;
100 msg.header.token = atomic_fetch_add(&gMsgId, 1) & INT_MAX;
101 msg.header.flags = NGF_ORIG;
102 msg.header.cmd = cmd;
103 snprintf((char *)msg.header.cmdstr, NG_CMDSTRSIZ, "cmd%d", cmd);
104
105 /* Deliver message */
106 if (NgDeliverMsg(cs, path, &msg, args, arglen) < 0)
107 return (-1);
108 return (msg.header.token);
109}
110
111/*
112 * Send a message given in ASCII format. We first ask the node to translate

Callers 15

NgSendAsciiMsgFunction · 0.85
NgRecvAsciiMsgFunction · 0.85
NgMkSockNodeFunction · 0.85
NgNameNodeFunction · 0.85
_NgDebugMsgFunction · 0.85
netgraphprotoprFunction · 0.85
ConfigCmdFunction · 0.85
ShowCmdFunction · 0.85
ConnectCmdFunction · 0.85
NameCmdFunction · 0.85
MkPeerCmdFunction · 0.85
MsgReadFunction · 0.85

Calls 3

memsetFunction · 0.85
snprintfFunction · 0.85
NgDeliverMsgFunction · 0.85

Tested by

no test coverage detected