summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nghook
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-07-18 16:52:27 +0000
committerphk <phk@FreeBSD.org>2000-07-18 16:52:27 +0000
commitbbe00ac533441c4cafca8001a4e8d43cf41406d5 (patch)
treeb797e98d1685321dcbbeadc63fdb607ceabf68d1 /usr.sbin/nghook
parentc6cca06ec0e47a8ffdca571ee7c6bacee79dce98 (diff)
downloadFreeBSD-src-bbe00ac533441c4cafca8001a4e8d43cf41406d5.zip
FreeBSD-src-bbe00ac533441c4cafca8001a4e8d43cf41406d5.tar.gz
Add the '-l' flag to nghook which loops the received data back.
Diffstat (limited to 'usr.sbin/nghook')
-rw-r--r--usr.sbin/nghook/main.c15
-rw-r--r--usr.sbin/nghook/nghook.84
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,
OpenPOWER on IntegriCloud