summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nghook
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2000-07-27 21:55:48 +0000
committerarchie <archie@FreeBSD.org>2000-07-27 21:55:48 +0000
commitca906221f0640dae22a8700265f162c20f9302b9 (patch)
tree93563eaea8ada8b1407e280d6bbeadde4d000af4 /usr.sbin/nghook
parent396b7d54ff5999a9870111fdcc49b401496f25d6 (diff)
downloadFreeBSD-src-ca906221f0640dae22a8700265f162c20f9302b9.zip
FreeBSD-src-ca906221f0640dae22a8700265f162c20f9302b9.tar.gz
Add '-n' flag: don't attempt to read any data from standard input.
Diffstat (limited to 'usr.sbin/nghook')
-rw-r--r--usr.sbin/nghook/main.c15
-rw-r--r--usr.sbin/nghook/nghook.818
2 files changed, 26 insertions, 7 deletions
diff --git a/usr.sbin/nghook/main.c b/usr.sbin/nghook/main.c
index 93ba6cd..c0ef43d 100644
--- a/usr.sbin/nghook/main.c
+++ b/usr.sbin/nghook/main.c
@@ -72,10 +72,11 @@ main(int ac, char *av[])
int csock, dsock;
int asciiFlag = 0;
int loopFlag = 0;
+ int noInput = 0;
int ch;
/* Parse flags */
- while ((ch = getopt(ac, av, "adl")) != EOF) {
+ while ((ch = getopt(ac, av, "adln")) != EOF) {
switch (ch) {
case 'a':
asciiFlag = 1;
@@ -86,6 +87,9 @@ main(int ac, char *av[])
case 'l':
loopFlag = 1;
break;
+ case 'n':
+ noInput = 1;
+ break;
case '?':
default:
Usage();
@@ -119,13 +123,18 @@ main(int ac, char *av[])
NGM_GENERIC_COOKIE, NGM_CONNECT, &ngc, sizeof(ngc)) < 0)
errx(EX_OSERR, "can't connect to node");
+ /* Close standard input if not reading from it */
+ if (noInput)
+ fclose(stdin);
+
/* Relay data */
while (1) {
fd_set rfds;
/* Setup bits */
FD_ZERO(&rfds);
- FD_SET(0, &rfds);
+ if (!noInput)
+ FD_SET(0, &rfds);
FD_SET(dsock, &rfds);
/* Wait for something to happen */
@@ -224,6 +233,6 @@ WriteAscii(u_char *buf, int len)
static void
Usage(void)
{
- errx(EX_USAGE, "usage: nghook [-da] path [hookname]");
+ errx(EX_USAGE, "usage: nghook [-adln] path [hookname]");
}
diff --git a/usr.sbin/nghook/nghook.8 b/usr.sbin/nghook/nghook.8
index 7460951..abab2c2 100644
--- a/usr.sbin/nghook/nghook.8
+++ b/usr.sbin/nghook/nghook.8
@@ -46,6 +46,7 @@ node
.Op Fl a
.Op Fl d
.Op Fl l
+.Op Fl n
.Ar path
.Op Ar hookname
.Sh DESCRIPTION
@@ -65,18 +66,27 @@ is assumed.
At this point all data written to standard input is sent
to the node and all data received from the node is relayed
to standard output.
+.Nm
+exits when
+.Dv EOF
+is detected on standard input.
.Pp
The options are as follows:
.Pp
.Bl -tag -width indent
.It Fl a
-Output each read packet in
-.Tn ASCII .
+Output each packet read in human-readable decoded
+.Tn ASCII
+form instead of raw binary.
.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.
+.It Fl n
+Don't attempt to read any data from standard input.
+.Nm
+will continue reading from the node until stopped by a signal.
.El
.Sh BUGS
Although all input is read in unbuffered mode,
@@ -84,7 +94,7 @@ there's no way to control the packetization of the input.
.Sh SEE ALSO
.Xr netgraph 4 ,
.Xr netgraph 3 ,
-.Xr ngctl 8 .
+.Xr ngctl 8
.Sh HISTORY
The
.Em netgraph
@@ -92,5 +102,5 @@ system was designed and first implemented at Whistle Communications, Inc.
in a version of
.Fx 2.2
customized for the Whistle InterJet.
-.Sh AUTHOR
+.Sh AUTHORS
.An Archie Cobbs Aq archie@whistle.com
OpenPOWER on IntegriCloud