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)
60 case ROLE_LEFT: stream << "left"; break;
61 case ROLE_RIGHT: stream << "right"; break;
62 default: stream << "unknown"; break;
67 void OptionHost::init(std::string addrPort)
69 std::string origAddrPort(addrPort);
70 size_t pos = addrPort.find_first_of("[");
72 if(pos != std::string::npos && pos != 0)
73 throw syntax_error(origAddrPort, pos); // an [ was found but not at the beginning;
76 if(pos != std::string::npos) {
77 addrPort.erase(pos, 1);
78 pos = addrPort.find_first_of("]");
80 if(pos == std::string::npos)
81 throw syntax_error(origAddrPort, origAddrPort.length()); //no trailing ] although an leading [ was found
83 if(pos < addrPort.length()-2) {
84 if(addrPort[pos+1] != ':')
85 throw syntax_error(origAddrPort, pos+2); // wrong port delimieter
87 addrPort[pos+1] = '/';
90 else if(pos != addrPort.length()-1)
91 throw syntax_error(origAddrPort, pos+2); // too few characters left
93 addrPort.erase(pos, 1);
96 pos = addrPort.find_first_of(":");
97 if(pos != std::string::npos && pos == addrPort.find_last_of(":")) {
98 // an ':' has been found and it is the only one -> assuming port present
105 std::stringstream tmp_stream(addrPort);
107 getline(tmp_stream, addr, '/');
108 if(!tmp_stream.good())
109 throw syntax_error(origAddrPort, addr.length());
115 port = "2323"; // default sync port
119 std::istream& operator>>(std::istream& stream, OptionHost& host)
127 void OptionNetwork::init(std::string network)
129 std::stringstream tmp_stream(network);
130 getline(tmp_stream, net_addr, '/');
131 if(!tmp_stream.good())
132 throw syntax_error(network, net_addr.length());
133 tmp_stream >> prefix_length;
136 std::istream& operator>>(std::istream& stream, OptionNetwork& network)
144 Options* Options::inst = NULL;
145 Mutex Options::instMutex;
146 Options& gOpt = Options::instance();
148 Options& Options::instance()
150 Lock lock(instMutex);
151 static instanceCleaner c;
153 inst = new Options();
158 Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
160 #if defined(ANYCTR_OPTIONS)
161 progname_ = "anytun-controld";
162 #elif defined(ANYCONF_OPTIONS)
163 progname_ = "anytun-config";
165 progname_ = "anytun";
168 cluster_opts = false;
169 connection_opts = false;
180 bind_to_.addr = "127.0.0.1";
181 bind_to_.port = "2323";
183 resolv_addr_type_ = ANY;
186 local_.port = "4444";
188 remote_.port = "4444";
189 local_sync_.addr = "";
190 local_sync_.port = "";
194 post_up_script_ = "";
198 seq_window_size_ = 0;
200 #if !defined(ANYCONF_OPTIONS)
204 auth_tag_length_ = 10;
209 auth_tag_length_ = 0;
215 auth_tag_length_ = 0;
227 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
228 else if(str == SHORT || str == LONG) { \
233 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
234 else if(str == SHORT || str == LONG) { \
239 #define PARSE_SIGNED_INT_PARAM(SHORT, LONG, VALUE, DO_POST) \
240 else if(str == SHORT || str == LONG) \
243 throw syntax_error(str, str.length()); \
244 std::stringstream tmp; \
252 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE, DO_POST) \
253 else if(str == SHORT || str == LONG) \
256 throw syntax_error(str, str.length()); \
257 if(argv[i+1][0] == '-') { \
258 u_int32_t pos = str.length() + 1; \
259 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
261 std::stringstream tmp; \
269 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2, DO_POST) \
270 else if(str == SHORT || str == LONG) \
273 throw syntax_error(str, str.length()); \
275 throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
276 if(argv[i+1][0] == '-') { \
277 u_int32_t pos = str.length() + 1; \
278 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
280 if(argv[i+2][0] == '-') { \
281 u_int32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
282 throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
284 std::stringstream tmp; \
285 tmp << argv[i+1] << " " << argv[i+2]; \
293 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST, TYPE, DO_POST) \
294 else if(str == SHORT || str == LONG) \
297 throw syntax_error(str, str.length()); \
298 if(argv[i+1][0] == '-') { \
299 u_int32_t pos = str.length() + 1; \
300 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
302 std::stringstream tmp(argv[i+1]); \
305 std::string tmp_line; \
306 getline(tmp,tmp_line,','); \
307 LIST.push_back(TYPE(tmp_line)); \
314 #define PARSE_HEXSTRING_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
315 else if(str == SHORT || str == LONG) \
318 throw syntax_error(str, str.length()); \
319 if(argv[i+1][0] == '-') { \
320 u_int32_t pos = str.length() + 1; \
321 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
323 VALUE = Buffer(std::string(argv[i+1])); \
324 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
325 argv[i+1][j] = '#'; \
331 #define PARSE_PHRASE_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
332 else if(str == SHORT || str == LONG) \
335 throw syntax_error(str, str.length()); \
336 if(argv[i+1][0] == '-') { \
337 u_int32_t pos = str.length() + 1; \
338 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
341 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
342 argv[i+1][j] = '#'; \
348 #define PARSE_STRING_LIST(SHORT, LONG, LIST, DO_POST) \
349 else if(str == SHORT || str == LONG) \
352 throw syntax_error(str, str.length()); \
353 if(argv[i+1][0] == '-') { \
354 u_int32_t pos = str.length() + 1; \
355 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
357 LIST.push_back(argv[i+1]); \
363 bool Options::parse(int argc, char* argv[])
365 WritersLock lock(mutex);
369 bool ipv4_only = false, ipv6_only = false;
370 std::string role = "";
371 for(int i=1; argc > 0; ++i)
373 std::string str(argv[i]);
376 if(str == "-h" || str == "--help") {
380 else if(str == "-v" || str == "--version") {
385 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
388 PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
389 PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
390 PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
391 PARSE_SCALAR_PARAM("-C","--chroot", chroot_dir_, NOTHING)
392 PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_, NOTHING)
397 PARSE_STRING_LIST("-L","--log", log_targets_, NOTHING)
398 PARSE_BOOL_PARAM("-U","--debug", debug_, NOTHING)
400 #if defined(ANYCTR_OPTIONS)
402 PARSE_SCALAR_PARAM("-f","--file", file_name_, NOTHING)
403 PARSE_SCALAR_PARAM("-X","--control-host", bind_to_, NOTHING)
406 #if defined(ANYTUN_OPTIONS)
408 PARSE_SCALAR_PARAM("-i","--interface", local_.addr, NOTHING)
409 PARSE_SCALAR_PARAM("-p","--port", local_.port, NOTHING)
410 PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_, NOTHING)
413 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
415 PARSE_SCALAR_PARAM("-r","--remote-host", remote_.addr, connection_opts = true)
416 PARSE_SCALAR_PARAM("-o","--remote-port", remote_.port, connection_opts = true)
417 PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only, connection_opts = true)
418 PARSE_BOOL_PARAM("-6","--ipv6-only", ipv6_only, connection_opts = true)
421 #if defined(ANYTUN_OPTIONS)
423 PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_.addr, cluster_opts = true)
424 PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_.port, cluster_opts = true)
425 PARSE_CSLIST_PARAM("-M","--sync-hosts", remote_sync_hosts_, OptionHost, cluster_opts = true)
426 PARSE_CSLIST_PARAM("-X","--control-host", remote_sync_hosts_, OptionHost, cluster_opts = true)
428 PARSE_SCALAR_PARAM("-d","--dev", dev_name_, NOTHING)
429 PARSE_SCALAR_PARAM("-t","--type", dev_type_, NOTHING)
430 PARSE_SCALAR_PARAM("-n","--ifconfig", ifconfig_param_, NOTHING)
431 PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_, NOTHING)
434 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
437 PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork, connection_opts = true)
440 PARSE_SCALAR_PARAM("-m","--mux", mux_, connection_opts = true)
441 PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_, connection_opts = true)
444 PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_, connection_opts = true)
445 PARSE_SCALAR_PARAM("-e","--role", role, connection_opts = true)
446 #ifndef NO_PASSPHRASE
447 PARSE_PHRASE_PARAM_SEC("-E","--passphrase", passphrase_, connection_opts = true)
449 PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_, connection_opts = true)
450 PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_, connection_opts = true)
454 #if defined(ANYTUN_OPTIONS)
457 PARSE_SCALAR_PARAM("-c","--cipher", cipher_, NOTHING)
458 PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_, NOTHING)
459 PARSE_SCALAR_PARAM("-b","--auth-tag-length", auth_tag_length_, NOTHING)
464 throw syntax_error(str, 0);
466 if(ipv4_only && ipv6_only)
467 throw syntax_error("-4 and -6 are mutual exclusive", -1);
469 resolv_addr_type_ = IPV4_ONLY;
471 resolv_addr_type_ = IPV6_ONLY;
474 if(role == "alice" || role == "server" || role == "left")
476 else if(role == "bob" || role == "client" || role == "right")
479 throw syntax_error("unknown role name: " + role, -1);
483 log_targets_.push_back("stdout:5");
487 if(log_targets_.empty()) {
489 #if !defined(ANYCONF_OPTIONS)
490 log_targets_.push_back(std::string("syslog:3,").append(progname_).append(",daemon"));
492 log_targets_.push_back("stderr:2");
496 log_targets_.push_back(std::string("eventlog:3,").append(progname_));
498 log_targets_.push_back("stdout:3");
506 void Options::parse_post()
508 #if defined(ANYTUN_OPTIONS)
509 if(cluster_opts && connection_opts)
510 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";
512 if(cipher_ == "null" && auth_algo_ == "null")
514 if((cipher_ != "null" || auth_algo_ != "null") && kd_prf_ == "null")
515 cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
517 u_int32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
518 if(!tag_len_max) auth_tag_length_ = 0;
519 else if(tag_len_max < auth_tag_length_) {
520 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 << ")";
521 auth_tag_length_ = tag_len_max;
525 if(dev_name_ == "" && dev_type_ == "")
529 void Options::printVersion()
531 #if defined(ANYCTR_OPTIONS)
532 std::cout << "anytun-controld";
533 #elif defined(ANYCONF_OPTIONS)
534 std::cout << "anytun-config";
536 std::cout << "anytun";
538 std::cout << VERSION_STRING_0 << std::endl;
539 std::cout << VERSION_STRING_1 << std::endl;
542 void Options::printUsage()
544 std::cout << "USAGE:" << std::endl;
546 #if defined(ANYCTR_OPTIONS)
547 std::cout << "anytun-controld " << std::endl;
548 #elif defined(ANYCONF_OPTIONS)
549 std::cout << "anytun-config " << std::endl;
551 std::cout << "anytun " << std::endl;
554 std::cout << " [-h|--help] prints this..." << std::endl;
555 std::cout << " [-v|--version] print version info and exit" << std::endl;
557 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
560 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
561 std::cout << " [-u|--username] <username> change to this user" << std::endl;
562 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
563 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
564 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
569 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
570 std::cout << " add a log target, can be invoked several times" << std::endl;
571 std::cout << " i.e.: stdout:5" << std::endl;
572 std::cout << " [-U|--debug] don't daemonize and log to stdout with maximum log level" << std::endl;
574 #if defined(ANYCTR_OPTIONS)
576 std::cout << " [-f|--file] <path> path to input file" << std::endl;
577 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
578 std::cout << " local tcp port and or ip address to bind to" << std::endl;
581 #if defined(ANYTUN_OPTIONS)
583 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
584 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
585 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
588 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
590 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
591 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
592 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
593 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
596 #if defined(ANYTUN_OPTIONS)
598 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
599 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
600 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
601 std::cout << " remote hosts to sync with" << std::endl;
602 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
603 std::cout << " fetch the config from this host" << std::endl;
605 std::cout << " [-d|--dev] <name> device name" << std::endl;
606 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
607 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
608 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
611 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
614 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
617 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
618 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
621 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
622 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
623 #ifndef NO_PASSPHRASE
624 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
626 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
627 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
631 #if defined(ANYTUN_OPTIONS)
634 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
635 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
636 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
642 void Options::printOptions()
644 ReadersLock lock(mutex);
646 std::cout << "Options:" << std::endl;
647 std::cout << std::endl;
648 std::cout << "daemonize = " << daemonize_ << std::endl;
649 std::cout << "username = '" << username_ << "'" << std::endl;
650 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
651 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
652 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
653 std::cout << std::endl;
654 std::cout << "log_targets:";
655 StringList::const_iterator lit = log_targets_.begin();
656 for(; lit != log_targets_.end(); ++lit)
657 std::cout << " '" << *lit << "',";
658 std::cout << std::endl;
659 std::cout << "debug = " << debug_ << std::endl;
660 std::cout << std::endl;
661 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
662 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
663 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
664 std::cout << std::endl;
665 std::cout << "resolv_addr_type = ";
666 switch(resolv_addr_type_) {
667 case ANY: std::cout << "any" << std::endl; break;
668 case IPV4_ONLY: std::cout << "ipv4-only" << std::endl; break;
669 case IPV6_ONLY: std::cout << "ipv6-only" << std::endl; break;
670 default: std::cout << "?" << std::endl; break;
672 std::cout << std::endl;
673 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
674 std::cout << "local.port = '" << local_.port << "'" << std::endl;
675 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
676 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
677 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
678 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
679 std::cout << "remote_sync_hosts:" << std::endl;
680 HostList::const_iterator hit = remote_sync_hosts_.begin();
681 for(; hit != remote_sync_hosts_.end(); ++hit)
682 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
683 std::cout << std::endl;
684 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
685 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
686 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
687 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
688 std::cout << "routes:" << std::endl;
689 NetworkList::const_iterator rit;
690 for(rit = routes_.begin(); rit != routes_.end(); ++rit)
691 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
692 std::cout << std::endl;
693 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
694 std::cout << "mux_id = " << mux_ << std::endl;
695 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
696 std::cout << std::endl;
697 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
698 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
699 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
700 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
701 std::cout << "role = ";
703 case ROLE_LEFT: std::cout << "left" << std::endl; break;
704 case ROLE_RIGHT: std::cout << "right" << std::endl; break;
705 default: std::cout << "??" << std::endl; break;
707 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
708 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
709 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
714 std::string Options::getProgname()
716 ReadersLock lock(mutex);
720 Options& Options::setProgname(std::string p)
722 WritersLock lock(mutex);
727 bool Options::getDaemonize()
729 ReadersLock lock(mutex);
733 Options& Options::setDaemonize(bool d)
735 WritersLock lock(mutex);
740 std::string Options::getUsername()
742 ReadersLock lock(mutex);
746 Options& Options::setUsername(std::string u)
748 WritersLock lock(mutex);
753 std::string Options::getGroupname()
755 ReadersLock lock(mutex);
759 Options& Options::setGroupname(std::string g)
761 WritersLock lock(mutex);
766 std::string Options::getChrootDir()
768 ReadersLock lock(mutex);
772 Options& Options::setChrootDir(std::string c)
774 WritersLock lock(mutex);
779 std::string Options::getPidFile()
781 ReadersLock lock(mutex);
785 Options& Options::setPidFile(std::string p)
787 WritersLock lock(mutex);
793 StringList Options::getLogTargets()
795 ReadersLock lock(mutex);
799 bool Options::getDebug()
801 ReadersLock lock(mutex);
805 Options& Options::setDebug(bool d)
807 WritersLock lock(mutex);
813 std::string Options::getFileName()
815 ReadersLock lock(mutex);
819 Options& Options::setFileName(std::string f)
821 WritersLock lock(mutex);
826 std::string Options::getBindToAddr()
828 ReadersLock lock(mutex);
829 return bind_to_.addr;
832 Options& Options::setBindToAddr(std::string b)
834 WritersLock lock(mutex);
839 std::string Options::getBindToPort()
841 ReadersLock lock(mutex);
842 return bind_to_.port;
845 Options& Options::setBindToPort(std::string b)
847 WritersLock lock(mutex);
853 ResolvAddrType Options::getResolvAddrType()
855 ReadersLock lock(mutex);
856 return resolv_addr_type_;
859 Options& Options::setResolvAddrType(ResolvAddrType r)
861 WritersLock lock(mutex);
862 resolv_addr_type_ = r;
866 std::string Options::getLocalAddr()
868 ReadersLock lock(mutex);
872 Options& Options::setLocalAddr(std::string l)
874 WritersLock lock(mutex);
879 std::string Options::getLocalPort()
881 ReadersLock lock(mutex);
885 Options& Options::setLocalPort(std::string l)
887 WritersLock lock(mutex);
892 std::string Options::getRemoteAddr()
894 ReadersLock lock(mutex);
898 Options& Options::setRemoteAddr(std::string r)
900 WritersLock lock(mutex);
905 std::string Options::getRemotePort()
907 ReadersLock lock(mutex);
911 Options& Options::setRemotePort(std::string r)
913 WritersLock lock(mutex);
918 std::string Options::getLocalSyncAddr()
920 ReadersLock lock(mutex);
921 return local_sync_.addr;
924 Options& Options::setLocalSyncAddr(std::string l)
926 WritersLock lock(mutex);
927 local_sync_.addr = l;
931 std::string Options::getLocalSyncPort()
933 ReadersLock lock(mutex);
934 return local_sync_.port;
937 Options& Options::setLocalSyncPort(std::string l)
939 WritersLock lock(mutex);
940 local_sync_.port = l;
944 HostList Options::getRemoteSyncHosts()
946 ReadersLock lock(mutex);
947 return remote_sync_hosts_;
952 std::string Options::getDevName()
954 ReadersLock lock(mutex);
958 Options& Options::setDevName(std::string d)
960 WritersLock lock(mutex);
965 std::string Options::getDevType()
967 ReadersLock lock(mutex);
971 Options& Options::setDevType(std::string d)
973 WritersLock lock(mutex);
978 OptionNetwork Options::getIfconfigParam()
980 ReadersLock lock(mutex);
981 return ifconfig_param_;
984 Options& Options::setIfconfigParam(OptionNetwork i)
986 WritersLock lock(mutex);
991 std::string Options::getPostUpScript()
993 ReadersLock lock(mutex);
994 return post_up_script_;
997 Options& Options::setPostUpScript(std::string p)
999 WritersLock lock(mutex);
1000 post_up_script_ = p;
1004 NetworkList Options::getRoutes()
1006 ReadersLock lock(mutex);
1012 sender_id_t Options::getSenderId()
1014 ReadersLock lock(mutex);
1018 Options& Options::setSenderId(sender_id_t s)
1020 WritersLock lock(mutex);
1025 mux_t Options::getMux()
1027 ReadersLock lock(mutex);
1031 Options& Options::setMux(mux_t m)
1033 WritersLock lock(mutex);
1038 window_size_t Options::getSeqWindowSize()
1040 ReadersLock lock(mutex);
1041 return seq_window_size_;
1044 Options& Options::setSeqWindowSize(window_size_t s)
1046 WritersLock lock(mutex);
1047 seq_window_size_ = s;
1053 std::string Options::getCipher()
1055 ReadersLock lock(mutex);
1059 Options& Options::setCipher(std::string c)
1061 WritersLock lock(mutex);
1066 std::string Options::getAuthAlgo()
1068 ReadersLock lock(mutex);
1072 Options& Options::setAuthAlgo(std::string a)
1074 WritersLock lock(mutex);
1079 u_int32_t Options::getAuthTagLength()
1081 ReadersLock lock(mutex);
1082 return auth_tag_length_;
1085 Options& Options::setAuthTagLength(u_int32_t a)
1087 WritersLock lock(mutex);
1088 auth_tag_length_ = a;
1093 std::string Options::getKdPrf()
1095 ReadersLock lock(mutex);
1099 Options& Options::setKdPrf(std::string k)
1101 WritersLock lock(mutex);
1106 role_t Options::getRole()
1108 ReadersLock lock(mutex);
1112 Options& Options::setRole(role_t r)
1114 WritersLock lock(mutex);
1119 std::string Options::getPassphrase()
1121 ReadersLock lock(mutex);
1125 Options& Options::setPassphrase(std::string p)
1127 WritersLock lock(mutex);
1132 Buffer Options::getKey()
1134 ReadersLock lock(mutex);
1138 Options& Options::setKey(std::string k)
1140 WritersLock lock(mutex);
1145 Buffer Options::getSalt()
1147 ReadersLock lock(mutex);
1151 Options& Options::setSalt(std::string s)
1153 WritersLock lock(mutex);