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

Function ng_deflate_rcvdata

freebsd/netgraph/ng_deflate.c:322–364  ·  view source on GitHub ↗

* Receive incoming data on our hook. */

Source from the content-addressed store, hash-verified

320 * Receive incoming data on our hook.
321 */
322static int
323ng_deflate_rcvdata(hook_p hook, item_p item)
324{
325 const node_p node = NG_HOOK_NODE(hook);
326 const priv_p priv = NG_NODE_PRIVATE(node);
327 struct mbuf *m, *out;
328 int error;
329
330 if (!priv->cfg.enable) {
331 NG_FREE_ITEM(item);
332 return (ENXIO);
333 }
334
335 NGI_GET_M(item, m);
336 /* Compress */
337 if (priv->compress) {
338 if ((error = ng_deflate_compress(node, m, &out)) != 0) {
339 NG_FREE_ITEM(item);
340 log(LOG_NOTICE, "%s: error: %d\n", __func__, error);
341 return (error);
342 }
343 } else { /* Decompress */
344 if ((error = ng_deflate_decompress(node, m, &out)) != 0) {
345 NG_FREE_ITEM(item);
346 log(LOG_NOTICE, "%s: error: %d\n", __func__, error);
347 if (priv->ctrlnode != 0) {
348 struct ng_mesg *msg;
349
350 /* Need to send a reset-request. */
351 NG_MKMESSAGE(msg, NGM_DEFLATE_COOKIE,
352 NGM_DEFLATE_RESETREQ, 0, M_NOWAIT);
353 if (msg == NULL)
354 return (error);
355 NG_SEND_MSG_ID(error, node, msg,
356 priv->ctrlnode, 0);
357 }
358 return (error);
359 }
360 }
361
362 NG_FWD_NEW_DATA(error, item, hook, out);
363 return (error);
364}
365
366/*
367 * Destroy node.

Callers

nothing calls this directly

Calls 3

ng_deflate_compressFunction · 0.85
ng_deflate_decompressFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected