summaryrefslogtreecommitdiffstats
path: root/usr.sbin/tftp-proxy
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2013-12-23 13:07:47 +0000
committerflorian <florian@openbsd.org>2013-12-23 13:07:47 +0000
commita4dc3638d0876a1fa426f30e8f3bee6673c25425 (patch)
tree043574383668e7f58510e10086e484b22060e9f4 /usr.sbin/tftp-proxy
parentImplement -a option in tftp-proxy to make it work on a NAT gateway. (diff)
downloadwireguard-openbsd-a4dc3638d0876a1fa426f30e8f3bee6673c25425.tar.xz
wireguard-openbsd-a4dc3638d0876a1fa426f30e8f3bee6673c25425.zip
Make it possible to give -a multiple times on the command line.
Initial diff by camield, tweaked by me. ok dlg, benno, camield manpage input/ok jmc
Diffstat (limited to 'usr.sbin/tftp-proxy')
-rw-r--r--usr.sbin/tftp-proxy/tftp-proxy.85
-rw-r--r--usr.sbin/tftp-proxy/tftp-proxy.c15
2 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/tftp-proxy/tftp-proxy.8 b/usr.sbin/tftp-proxy/tftp-proxy.8
index 9cbda74b888..5fc83c289c5 100644
--- a/usr.sbin/tftp-proxy/tftp-proxy.8
+++ b/usr.sbin/tftp-proxy/tftp-proxy.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tftp-proxy.8,v 1.4 2013/12/23 13:06:53 florian Exp $
+.\" $OpenBSD: tftp-proxy.8,v 1.5 2013/12/23 13:07:47 florian Exp $
.\"
.\" Copyright (c) 2005 joshua stein <jcs@openbsd.org>
.\"
@@ -87,6 +87,9 @@ Instead of a
rule an
.Dq rdr
rule will be generated.
+It is possible to have two
+.Fl a
+options to specify both an IPv4 and an IPv6 address.
.It Fl d
Do not daemonize.
If this option is specified,
diff --git a/usr.sbin/tftp-proxy/tftp-proxy.c b/usr.sbin/tftp-proxy/tftp-proxy.c
index 3ff19b208ff..4c6d36364cd 100644
--- a/usr.sbin/tftp-proxy/tftp-proxy.c
+++ b/usr.sbin/tftp-proxy/tftp-proxy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tftp-proxy.c,v 1.8 2013/12/23 13:06:53 florian Exp $
+/* $OpenBSD: tftp-proxy.c,v 1.9 2013/12/23 13:07:47 florian Exp $
*
* Copyright (c) 2005 DLS Internet Services
* Copyright (c) 2004, 2005 Camiel Dobbelaar, <cd@sentia.nl>
@@ -196,10 +196,10 @@ main(int argc, char *argv[])
int c;
const char *errstr;
+ struct src_addr *saddr, *saddr2;
struct passwd *pw;
char *addr = "localhost";
- char *saddr = NULL;
char *port = "6969";
int family = AF_UNSPEC;
@@ -216,7 +216,7 @@ main(int argc, char *argv[])
family = AF_INET6;
break;
case 'a':
- saddr = optarg;
+ source_addresses(optarg, family);
break;
case 'd':
verbose = debug = 1;
@@ -254,8 +254,13 @@ main(int argc, char *argv[])
if (pw == NULL)
lerrx(1, "no %s user", NOPRIV_USER);
- if (saddr != NULL)
- source_addresses(saddr, family);
+ /* Family option may have been specified late. */
+ if (family != AF_UNSPEC)
+ TAILQ_FOREACH_SAFE(saddr, &src_addrs, entry, saddr2)
+ if (saddr->addr.ss_family != family) {
+ TAILQ_REMOVE(&src_addrs, saddr, entry);
+ free(saddr);
+ }
switch (fork()) {
case -1: