diff options
-rw-r--r-- | usr.sbin/nghook/main.c | 15 | ||||
-rw-r--r-- | usr.sbin/nghook/nghook.8 | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/usr.sbin/nghook/main.c b/usr.sbin/nghook/main.c index 8027dc6..93ba6cd 100644 --- a/usr.sbin/nghook/main.c +++ b/usr.sbin/nghook/main.c @@ -71,16 +71,20 @@ main(int ac, char *av[]) char *path = NULL, *hook = DEFAULT_HOOKNAME; int csock, dsock; int asciiFlag = 0; + int loopFlag = 0; int ch; /* Parse flags */ - while ((ch = getopt(ac, av, "da")) != EOF) { + while ((ch = getopt(ac, av, "adl")) != EOF) { switch (ch) { + case 'a': + asciiFlag = 1; + break; case 'd': NgSetDebug(NgSetDebug(-1) + 1); break; - case 'a': - asciiFlag = 1; + case 'l': + loopFlag = 1; break; case '?': default: @@ -152,6 +156,11 @@ main(int ac, char *av[]) rl, wl); } } + /* Loopback */ + if (loopFlag) { + if (NgSendData(dsock, NG_SOCK_HOOK_NAME, buf, rl) < 0) + err(EX_OSERR, "write(hook)"); + } } /* Check data from stdin */ diff --git a/usr.sbin/nghook/nghook.8 b/usr.sbin/nghook/nghook.8 index 0a64c87..7460951 100644 --- a/usr.sbin/nghook/nghook.8 +++ b/usr.sbin/nghook/nghook.8 @@ -45,6 +45,7 @@ node .Nm .Op Fl a .Op Fl d +.Op Fl l .Ar path .Op Ar hookname .Sh DESCRIPTION @@ -73,6 +74,9 @@ Output each read packet in .Tn ASCII . .It Fl d Increase the debugging verbosity level. +.It Fl l +Loops all received data back to the hook in addition to writing it +to standard output. .El .Sh BUGS Although all input is read in unbuffered mode, |