summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2014-02-10 19:54:17 +0000
committerChristian Pointner <equinox@anytun.org>2014-02-10 19:54:17 +0000
commit0b0b66bdeab69e0cd95f657ddee5bab5c0c7187c (patch)
tree6ed3c238b19951a29a436bd44450205661d76abc
parentclang --analyze yielded bugs (diff)
added explicit option for RAIL mode
-rw-r--r--doc/uanytun.818
-rw-r--r--doc/uanytun.8.txt7
-rw-r--r--src/options.c5
-rw-r--r--src/options.h1
-rw-r--r--src/uanytun.c2
-rw-r--r--src/udp.c6
-rw-r--r--src/udp.h3
7 files changed, 33 insertions, 9 deletions
diff --git a/doc/uanytun.8 b/doc/uanytun.8
index 4e60f6b..4fe8184 100644
--- a/doc/uanytun.8
+++ b/doc/uanytun.8
@@ -2,12 +2,12 @@
.\" Title: uanytun
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
-.\" Date: 02/07/2014
+.\" Date: 02/10/2014
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
-.TH "UANYTUN" "8" "02/07/2014" "\ \&" "\ \&"
+.TH "UANYTUN" "8" "02/10/2014" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -43,6 +43,7 @@ uanytun \- micro anycast tunneling daemon
[ \fB\-U|\-\-debug\fR ]
[ \fB\-i|\-\-interface\fR <ip\-address> ]
[ \fB\-p|\-\-port\fR <port>[:<port>] ]
+ [ \fB\-Y|\-\-rail\-mode\fR ]
[ \fB\-r|\-\-remote\-host\fR <hostname|ip> ]
[ \fB\-o|\-\-remote\-port\fR <port>[:<port>] ]
[ \fB\-4|\-\-ipv4\-only\fR ]
@@ -150,9 +151,18 @@ This IP address is used as the sender address for outgoing packets\&. The defaul
.PP
\fB\-p, \-\-port \fR\fB\fI<port>[:<port>]\fR\fR
.RS 4
-The local UDP port that is used to send and receive the payload data\&. The two tunnel endpoints can use different ports\&. The default port is 4444\&. You can also specify a port range which enables
+The local UDP port that is used to send and receive the payload data\&. The two tunnel endpoints can use different ports\&. The default port is 4444\&. In
\fBRAIL\fR
-mode\&. See section
+mode you must specify a port range\&. See section
+\fBRAIL\fR
+below to find out what this is\&.
+.RE
+.PP
+\fB\-Y, \-\-rail\-mode\fR
+.RS 4
+This option instructs
+\fBuAnytun\fR
+to run in RAIL mode\&. See section
\fBRAIL\fR
below to find out what this is\&.
.RE
diff --git a/doc/uanytun.8.txt b/doc/uanytun.8.txt
index 5a75bcb..5bb236f 100644
--- a/doc/uanytun.8.txt
+++ b/doc/uanytun.8.txt
@@ -22,6 +22,7 @@ uanytun
[ -U|--debug ]
[ -i|--interface <ip-address> ]
[ -p|--port <port>[:<port>] ]
+ [ -Y|--rail-mode ]
[ -r|--remote-host <hostname|ip> ]
[ -o|--remote-port <port>[:<port>] ]
[ -4|--ipv4-only ]
@@ -114,7 +115,11 @@ passed to the daemon:
The local UDP port that is used to send and receive the
payload data. The two tunnel endpoints can use different
ports. The default port is 4444.
- You can also specify a port range which enables *RAIL* mode. See section
+ In *RAIL* mode you must specify a port range. See section
+ *RAIL* below to find out what this is.
+
+*-Y, --rail-mode*::
+ This option instructs *uAnytun* to run in RAIL mode. See section
*RAIL* below to find out what this is.
*-r, --remote-host '<hostname|ip>'*::
diff --git a/src/options.c b/src/options.c
index 3271c06..240a286 100644
--- a/src/options.c
+++ b/src/options.c
@@ -209,7 +209,6 @@ int options_parse_ifconfig(const char* arg, ifconfig_param_t* ifcfg)
return 1;
}
-
int options_parse(options_t* opt, int argc, char* argv[])
{
if(!opt)
@@ -246,6 +245,7 @@ int options_parse(options_t* opt, int argc, char* argv[])
PARSE_INT_PARAM("-s","--sender-id", opt->sender_id_)
PARSE_STRING_LIST("-L","--log", opt->log_targets_)
PARSE_BOOL_PARAM("-U", "--debug", opt->debug_)
+ PARSE_BOOL_PARAM("-Y", "--rail-mode", opt->rail_mode_)
PARSE_STRING_PARAM("-r","--remote-host", opt->remote_addr_)
PARSE_STRING_PARAM("-o","--remote-port", opt->remote_port_)
PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only)
@@ -347,6 +347,7 @@ void options_default(options_t* opt)
opt->local_addr_ = NULL;
opt->local_port_ = strdup("4444");
opt->sender_id_ = 0;
+ opt->rail_mode_ = 0;
opt->remote_addr_ = NULL;
opt->remote_port_ = strdup("4444");
opt->resolv_addr_type_ = ANY;
@@ -439,6 +440,7 @@ void options_print_usage()
printf(" add a log target, can be invoked several times\n");
printf(" [-U|--debug] don't daemonize and log to stdout with maximum log level\n");
+ printf(" [-Y|--rail-mode] enable RAIL mode\n");
printf(" [-r|--remote-host] <hostname|ip> remote host\n");
printf(" [-o|--remote-port] <port>[:<port>] remote port (use port:port for range - RAIL)\n");
printf(" [-4|--ipv4-only] always resolv IPv4 addresses\n");
@@ -487,6 +489,7 @@ void options_print(options_t* opt)
printf("local_addr: '%s'\n", opt->local_addr_);
printf("local_port: '%s'\n", opt->local_port_);
printf("sender_id: %d\n", opt->sender_id_);
+ printf("rail-mode: %s\n", !opt->rail_mode_ ? "false" : "true");
printf("remote_addr: '%s'\n", opt->remote_addr_);
printf("remote_port: '%s'\n", opt->remote_port_);
printf("resolv_addr_type: ");
diff --git a/src/options.h b/src/options.h
index 699f2c7..05f1c21 100644
--- a/src/options.h
+++ b/src/options.h
@@ -62,6 +62,7 @@ struct options_struct {
char* local_addr_;
char* local_port_;
sender_id_t sender_id_;
+ int rail_mode_;
char* remote_addr_;
char* remote_port_;
resolv_addr_type_t resolv_addr_type_;
diff --git a/src/uanytun.c b/src/uanytun.c
index edb0bfe..c23294c 100644
--- a/src/uanytun.c
+++ b/src/uanytun.c
@@ -367,7 +367,7 @@ int main(int argc, char* argv[])
udp_t sock;
- ret = udp_init(&sock, opt.local_addr_, opt.local_port_, opt.resolv_addr_type_);
+ ret = udp_init(&sock, opt.local_addr_, opt.local_port_, opt.resolv_addr_type_, opt.rail_mode_);
if(ret) {
log_printf(ERROR, "error on udp_init, exitting");
tun_close(&dev);
diff --git a/src/udp.c b/src/udp.c
index e774ef4..f81dee7 100644
--- a/src/udp.c
+++ b/src/udp.c
@@ -52,13 +52,14 @@
#include <arpa/inet.h>
#include <netinet/in.h>
-int udp_init(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type)
+int udp_init(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type, int rail_mode)
{
if(!sock || !port)
return -1;
sock->socks_ = NULL;
sock->active_sock_ = NULL;
+ sock->rail_mode_ = rail_mode;
struct addrinfo hints, *res;
@@ -146,6 +147,9 @@ int udp_init(udp_t* sock, const char* local_addr, const char* port, resolv_addr_
freeaddrinfo(res);
+ if(sock->rail_mode_)
+ log_printf(NOTICE, "RAIL mode enabled");
+
return 0;
}
diff --git a/src/udp.h b/src/udp.h
index ffc87d6..8f54ed4 100644
--- a/src/udp.h
+++ b/src/udp.h
@@ -58,10 +58,11 @@ typedef struct udp_socket_struct udp_socket_t;
struct udp_struct {
udp_socket_t* socks_;
udp_socket_t* active_sock_;
+ int rail_mode_;
};
typedef struct udp_struct udp_t;
-int udp_init(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type);
+int udp_init(udp_t* sock, const char* local_addr, const char* port, resolv_addr_type_t resolv_type, int rail_mode);
int udp_init_fd_set(udp_t* sock, fd_set* set);
int udp_has_remote(udp_t* sock);
int udp_resolv_remote(udp_t* sock, const char* remote_addr, const char* port, resolv_addr_type_t resolv_type);