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

Function ng_vjc_rcvmsg

freebsd/netgraph/ng_vjc.c:290–392  ·  view source on GitHub ↗

* Receive a control message */

Source from the content-addressed store, hash-verified

288 * Receive a control message
289 */
290static int
291ng_vjc_rcvmsg(node_p node, item_p item, hook_p lasthook)
292{
293 const priv_p priv = NG_NODE_PRIVATE(node);
294 struct ng_mesg *resp = NULL;
295 int error = 0;
296 struct ng_mesg *msg;
297
298 NGI_GET_MSG(item, msg);
299 /* Check type cookie */
300 switch (msg->header.typecookie) {
301 case NGM_VJC_COOKIE:
302 switch (msg->header.cmd) {
303 case NGM_VJC_SET_CONFIG:
304 {
305 struct ngm_vjc_config *const c =
306 (struct ngm_vjc_config *) msg->data;
307
308 if (msg->header.arglen != sizeof(*c))
309 ERROUT(EINVAL);
310 if ((priv->conf.enableComp || priv->conf.enableDecomp)
311 && (c->enableComp || c->enableDecomp))
312 ERROUT(EALREADY);
313 if (c->enableComp) {
314 if (c->maxChannel > NG_VJC_MAX_CHANNELS - 1
315 || c->maxChannel < NG_VJC_MIN_CHANNELS - 1)
316 ERROUT(EINVAL);
317 } else
318 c->maxChannel = NG_VJC_MAX_CHANNELS - 1;
319 if (c->enableComp != 0 || c->enableDecomp != 0) {
320 bzero(&priv->slc, sizeof(priv->slc));
321 sl_compress_init(&priv->slc, c->maxChannel);
322 }
323 priv->conf = *c;
324 break;
325 }
326 case NGM_VJC_GET_CONFIG:
327 {
328 struct ngm_vjc_config *conf;
329
330 NG_MKRESPONSE(resp, msg, sizeof(*conf), M_NOWAIT);
331 if (resp == NULL)
332 ERROUT(ENOMEM);
333 conf = (struct ngm_vjc_config *)resp->data;
334 *conf = priv->conf;
335 break;
336 }
337 case NGM_VJC_GET_STATE:
338 {
339 const struct slcompress *const sl0 = &priv->slc;
340 struct slcompress *sl;
341 u_int16_t index;
342 int i;
343
344 /* Get response structure */
345 NG_MKRESPONSE(resp, msg, sizeof(*sl), M_NOWAIT);
346 if (resp == NULL)
347 ERROUT(ENOMEM);

Callers

nothing calls this directly

Calls 3

bzeroFunction · 0.85
sl_compress_initFunction · 0.85
sl_uncompress_tcpFunction · 0.85

Tested by

no test coverage detected