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

Function ReadSockets

tools/ngctl/main.c:458–482  ·  view source on GitHub ↗

* Read and process data on netgraph control and data sockets. */

Source from the content-addressed store, hash-verified

456 * Read and process data on netgraph control and data sockets.
457 */
458static void
459ReadSockets(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/*

Callers 2

MonitorFunction · 0.85
DoInteractiveFunction · 0.85

Calls 5

MsgReadFunction · 0.85
NgAllocRecvDataFunction · 0.85
DumpAsciiFunction · 0.85
printfFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected