summaryrefslogtreecommitdiff
path: root/src/options.cpp
diff options
context:
space:
mode:
authorChristian Pointner <equinox@anytun.org>2009-01-18 23:31:33 +0000
committerChristian Pointner <equinox@anytun.org>2009-01-18 23:31:33 +0000
commita39dd07546ab48648021f03e87b2831ffaf50df8 (patch)
tree788b8db0b2dd4162318084739b863412b7a73612 /src/options.cpp
parentdoing replay protection before learning remote host (diff)
some cleanup
Diffstat (limited to 'src/options.cpp')
-rw-r--r--src/options.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/options.cpp b/src/options.cpp
index d241eae..58ac181 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -169,9 +169,15 @@ Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
mux_ = 0;
seq_window_size_ = 0;
+#ifndef NO_CRYPT
cipher_ = "aes-ctr";
auth_algo_ = "sha1";
kd_prf_ = "aes-ctr";
+#else
+ cipher_ = "null";
+ auth_algo_ = "null";
+ kd_prf_ = "null";
+#endif
ld_kdr_ = 0;
}
@@ -305,11 +311,13 @@ bool Options::parse(int argc, char* argv[])
if(str == "-h" || str == "--help")
return false;
+#ifndef NO_DAEMON
PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_)
PARSE_BOOL_PARAM("-C","--chroot", chroot_)
PARSE_SCALAR_PARAM("-u","--username", username_)
PARSE_SCALAR_PARAM("-H","--chroot-dir", chroot_dir_)
PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_)
+#endif
// PARSE_SCALAR_PARAM("-f","--file", file_name_)
// PARSE_SCALAR_PARAM("-X","--control-host", bind_to_)
@@ -326,13 +334,16 @@ bool Options::parse(int argc, char* argv[])
PARSE_SCALAR_PARAM("-d","--dev", dev_name_)
PARSE_SCALAR_PARAM("-t","--type", dev_type_)
PARSE_SCALAR_PARAM2("-n","--ifconfig", ifconfig_param_local_, ifconfig_param_remote_netmask_)
+#ifndef NO_EXEC
PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_)
+#endif
PARSE_CSLIST_PARAM("-R","--route", routes_, OptionRoute)
PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_)
PARSE_SCALAR_PARAM("-m","--mux", mux_)
PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_)
+#ifndef NO_CRYPT
PARSE_SCALAR_PARAM("-c","--cipher", cipher_)
PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_)
PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_)
@@ -342,6 +353,7 @@ bool Options::parse(int argc, char* argv[])
#endif
PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_)
PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_)
+#endif
else
throw syntax_error(str, 0);
}
@@ -363,12 +375,13 @@ void Options::printUsage()
std::cout << "USAGE:" << std::endl;
std::cout << "anytun " << std::endl;
std::cout << " [-h|--help] prints this..." << std::endl;
-
+#ifndef NO_DAEMON
std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
std::cout << " [-C|--chroot] chroot and drop privileges" << std::endl;
std::cout << " [-u|--username] <username> if chroot change to this user" << std::endl;
std::cout << " [-H|--chroot-dir] <path> chroot to this directory" << std::endl;
std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
+#endif
// std::cout << " [-f|--file] <path> path to input file" << std::endl;
// std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
@@ -387,15 +400,18 @@ void Options::printUsage()
std::cout << " [-d|--dev] <name> device name" << std::endl;
std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
- std::cout << " [-n|--ifconfig] <local> the local address for the tun/tap device" << std::endl
- << " <remote|netmask> the remote address(tun) or netmask(tap)" << std::endl;
+ std::cout << " [-n|--ifconfig] <local> the local address for the tun/tap device" << std::endl;
+ std::cout << " <remote|netmask> the remote address(tun) or netmask(tap)" << std::endl;
+#ifndef NO_EXEC
std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
+#endif
std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
+#ifndef NO_CRYPT
std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
@@ -405,6 +421,7 @@ void Options::printUsage()
#endif
std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
+#endif
}
void Options::printOptions()