summaryrefslogtreecommitdiffstats
path: root/sbin/routed/rtquery
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1998-07-28 06:36:31 +0000
committercharnier <charnier@FreeBSD.org>1998-07-28 06:36:31 +0000
commitcd64002d5da7c3bacf30747f3a6af5baca8676a6 (patch)
tree083e700ad435744b33aa1ed531c4da6bb11f49b8 /sbin/routed/rtquery
parent6999d30e2ecf654e56794fbef703e59c1826883a (diff)
downloadFreeBSD-src-cd64002d5da7c3bacf30747f3a6af5baca8676a6.zip
FreeBSD-src-cd64002d5da7c3bacf30747f3a6af5baca8676a6.tar.gz
Spelling, add rcsid, remove unused #includes.
Convert 1000000 usec to 1 sec 0 usec. Use provided safe malloc (rtmalloc()) instead of malloc(): exit on allocation failure. Correct use of .Nm Add usage() and use errx().
Diffstat (limited to 'sbin/routed/rtquery')
-rw-r--r--sbin/routed/rtquery/rtquery.850
-rw-r--r--sbin/routed/rtquery/rtquery.c57
2 files changed, 56 insertions, 51 deletions
diff --git a/sbin/routed/rtquery/rtquery.8 b/sbin/routed/rtquery/rtquery.8
index 301c5d3..4c51c8f 100644
--- a/sbin/routed/rtquery/rtquery.8
+++ b/sbin/routed/rtquery/rtquery.8
@@ -1,4 +1,4 @@
-.\" $Id: rtquery.8,v 1.6 1997/02/22 14:33:13 peter Exp $
+.\" $Id: rtquery.8,v 1.7 1997/06/13 20:58:09 max Exp $
.Dd June 1, 1996
.Dt RTQUERY 8
.Os BSD 4.4
@@ -6,16 +6,17 @@
.Nm rtquery
.Nd query routing daemons for their routing tables
.Sh SYNOPSIS
-.Nm
+.Nm rtquery
.Op Fl np1
.Op Fl w Ar timeout
.Op Fl r Ar addr
.Op Fl a Ar secret
-.Ar host ...
-
-.Nm
+.Ar host
+.Ar
+.Nm rtquery
.Op Fl t Ar op
-.Ar host ...
+.Ar host
+.Ar
.Sh DESCRIPTION
.Nm Rtquery
is used to query a RIP network routing daemon,
@@ -30,20 +31,22 @@ command. The routing information in any routing
.Em response
packets returned is displayed numerically and symbolically.
.Pp
-.Em Rtquery
+.Nm Rtquery
by default uses the
.Em request
command.
When the
-.Ar -p
+.Fl p
option is specified,
-.Nm rtquery
+.Nm
uses the
.Em poll
command, an
undocumented extension to the RIP protocol supported by
.Xr gated 8 .
-When querying gated, the
+When querying
+.Xr gated 8 ,
+the
.Em poll
command is preferred over the
.Em request
@@ -68,9 +71,8 @@ and so answers completely.
is also used to turn tracing on or off in
.Nm routed .
.Pp
-Options supported by
-.Nm rtquery :
-.Bl -tag -width Ds
+The following options are available:
+.Bl -tag -width indent
.It Fl n
Normally network and host numbers are displayed both symbolically
and numerically.
@@ -78,44 +80,44 @@ The
.Fl n
option displays only the numeric network and host numbers.
.It Fl p
-Uses the
+Use the
.Em Poll
command to request full routing information from
.Xr gated 8 .
This is an undocumented extension RIP protocol supported only by
.Xr gated 8 .
.It Fl 1
-query using RIP version 1 instead of RIP version 2.
+Query using RIP version 1 instead of RIP version 2.
.It Fl w Ar timeout
-changes the delay for an answer from each host.
+Change the delay for an answer from each host.
By default, each host is given 15 seconds to respond.
.It Fl r Ar addr
-ask about the route to destination
+Ask about the route to destination
.Em addr .
.It Fl a Ar passwd=XXX
.It Fl a Ar md5_passwd=XXX|KeyID
-cause the query to be sent with the indicated cleartext or MD5 password.
+Cause the query to be sent with the indicated cleartext or MD5 password.
.It Fl t Ar op
-change tracing, where
+Change tracing, where
.Em op
is one of the following.
Requests from processes not running with UID 0 or on distant networks
are generally ignored by the daemon except for a message in the system log.
-.Xr gated 8
+.Xr Gated 8
is likely to ignore these debugging requests.
.El
.Bl -tag -width Ds -offset indent-two
.It Em on=tracefile
-turn tracing on into the specified file. That file must usually
+Turn tracing on into the specified file. That file must usually
have been specified when the daemon was started or be the same
as a fixed name, often
.Pa /etc/routed.trace .
.It Em more
-increases the debugging level.
+Increase the debugging level.
.It Em off
-turns off tracing.
+Turn off tracing.
.It Em dump
-dumps the daemon's routing table to the current tracefile.
+Dump the daemon's routing table to the current tracefile.
.El
.Sh SEE ALSO
.Xr gated 8 ,
diff --git a/sbin/routed/rtquery/rtquery.c b/sbin/routed/rtquery/rtquery.c
index 783c561..071b8e9 100644
--- a/sbin/routed/rtquery/rtquery.c
+++ b/sbin/routed/rtquery/rtquery.c
@@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 6/5/93";
#endif
static const char rcsid[] =
- "$Id: rtquery.c,v 1.7 1998/01/14 07:17:12 charnier Exp $";
+ "$Id: rtquery.c,v 1.8 1998/07/22 05:49:36 phk Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -106,9 +106,9 @@ static void query_loop(char *argv[], int);
static int getnet(char *, struct netinfo *);
static u_int std_mask(u_int);
static int parse_quote(char **, char *, char *, char *, int);
+static void usage(void);
-
-void
+int
main(int argc,
char *argv[])
{
@@ -140,21 +140,19 @@ main(int argc,
wtime = (int)strtoul(optarg, &p, 0);
if (*p != '\0'
|| wtime <= 0)
- goto usage;
+ usage();
break;
case 'r':
not_trace = 1;
if (rflag)
- goto usage;
+ usage();
rflag = getnet(optarg, &OMSG.rip_nets[0]);
if (!rflag) {
struct hostent *hp = gethostbyname(optarg);
- if (hp == 0) {
- fprintf(stderr, "rtquery: %s:", optarg);
- herror(0);
- exit(1);
- }
+ if (hp == 0)
+ errx(1, "%s: %s",
+ optarg, hstrerror(h_errno));
bcopy(hp->h_addr, &OMSG.rip_nets[0].n_dst,
sizeof(OMSG.rip_nets[0].n_dst));
OMSG.rip_nets[0].n_family = RIP_AF_INET;
@@ -183,28 +181,28 @@ main(int argc,
OMSG.rip_cmd = RIPCMD_TRACEON;
if (!value
|| strlen(value) > MAXPATHLEN)
- goto usage;
+ usage();
break;
case TRACE_MORE:
if (value)
- goto usage;
+ usage();
OMSG.rip_cmd = RIPCMD_TRACEON;
value = "";
break;
case TRACE_OFF:
if (value)
- goto usage;
+ usage();
OMSG.rip_cmd = RIPCMD_TRACEOFF;
value = "";
break;
case TRACE_DUMP:
if (value)
- goto usage;
+ usage();
OMSG.rip_cmd = RIPCMD_TRACEON;
value = "dump/../table";
break;
default:
- goto usage;
+ usage();
}
strcpy((char*)OMSG.rip_tracefile, value);
omsg_len += strlen(value) - sizeof(OMSG.ripun);
@@ -215,38 +213,34 @@ main(int argc,
not_trace = 1;
p = strchr(optarg,'=');
if (!p)
- goto usage;
+ usage();
*p++ = '\0';
if (!strcasecmp("passwd",optarg))
auth_type = RIP_AUTH_PW;
else if (!strcasecmp("md5_passwd",optarg))
auth_type = RIP_AUTH_MD5;
else
- goto usage;
+ usage();
if (0 > parse_quote(&p,"|",&delim,
passwd,sizeof(passwd)))
- goto usage;
+ usage();
if (auth_type == RIP_AUTH_MD5
&& delim == '|') {
keyid = strtoul(p+1,&p,0);
if (keyid > 255 || *p != '\0')
- goto usage;
+ usage();
} else if (delim != '\0') {
- goto usage;
+ usage();
}
break;
default:
- goto usage;
+ usage();
}
argv += optind;
argc -= optind;
- if ((not_trace && trace) || argc == 0) {
-usage: fprintf(stderr, "%s\n%s\n",
- "usage: rtquery [-np1v] [-r addr] [-w timeout] [-a secret] host ...",
- " rtquery [-t op] host ...");
- exit(1);
- }
+ if ((not_trace && trace) || argc == 0)
+ usage();
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0)
@@ -267,9 +261,18 @@ usage: fprintf(stderr, "%s\n%s\n",
trace_loop(argv);
else
query_loop(argv, argc);
+ return(0);
/* NOTREACHED */
}
+static void
+usage()
+{
+ fprintf(stderr, "%s\n%s\n",
+ "usage: rtquery [-np1v] [-r addr] [-w timeout] [-a secret] host ...",
+ " rtquery [-t op] host ...");
+ exit(1);
+}
/* tell the target hosts about tracing
*/
OpenPOWER on IntegriCloud