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-2008 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 version 3 as
21 * published by the Free Software Foundation.
23 * Anytun is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with anytun. If not, see <http://www.gnu.org/licenses/>.
38 #include "datatypes.h"
41 #include "authAlgoFactory.h"
43 std::ostream& operator<<(std::ostream& stream, syntax_error const& error)
45 stream << "syntax error: " << error.what() << std::endl;
48 for(int32_t i = 0; i < error.pos; ++i) stream << " ";
54 std::ostream& operator<<(std::ostream& stream, role_t const& role)
57 case ROLE_LEFT: stream << "left"; break;
58 case ROLE_RIGHT: stream << "right"; break;
59 default: stream << "unknown"; break;
64 void OptionHost::init(std::string addrPort)
66 std::string origAddrPort(addrPort);
67 size_t pos = addrPort.find_first_of("[");
69 if(pos != std::string::npos && pos != 0)
70 throw syntax_error(origAddrPort, pos); // an [ was found but not at the beginning;
73 if(pos != std::string::npos) {
74 addrPort.erase(pos, 1);
75 pos = addrPort.find_first_of("]");
77 if(pos == std::string::npos)
78 throw syntax_error(origAddrPort, origAddrPort.length()); //no trailing ] although an leading [ was found
80 if(pos < addrPort.length()-2) {
81 if(addrPort[pos+1] != ':')
82 throw syntax_error(origAddrPort, pos+2); // wrong port delimieter
84 addrPort[pos+1] = '/';
87 else if(pos != addrPort.length()-1)
88 throw syntax_error(origAddrPort, pos+2); // too few characters left
90 addrPort.erase(pos, 1);
93 pos = addrPort.find_first_of(":");
94 if(pos != std::string::npos && pos == addrPort.find_last_of(":")) {
95 // an ':' has been found and it is the only one -> assuming port present
102 std::stringstream tmp_stream(addrPort);
104 getline(tmp_stream, addr, '/');
105 if(!tmp_stream.good())
106 throw syntax_error(origAddrPort, addr.length());
112 port = "2323"; // default sync port
116 std::istream& operator>>(std::istream& stream, OptionHost& host)
124 void OptionNetwork::init(std::string network)
126 std::stringstream tmp_stream(network);
127 getline(tmp_stream, net_addr, '/');
128 if(!tmp_stream.good())
129 throw syntax_error(network, net_addr.length());
130 tmp_stream >> prefix_length;
133 std::istream& operator>>(std::istream& stream, OptionNetwork& network)
141 Options* Options::inst = NULL;
142 Mutex Options::instMutex;
143 Options& gOpt = Options::instance();
145 Options& Options::instance()
147 Lock lock(instMutex);
148 static instanceCleaner c;
150 inst = new Options();
155 Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
157 #if defined(ANYCTR_OPTIONS)
158 progname_ = "anytun-controld";
159 #elif defined(ANYCONF_OPTIONS)
160 progname_ = "anytun-config";
162 progname_ = "anytun";
165 cluster_opts = false;
166 connection_opts = false;
175 bind_to_.addr = "127.0.0.1";
176 bind_to_.port = "2323";
178 resolv_addr_type_ = ANY;
181 local_.port = "4444";
183 remote_.port = "4444";
184 local_sync_.addr = "";
185 local_sync_.port = "";
189 post_up_script_ = "";
193 seq_window_size_ = 0;
195 #if !defined(ANYCONF_OPTIONS)
199 auth_tag_length_ = 10;
204 auth_tag_length_ = 0;
210 auth_tag_length_ = 0;
222 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
223 else if(str == SHORT || str == LONG) { \
228 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
229 else if(str == SHORT || str == LONG) { \
234 #define PARSE_SIGNED_INT_PARAM(SHORT, LONG, VALUE, DO_POST) \
235 else if(str == SHORT || str == LONG) \
238 throw syntax_error(str, str.length()); \
239 std::stringstream tmp; \
247 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE, DO_POST) \
248 else if(str == SHORT || str == LONG) \
251 throw syntax_error(str, str.length()); \
252 if(argv[i+1][0] == '-') { \
253 u_int32_t pos = str.length() + 1; \
254 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
256 std::stringstream tmp; \
264 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2, DO_POST) \
265 else if(str == SHORT || str == LONG) \
268 throw syntax_error(str, str.length()); \
270 throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
271 if(argv[i+1][0] == '-') { \
272 u_int32_t pos = str.length() + 1; \
273 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
275 if(argv[i+2][0] == '-') { \
276 u_int32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
277 throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
279 std::stringstream tmp; \
280 tmp << argv[i+1] << " " << argv[i+2]; \
288 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST, TYPE, DO_POST) \
289 else if(str == SHORT || str == LONG) \
292 throw syntax_error(str, str.length()); \
293 if(argv[i+1][0] == '-') { \
294 u_int32_t pos = str.length() + 1; \
295 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
297 std::stringstream tmp(argv[i+1]); \
300 std::string tmp_line; \
301 getline(tmp,tmp_line,','); \
302 LIST.push_back(TYPE(tmp_line)); \
309 #define PARSE_HEXSTRING_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
310 else if(str == SHORT || str == LONG) \
313 throw syntax_error(str, str.length()); \
314 if(argv[i+1][0] == '-') { \
315 u_int32_t pos = str.length() + 1; \
316 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
318 VALUE = Buffer(std::string(argv[i+1])); \
319 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
320 argv[i+1][j] = '#'; \
326 #define PARSE_PHRASE_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
327 else if(str == SHORT || str == LONG) \
330 throw syntax_error(str, str.length()); \
331 if(argv[i+1][0] == '-') { \
332 u_int32_t pos = str.length() + 1; \
333 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
336 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
337 argv[i+1][j] = '#'; \
343 #define PARSE_STRING_LIST(SHORT, LONG, LIST, DO_POST) \
344 else if(str == SHORT || str == LONG) \
347 throw syntax_error(str, str.length()); \
348 if(argv[i+1][0] == '-') { \
349 u_int32_t pos = str.length() + 1; \
350 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
352 LIST.push_back(argv[i+1]); \
358 bool Options::parse(int argc, char* argv[])
360 WritersLock lock(mutex);
364 bool ipv4_only = false, ipv6_only = false;
365 std::string role = "";
366 for(int i=1; argc > 0; ++i)
368 std::string str(argv[i]);
371 if(str == "-h" || str == "--help")
374 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
377 PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
378 PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
379 PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
380 PARSE_SCALAR_PARAM("-C","--chroot", chroot_dir_, NOTHING)
381 PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_, NOTHING)
386 PARSE_STRING_LIST("-L","--log", log_targets_, NOTHING)
388 #if defined(ANYCTR_OPTIONS)
390 PARSE_SCALAR_PARAM("-f","--file", file_name_, NOTHING)
391 PARSE_SCALAR_PARAM("-X","--control-host", bind_to_, NOTHING)
394 #if defined(ANYTUN_OPTIONS)
396 PARSE_SCALAR_PARAM("-i","--interface", local_.addr, NOTHING)
397 PARSE_SCALAR_PARAM("-p","--port", local_.port, NOTHING)
398 PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_, NOTHING)
401 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
403 PARSE_SCALAR_PARAM("-r","--remote-host", remote_.addr, connection_opts = true)
404 PARSE_SCALAR_PARAM("-o","--remote-port", remote_.port, connection_opts = true)
405 PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only, connection_opts = true)
406 PARSE_BOOL_PARAM("-6","--ipv6-only", ipv6_only, connection_opts = true)
409 #if defined(ANYTUN_OPTIONS)
411 PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_.addr, cluster_opts = true)
412 PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_.port, cluster_opts = true)
413 PARSE_CSLIST_PARAM("-M","--sync-hosts", remote_sync_hosts_, OptionHost, cluster_opts = true)
414 PARSE_CSLIST_PARAM("-X","--control-host", remote_sync_hosts_, OptionHost, cluster_opts = true)
416 PARSE_SCALAR_PARAM("-d","--dev", dev_name_, NOTHING)
417 PARSE_SCALAR_PARAM("-t","--type", dev_type_, NOTHING)
418 PARSE_SCALAR_PARAM("-n","--ifconfig", ifconfig_param_, NOTHING)
420 PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_, NOTHING)
424 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
427 PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork, connection_opts = true)
430 PARSE_SCALAR_PARAM("-m","--mux", mux_, connection_opts = true)
431 PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_, connection_opts = true)
434 PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_, connection_opts = true)
435 PARSE_SCALAR_PARAM("-e","--role", role, connection_opts = true)
436 #ifndef NO_PASSPHRASE
437 PARSE_PHRASE_PARAM_SEC("-E","--passphrase", passphrase_, connection_opts = true)
439 PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_, connection_opts = true)
440 PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_, connection_opts = true)
444 #if defined(ANYTUN_OPTIONS)
447 PARSE_SCALAR_PARAM("-c","--cipher", cipher_, NOTHING)
448 PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_, NOTHING)
449 PARSE_SCALAR_PARAM("-b","--auth-tag-length", auth_tag_length_, NOTHING)
454 throw syntax_error(str, 0);
456 if(ipv4_only && ipv6_only)
457 throw syntax_error("-4 and -6 are mutual exclusive", -1);
459 resolv_addr_type_ = IPV4_ONLY;
461 resolv_addr_type_ = IPV6_ONLY;
464 if(role == "alice" || role == "server" || role == "left")
466 else if(role == "bob" || role == "client" || role == "right")
469 throw syntax_error("unknown role name: " + role, -1);
475 void Options::parse_post()
477 #if defined(ANYTUN_OPTIONS)
478 if(cluster_opts && connection_opts)
479 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";
481 if(cipher_ == "null" && auth_algo_ == "null")
483 if((cipher_ != "null" || auth_algo_ != "null") && kd_prf_ == "null")
484 cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
486 u_int32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
487 if(!tag_len_max) auth_tag_length_ = 0;
488 else if(tag_len_max < auth_tag_length_) {
489 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 << ")";
490 auth_tag_length_ = tag_len_max;
494 if(dev_name_ == "" && dev_type_ == "")
498 void Options::printUsage()
500 std::cout << "USAGE:" << std::endl;
502 #if defined(ANYCTR_OPTIONS)
503 std::cout << "anytun-controld " << std::endl;
504 #elif defined(ANYCONF_OPTIONS)
505 std::cout << "anytun-config " << std::endl;
507 std::cout << "anytun " << std::endl;
510 std::cout << " [-h|--help] prints this..." << std::endl;
512 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
515 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
516 std::cout << " [-u|--username] <username> change to this user" << std::endl;
517 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
518 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
519 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
524 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
525 std::cout << " add a log target, can be invoked several times" << std::endl;
527 #if defined(ANYCTR_OPTIONS)
529 std::cout << " [-f|--file] <path> path to input file" << std::endl;
530 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
531 std::cout << " local tcp port and or ip address to bind to" << std::endl;
534 #if defined(ANYTUN_OPTIONS)
536 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
537 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
538 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
541 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
543 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
544 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
545 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
546 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
549 #if defined(ANYTUN_OPTIONS)
551 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
552 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
553 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
554 std::cout << " remote hosts to sync with" << std::endl;
555 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
556 std::cout << " fetch the config from this host" << std::endl;
558 std::cout << " [-d|--dev] <name> device name" << std::endl;
559 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
560 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
562 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
566 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
569 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
572 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
573 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
576 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
577 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
578 #ifndef NO_PASSPHRASE
579 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
581 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
582 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
586 #if defined(ANYTUN_OPTIONS)
589 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
590 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
591 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
597 void Options::printOptions()
599 ReadersLock lock(mutex);
601 std::cout << "Options:" << std::endl;
602 std::cout << std::endl;
603 std::cout << "daemonize = " << daemonize_ << std::endl;
604 std::cout << "username = '" << username_ << "'" << std::endl;
605 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
606 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
607 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
608 std::cout << std::endl;
609 std::cout << "log_targets:";
610 StringList::const_iterator lit = log_targets_.begin();
611 for(; lit != log_targets_.end(); ++lit)
612 std::cout << " '" << *lit << "',";
613 std::cout << std::endl << std::endl;
614 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
615 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
616 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
617 std::cout << std::endl;
618 std::cout << "resolv_addr_type = ";
619 switch(resolv_addr_type_) {
620 case ANY: std::cout << "any" << std::endl; break;
621 case IPV4_ONLY: std::cout << "ipv4-only" << std::endl; break;
622 case IPV6_ONLY: std::cout << "ipv6-only" << std::endl; break;
623 default: std::cout << "?" << std::endl; break;
625 std::cout << std::endl;
626 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
627 std::cout << "local.port = '" << local_.port << "'" << std::endl;
628 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
629 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
630 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
631 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
632 std::cout << "remote_sync_hosts:" << std::endl;
633 HostList::const_iterator hit = remote_sync_hosts_.begin();
634 for(; hit != remote_sync_hosts_.end(); ++hit)
635 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
636 std::cout << std::endl;
637 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
638 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
639 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
640 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
641 std::cout << "routes:" << std::endl;
642 NetworkList::const_iterator rit;
643 for(rit = routes_.begin(); rit != routes_.end(); ++rit)
644 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
645 std::cout << std::endl;
646 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
647 std::cout << "mux_id = " << mux_ << std::endl;
648 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
649 std::cout << std::endl;
650 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
651 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
652 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
653 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
654 std::cout << "role = ";
656 case ROLE_LEFT: std::cout << "left" << std::endl; break;
657 case ROLE_RIGHT: std::cout << "right" << std::endl; break;
658 default: std::cout << "??" << std::endl; break;
660 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
661 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
662 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
667 std::string Options::getProgname()
669 ReadersLock lock(mutex);
673 Options& Options::setProgname(std::string p)
675 WritersLock lock(mutex);
680 bool Options::getDaemonize()
682 ReadersLock lock(mutex);
686 Options& Options::setDaemonize(bool d)
688 WritersLock lock(mutex);
693 std::string Options::getUsername()
695 ReadersLock lock(mutex);
699 Options& Options::setUsername(std::string u)
701 WritersLock lock(mutex);
706 std::string Options::getGroupname()
708 ReadersLock lock(mutex);
712 Options& Options::setGroupname(std::string g)
714 WritersLock lock(mutex);
719 std::string Options::getChrootDir()
721 ReadersLock lock(mutex);
725 Options& Options::setChrootDir(std::string c)
727 WritersLock lock(mutex);
732 std::string Options::getPidFile()
734 ReadersLock lock(mutex);
738 Options& Options::setPidFile(std::string p)
740 WritersLock lock(mutex);
747 StringList Options::getLogTargets()
749 ReadersLock lock(mutex);
755 std::string Options::getFileName()
757 ReadersLock lock(mutex);
761 Options& Options::setFileName(std::string f)
763 WritersLock lock(mutex);
768 std::string Options::getBindToAddr()
770 ReadersLock lock(mutex);
771 return bind_to_.addr;
774 Options& Options::setBindToAddr(std::string b)
776 WritersLock lock(mutex);
781 std::string Options::getBindToPort()
783 ReadersLock lock(mutex);
784 return bind_to_.port;
787 Options& Options::setBindToPort(std::string b)
789 WritersLock lock(mutex);
795 ResolvAddrType Options::getResolvAddrType()
797 ReadersLock lock(mutex);
798 return resolv_addr_type_;
801 Options& Options::setResolvAddrType(ResolvAddrType r)
803 WritersLock lock(mutex);
804 resolv_addr_type_ = r;
808 std::string Options::getLocalAddr()
810 ReadersLock lock(mutex);
814 Options& Options::setLocalAddr(std::string l)
816 WritersLock lock(mutex);
821 std::string Options::getLocalPort()
823 ReadersLock lock(mutex);
827 Options& Options::setLocalPort(std::string l)
829 WritersLock lock(mutex);
834 std::string Options::getRemoteAddr()
836 ReadersLock lock(mutex);
840 Options& Options::setRemoteAddr(std::string r)
842 WritersLock lock(mutex);
847 std::string Options::getRemotePort()
849 ReadersLock lock(mutex);
853 Options& Options::setRemotePort(std::string r)
855 WritersLock lock(mutex);
860 std::string Options::getLocalSyncAddr()
862 ReadersLock lock(mutex);
863 return local_sync_.addr;
866 Options& Options::setLocalSyncAddr(std::string l)
868 WritersLock lock(mutex);
869 local_sync_.addr = l;
873 std::string Options::getLocalSyncPort()
875 ReadersLock lock(mutex);
876 return local_sync_.port;
879 Options& Options::setLocalSyncPort(std::string l)
881 WritersLock lock(mutex);
882 local_sync_.port = l;
886 HostList Options::getRemoteSyncHosts()
888 ReadersLock lock(mutex);
889 return remote_sync_hosts_;
894 std::string Options::getDevName()
896 ReadersLock lock(mutex);
900 Options& Options::setDevName(std::string d)
902 WritersLock lock(mutex);
907 std::string Options::getDevType()
909 ReadersLock lock(mutex);
913 Options& Options::setDevType(std::string d)
915 WritersLock lock(mutex);
920 OptionNetwork Options::getIfconfigParam()
922 ReadersLock lock(mutex);
923 return ifconfig_param_;
926 Options& Options::setIfconfigParam(OptionNetwork i)
928 WritersLock lock(mutex);
933 std::string Options::getPostUpScript()
935 ReadersLock lock(mutex);
936 return post_up_script_;
939 Options& Options::setPostUpScript(std::string p)
941 WritersLock lock(mutex);
946 NetworkList Options::getRoutes()
948 ReadersLock lock(mutex);
954 sender_id_t Options::getSenderId()
956 ReadersLock lock(mutex);
960 Options& Options::setSenderId(sender_id_t s)
962 WritersLock lock(mutex);
967 mux_t Options::getMux()
969 ReadersLock lock(mutex);
973 Options& Options::setMux(mux_t m)
975 WritersLock lock(mutex);
980 window_size_t Options::getSeqWindowSize()
982 ReadersLock lock(mutex);
983 return seq_window_size_;
986 Options& Options::setSeqWindowSize(window_size_t s)
988 WritersLock lock(mutex);
989 seq_window_size_ = s;
995 std::string Options::getCipher()
997 ReadersLock lock(mutex);
1001 Options& Options::setCipher(std::string c)
1003 WritersLock lock(mutex);
1008 std::string Options::getAuthAlgo()
1010 ReadersLock lock(mutex);
1014 Options& Options::setAuthAlgo(std::string a)
1016 WritersLock lock(mutex);
1021 u_int32_t Options::getAuthTagLength()
1023 ReadersLock lock(mutex);
1024 return auth_tag_length_;
1027 Options& Options::setAuthTagLength(u_int32_t a)
1029 WritersLock lock(mutex);
1030 auth_tag_length_ = a;
1035 std::string Options::getKdPrf()
1037 ReadersLock lock(mutex);
1041 Options& Options::setKdPrf(std::string k)
1043 WritersLock lock(mutex);
1048 role_t Options::getRole()
1050 ReadersLock lock(mutex);
1054 Options& Options::setRole(role_t r)
1056 WritersLock lock(mutex);
1061 std::string Options::getPassphrase()
1063 ReadersLock lock(mutex);
1067 Options& Options::setPassphrase(std::string p)
1069 WritersLock lock(mutex);
1074 Buffer Options::getKey()
1076 ReadersLock lock(mutex);
1080 Options& Options::setKey(std::string k)
1082 WritersLock lock(mutex);
1087 Buffer Options::getSalt()
1089 ReadersLock lock(mutex);
1093 Options& Options::setSalt(std::string s)
1095 WritersLock lock(mutex);