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

Function ng_mppc_rcvdata

freebsd/netgraph/ng_mppc.c:370–422  ·  view source on GitHub ↗

* Receive incoming data on our hook. */

Source from the content-addressed store, hash-verified

368 * Receive incoming data on our hook.
369 */
370static int
371ng_mppc_rcvdata(hook_p hook, item_p item)
372{
373 const node_p node = NG_HOOK_NODE(hook);
374 const priv_p priv = NG_NODE_PRIVATE(node);
375 int error;
376 struct mbuf *m;
377
378 NGI_GET_M(item, m);
379 /* Compress and/or encrypt */
380 if (hook == priv->xmit.hook) {
381 if (!priv->xmit.cfg.enable) {
382 NG_FREE_M(m);
383 NG_FREE_ITEM(item);
384 return (ENXIO);
385 }
386 if ((error = ng_mppc_compress(node, &m)) != 0) {
387 NG_FREE_ITEM(item);
388 return(error);
389 }
390 NG_FWD_NEW_DATA(error, item, priv->xmit.hook, m);
391 return (error);
392 }
393
394 /* Decompress and/or decrypt */
395 if (hook == priv->recv.hook) {
396 if (!priv->recv.cfg.enable) {
397 NG_FREE_M(m);
398 NG_FREE_ITEM(item);
399 return (ENXIO);
400 }
401 if ((error = ng_mppc_decompress(node, &m)) != 0) {
402 NG_FREE_ITEM(item);
403 if (error == EINVAL && priv->ctrlnode != 0) {
404 struct ng_mesg *msg;
405
406 /* Need to send a reset-request */
407 NG_MKMESSAGE(msg, NGM_MPPC_COOKIE,
408 NGM_MPPC_RESETREQ, 0, M_NOWAIT);
409 if (msg == NULL)
410 return (error);
411 NG_SEND_MSG_ID(error, node, msg,
412 priv->ctrlnode, 0);
413 }
414 return (error);
415 }
416 NG_FWD_NEW_DATA(error, item, priv->recv.hook, m);
417 return (error);
418 }
419
420 /* Oops */
421 panic("%s: unknown hook", __func__);
422}
423
424/*
425 * Destroy node

Callers

nothing calls this directly

Calls 3

ng_mppc_compressFunction · 0.85
ng_mppc_decompressFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected