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"
42 #include "authAlgoFactory.h"
44 std::ostream& operator<<(std::ostream& stream, syntax_error const& error)
46 stream << "syntax error: " << error.what() << std::endl;
49 for(int32_t i = 0; i < error.pos; ++i) stream << " ";
55 std::ostream& operator<<(std::ostream& stream, role_t const& role)
58 case ROLE_LEFT: stream << "left"; break;
59 case ROLE_RIGHT: stream << "right"; break;
60 default: stream << "unknown"; break;
65 void OptionHost::init(std::string addrPort)
67 std::string origAddrPort(addrPort);
68 size_t pos = addrPort.find_first_of("[");
70 if(pos != std::string::npos && pos != 0)
71 throw syntax_error(origAddrPort, pos); // an [ was found but not at the beginning;
74 if(pos != std::string::npos) {
75 addrPort.erase(pos, 1);
76 pos = addrPort.find_first_of("]");
78 if(pos == std::string::npos)
79 throw syntax_error(origAddrPort, origAddrPort.length()); //no trailing ] although an leading [ was found
81 if(pos < addrPort.length()-2) {
82 if(addrPort[pos+1] != ':')
83 throw syntax_error(origAddrPort, pos+2); // wrong port delimieter
85 addrPort[pos+1] = '/';
88 else if(pos != addrPort.length()-1)
89 throw syntax_error(origAddrPort, pos+2); // too few characters left
91 addrPort.erase(pos, 1);
94 pos = addrPort.find_first_of(":");
95 if(pos != std::string::npos && pos == addrPort.find_last_of(":")) {
96 // an ':' has been found and it is the only one -> assuming port present
103 std::stringstream tmp_stream(addrPort);
105 getline(tmp_stream, addr, '/');
106 if(!tmp_stream.good())
107 throw syntax_error(origAddrPort, addr.length());
113 port = "2323"; // default sync port
117 std::istream& operator>>(std::istream& stream, OptionHost& host)
125 void OptionNetwork::init(std::string network)
127 std::stringstream tmp_stream(network);
128 getline(tmp_stream, net_addr, '/');
129 if(!tmp_stream.good())
130 throw syntax_error(network, net_addr.length());
131 tmp_stream >> prefix_length;
134 std::istream& operator>>(std::istream& stream, OptionNetwork& network)
142 Options* Options::inst = NULL;
143 Mutex Options::instMutex;
144 Options& gOpt = Options::instance();
146 Options& Options::instance()
148 Lock lock(instMutex);
149 static instanceCleaner c;
151 inst = new Options();
156 Options::Options() : key_(u_int32_t(0)), salt_(u_int32_t(0))
158 #if defined(ANYCTR_OPTIONS)
159 progname_ = "anytun-controld";
160 #elif defined(ANYCONF_OPTIONS)
161 progname_ = "anytun-config";
163 progname_ = "anytun";
166 cluster_opts = false;
167 connection_opts = false;
176 bind_to_.addr = "127.0.0.1";
177 bind_to_.port = "2323";
179 resolv_addr_type_ = ANY;
182 local_.port = "4444";
184 remote_.port = "4444";
185 local_sync_.addr = "";
186 local_sync_.port = "";
190 post_up_script_ = "";
194 seq_window_size_ = 0;
196 #if !defined(ANYCONF_OPTIONS)
200 auth_tag_length_ = 10;
205 auth_tag_length_ = 0;
211 auth_tag_length_ = 0;
223 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
224 else if(str == SHORT || str == LONG) { \
229 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE, DO_POST) \
230 else if(str == SHORT || str == LONG) { \
235 #define PARSE_SIGNED_INT_PARAM(SHORT, LONG, VALUE, DO_POST) \
236 else if(str == SHORT || str == LONG) \
239 throw syntax_error(str, str.length()); \
240 std::stringstream tmp; \
248 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE, DO_POST) \
249 else if(str == SHORT || str == LONG) \
252 throw syntax_error(str, str.length()); \
253 if(argv[i+1][0] == '-') { \
254 u_int32_t pos = str.length() + 1; \
255 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
257 std::stringstream tmp; \
265 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2, DO_POST) \
266 else if(str == SHORT || str == LONG) \
269 throw syntax_error(str, str.length()); \
271 throw syntax_error(str.append(" ").append(argv[i+1]), str.length()); \
272 if(argv[i+1][0] == '-') { \
273 u_int32_t pos = str.length() + 1; \
274 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
276 if(argv[i+2][0] == '-') { \
277 u_int32_t pos = str.length() + 1 + strlen(argv[i+1]) + 1; \
278 throw syntax_error(str.append(" ").append(argv[i+1]).append(" ").append(argv[i+2]), pos); \
280 std::stringstream tmp; \
281 tmp << argv[i+1] << " " << argv[i+2]; \
289 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST, TYPE, DO_POST) \
290 else if(str == SHORT || str == LONG) \
293 throw syntax_error(str, str.length()); \
294 if(argv[i+1][0] == '-') { \
295 u_int32_t pos = str.length() + 1; \
296 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
298 std::stringstream tmp(argv[i+1]); \
301 std::string tmp_line; \
302 getline(tmp,tmp_line,','); \
303 LIST.push_back(TYPE(tmp_line)); \
310 #define PARSE_HEXSTRING_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
311 else if(str == SHORT || str == LONG) \
314 throw syntax_error(str, str.length()); \
315 if(argv[i+1][0] == '-') { \
316 u_int32_t pos = str.length() + 1; \
317 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
319 VALUE = Buffer(std::string(argv[i+1])); \
320 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
321 argv[i+1][j] = '#'; \
327 #define PARSE_PHRASE_PARAM_SEC(SHORT, LONG, VALUE, DO_POST) \
328 else if(str == SHORT || str == LONG) \
331 throw syntax_error(str, str.length()); \
332 if(argv[i+1][0] == '-') { \
333 u_int32_t pos = str.length() + 1; \
334 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
337 for(size_t j=0; j < strlen(argv[i+1]); ++j) \
338 argv[i+1][j] = '#'; \
344 #define PARSE_STRING_LIST(SHORT, LONG, LIST, DO_POST) \
345 else if(str == SHORT || str == LONG) \
348 throw syntax_error(str, str.length()); \
349 if(argv[i+1][0] == '-') { \
350 u_int32_t pos = str.length() + 1; \
351 throw syntax_error(str.append(" ").append(argv[i+1]), pos); \
353 LIST.push_back(argv[i+1]); \
359 bool Options::parse(int argc, char* argv[])
361 WritersLock lock(mutex);
365 bool ipv4_only = false, ipv6_only = false;
366 std::string role = "";
367 for(int i=1; argc > 0; ++i)
369 std::string str(argv[i]);
372 if(str == "-h" || str == "--help")
375 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
378 PARSE_INVERSE_BOOL_PARAM("-D","--nodaemonize", daemonize_, NOTHING)
379 PARSE_SCALAR_PARAM("-u","--username", username_, NOTHING)
380 PARSE_SCALAR_PARAM("-g","--groupname", groupname_, NOTHING)
381 PARSE_SCALAR_PARAM("-C","--chroot", chroot_dir_, NOTHING)
382 PARSE_SCALAR_PARAM("-P","--write-pid", pid_file_, NOTHING)
387 PARSE_STRING_LIST("-L","--log", log_targets_, NOTHING)
389 #if defined(ANYCTR_OPTIONS)
391 PARSE_SCALAR_PARAM("-f","--file", file_name_, NOTHING)
392 PARSE_SCALAR_PARAM("-X","--control-host", bind_to_, NOTHING)
395 #if defined(ANYTUN_OPTIONS)
397 PARSE_SCALAR_PARAM("-i","--interface", local_.addr, NOTHING)
398 PARSE_SCALAR_PARAM("-p","--port", local_.port, NOTHING)
399 PARSE_SCALAR_PARAM("-s","--sender-id", sender_id_, NOTHING)
402 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
404 PARSE_SCALAR_PARAM("-r","--remote-host", remote_.addr, connection_opts = true)
405 PARSE_SCALAR_PARAM("-o","--remote-port", remote_.port, connection_opts = true)
406 PARSE_BOOL_PARAM("-4","--ipv4-only", ipv4_only, connection_opts = true)
407 PARSE_BOOL_PARAM("-6","--ipv6-only", ipv6_only, connection_opts = true)
410 #if defined(ANYTUN_OPTIONS)
412 PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_.addr, cluster_opts = true)
413 PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_.port, cluster_opts = true)
414 PARSE_CSLIST_PARAM("-M","--sync-hosts", remote_sync_hosts_, OptionHost, cluster_opts = true)
415 PARSE_CSLIST_PARAM("-X","--control-host", remote_sync_hosts_, OptionHost, cluster_opts = true)
417 PARSE_SCALAR_PARAM("-d","--dev", dev_name_, NOTHING)
418 PARSE_SCALAR_PARAM("-t","--type", dev_type_, NOTHING)
419 PARSE_SCALAR_PARAM("-n","--ifconfig", ifconfig_param_, NOTHING)
421 PARSE_SCALAR_PARAM("-x","--post-up-script", post_up_script_, NOTHING)
425 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
428 PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork, connection_opts = true)
431 PARSE_SCALAR_PARAM("-m","--mux", mux_, connection_opts = true)
432 PARSE_SCALAR_PARAM("-w","--window-size", seq_window_size_, connection_opts = true)
435 PARSE_SCALAR_PARAM("-k","--kd-prf", kd_prf_, connection_opts = true)
436 PARSE_SCALAR_PARAM("-e","--role", role, connection_opts = true)
437 #ifndef NO_PASSPHRASE
438 PARSE_PHRASE_PARAM_SEC("-E","--passphrase", passphrase_, connection_opts = true)
440 PARSE_HEXSTRING_PARAM_SEC("-K","--key", key_, connection_opts = true)
441 PARSE_HEXSTRING_PARAM_SEC("-A","--salt", salt_, connection_opts = true)
445 #if defined(ANYTUN_OPTIONS)
448 PARSE_SCALAR_PARAM("-c","--cipher", cipher_, NOTHING)
449 PARSE_SCALAR_PARAM("-a","--auth-algo", auth_algo_, NOTHING)
450 PARSE_SCALAR_PARAM("-b","--auth-tag-length", auth_tag_length_, NOTHING)
455 throw syntax_error(str, 0);
457 if(ipv4_only && ipv6_only)
458 throw syntax_error("-4 and -6 are mutual exclusive", -1);
460 resolv_addr_type_ = IPV4_ONLY;
462 resolv_addr_type_ = IPV6_ONLY;
465 if(role == "alice" || role == "server" || role == "left")
467 else if(role == "bob" || role == "client" || role == "right")
470 throw syntax_error("unknown role name: " + role, -1);
476 void Options::parse_post()
478 #if defined(ANYTUN_OPTIONS)
479 if(cluster_opts && connection_opts)
480 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";
482 if(cipher_ == "null" && auth_algo_ == "null")
484 if((cipher_ != "null" || auth_algo_ != "null") && kd_prf_ == "null")
485 cLog.msg(Log::PRIO_WARNING) << "using NULL key derivation with encryption and or authentication enabled!";
487 u_int32_t tag_len_max = AuthAlgoFactory::getDigestLength(auth_algo_);
488 if(!tag_len_max) auth_tag_length_ = 0;
489 else if(tag_len_max < auth_tag_length_) {
490 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 << ")";
491 auth_tag_length_ = tag_len_max;
495 if(dev_name_ == "" && dev_type_ == "")
499 void Options::printUsage()
501 std::cout << "USAGE:" << std::endl;
503 #if defined(ANYCTR_OPTIONS)
504 std::cout << "anytun-controld " << std::endl;
505 #elif defined(ANYCONF_OPTIONS)
506 std::cout << "anytun-config " << std::endl;
508 std::cout << "anytun " << std::endl;
511 std::cout << " [-h|--help] prints this..." << std::endl;
513 #if defined(ANYTUN_OPTIONS) || defined(ANYCTR_OPTIONS)
516 std::cout << " [-D|--nodaemonize] don't run in background" << std::endl;
517 std::cout << " [-u|--username] <username> change to this user" << std::endl;
518 std::cout << " [-g|--groupname] <groupname> change to this group" << std::endl;
519 std::cout << " [-C|--chroot] <path> chroot to this directory" << std::endl;
520 std::cout << " [-P|--write-pid] <path> write pid to this file" << std::endl;
525 std::cout << " [-L|--log] <target>:<level>[,<param1>[,<param2>..]]" << std::endl;
526 std::cout << " add a log target, can be invoked several times" << std::endl;
528 #if defined(ANYCTR_OPTIONS)
530 std::cout << " [-f|--file] <path> path to input file" << std::endl;
531 std::cout << " [-X|--control-host] < <hostname|ip>[:<port>] | :<port> >" << std::endl;
532 std::cout << " local tcp port and or ip address to bind to" << std::endl;
535 #if defined(ANYTUN_OPTIONS)
537 std::cout << " [-i|--interface] <hostname|ip> local anycast ip address to bind to" << std::endl;
538 std::cout << " [-p|--port] <port> local anycast(data) port to bind to" << std::endl;
539 std::cout << " [-s|--sender-id ] <sender id> the sender id to use" << std::endl;
542 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
544 std::cout << " [-r|--remote-host] <hostname|ip> remote host" << std::endl;
545 std::cout << " [-o|--remote-port] <port> remote port" << std::endl;
546 std::cout << " [-4|--ipv4-only] always resolv IPv4 addresses" << std::endl;
547 std::cout << " [-6|--ipv6-only] always resolv IPv6 addresses" << std::endl;
550 #if defined(ANYTUN_OPTIONS)
552 std::cout << " [-I|--sync-interface] <ip-address> local unicast(sync) ip address to bind to" << std::endl;
553 std::cout << " [-S|--sync-port] <port> local unicast(sync) port to bind to" << std::endl;
554 std::cout << " [-M|--sync-hosts] <hostname|ip>[:<port>][,<hostname|ip>[:<port>][...]]"<< std::endl;
555 std::cout << " remote hosts to sync with" << std::endl;
556 std::cout << " [-X|--control-host] <hostname|ip>[:<port>]"<< std::endl;
557 std::cout << " fetch the config from this host" << std::endl;
559 std::cout << " [-d|--dev] <name> device name" << std::endl;
560 std::cout << " [-t|--type] <tun|tap> device type" << std::endl;
561 std::cout << " [-n|--ifconfig] <local>/<prefix> the local address for the tun/tap device and the used prefix length" << std::endl;
563 std::cout << " [-x|--post-up-script] <script> script gets called after interface is created" << std::endl;
567 #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS)
570 std::cout << " [-R|--route] <net>/<prefix length> add a route to connection, can be invoked several times" << std::endl;
573 std::cout << " [-m|--mux] <mux-id> the multiplex id to use" << std::endl;
574 std::cout << " [-w|--window-size] <window size> seqence number window size" << std::endl;
577 std::cout << " [-k|--kd-prf] <kd-prf type> key derivation pseudo random function" << std::endl;
578 std::cout << " [-e|--role] <role> left (alice) or right (bob)" << std::endl;
579 #ifndef NO_PASSPHRASE
580 std::cout << " [-E|--passphrase] <pass phrase> a passprhase to generate master key and salt from" << std::endl;
582 std::cout << " [-K|--key] <master key> master key to use for encryption" << std::endl;
583 std::cout << " [-A|--salt] <master salt> master salt to use for encryption" << std::endl;
587 #if defined(ANYTUN_OPTIONS)
590 std::cout << " [-c|--cipher] <cipher type> payload encryption algorithm" << std::endl;
591 std::cout << " [-a|--auth-algo] <algo type> message authentication algorithm" << std::endl;
592 std::cout << " [-b|--auth-tag-length] length of the auth tag" << std::endl;
598 void Options::printOptions()
600 ReadersLock lock(mutex);
602 std::cout << "Options:" << std::endl;
603 std::cout << std::endl;
604 std::cout << "daemonize = " << daemonize_ << std::endl;
605 std::cout << "username = '" << username_ << "'" << std::endl;
606 std::cout << "groupname = '" << groupname_ << "'" << std::endl;
607 std::cout << "chroot_dir = '" << chroot_dir_ << "'" << std::endl;
608 std::cout << "pid_file = '" << pid_file_ << "'" << std::endl;
609 std::cout << std::endl;
610 std::cout << "log_targets:";
611 StringList::const_iterator lit = log_targets_.begin();
612 for(; lit != log_targets_.end(); ++lit)
613 std::cout << " '" << *lit << "',";
614 std::cout << std::endl << std::endl;
615 std::cout << "file_name = '" << file_name_ << "'" << std::endl;
616 std::cout << "bind_to.addr = '" << bind_to_.addr << "'" << std::endl;
617 std::cout << "bind_to.port = '" << bind_to_.port << "'" << std::endl;
618 std::cout << std::endl;
619 std::cout << "resolv_addr_type = ";
620 switch(resolv_addr_type_) {
621 case ANY: std::cout << "any" << std::endl; break;
622 case IPV4_ONLY: std::cout << "ipv4-only" << std::endl; break;
623 case IPV6_ONLY: std::cout << "ipv6-only" << std::endl; break;
624 default: std::cout << "?" << std::endl; break;
626 std::cout << std::endl;
627 std::cout << "local.addr = '" << local_.addr << "'" << std::endl;
628 std::cout << "local.port = '" << local_.port << "'" << std::endl;
629 std::cout << "remote.addr = '" << remote_.addr << "'" << std::endl;
630 std::cout << "remote.port = '" << remote_.port << "'" << std::endl;
631 std::cout << "local_sync.addr = '" << local_sync_.addr << "'" << std::endl;
632 std::cout << "local_sync.port = '" << local_sync_.port << "'" << std::endl;
633 std::cout << "remote_sync_hosts:" << std::endl;
634 HostList::const_iterator hit = remote_sync_hosts_.begin();
635 for(; hit != remote_sync_hosts_.end(); ++hit)
636 std::cout << " '" << hit->addr << "','" << hit->port << "'" << std::endl;
637 std::cout << std::endl;
638 std::cout << "dev_name = '" << dev_name_ << "'" << std::endl;
639 std::cout << "dev_type = '" << dev_type_ << "'" << std::endl;
640 std::cout << "ifconfig_param_local = '" << ifconfig_param_.net_addr << "/" << ifconfig_param_.prefix_length << "'" << std::endl;
641 std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl;
642 std::cout << "routes:" << std::endl;
643 NetworkList::const_iterator rit;
644 for(rit = routes_.begin(); rit != routes_.end(); ++rit)
645 std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl;
646 std::cout << std::endl;
647 std::cout << "sender_id = '" << sender_id_ << "'" << std::endl;
648 std::cout << "mux_id = " << mux_ << std::endl;
649 std::cout << "seq_window_size = '" << seq_window_size_ << "'" << std::endl;
650 std::cout << std::endl;
651 std::cout << "cipher = '" << cipher_ << "'" << std::endl;
652 std::cout << "auth_algo = '" << auth_algo_ << "'" << std::endl;
653 std::cout << "auth_tag_length = " << auth_tag_length_ << std::endl;
654 std::cout << "kd_prf = '" << kd_prf_ << "'" << std::endl;
655 std::cout << "role = ";
657 case ROLE_LEFT: std::cout << "left" << std::endl; break;
658 case ROLE_RIGHT: std::cout << "right" << std::endl; break;
659 default: std::cout << "??" << std::endl; break;
661 std::cout << "passphrase = '" << passphrase_ << "'" << std::endl;
662 std::cout << "key = " << key_.getHexDumpOneLine() << std::endl;
663 std::cout << "salt = " << salt_.getHexDumpOneLine() << std::endl;
668 std::string Options::getProgname()
670 ReadersLock lock(mutex);
674 Options& Options::setProgname(std::string p)
676 WritersLock lock(mutex);
681 bool Options::getDaemonize()
683 ReadersLock lock(mutex);
687 Options& Options::setDaemonize(bool d)
689 WritersLock lock(mutex);
694 std::string Options::getUsername()
696 ReadersLock lock(mutex);
700 Options& Options::setUsername(std::string u)
702 WritersLock lock(mutex);
707 std::string Options::getGroupname()
709 ReadersLock lock(mutex);
713 Options& Options::setGroupname(std::string g)
715 WritersLock lock(mutex);
720 std::string Options::getChrootDir()
722 ReadersLock lock(mutex);
726 Options& Options::setChrootDir(std::string c)
728 WritersLock lock(mutex);
733 std::string Options::getPidFile()
735 ReadersLock lock(mutex);
739 Options& Options::setPidFile(std::string p)
741 WritersLock lock(mutex);
748 StringList Options::getLogTargets()
750 ReadersLock lock(mutex);
756 std::string Options::getFileName()
758 ReadersLock lock(mutex);
762 Options& Options::setFileName(std::string f)
764 WritersLock lock(mutex);
769 std::string Options::getBindToAddr()
771 ReadersLock lock(mutex);
772 return bind_to_.addr;
775 Options& Options::setBindToAddr(std::string b)
777 WritersLock lock(mutex);
782 std::string Options::getBindToPort()
784 ReadersLock lock(mutex);
785 return bind_to_.port;
788 Options& Options::setBindToPort(std::string b)
790 WritersLock lock(mutex);
796 ResolvAddrType Options::getResolvAddrType()
798 ReadersLock lock(mutex);
799 return resolv_addr_type_;
802 Options& Options::setResolvAddrType(ResolvAddrType r)
804 WritersLock lock(mutex);
805 resolv_addr_type_ = r;
809 std::string Options::getLocalAddr()
811 ReadersLock lock(mutex);
815 Options& Options::setLocalAddr(std::string l)
817 WritersLock lock(mutex);
822 std::string Options::getLocalPort()
824 ReadersLock lock(mutex);
828 Options& Options::setLocalPort(std::string l)
830 WritersLock lock(mutex);
835 std::string Options::getRemoteAddr()
837 ReadersLock lock(mutex);
841 Options& Options::setRemoteAddr(std::string r)
843 WritersLock lock(mutex);
848 std::string Options::getRemotePort()
850 ReadersLock lock(mutex);
854 Options& Options::setRemotePort(std::string r)
856 WritersLock lock(mutex);
861 std::string Options::getLocalSyncAddr()
863 ReadersLock lock(mutex);
864 return local_sync_.addr;
867 Options& Options::setLocalSyncAddr(std::string l)
869 WritersLock lock(mutex);
870 local_sync_.addr = l;
874 std::string Options::getLocalSyncPort()
876 ReadersLock lock(mutex);
877 return local_sync_.port;
880 Options& Options::setLocalSyncPort(std::string l)
882 WritersLock lock(mutex);
883 local_sync_.port = l;
887 HostList Options::getRemoteSyncHosts()
889 ReadersLock lock(mutex);
890 return remote_sync_hosts_;
895 std::string Options::getDevName()
897 ReadersLock lock(mutex);
901 Options& Options::setDevName(std::string d)
903 WritersLock lock(mutex);
908 std::string Options::getDevType()
910 ReadersLock lock(mutex);
914 Options& Options::setDevType(std::string d)
916 WritersLock lock(mutex);
921 OptionNetwork Options::getIfconfigParam()
923 ReadersLock lock(mutex);
924 return ifconfig_param_;
927 Options& Options::setIfconfigParam(OptionNetwork i)
929 WritersLock lock(mutex);
934 std::string Options::getPostUpScript()
936 ReadersLock lock(mutex);
937 return post_up_script_;
940 Options& Options::setPostUpScript(std::string p)
942 WritersLock lock(mutex);
947 NetworkList Options::getRoutes()
949 ReadersLock lock(mutex);
955 sender_id_t Options::getSenderId()
957 ReadersLock lock(mutex);
961 Options& Options::setSenderId(sender_id_t s)
963 WritersLock lock(mutex);
968 mux_t Options::getMux()
970 ReadersLock lock(mutex);
974 Options& Options::setMux(mux_t m)
976 WritersLock lock(mutex);
981 window_size_t Options::getSeqWindowSize()
983 ReadersLock lock(mutex);
984 return seq_window_size_;
987 Options& Options::setSeqWindowSize(window_size_t s)
989 WritersLock lock(mutex);
990 seq_window_size_ = s;
996 std::string Options::getCipher()
998 ReadersLock lock(mutex);
1002 Options& Options::setCipher(std::string c)
1004 WritersLock lock(mutex);
1009 std::string Options::getAuthAlgo()
1011 ReadersLock lock(mutex);
1015 Options& Options::setAuthAlgo(std::string a)
1017 WritersLock lock(mutex);
1022 u_int32_t Options::getAuthTagLength()
1024 ReadersLock lock(mutex);
1025 return auth_tag_length_;
1028 Options& Options::setAuthTagLength(u_int32_t a)
1030 WritersLock lock(mutex);
1031 auth_tag_length_ = a;
1036 std::string Options::getKdPrf()
1038 ReadersLock lock(mutex);
1042 Options& Options::setKdPrf(std::string k)
1044 WritersLock lock(mutex);
1049 role_t Options::getRole()
1051 ReadersLock lock(mutex);
1055 Options& Options::setRole(role_t r)
1057 WritersLock lock(mutex);
1062 std::string Options::getPassphrase()
1064 ReadersLock lock(mutex);
1068 Options& Options::setPassphrase(std::string p)
1070 WritersLock lock(mutex);
1075 Buffer Options::getKey()
1077 ReadersLock lock(mutex);
1081 Options& Options::setKey(std::string k)
1083 WritersLock lock(mutex);
1088 Buffer Options::getSalt()
1090 ReadersLock lock(mutex);
1094 Options& Options::setSalt(std::string s)
1096 WritersLock lock(mutex);