* Receive incoming data from netgraph system. Put it on our * output queue and start output if necessary. */
| 308 | * output queue and start output if necessary. |
| 309 | */ |
| 310 | static int |
| 311 | ngt_rcvdata(hook_p hook, item_p item) |
| 312 | { |
| 313 | const sc_p sc = NG_NODE_PRIVATE(NG_HOOK_NODE(hook)); |
| 314 | struct tty *tp = sc->tp; |
| 315 | struct mbuf *m; |
| 316 | |
| 317 | if (hook != sc->hook) |
| 318 | panic("%s", __func__); |
| 319 | |
| 320 | NGI_GET_M(item, m); |
| 321 | NG_FREE_ITEM(item); |
| 322 | |
| 323 | if (tp == NULL) { |
| 324 | NG_FREE_M(m); |
| 325 | return (ENXIO); |
| 326 | } |
| 327 | |
| 328 | IF_LOCK(&sc->outq); |
| 329 | if (_IF_QFULL(&sc->outq)) { |
| 330 | IF_UNLOCK(&sc->outq); |
| 331 | NG_FREE_M(m); |
| 332 | return (ENOBUFS); |
| 333 | } |
| 334 | |
| 335 | _IF_ENQUEUE(&sc->outq, m); |
| 336 | sc->outqlen += m->m_pkthdr.len; |
| 337 | IF_UNLOCK(&sc->outq); |
| 338 | |
| 339 | /* notify the TTY that data is ready */ |
| 340 | tty_lock(tp); |
| 341 | if (!tty_gone(tp)) |
| 342 | ttydevsw_outwakeup(tp); |
| 343 | tty_unlock(tp); |
| 344 | |
| 345 | return (0); |
| 346 | } |
| 347 | |
| 348 | static size_t |
| 349 | ngt_getc_inject(struct tty *tp, void *buf, size_t len) |
nothing calls this directly
no test coverage detected