* Receive incoming data on our hook. */
| 296 | * Receive incoming data on our hook. |
| 297 | */ |
| 298 | static int |
| 299 | ng_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. |
nothing calls this directly
no test coverage detected