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 methodes 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-2009 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/>.
39 #include "datatypes.h"
44 #include "authAlgoFactory.h"
46 std::ostream& operator<<(std::ostream& stream, syntax_error const& error)
48 stream << "syntax error: " << error.what() << std::endl;
51 for(int32_t i = 0; i < error.pos; ++i) { stream << " "; }
57 std::ostream& operator<<(std::ostream& stream, role_t const& role)
73 void OptionHost::init(std::string addrPort)
75 std::string origAddrPort(addrPort);
76 size_t pos = addrPort.find_first_of("[");
78 if(pos != std::string::npos && pos != 0) {
79 throw syntax_error(origAddrPort, pos); // an [ was found but not at the beginning;
83 if(pos != std::string::npos) {
84 addrPort.erase(pos, 1);
85 pos = addrPort.find_first_of("]");
87 if(pos == std::string::npos) {
88 throw syntax_error(origAddrPort, origAddrPort.length()); //no trailing ] although an leading [ was found
91 if(pos < addrPort.length()-2) {
92 if(addrPort[pos+1] != ':') {
93 throw syntax_error(origAddrPort, pos+2); // wrong port delimieter
96 addrPort[pos+1] = '/';
98 } else if(pos != addrPort.length()-1) {
99 throw syntax_error(origAddrPort, pos+2); // too few characters left
102 addrPort.erase(pos, 1);
104 pos = addrPort.find_first_of(":");
105 if(pos != std::string::npos && pos == addrPort.find_last_of(":")) {
106 // an ':' has been found and it is the only one -> assuming port present
113 std::stringstream tmp_stream(addrPort);
115 getline(tmp_stream, addr, '/');
116 if(!tmp_stream.good()) {
117 throw syntax_error(origAddrPort, addr.length());
123 port = "2323"; // default sync port
127 std::istream& operator>>(std::istream& stream, OptionHost& host)
135 void OptionNetwork::init(std::string network)
137 std::stringstream tmp_stream(network);
138 getline(tmp_stream, net_addr, '/');
139 if(!tmp_stream.good()) {
140 throw syntax_error(network, net_addr.length());
142 tmp_stream >> prefix_length;
145 std::istream& operator>>(std::istream& stream, OptionNetwork& network)
153 Options* Options::inst = NULL;
154 Mutex Options::instMutex;
155 Options& gOpt = Options::instance();
157 Options& Options::instance()
159 Lock lock(instMutex);
160 static instanceCleaner c;
162 inst = new Options();
168 Options::Options() : key_(uint32_t(0)), salt_(uint32_t(0))
170 #if defined(ANYCTR_OPTIONS)
171 progname_ = "anytun-controld";
172 #elif defined(ANYCONF_OPTIONS)
173 progname_ = "anytun-config";
175 progname_ = "anytun";
178 cluster_opts = false;
179 connection_opts = false;
190 bind_to_.addr = "127.0.0.1";
191 bind_to_.port = "2323";
193 resolv_addr_type_ = ANY;
196 local_.port = "4444";
198 remote_.port = "4444";
199 local_sync_.addr = "";
200 local_sync_.port = "";
204 post_up_script_ = "";
208 seq_window_size_ = 0;
210 #if !defined(ANYCONF_OPTIONS)
214 auth_tag_length_ = 10;
219 auth_tag_length_ = 0;
225 auth_tag_length_ = 0;
237 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
238 else if(str == SHORT || str == LONG) { \
243 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
244 else if(str == SHORT || str == LONG) { \
249 #define PARSE_SIGNED_INT_PARAM(SHORT, LONG, VALUE, DO_POST) \
250 else if(str == SHORT || str == LONG) \
253 throw syntax_error(str, str.length()); \
254 std::stringstream tmp; \
262 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE, DO_POST) \
263 else if(str == SHORT || str == LONG) \
266 throw syntax_error(str, str.length()); \
267 if(argv[i+1][0] == '-') { \
268 uint32_t pos = str.length() + 1; \
269 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
271 std::stringstream tmp; \
279 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2, DO_POST) \
280 else if(str == SHORT || str == LONG) \
283 throw syntax_error(str, str.length()); \
285 throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
286 if(argv[i+1][0] == '-') { \
287 uint32_t pos = str.length() + 1; \
288 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
290 if(argv[i+2][0] == '-') { \
291 uint32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
292 throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
294 std::stringstream tmp; \
295 tmp << argv[i+1] << " " << argv[i+2]; \
303 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST, TYPE, DO_POST) \
304 else if(str == SHORT || str == LONG) \
307 throw syntax_error(str, str.length()); \
308 if(argv[i+1][0] == '-') { \
309 uint32_t pos = str.length() + 1; \
310 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
312 std::stringstream tmp(argv[i+1]); \
315 std::string tmp_line; \
316 getline(tmp,tmp_line,','); \
317 LIST.push_back(TYPE(tmp_line)); \
324 #define PARSE_HEXSTRING_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
325 else if(str == SHORT || str == LONG) \
328 throw syntax_error(str, str.length()); \
329 if(argv[i+1][0] == '-') { \
330 uint32_t pos = str.length() + 1; \
331 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
333 VALUE = Buffer(std::string(argv[i+1])); \
334 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
335 argv[i+1][j] = '#'; \
341 #define PARSE_PHRASE_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
342 else if(str == SHORT || str == LONG) \
345 throw syntax_error(str, str.length()); \
346 if(argv[i+1][0] == '-') { \
347 uint32_t pos = str.length() + 1; \
348 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
351 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
352 argv[i+1][j] = '#'; \
358 #define PARSE_STRING_LIST(SHORT, LONG, LIST, DO_POST) \
359 else if(str == SHORT || str == LONG) \
362 throw syntax_error(str, str.length()); \
363 if(argv[i+1][0] == '-') { \
364 uint32_t pos = str.length() + 1; \
365 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
367 LIST.push_back(argv[i+1]); \
373 bool Options::parse(int argc, char* argv[])
375 WritersLock lock(mutex);
379 bool ipv4_only = false, ipv6_only = false;
380 std::string role = "";
381 for(int i=1; argc > 0; ++i) {
382 std::string str(argv[i]);
385 if(str == "-h" || str == "--help") {
388 } else if(str == "-v" || str == "--version") {
393 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
396 PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
397 PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
398 PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
399 PARSE_SCALAR_PARAM("-C","--chroot", chroot_dir_, NOTHING)
400 PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_, NOTHING)
405 PARSE_STRING_LIST("-L","--log", log_targets_, NOTHING)
406 PARSE_BOOL_PARAM("-U","--debug", debug_, NOTHING)
408 #if defined(ANYCTR_OPTIONS)
410 PARSE_SCALAR_PARAM("-f","--file", file_name_, NOTHING)
411 PARSE_SCALAR_PARAM("-X","--control-host", bind_to_, NOTHING)
414 #if defined(ANYTUN_OPTIONS)
416 PARSE_SCALAR_PARAM("-i","--interface", local_.addr, NOTHING)
417 PARSE_SCALAR_PARAM("-p","--port", local_.port, NOTHING)
418 PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_, NOTHING)
421 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
423 PARSE_SCALAR_PARAM("-r","--remote-host", remote_.addr, connection_opts = true)
424 PARSE_SCALAR_PARAM("-o","--remote-port", remote_.port, connection_opts = true)
425 PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only, connection_opts = true)
426 PARSE_BOOL_PARAM("-6","--ipv6-only", ipv6_only, connection_opts = true)
429 #if defined(ANYTUN_OPTIONS)
431 PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_.addr, cluster_opts = true)
432 PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_.port, cluster_opts = true)
433 PARSE_CSLIST_PARAM("-M","--sync-hosts", remote_sync_hosts_, OptionHost, cluster_opts = true)
434 PARSE_CSLIST_PARAM("-X","--control-host", remote_sync_hosts_, OptionHost, cluster_opts = true)
436 PARSE_SCALAR_PARAM("-d","--dev", dev_name_, NOTHING)
437 PARSE_SCALAR_PARAM("-t","--type", dev_type_, NOTHING)
438 PARSE_SCALAR_PARAM("-n","--ifconfig", ifconfig_param_, NOTHING)
439 PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_, NOTHING)
442 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
445 PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork, connection_opts = true)
448 PARSE_SCALAR_PARAM("-m","--mux", mux_, connection_opts = true)
449 PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_, connection_opts = true)
452 PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_, connection_opts = true)
453 PARSE_SCALAR_PARAM("-e","--role", role, connection_opts = true)
454 #ifndef NO_PASSPHRASE
455 PARSE_PHRASE_PARAM_SEC("-E","--passphrase", passphrase_, connection_opts = true)
457 PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_, connection_opts = true)
458 PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_, connection_opts = true)
462 #if defined(ANYTUN_OPTIONS)
465 PARSE_SCALAR_PARAM("-c","--cipher", cipher_, NOTHING)
466 PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_, NOTHING)
467 PARSE_SCALAR_PARAM("-b","--auth-tag-length", auth_tag_length_, NOTHING)
472 throw syntax_error(str, 0);
475 if(ipv4_only && ipv6_only) {
476 throw syntax_error("-4 and -6 are mutual exclusive", -1);
479 resolv_addr_type_ = IPV4_ONLY;
482 resolv_addr_type_ = IPV6_ONLY;
486 if(role == "alice" || role == "server" || role == "left") {
488 } else if(role == "bob" || role == "client" || role == "right") {
491 throw syntax_error("unknown role name: " + role, -1);
496 log_targets_.push_back("stdout:5");
500 if(log_targets_.empty()) {
502 #if !defined(ANYCONF_OPTIONS)
503 log_targets_.push_back(std::string("syslog:3,").append(progname_).append(",daemon"));
505 log_targets_.push_back("stderr:2");
509 log_targets_.push_back(std::string("eventlog:3,").append(progname_));
511 log_targets_.push_back("stdout:3");
519 void Options::parse_post()
521 #if defined(ANYTUN_OPTIONS)
522 if(cluster_opts && connection_opts) {
523 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";
526 if(cipher_ == "null" && auth_algo_ == "null") {
529 if((cipher_ != "null" || auth_algo_ != "null") && kd_prf_ == "null") {
530 cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
533 uint32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
534 if(!tag_len_max) { auth_tag_length_ = 0; }
535 else if(tag_len_max < auth_tag_length_) {
536 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 << ")";
537 auth_tag_length_ = tag_len_max;
541 if(dev_name_ == "" && dev_type_ == "") {
546 void Options::printVersion()
548 #if defined(ANYCTR_OPTIONS)
549 std::cout << "anytun-controld";
550 #elif defined(ANYCONF_OPTIONS)
551 std::cout << "anytun-config";
553 std::cout << "anytun";
555 std::cout << VERSION_STRING_0 << std::endl;
556 std::cout << VERSION_STRING_1 << std::endl;
559 void Options::printUsage()
561 std::cout << "USAGE:" << std::endl;
563 #if defined(ANYCTR_OPTIONS)
564 std::cout << "anytun-controld " << std::endl;
565 #elif defined(ANYCONF_OPTIONS)
566 std::cout << "anytun-config " << std::endl;
568 std::cout << "anytun " << std::endl;
571 std::cout << " [-h|--help] prints this..." << std::endl;
572 std::cout << " [-v|--version] print version info and exit" << std::endl;
574 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
577 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
578 std::cout << " [-u|--username] <username> change to this user" << std::endl;
579 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
580 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
581 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
586 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
587 std::cout << " add a log target, can be invoked several times" << std::endl;
588 std::cout << " i.e.: stdout:5" << std::endl;
589 std::cout << " [-U|--debug] don't daemonize and log to stdout with maximum log level" << std::endl;
591 #if defined(ANYCTR_OPTIONS)
593 std::cout << " [-f|--file] <path> path to input file" << std::endl;
594 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
595 std::cout << " local tcp port and or ip address to bind to" << std::endl;
598 #if defined(ANYTUN_OPTIONS)
600 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
601 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
602 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
605 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
607 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
608 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
609 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
610 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
613 #if defined(ANYTUN_OPTIONS)
615 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
616 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
617 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
618 std::cout << " remote hosts to sync with" << std::endl;
619 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
620 std::cout << " fetch the config from this host" << std::endl;
622 std::cout << " [-d|--dev] <name> device name" << std::endl;
623 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
624 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
625 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
628 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
631 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
634 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
635 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
638 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
639 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
640 #ifndef NO_PASSPHRASE
641 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
643 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
644 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
648 #if defined(ANYTUN_OPTIONS)
651 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
652 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
653 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
659 void Options::printOptions()
661 ReadersLock lock(mutex);
663 std::cout << "Options:" << std::endl;
664 std::cout << std::endl;
665 std::cout << "daemonize = " << daemonize_ << std::endl;
666 std::cout << "username = '" << username_ << "'" << std::endl;
667 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
668 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
669 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
670 std::cout << std::endl;
671 std::cout << "log_targets:";
672 StringList::const_iterator lit = log_targets_.begin();
673 for(; lit != log_targets_.end(); ++lit) {
674 std::cout << " '" << *lit << "',";
676 std::cout << std::endl;
677 std::cout << "debug = " << debug_ << std::endl;
678 std::cout << std::endl;
679 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
680 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
681 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
682 std::cout << std::endl;
683 std::cout << "resolv_addr_type = ";
684 switch(resolv_addr_type_) {
686 std::cout << "any" << std::endl;
689 std::cout << "ipv4-only" << std::endl;
692 std::cout << "ipv6-only" << std::endl;
695 std::cout << "?" << std::endl;
698 std::cout << std::endl;
699 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
700 std::cout << "local.port = '" << local_.port << "'" << std::endl;
701 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
702 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
703 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
704 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
705 std::cout << "remote_sync_hosts:" << std::endl;
706 HostList::const_iterator hit = remote_sync_hosts_.begin();
707 for(; hit != remote_sync_hosts_.end(); ++hit) {
708 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
710 std::cout << std::endl;
711 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
712 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
713 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
714 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
715 std::cout << "routes:" << std::endl;
716 NetworkList::const_iterator rit;
717 for(rit = routes_.begin(); rit != routes_.end(); ++rit) {
718 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
720 std::cout << std::endl;
721 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
722 std::cout << "mux_id = " << mux_ << std::endl;
723 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
724 std::cout << std::endl;
725 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
726 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
727 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
728 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
729 std::cout << "role = ";
732 std::cout << "left" << std::endl;
735 std::cout << "right" << std::endl;
738 std::cout << "??" << std::endl;
741 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
742 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
743 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
748 std::string Options::getProgname()
750 ReadersLock lock(mutex);
754 Options& Options::setProgname(std::string p)
756 WritersLock lock(mutex);
761 bool Options::getDaemonize()
763 ReadersLock lock(mutex);
767 Options& Options::setDaemonize(bool d)
769 WritersLock lock(mutex);
774 std::string Options::getUsername()
776 ReadersLock lock(mutex);
780 Options& Options::setUsername(std::string u)
782 WritersLock lock(mutex);
787 std::string Options::getGroupname()
789 ReadersLock lock(mutex);
793 Options& Options::setGroupname(std::string g)
795 WritersLock lock(mutex);
800 std::string Options::getChrootDir()
802 ReadersLock lock(mutex);
806 Options& Options::setChrootDir(std::string c)
808 WritersLock lock(mutex);
813 std::string Options::getPidFile()
815 ReadersLock lock(mutex);
819 Options& Options::setPidFile(std::string p)
821 WritersLock lock(mutex);
827 StringList Options::getLogTargets()
829 ReadersLock lock(mutex);
833 bool Options::getDebug()
835 ReadersLock lock(mutex);
839 Options& Options::setDebug(bool d)
841 WritersLock lock(mutex);
847 std::string Options::getFileName()
849 ReadersLock lock(mutex);
853 Options& Options::setFileName(std::string f)
855 WritersLock lock(mutex);
860 std::string Options::getBindToAddr()
862 ReadersLock lock(mutex);
863 return bind_to_.addr;
866 Options& Options::setBindToAddr(std::string b)
868 WritersLock lock(mutex);
873 std::string Options::getBindToPort()
875 ReadersLock lock(mutex);
876 return bind_to_.port;
879 Options& Options::setBindToPort(std::string b)
881 WritersLock lock(mutex);
887 ResolvAddrType Options::getResolvAddrType()
889 ReadersLock lock(mutex);
890 return resolv_addr_type_;
893 Options& Options::setResolvAddrType(ResolvAddrType r)
895 WritersLock lock(mutex);
896 resolv_addr_type_ = r;
900 std::string Options::getLocalAddr()
902 ReadersLock lock(mutex);
906 Options& Options::setLocalAddr(std::string l)
908 WritersLock lock(mutex);
913 std::string Options::getLocalPort()
915 ReadersLock lock(mutex);
919 Options& Options::setLocalPort(std::string l)
921 WritersLock lock(mutex);
926 std::string Options::getRemoteAddr()
928 ReadersLock lock(mutex);
932 Options& Options::setRemoteAddr(std::string r)
934 WritersLock lock(mutex);
939 std::string Options::getRemotePort()
941 ReadersLock lock(mutex);
945 Options& Options::setRemotePort(std::string r)
947 WritersLock lock(mutex);
952 std::string Options::getLocalSyncAddr()
954 ReadersLock lock(mutex);
955 return local_sync_.addr;
958 Options& Options::setLocalSyncAddr(std::string l)
960 WritersLock lock(mutex);
961 local_sync_.addr = l;
965 std::string Options::getLocalSyncPort()
967 ReadersLock lock(mutex);
968 return local_sync_.port;
971 Options& Options::setLocalSyncPort(std::string l)
973 WritersLock lock(mutex);
974 local_sync_.port = l;
978 HostList Options::getRemoteSyncHosts()
980 ReadersLock lock(mutex);
981 return remote_sync_hosts_;
986 std::string Options::getDevName()
988 ReadersLock lock(mutex);
992 Options& Options::setDevName(std::string d)
994 WritersLock lock(mutex);
999 std::string Options::getDevType()
1001 ReadersLock lock(mutex);
1005 Options& Options::setDevType(std::string d)
1007 WritersLock lock(mutex);
1012 OptionNetwork Options::getIfconfigParam()
1014 ReadersLock lock(mutex);
1015 return ifconfig_param_;
1018 Options& Options::setIfconfigParam(OptionNetwork i)
1020 WritersLock lock(mutex);
1021 ifconfig_param_ = i;
1025 std::string Options::getPostUpScript()
1027 ReadersLock lock(mutex);
1028 return post_up_script_;
1031 Options& Options::setPostUpScript(std::string p)
1033 WritersLock lock(mutex);
1034 post_up_script_ = p;
1038 NetworkList Options::getRoutes()
1040 ReadersLock lock(mutex);
1046 sender_id_t Options::getSenderId()
1048 ReadersLock lock(mutex);
1052 Options& Options::setSenderId(sender_id_t s)
1054 WritersLock lock(mutex);
1059 mux_t Options::getMux()
1061 ReadersLock lock(mutex);
1065 Options& Options::setMux(mux_t m)
1067 WritersLock lock(mutex);
1072 window_size_t Options::getSeqWindowSize()
1074 ReadersLock lock(mutex);
1075 return seq_window_size_;
1078 Options& Options::setSeqWindowSize(window_size_t s)
1080 WritersLock lock(mutex);
1081 seq_window_size_ = s;
1087 std::string Options::getCipher()
1089 ReadersLock lock(mutex);
1093 Options& Options::setCipher(std::string c)
1095 WritersLock lock(mutex);
1100 std::string Options::getAuthAlgo()
1102 ReadersLock lock(mutex);
1106 Options& Options::setAuthAlgo(std::string a)
1108 WritersLock lock(mutex);
1113 uint32_t Options::getAuthTagLength()
1115 ReadersLock lock(mutex);
1116 return auth_tag_length_;
1119 Options& Options::setAuthTagLength(uint32_t a)
1121 WritersLock lock(mutex);
1122 auth_tag_length_ = a;
1127 std::string Options::getKdPrf()
1129 ReadersLock lock(mutex);
1133 Options& Options::setKdPrf(std::string k)
1135 WritersLock lock(mutex);
1140 role_t Options::getRole()
1142 ReadersLock lock(mutex);
1146 Options& Options::setRole(role_t r)
1148 WritersLock lock(mutex);
1153 std::string Options::getPassphrase()
1155 ReadersLock lock(mutex);
1159 Options& Options::setPassphrase(std::string p)
1161 WritersLock lock(mutex);
1166 Buffer Options::getKey()
1168 ReadersLock lock(mutex);
1172 Options& Options::setKey(std::string k)
1174 WritersLock lock(mutex);
1179 Buffer Options::getSalt()
1181 ReadersLock lock(mutex);
1185 Options& Options::setSalt(std::string s)
1187 WritersLock lock(mutex);