diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-27 17:10:30 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2005-05-27 17:10:30 +0000 |
commit | 9877e0947f4fd1cabff91f747693c89779b61ec8 (patch) | |
tree | a641035b970caf2167b49f95d743dfb16a0c6cfc /usr.sbin/bgpctl | |
parent | a2a1689517aa0ef0393afb2837820c49101a17a2 (diff) |
Add a flag for specifying the socket to open to talk to bgpd.
Needed for upcomming spamd madness. Requested and OK beck@
Diffstat (limited to 'usr.sbin/bgpctl')
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.8 | 10 | ||||
-rw-r--r-- | usr.sbin/bgpctl/bgpctl.c | 18 |
2 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/bgpctl/bgpctl.8 b/usr.sbin/bgpctl/bgpctl.8 index 2d8346c4f20..642214330da 100644 --- a/usr.sbin/bgpctl/bgpctl.8 +++ b/usr.sbin/bgpctl/bgpctl.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: bgpctl.8,v 1.25 2004/12/31 10:47:37 jaredy Exp $ +.\" $OpenBSD: bgpctl.8,v 1.26 2005/05/27 17:10:29 claudio Exp $ .\" .\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> .\" @@ -23,6 +23,7 @@ .Sh SYNOPSIS .Nm bgpctl .Op Fl n +.Op Fl s Ar socket .Ar command .Op Ar arguments ... .Sh DESCRIPTION @@ -41,6 +42,13 @@ The options are as follows: .Bl -tag -width Ds .It Fl n Show neighbors' IP-addresses instead of their description. +.It Fl s Ar socket +Use +.Ar socket +instead of the default +.Pa /var/run/bgpd.sock +to communicate with +.Xr bgpd 8 . .El .Pp The commands are as follows: diff --git a/usr.sbin/bgpctl/bgpctl.c b/usr.sbin/bgpctl/bgpctl.c index fdedf94076a..4f772ee29cf 100644 --- a/usr.sbin/bgpctl/bgpctl.c +++ b/usr.sbin/bgpctl/bgpctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpctl.c,v 1.79 2005/05/23 20:08:59 claudio Exp $ */ +/* $OpenBSD: bgpctl.c,v 1.80 2005/05/27 17:10:29 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -77,7 +77,8 @@ usage(void) { extern char *__progname; - fprintf(stderr, "usage: %s [-n] <command> [arg [...]]\n", __progname); + fprintf(stderr, "usage: %s [-s socket] [-n] " + "<command> [arg [...]]\n", __progname); exit(1); } @@ -90,13 +91,18 @@ main(int argc, char *argv[]) struct network_config net; struct parse_result *res; struct ctl_neighbor neighbor; + char *sockname; - while ((ch = getopt(argc, argv, "n")) != -1) { + sockname = SOCKET_NAME; + while ((ch = getopt(argc, argv, "ns:")) != -1) { switch (ch) { case 'n': if (++nodescr > 1) usage(); break; + case 's': + sockname = optarg; + break; default: usage(); /* NOTREACHED */ @@ -116,9 +122,11 @@ main(int argc, char *argv[]) bzero(&sun, sizeof(sun)); sun.sun_family = AF_UNIX; - strlcpy(sun.sun_path, SOCKET_NAME, sizeof(sun.sun_path)); + if (strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path)) >= + sizeof(sun.sun_path)) + errx(1, "socket name too long"); if (connect(fd, (struct sockaddr *)&sun, sizeof(sun)) == -1) - err(1, "connect: %s", SOCKET_NAME); + err(1, "connect: %s", sockname); if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL) fatal(NULL); |