4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methods used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007-2014 Markus Grüneis, Othmar Gsenger, Erwin Nindl,
15 * Christian Pointner <satp@wirdorange.org>
17 * This file is part of Anytun.
19 * Anytun is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
24 * Anytun is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with Anytun. If not, see <http://www.gnu.org/licenses/>.
32 * In addition, as a special exception, the copyright holders give
33 * permission to link the code of portions of this program with the
34 * OpenSSL library under certain conditions as described in each
35 * individual source file, and distribute linked combinations
37 * You must obey the GNU General Public License in all respects
38 * for all of the code used other than OpenSSL. If you modify
39 * file(s) with this exception, you may extend this exception to your
40 * version of the file(s), but you are not obligated to do so. If you
41 * do not wish to do so, delete this exception statement from your
42 * version. If you delete this exception statement from all source
43 * files in the program, then also delete it here.
52 #include "datatypes.h"
57 #include "authAlgoFactory.h"
59 std::ostream& operator<<(std::ostream& stream, syntax_error const& error)
61 stream << "syntax error: " << error.what() << std::endl;
64 for(int32_t i = 0; i < error.pos; ++i) { stream << " "; }
70 std::ostream& operator<<(std::ostream& stream, role_t const& role)
86 void OptionHost::init(std::string addrPort)
88 std::string origAddrPort(addrPort);
89 size_t pos = addrPort.find_first_of("[");
91 if(pos != std::string::npos && pos != 0) {
92 throw syntax_error(origAddrPort, pos); // an [ was found but not at the beginning;
96 if(pos != std::string::npos) {
97 addrPort.erase(pos, 1);
98 pos = addrPort.find_first_of("]");
100 if(pos == std::string::npos) {
101 throw syntax_error(origAddrPort, origAddrPort.length()); //no trailing ] although an leading [ was found
104 if(pos < addrPort.length()-2) {
105 if(addrPort[pos+1] != ':') {
106 throw syntax_error(origAddrPort, pos+2); // wrong port delimieter
109 addrPort[pos+1] = '/';
111 } else if(pos != addrPort.length()-1) {
112 throw syntax_error(origAddrPort, pos+2); // too few characters left
115 addrPort.erase(pos, 1);
117 pos = addrPort.find_first_of(":");
118 if(pos != std::string::npos && pos == addrPort.find_last_of(":")) {
119 // an ':' has been found and it is the only one -> assuming port present
126 std::stringstream tmp_stream(addrPort);
128 getline(tmp_stream, addr, '/');
129 if(!tmp_stream.good()) {
130 throw syntax_error(origAddrPort, addr.length());
136 port = "2323"; // default sync port
140 std::istream& operator>>(std::istream& stream, OptionHost& host)
148 void OptionNetwork::init(std::string network)
150 std::stringstream tmp_stream(network);
151 getline(tmp_stream, net_addr, '/');
152 if(!tmp_stream.good()) {
153 throw syntax_error(network, net_addr.length());
155 tmp_stream >> prefix_length;
158 std::istream& operator>>(std::istream& stream, OptionNetwork& network)
166 Options& gOpt = Options::instance();
168 Options& Options::instance()
170 static Options instance;
174 Options::Options() : key_(uint32_t(0)), salt_(uint32_t(0))
176 #if defined(ANYCTR_OPTIONS)
177 progname_ = "anytun-controld";
178 #elif defined(ANYCONF_OPTIONS)
179 progname_ = "anytun-config";
181 progname_ = "anytun";
184 cluster_opts = false;
185 connection_opts = false;
196 bind_to_.addr = "127.0.0.1";
197 bind_to_.port = "2323";
199 resolv_addr_type_ = ANY;
202 local_.port = "4444";
204 remote_.port = "4444";
205 local_sync_.addr = "";
206 local_sync_.port = "";
210 post_up_script_ = "";
214 seq_window_size_ = 0;
216 #if !defined(ANYCONF_OPTIONS)
220 auth_tag_length_ = 10;
225 auth_tag_length_ = 0;
231 auth_tag_length_ = 0;
243 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
244 else if(str == SHORT || str == LONG) { \
249 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
250 else if(str == SHORT || str == LONG) { \
255 #define PARSE_SIGNED_INT_PARAM(SHORT, LONG, VALUE, DO_POST) \
256 else if(str == SHORT || str == LONG) \
259 throw syntax_error(str, str.length()); \
260 std::stringstream tmp; \
268 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE, DO_POST) \
269 else if(str == SHORT || str == LONG) \
272 throw syntax_error(str, str.length()); \
273 if(argv[i+1][0] == '-') { \
274 uint32_t pos = str.length() + 1; \
275 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
277 std::stringstream tmp; \
285 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2, DO_POST) \
286 else if(str == SHORT || str == LONG) \
289 throw syntax_error(str, str.length()); \
291 throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
292 if(argv[i+1][0] == '-') { \
293 uint32_t pos = str.length() + 1; \
294 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
296 if(argv[i+2][0] == '-') { \
297 uint32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
298 throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
300 std::stringstream tmp; \
301 tmp << argv[i+1] << " " << argv[i+2]; \
309 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST, TYPE, DO_POST) \
310 else if(str == SHORT || str == LONG) \
313 throw syntax_error(str, str.length()); \
314 if(argv[i+1][0] == '-') { \
315 uint32_t pos = str.length() + 1; \
316 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
318 std::stringstream tmp(argv[i+1]); \
321 std::string tmp_line; \
322 getline(tmp,tmp_line,','); \
323 LIST.push_back(TYPE(tmp_line)); \
330 #define PARSE_HEXSTRING_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
331 else if(str == SHORT || str == LONG) \
334 throw syntax_error(str, str.length()); \
335 if(argv[i+1][0] == '-') { \
336 uint32_t pos = str.length() + 1; \
337 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
339 VALUE = Buffer(std::string(argv[i+1])); \
340 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
341 argv[i+1][j] = '#'; \
347 #define PARSE_PHRASE_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
348 else if(str == SHORT || str == LONG) \
351 throw syntax_error(str, str.length()); \
352 if(argv[i+1][0] == '-') { \
353 uint32_t pos = str.length() + 1; \
354 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
357 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
358 argv[i+1][j] = '#'; \
364 #define PARSE_STRING_LIST(SHORT, LONG, LIST, DO_POST) \
365 else if(str == SHORT || str == LONG) \
368 throw syntax_error(str, str.length()); \
369 if(argv[i+1][0] == '-') { \
370 uint32_t pos = str.length() + 1; \
371 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
373 LIST.push_back(argv[i+1]); \
379 bool Options::parse(int argc, char* argv[])
381 WritersLock lock(mutex);
385 bool ipv4_only = false, ipv6_only = false;
386 std::string role = "";
387 for(int i=1; argc > 0; ++i) {
388 std::string str(argv[i]);
391 if(str == "-h" || str == "--help") {
394 } else if(str == "-v" || str == "--version") {
399 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
401 #if !defined(_MSC_VER) && !defined(MINGW)
402 PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
403 PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
404 PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
405 PARSE_SCALAR_PARAM("-C","--chroot", chroot_dir_, NOTHING)
406 PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_, NOTHING)
411 PARSE_STRING_LIST("-L","--log", log_targets_, NOTHING)
412 PARSE_BOOL_PARAM("-U","--debug", debug_, NOTHING)
414 #if defined(ANYCTR_OPTIONS)
416 PARSE_SCALAR_PARAM("-f","--file", file_name_, NOTHING)
417 PARSE_SCALAR_PARAM("-X","--control-host", bind_to_, NOTHING)
420 #if defined(ANYTUN_OPTIONS)
422 PARSE_SCALAR_PARAM("-i","--interface", local_.addr, NOTHING)
423 PARSE_SCALAR_PARAM("-p","--port", local_.port, NOTHING)
424 PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_, NOTHING)
427 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
429 PARSE_SCALAR_PARAM("-r","--remote-host", remote_.addr, connection_opts = true)
430 PARSE_SCALAR_PARAM("-o","--remote-port", remote_.port, connection_opts = true)
431 PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only, connection_opts = true)
432 PARSE_BOOL_PARAM("-6","--ipv6-only", ipv6_only, connection_opts = true)
435 #if defined(ANYTUN_OPTIONS)
437 PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_.addr, cluster_opts = true)
438 PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_.port, cluster_opts = true)
439 PARSE_CSLIST_PARAM("-M","--sync-hosts", remote_sync_hosts_, OptionHost, cluster_opts = true)
440 PARSE_CSLIST_PARAM("-X","--control-host", remote_sync_hosts_, OptionHost, cluster_opts = true)
442 PARSE_SCALAR_PARAM("-d","--dev", dev_name_, NOTHING)
443 PARSE_SCALAR_PARAM("-t","--type", dev_type_, NOTHING)
444 PARSE_SCALAR_PARAM("-n","--ifconfig", ifconfig_param_, NOTHING)
445 PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_, NOTHING)
448 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
451 PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork, connection_opts = true)
454 PARSE_SCALAR_PARAM("-m","--mux", mux_, connection_opts = true)
455 PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_, connection_opts = true)
458 PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_, connection_opts = true)
459 PARSE_SCALAR_PARAM("-e","--role", role, connection_opts = true)
460 #ifndef NO_PASSPHRASE
461 PARSE_PHRASE_PARAM_SEC("-E","--passphrase", passphrase_, connection_opts = true)
463 PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_, connection_opts = true)
464 PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_, connection_opts = true)
468 #if defined(ANYTUN_OPTIONS)
471 PARSE_SCALAR_PARAM("-c","--cipher", cipher_, NOTHING)
472 PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_, NOTHING)
473 PARSE_SCALAR_PARAM("-b","--auth-tag-length", auth_tag_length_, NOTHING)
478 throw syntax_error(str, 0);
481 if(ipv4_only && ipv6_only) {
482 throw syntax_error("-4 and -6 are mutual exclusive", -1);
485 resolv_addr_type_ = IPV4_ONLY;
488 resolv_addr_type_ = IPV6_ONLY;
492 if(role == "alice" || role == "server" || role == "left") {
494 } else if(role == "bob" || role == "client" || role == "right") {
497 throw syntax_error("unknown role name: " + role, -1);
502 log_targets_.push_back("stdout:5");
506 if(log_targets_.empty()) {
507 #if !defined(_MSC_VER) && !defined(MINGW)
508 #if !defined(ANYCONF_OPTIONS)
509 log_targets_.push_back(std::string("syslog:3,").append(progname_).append(",daemon"));
511 log_targets_.push_back("stderr:2");
515 log_targets_.push_back(std::string("eventlog:3,").append(progname_));
517 log_targets_.push_back("stdout:3");
525 void Options::parse_post()
527 #if defined(ANYTUN_OPTIONS)
528 if(cluster_opts && connection_opts) {
529 cLog.msg(Log::PRIO_WARNING) << "you have provided options for cluster support as well as connection oriented options, we strongly recommend to use anytun-config and anytun-controld when building a cluster";
532 if(cipher_ == "null" && auth_algo_ == "null") {
535 if((cipher_ != "null" || auth_algo_ != "null") && kd_prf_ == "null") {
536 cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
539 uint32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
540 if(!tag_len_max) { auth_tag_length_ = 0; }
541 else if(tag_len_max < auth_tag_length_) {
542 cLog.msg(Log::PRIO_WARNING) << auth_algo_ << " auth algo can't generate tags of length " << auth_tag_length_ << ", using maximum tag length(" << tag_len_max << ")";
543 auth_tag_length_ = tag_len_max;
547 if(dev_name_ == "" && dev_type_ == "") {
552 void Options::printVersion()
554 #if defined(ANYCTR_OPTIONS)
555 std::cout << "anytun-controld";
556 #elif defined(ANYCONF_OPTIONS)
557 std::cout << "anytun-config";
559 std::cout << "anytun";
561 std::cout << VERSION_STRING_0 << std::endl;
563 #if defined(__clang__)
564 std::cout << VERSION_STRING_1 << ", using CLANG " << __clang_version__ << std::endl;
565 #elif defined(__GNUC__)
566 std::cout << VERSION_STRING_1 << ", using GCC " << __GNUC__ << '.' << __GNUC_MINOR__
567 << '.' << __GNUC_PATCHLEVEL__ << std::endl;
569 std::cout << VERSION_STRING_1 << std::endl;
574 void Options::printUsage()
576 std::cout << "USAGE:" << std::endl;
578 #if defined(ANYCTR_OPTIONS)
579 std::cout << "anytun-controld " << std::endl;
580 #elif defined(ANYCONF_OPTIONS)
581 std::cout << "anytun-config " << std::endl;
583 std::cout << "anytun " << std::endl;
586 std::cout << " [-h|--help] prints this..." << std::endl;
587 std::cout << " [-v|--version] print version info and exit" << std::endl;
589 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
591 #if !defined(_MSC_VER) && !defined(MINGW)
592 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
593 std::cout << " [-u|--username] <username> change to this user" << std::endl;
594 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
595 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
596 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
601 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
602 std::cout << " add a log target, can be invoked several times" << std::endl;
603 std::cout << " i.e.: stdout:5" << std::endl;
604 std::cout << " [-U|--debug] don't daemonize and log to stdout with maximum log level" << std::endl;
606 #if defined(ANYCTR_OPTIONS)
608 std::cout << " [-f|--file] <path> path to input file" << std::endl;
609 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
610 std::cout << " local tcp port and or ip address to bind to" << std::endl;
613 #if defined(ANYTUN_OPTIONS)
615 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
616 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
617 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
620 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
622 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
623 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
624 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
625 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
628 #if defined(ANYTUN_OPTIONS)
630 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
631 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
632 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
633 std::cout << " remote hosts to sync with" << std::endl;
634 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
635 std::cout << " fetch the config from this host" << std::endl;
637 std::cout << " [-d|--dev] <name> device name" << std::endl;
638 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
639 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
640 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
643 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
646 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
649 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
650 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
653 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
654 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
655 #ifndef NO_PASSPHRASE
656 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
658 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
659 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
663 #if defined(ANYTUN_OPTIONS)
666 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
667 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
668 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
674 void Options::printOptions()
676 ReadersLock lock(mutex);
678 std::cout << "Options:" << std::endl;
679 std::cout << std::endl;
680 std::cout << "daemonize = " << daemonize_ << std::endl;
681 std::cout << "username = '" << username_ << "'" << std::endl;
682 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
683 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
684 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
685 std::cout << std::endl;
686 std::cout << "log_targets:";
687 StringList::const_iterator lit = log_targets_.begin();
688 for(; lit != log_targets_.end(); ++lit) {
689 std::cout << " '" << *lit << "',";
691 std::cout << std::endl;
692 std::cout << "debug = " << debug_ << std::endl;
693 std::cout << std::endl;
694 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
695 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
696 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
697 std::cout << std::endl;
698 std::cout << "resolv_addr_type = ";
699 switch(resolv_addr_type_) {
701 std::cout << "any" << std::endl;
704 std::cout << "ipv4-only" << std::endl;
707 std::cout << "ipv6-only" << std::endl;
710 std::cout << "?" << std::endl;
713 std::cout << std::endl;
714 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
715 std::cout << "local.port = '" << local_.port << "'" << std::endl;
716 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
717 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
718 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
719 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
720 std::cout << "remote_sync_hosts:" << std::endl;
721 HostList::const_iterator hit = remote_sync_hosts_.begin();
722 for(; hit != remote_sync_hosts_.end(); ++hit) {
723 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
725 std::cout << std::endl;
726 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
727 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
728 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
729 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
730 std::cout << "routes:" << std::endl;
731 NetworkList::const_iterator rit;
732 for(rit = routes_.begin(); rit != routes_.end(); ++rit) {
733 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
735 std::cout << std::endl;
736 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
737 std::cout << "mux_id = " << mux_ << std::endl;
738 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
739 std::cout << std::endl;
740 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
741 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
742 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
743 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
744 std::cout << "role = ";
747 std::cout << "left" << std::endl;
750 std::cout << "right" << std::endl;
753 std::cout << "??" << std::endl;
756 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
757 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
758 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
763 std::string Options::getProgname()
765 ReadersLock lock(mutex);
769 Options& Options::setProgname(std::string p)
771 WritersLock lock(mutex);
776 bool Options::getDaemonize()
778 ReadersLock lock(mutex);
782 Options& Options::setDaemonize(bool d)
784 WritersLock lock(mutex);
789 std::string Options::getUsername()
791 ReadersLock lock(mutex);
795 Options& Options::setUsername(std::string u)
797 WritersLock lock(mutex);
802 std::string Options::getGroupname()
804 ReadersLock lock(mutex);
808 Options& Options::setGroupname(std::string g)
810 WritersLock lock(mutex);
815 std::string Options::getChrootDir()
817 ReadersLock lock(mutex);
821 Options& Options::setChrootDir(std::string c)
823 WritersLock lock(mutex);
828 std::string Options::getPidFile()
830 ReadersLock lock(mutex);
834 Options& Options::setPidFile(std::string p)
836 WritersLock lock(mutex);
842 StringList Options::getLogTargets()
844 ReadersLock lock(mutex);
848 bool Options::getDebug()
850 ReadersLock lock(mutex);
854 Options& Options::setDebug(bool d)
856 WritersLock lock(mutex);
862 std::string Options::getFileName()
864 ReadersLock lock(mutex);
868 Options& Options::setFileName(std::string f)
870 WritersLock lock(mutex);
875 std::string Options::getBindToAddr()
877 ReadersLock lock(mutex);
878 return bind_to_.addr;
881 Options& Options::setBindToAddr(std::string b)
883 WritersLock lock(mutex);
888 std::string Options::getBindToPort()
890 ReadersLock lock(mutex);
891 return bind_to_.port;
894 Options& Options::setBindToPort(std::string b)
896 WritersLock lock(mutex);
902 ResolvAddrType Options::getResolvAddrType()
904 ReadersLock lock(mutex);
905 return resolv_addr_type_;
908 Options& Options::setResolvAddrType(ResolvAddrType r)
910 WritersLock lock(mutex);
911 resolv_addr_type_ = r;
915 std::string Options::getLocalAddr()
917 ReadersLock lock(mutex);
921 Options& Options::setLocalAddr(std::string l)
923 WritersLock lock(mutex);
928 std::string Options::getLocalPort()
930 ReadersLock lock(mutex);
934 Options& Options::setLocalPort(std::string l)
936 WritersLock lock(mutex);
941 std::string Options::getRemoteAddr()
943 ReadersLock lock(mutex);
947 Options& Options::setRemoteAddr(std::string r)
949 WritersLock lock(mutex);
954 std::string Options::getRemotePort()
956 ReadersLock lock(mutex);
960 Options& Options::setRemotePort(std::string r)
962 WritersLock lock(mutex);
967 std::string Options::getLocalSyncAddr()
969 ReadersLock lock(mutex);
970 return local_sync_.addr;
973 Options& Options::setLocalSyncAddr(std::string l)
975 WritersLock lock(mutex);
976 local_sync_.addr = l;
980 std::string Options::getLocalSyncPort()
982 ReadersLock lock(mutex);
983 return local_sync_.port;
986 Options& Options::setLocalSyncPort(std::string l)
988 WritersLock lock(mutex);
989 local_sync_.port = l;
993 HostList Options::getRemoteSyncHosts()
995 ReadersLock lock(mutex);
996 return remote_sync_hosts_;
1001 std::string Options::getDevName()
1003 ReadersLock lock(mutex);
1007 Options& Options::setDevName(std::string d)
1009 WritersLock lock(mutex);
1014 std::string Options::getDevType()
1016 ReadersLock lock(mutex);
1020 Options& Options::setDevType(std::string d)
1022 WritersLock lock(mutex);
1027 OptionNetwork Options::getIfconfigParam()
1029 ReadersLock lock(mutex);
1030 return ifconfig_param_;
1033 Options& Options::setIfconfigParam(OptionNetwork i)
1035 WritersLock lock(mutex);
1036 ifconfig_param_ = i;
1040 std::string Options::getPostUpScript()
1042 ReadersLock lock(mutex);
1043 return post_up_script_;
1046 Options& Options::setPostUpScript(std::string p)
1048 WritersLock lock(mutex);
1049 post_up_script_ = p;
1053 NetworkList Options::getRoutes()
1055 ReadersLock lock(mutex);
1061 sender_id_t Options::getSenderId()
1063 ReadersLock lock(mutex);
1067 Options& Options::setSenderId(sender_id_t s)
1069 WritersLock lock(mutex);
1074 mux_t Options::getMux()
1076 ReadersLock lock(mutex);
1080 Options& Options::setMux(mux_t m)
1082 WritersLock lock(mutex);
1087 window_size_t Options::getSeqWindowSize()
1089 ReadersLock lock(mutex);
1090 return seq_window_size_;
1093 Options& Options::setSeqWindowSize(window_size_t s)
1095 WritersLock lock(mutex);
1096 seq_window_size_ = s;
1102 std::string Options::getCipher()
1104 ReadersLock lock(mutex);
1108 Options& Options::setCipher(std::string c)
1110 WritersLock lock(mutex);
1115 std::string Options::getAuthAlgo()
1117 ReadersLock lock(mutex);
1121 Options& Options::setAuthAlgo(std::string a)
1123 WritersLock lock(mutex);
1128 uint32_t Options::getAuthTagLength()
1130 ReadersLock lock(mutex);
1131 return auth_tag_length_;
1134 Options& Options::setAuthTagLength(uint32_t a)
1136 WritersLock lock(mutex);
1137 auth_tag_length_ = a;
1142 std::string Options::getKdPrf()
1144 ReadersLock lock(mutex);
1148 Options& Options::setKdPrf(std::string k)
1150 WritersLock lock(mutex);
1155 role_t Options::getRole()
1157 ReadersLock lock(mutex);
1161 Options& Options::setRole(role_t r)
1163 WritersLock lock(mutex);
1168 std::string Options::getPassphrase()
1170 ReadersLock lock(mutex);
1174 Options& Options::setPassphrase(std::string p)
1176 WritersLock lock(mutex);
1181 Buffer Options::getKey()
1183 ReadersLock lock(mutex);
1187 Options& Options::setKey(std::string k)
1189 WritersLock lock(mutex);
1194 Buffer Options::getSalt()
1196 ReadersLock lock(mutex);
1200 Options& Options::setSalt(std::string s)
1202 WritersLock lock(mutex);