* 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. */
| 88 | * If successful, returns the message ID (token) used. |
| 89 | */ |
| 90 | int |
| 91 | NgSendMsg(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 |
no test coverage detected