* Receive incoming data on our hook. */
| 320 | * Receive incoming data on our hook. |
| 321 | */ |
| 322 | static int |
| 323 | ng_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. |
nothing calls this directly
no test coverage detected