summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ospfctl
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2009-04-07 14:57:33 +0000
committerreyk <reyk@openbsd.org>2009-04-07 14:57:33 +0000
commitd1b947733dcdf568bc8e5f8d4bbc67edec089ae8 (patch)
tree96bdb92d47c496d86dfd097d70dfe3b7c38fc6ce /usr.sbin/ospfctl
parentbnf-tweaks (diff)
downloadwireguard-openbsd-d1b947733dcdf568bc8e5f8d4bbc67edec089ae8.tar.xz
wireguard-openbsd-d1b947733dcdf568bc8e5f8d4bbc67edec089ae8.zip
allow to specify an alternate control socket instead of /var/run/ospfd.sock.
this is required to run multiple instances of ospfd. ok claudio@
Diffstat (limited to 'usr.sbin/ospfctl')
-rw-r--r--usr.sbin/ospfctl/ospfctl.816
-rw-r--r--usr.sbin/ospfctl/ospfctl.c28
2 files changed, 37 insertions, 7 deletions
diff --git a/usr.sbin/ospfctl/ospfctl.8 b/usr.sbin/ospfctl/ospfctl.8
index 8bc7c2ed269..18a64881602 100644
--- a/usr.sbin/ospfctl/ospfctl.8
+++ b/usr.sbin/ospfctl/ospfctl.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ospfctl.8,v 1.18 2008/12/06 13:18:12 sobrado Exp $
+.\" $OpenBSD: ospfctl.8,v 1.19 2009/04/07 14:57:33 reyk Exp $
.\"
.\" Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 6 2008 $
+.Dd $Mdocdate: April 7 2009 $
.Dt OSPFCTL 8
.Os
.Sh NAME
@@ -22,6 +22,7 @@
.Nd control the Open Shortest Path First daemon
.Sh SYNOPSIS
.Nm
+.Op Fl s Ar socket
.Ar command
.Op Ar argument ...
.Sh DESCRIPTION
@@ -31,6 +32,17 @@ program controls the
.Xr ospfd 8
daemon.
.Pp
+The following option is available:
+.Bl -tag -width Ds
+.It Fl s Ar socket
+Use
+.Ar socket
+instead of the default
+.Pa /var/run/ospfd.sock
+to communicate with
+.Xr ospfd 8 .
+.El
+.Pp
The following commands are available:
.Bl -tag -width Ds
.It Cm fib couple
diff --git a/usr.sbin/ospfctl/ospfctl.c b/usr.sbin/ospfctl/ospfctl.c
index 53a8bf870bd..dbfdbb386f8 100644
--- a/usr.sbin/ospfctl/ospfctl.c
+++ b/usr.sbin/ospfctl/ospfctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfctl.c,v 1.45 2009/01/30 12:43:18 norby Exp $ */
+/* $OpenBSD: ospfctl.c,v 1.46 2009/04/07 14:57:33 reyk Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -76,7 +76,8 @@ usage(void)
{
extern char *__progname;
- fprintf(stderr, "usage: %s command [argument ...]\n", __progname);
+ fprintf(stderr, "usage: %s [-s socket] command [argument ...]\n",
+ __progname);
exit(1);
}
@@ -97,9 +98,25 @@ main(int argc, char *argv[])
int ctl_sock;
int done = 0;
int n;
+ int ch;
+ char *sockname;
+
+ sockname = OSPFD_SOCKET;
+ while ((ch = getopt(argc, argv, "s:")) != -1) {
+ switch (ch) {
+ case 's':
+ sockname = optarg;
+ break;
+ default:
+ usage();
+ /* NOTREACHED */
+ }
+ }
+ argc -= optind;
+ argv += optind;
/* parse options */
- if ((res = parse(argc - 1, argv + 1)) == NULL)
+ if ((res = parse(argc, argv)) == NULL)
exit(1);
/* connect to ospfd control socket */
@@ -108,9 +125,10 @@ main(int argc, char *argv[])
bzero(&sun, sizeof(sun));
sun.sun_family = AF_UNIX;
- strlcpy(sun.sun_path, OSPFD_SOCKET, sizeof(sun.sun_path));
+
+ strlcpy(sun.sun_path, sockname, sizeof(sun.sun_path));
if (connect(ctl_sock, (struct sockaddr *)&sun, sizeof(sun)) == -1)
- err(1, "connect: %s", OSPFD_SOCKET);
+ err(1, "connect: %s", sockname);
if ((ibuf = malloc(sizeof(struct imsgbuf))) == NULL)
err(1, NULL);