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;
562 std::cout << VERSION_STRING_1 << std::endl;
565 void Options::printUsage()
567 std::cout << "USAGE:" << std::endl;
569 #if defined(ANYCTR_OPTIONS)
570 std::cout << "anytun-controld " << std::endl;
571 #elif defined(ANYCONF_OPTIONS)
572 std::cout << "anytun-config " << std::endl;
574 std::cout << "anytun " << std::endl;
577 std::cout << " [-h|--help] prints this..." << std::endl;
578 std::cout << " [-v|--version] print version info and exit" << std::endl;
580 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
582 #if !defined(_MSC_VER) && !defined(MINGW)
583 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
584 std::cout << " [-u|--username] <username> change to this user" << std::endl;
585 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
586 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
587 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
592 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
593 std::cout << " add a log target, can be invoked several times" << std::endl;
594 std::cout << " i.e.: stdout:5" << std::endl;
595 std::cout << " [-U|--debug] don't daemonize and log to stdout with maximum log level" << std::endl;
597 #if defined(ANYCTR_OPTIONS)
599 std::cout << " [-f|--file] <path> path to input file" << std::endl;
600 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
601 std::cout << " local tcp port and or ip address to bind to" << std::endl;
604 #if defined(ANYTUN_OPTIONS)
606 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
607 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
608 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
611 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
613 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
614 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
615 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
616 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
619 #if defined(ANYTUN_OPTIONS)
621 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
622 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
623 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
624 std::cout << " remote hosts to sync with" << std::endl;
625 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
626 std::cout << " fetch the config from this host" << std::endl;
628 std::cout << " [-d|--dev] <name> device name" << std::endl;
629 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
630 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
631 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
634 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
637 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
640 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
641 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
644 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
645 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
646 #ifndef NO_PASSPHRASE
647 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
649 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
650 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
654 #if defined(ANYTUN_OPTIONS)
657 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
658 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
659 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
665 void Options::printOptions()
667 ReadersLock lock(mutex);
669 std::cout << "Options:" << std::endl;
670 std::cout << std::endl;
671 std::cout << "daemonize = " << daemonize_ << std::endl;
672 std::cout << "username = '" << username_ << "'" << std::endl;
673 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
674 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
675 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
676 std::cout << std::endl;
677 std::cout << "log_targets:";
678 StringList::const_iterator lit = log_targets_.begin();
679 for(; lit != log_targets_.end(); ++lit) {
680 std::cout << " '" << *lit << "',";
682 std::cout << std::endl;
683 std::cout << "debug = " << debug_ << std::endl;
684 std::cout << std::endl;
685 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
686 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
687 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
688 std::cout << std::endl;
689 std::cout << "resolv_addr_type = ";
690 switch(resolv_addr_type_) {
692 std::cout << "any" << std::endl;
695 std::cout << "ipv4-only" << std::endl;
698 std::cout << "ipv6-only" << std::endl;
701 std::cout << "?" << std::endl;
704 std::cout << std::endl;
705 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
706 std::cout << "local.port = '" << local_.port << "'" << std::endl;
707 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
708 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
709 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
710 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
711 std::cout << "remote_sync_hosts:" << std::endl;
712 HostList::const_iterator hit = remote_sync_hosts_.begin();
713 for(; hit != remote_sync_hosts_.end(); ++hit) {
714 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
716 std::cout << std::endl;
717 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
718 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
719 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
720 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
721 std::cout << "routes:" << std::endl;
722 NetworkList::const_iterator rit;
723 for(rit = routes_.begin(); rit != routes_.end(); ++rit) {
724 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
726 std::cout << std::endl;
727 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
728 std::cout << "mux_id = " << mux_ << std::endl;
729 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
730 std::cout << std::endl;
731 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
732 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
733 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
734 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
735 std::cout << "role = ";
738 std::cout << "left" << std::endl;
741 std::cout << "right" << std::endl;
744 std::cout << "??" << std::endl;
747 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
748 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
749 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
754 std::string Options::getProgname()
756 ReadersLock lock(mutex);
760 Options& Options::setProgname(std::string p)
762 WritersLock lock(mutex);
767 bool Options::getDaemonize()
769 ReadersLock lock(mutex);
773 Options& Options::setDaemonize(bool d)
775 WritersLock lock(mutex);
780 std::string Options::getUsername()
782 ReadersLock lock(mutex);
786 Options& Options::setUsername(std::string u)
788 WritersLock lock(mutex);
793 std::string Options::getGroupname()
795 ReadersLock lock(mutex);
799 Options& Options::setGroupname(std::string g)
801 WritersLock lock(mutex);
806 std::string Options::getChrootDir()
808 ReadersLock lock(mutex);
812 Options& Options::setChrootDir(std::string c)
814 WritersLock lock(mutex);
819 std::string Options::getPidFile()
821 ReadersLock lock(mutex);
825 Options& Options::setPidFile(std::string p)
827 WritersLock lock(mutex);
833 StringList Options::getLogTargets()
835 ReadersLock lock(mutex);
839 bool Options::getDebug()
841 ReadersLock lock(mutex);
845 Options& Options::setDebug(bool d)
847 WritersLock lock(mutex);
853 std::string Options::getFileName()
855 ReadersLock lock(mutex);
859 Options& Options::setFileName(std::string f)
861 WritersLock lock(mutex);
866 std::string Options::getBindToAddr()
868 ReadersLock lock(mutex);
869 return bind_to_.addr;
872 Options& Options::setBindToAddr(std::string b)
874 WritersLock lock(mutex);
879 std::string Options::getBindToPort()
881 ReadersLock lock(mutex);
882 return bind_to_.port;
885 Options& Options::setBindToPort(std::string b)
887 WritersLock lock(mutex);
893 ResolvAddrType Options::getResolvAddrType()
895 ReadersLock lock(mutex);
896 return resolv_addr_type_;
899 Options& Options::setResolvAddrType(ResolvAddrType r)
901 WritersLock lock(mutex);
902 resolv_addr_type_ = r;
906 std::string Options::getLocalAddr()
908 ReadersLock lock(mutex);
912 Options& Options::setLocalAddr(std::string l)
914 WritersLock lock(mutex);
919 std::string Options::getLocalPort()
921 ReadersLock lock(mutex);
925 Options& Options::setLocalPort(std::string l)
927 WritersLock lock(mutex);
932 std::string Options::getRemoteAddr()
934 ReadersLock lock(mutex);
938 Options& Options::setRemoteAddr(std::string r)
940 WritersLock lock(mutex);
945 std::string Options::getRemotePort()
947 ReadersLock lock(mutex);
951 Options& Options::setRemotePort(std::string r)
953 WritersLock lock(mutex);
958 std::string Options::getLocalSyncAddr()
960 ReadersLock lock(mutex);
961 return local_sync_.addr;
964 Options& Options::setLocalSyncAddr(std::string l)
966 WritersLock lock(mutex);
967 local_sync_.addr = l;
971 std::string Options::getLocalSyncPort()
973 ReadersLock lock(mutex);
974 return local_sync_.port;
977 Options& Options::setLocalSyncPort(std::string l)
979 WritersLock lock(mutex);
980 local_sync_.port = l;
984 HostList Options::getRemoteSyncHosts()
986 ReadersLock lock(mutex);
987 return remote_sync_hosts_;
992 std::string Options::getDevName()
994 ReadersLock lock(mutex);
998 Options& Options::setDevName(std::string d)
1000 WritersLock lock(mutex);
1005 std::string Options::getDevType()
1007 ReadersLock lock(mutex);
1011 Options& Options::setDevType(std::string d)
1013 WritersLock lock(mutex);
1018 OptionNetwork Options::getIfconfigParam()
1020 ReadersLock lock(mutex);
1021 return ifconfig_param_;
1024 Options& Options::setIfconfigParam(OptionNetwork i)
1026 WritersLock lock(mutex);
1027 ifconfig_param_ = i;
1031 std::string Options::getPostUpScript()
1033 ReadersLock lock(mutex);
1034 return post_up_script_;
1037 Options& Options::setPostUpScript(std::string p)
1039 WritersLock lock(mutex);
1040 post_up_script_ = p;
1044 NetworkList Options::getRoutes()
1046 ReadersLock lock(mutex);
1052 sender_id_t Options::getSenderId()
1054 ReadersLock lock(mutex);
1058 Options& Options::setSenderId(sender_id_t s)
1060 WritersLock lock(mutex);
1065 mux_t Options::getMux()
1067 ReadersLock lock(mutex);
1071 Options& Options::setMux(mux_t m)
1073 WritersLock lock(mutex);
1078 window_size_t Options::getSeqWindowSize()
1080 ReadersLock lock(mutex);
1081 return seq_window_size_;
1084 Options& Options::setSeqWindowSize(window_size_t s)
1086 WritersLock lock(mutex);
1087 seq_window_size_ = s;
1093 std::string Options::getCipher()
1095 ReadersLock lock(mutex);
1099 Options& Options::setCipher(std::string c)
1101 WritersLock lock(mutex);
1106 std::string Options::getAuthAlgo()
1108 ReadersLock lock(mutex);
1112 Options& Options::setAuthAlgo(std::string a)
1114 WritersLock lock(mutex);
1119 uint32_t Options::getAuthTagLength()
1121 ReadersLock lock(mutex);
1122 return auth_tag_length_;
1125 Options& Options::setAuthTagLength(uint32_t a)
1127 WritersLock lock(mutex);
1128 auth_tag_length_ = a;
1133 std::string Options::getKdPrf()
1135 ReadersLock lock(mutex);
1139 Options& Options::setKdPrf(std::string k)
1141 WritersLock lock(mutex);
1146 role_t Options::getRole()
1148 ReadersLock lock(mutex);
1152 Options& Options::setRole(role_t r)
1154 WritersLock lock(mutex);
1159 std::string Options::getPassphrase()
1161 ReadersLock lock(mutex);
1165 Options& Options::setPassphrase(std::string p)
1167 WritersLock lock(mutex);
1172 Buffer Options::getKey()
1174 ReadersLock lock(mutex);
1178 Options& Options::setKey(std::string k)
1180 WritersLock lock(mutex);
1185 Buffer Options::getSalt()
1187 ReadersLock lock(mutex);
1191 Options& Options::setSalt(std::string s)
1193 WritersLock lock(mutex);