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

Function ng_pred1_rcvdata

freebsd/netgraph/ng_pred1.c:298–341  ·  view source on GitHub ↗

* Receive incoming data on our hook. */

Source from the content-addressed store, hash-verified

296 * Receive incoming data on our hook.
297 */
298static int
299ng_pred1_rcvdata(hook_p hook, item_p item)
300{
301 const node_p node = NG_HOOK_NODE(hook);
302 const priv_p priv = NG_NODE_PRIVATE(node);
303 struct mbuf *m, *out;
304 int error;
305
306 if (!priv->cfg.enable) {
307 NG_FREE_ITEM(item);
308 return (ENXIO);
309 }
310
311 NGI_GET_M(item, m);
312 /* Compress. */
313 if (priv->compress) {
314 if ((error = ng_pred1_compress(node, m, &out)) != 0) {
315 NG_FREE_ITEM(item);
316 log(LOG_NOTICE, "%s: error: %d\n", __func__, error);
317 return (error);
318 }
319
320 } else { /* Decompress. */
321 if ((error = ng_pred1_decompress(node, m, &out)) != 0) {
322 NG_FREE_ITEM(item);
323 log(LOG_NOTICE, "%s: error: %d\n", __func__, error);
324 if (priv->ctrlnode != 0) {
325 struct ng_mesg *msg;
326
327 /* Need to send a reset-request. */
328 NG_MKMESSAGE(msg, NGM_PRED1_COOKIE,
329 NGM_PRED1_RESETREQ, 0, M_NOWAIT);
330 if (msg == NULL)
331 return (error);
332 NG_SEND_MSG_ID(error, node, msg,
333 priv->ctrlnode, 0);
334 }
335 return (error);
336 }
337 }
338
339 NG_FWD_NEW_DATA(error, item, hook, out);
340 return (error);
341}
342
343/*
344 * Destroy node.

Callers

nothing calls this directly

Calls 3

ng_pred1_compressFunction · 0.85
ng_pred1_decompressFunction · 0.85
logFunction · 0.50

Tested by

no test coverage detected