* Read and process data on netgraph control and data sockets. */
| 456 | * Read and process data on netgraph control and data sockets. |
| 457 | */ |
| 458 | static void |
| 459 | ReadSockets(fd_set *rfds) |
| 460 | { |
| 461 | /* Display any incoming control message. */ |
| 462 | if (FD_ISSET(csock, rfds)) |
| 463 | MsgRead(); |
| 464 | |
| 465 | /* Display any incoming data packet. */ |
| 466 | if (FD_ISSET(dsock, rfds)) { |
| 467 | char hook[NG_HOOKSIZ]; |
| 468 | u_char *buf; |
| 469 | int rl; |
| 470 | |
| 471 | /* Read packet from socket. */ |
| 472 | if ((rl = NgAllocRecvData(dsock, &buf, hook)) < 0) |
| 473 | err(EX_OSERR, "reading hook \"%s\"", hook); |
| 474 | if (rl == 0) |
| 475 | errx(EX_OSERR, "EOF from hook \"%s\"?", hook); |
| 476 | |
| 477 | /* Write packet to stdout. */ |
| 478 | printf("Rec'd data packet on hook \"%s\":\n", hook); |
| 479 | DumpAscii(buf, rl); |
| 480 | free(buf); |
| 481 | } |
| 482 | } |
| 483 | #endif |
| 484 | |
| 485 | /* |
no test coverage detected