commit 10c8fe1a18c3eea120d2debf7ef93f36eec6bf5c
parent 5473685396668e081a29508c6790f74fdba0d270
Author: sin <sin@2f30.org>
Date: Thu, 14 Apr 2016 09:12:04 +0100
add support for ipv6 over ipv4
Linux port has not been tested.
Diffstat:
5 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/WHATSNEW b/WHATSNEW
@@ -5,7 +5,7 @@
* EVP_AEAD_* high level API support. Choice between four
different ciphers depending on version of libressl used.
* Default cipher switched to chacha20-poly1305.
- * IPv4 over IPv6 tunnel support.
+ * IPv4 over IPv6 tunnel support and vice versa.
* TCP keepalive enabled by default.
* Switch to non-blocking sockets for faster recovery
when headers are modified in transit.
diff --git a/dev_bsd.c b/dev_bsd.c
@@ -46,7 +46,7 @@ int
devwrite(int fd, unsigned char *buf, int len)
{
struct iovec iov[2];
- uint32_t type = htonl(AF_INET);
+ uint32_t type = htonl(aftype);
int n;
switch (devtype) {
diff --git a/stun.8 b/stun.8
@@ -1,4 +1,4 @@
-.Dd April 12, 2016
+.Dd April 14, 2016
.Dt STUN 8
.Os
.Sh NAME
@@ -6,14 +6,15 @@
.Nd simple tunnel
.Sh SYNOPSIS
.Nm stun
-.Op Fl d
-.Fl s
+.Op Fl 46
+.Op Fl ds
.Op Fl b Ar address
.Op Fl p Ar port
.Op Fl t Ar devtype
.Op Fl c Ar cipher
.Ar interface
.Nm stun
+.Op Fl 46
.Op Fl d
.Fl h Ar host
.Op Fl p Ar port
@@ -27,6 +28,10 @@ client per server. Routing between clients is done by the networking
stack on the server side.
.Sh OPTIONS
.Bl -tag -width "-b address"
+.It Fl 4
+Set the tunnel address family to IPv4.
+.It Fl 6
+Set the tunnel address family to IPv6.
.It Fl d
Enable debug output.
.It Fl s
diff --git a/stun.c b/stun.c
@@ -58,14 +58,15 @@ char *host;
char *port = DEFPORT;
char *cipher = DEFCIPHER;
int devtype = TUNDEV;
+int aftype = AF_INET;
int debug;
int sflag;
void
usage(void)
{
- fprintf(stderr, "usage: stun [-d] -s [-b address] [-p port] [-t devtype] [-c cipher] interface\n");
- fprintf(stderr, " stun [-d] -h host [-p port] [-t devtype] [-c cipher] interface\n");
+ fprintf(stderr, "usage: stun [-46] [-d] -s [-b address] [-p port] [-t devtype] [-c cipher] interface\n");
+ fprintf(stderr, " stun [-46] [-d] -h host [-p port] [-t devtype] [-c cipher] interface\n");
exit(1);
}
@@ -77,6 +78,12 @@ main(int argc, char *argv[])
int devfd, listenfd, netfd;
ARGBEGIN {
+ case '4':
+ aftype = AF_INET;
+ break;
+ case '6':
+ aftype = AF_INET6;
+ break;
case 'd':
debug = 1;
break;
diff --git a/stun.h b/stun.h
@@ -25,6 +25,7 @@ enum {
/* stun.c */
extern int devtype;
+extern int aftype;
extern int debug;
/* auth.c */