4 * The secure anycast tunneling protocol (satp) defines a protocol used
5 * for communication between any combination of unicast and anycast
6 * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel
7 * mode and allows tunneling of every ETHER TYPE protocol (e.g.
8 * ethernet, ip, arp ...). satp directly includes cryptography and
9 * message authentication based on the methods used by SRTP. It is
10 * intended to deliver a generic, scaleable and secure solution for
11 * tunneling and relaying of packets of any protocol.
14 * Copyright (C) 2007-2014 Markus Grüneis, Othmar Gsenger, Erwin Nindl,
15 * Christian Pointner <satp@wirdorange.org>
17 * This file is part of Anytun.
19 * Anytun is free software: you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation, either version 3 of the License, or
24 * Anytun is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with Anytun. If not, see <http://www.gnu.org/licenses/>.
32 * In addition, as a special exception, the copyright holders give
33 * permission to link the code of portions of this program with the
34 * OpenSSL library under certain conditions as described in each
35 * individual source file, and distribute linked combinations
37 * You must obey the GNU General Public License in all respects
38 * for all of the code used other than OpenSSL. If you modify
39 * file(s) with this exception, you may extend this exception to your
40 * version of the file(s), but you are not obligated to do so. If you
41 * do not wish to do so, delete this exception statement from your
42 * version. If you delete this exception statement from all source
43 * files in the program, then also delete it here.
46 #ifndef ANYTUN_options_h_INCLUDED
47 #define ANYTUN_options_h_INCLUDED
49 #include "datatypes.h"
51 #include "threadUtils.hpp"
54 class syntax_error : public std::runtime_error
57 syntax_error(std::string t, int32_t p) : runtime_error(t), pos(p) {};
60 std::ostream& operator<<(std::ostream& stream, syntax_error const& error);
65 OptionHost() : addr(""), port("") {};
66 OptionHost(std::string addrPort) { init(addrPort); };
67 OptionHost(std::string a, std::string p) : addr(a), port(p) {};
69 void init(std::string addrPort);
74 typedef std::list<OptionHost> HostList;
75 std::istream& operator>>(std::istream& stream, OptionHost& host);
80 OptionNetwork() : net_addr(""), prefix_length(0) {};
81 OptionNetwork(std::string network) { init(network); };
82 OptionNetwork(std::string n, uint16_t p) : net_addr(n), prefix_length(p) {};
84 void init(std::string network);
87 uint16_t prefix_length;
89 typedef std::list<OptionNetwork> NetworkList;
90 std::istream& operator>>(std::istream& stream, OptionNetwork& network);
92 typedef std::list<std::string> StringList;
94 typedef enum { ROLE_LEFT, ROLE_RIGHT } role_t;
95 std::ostream& operator<<(std::ostream& stream, role_t const& role);
100 static Options& instance();
102 bool parse(int argc, char* argv[]);
108 std::string getProgname();
109 Options& setProgname(std::string p);
111 Options& setDaemonize(bool d);
112 std::string getUsername();
113 Options& setUsername(std::string u);
114 std::string getGroupname();
115 Options& setGroupname(std::string g);
116 std::string getChrootDir();
117 Options& setChrootDir(std::string c);
118 std::string getPidFile();
119 Options& setPidFile(std::string p);
121 StringList getLogTargets();
123 Options& setDebug(bool d);
125 std::string getFileName();
126 Options& setFileName(std::string f);
127 std::string getBindToAddr();
128 Options& setBindToAddr(std::string b);
129 std::string getBindToPort();
130 Options& setBindToPort(std::string b);
132 ResolvAddrType getResolvAddrType();
133 Options& setResolvAddrType(ResolvAddrType r);
134 std::string getLocalAddr();
135 Options& setLocalAddr(std::string l);
136 std::string getLocalPort();
137 Options& setLocalPort(std::string l);
138 std::string getRemoteAddr();
139 Options& setRemoteAddr(std::string r);
140 std::string getRemotePort();
141 Options& setRemotePort(std::string r);
143 std::string getLocalSyncAddr();
144 Options& setLocalSyncAddr(std::string l);
145 std::string getLocalSyncPort();
146 Options& setLocalSyncPort(std::string l);
147 HostList getRemoteSyncHosts();
149 std::string getDevName();
150 Options& setDevName(std::string d);
151 std::string getDevType();
152 Options& setDevType(std::string d);
153 OptionNetwork getIfconfigParam();
154 Options& setIfconfigParam(OptionNetwork i);
155 std::string getPostUpScript();
156 Options& setPostUpScript(std::string p);
157 NetworkList getRoutes();
159 sender_id_t getSenderId();
160 Options& setSenderId(sender_id_t s);
162 Options& setMux(mux_t m);
163 window_size_t getSeqWindowSize();
164 Options& setSeqWindowSize(window_size_t s);
166 std::string getCipher();
167 Options& setCipher(std::string c);
168 std::string getAuthAlgo();
169 Options& setAuthAlgo(std::string a);
170 uint32_t getAuthTagLength();
171 Options& setAuthTagLength(uint32_t a);
172 std::string getKdPrf();
173 Options& setKdPrf(std::string k);
175 Options& setRole(role_t r);
176 std::string getPassphrase();
177 Options& setPassphrase(std::string p);
178 Options& setKey(std::string k);
180 Options& setSalt(std::string s);
187 Options(const Options& l);
188 void operator=(const Options& l);
193 bool connection_opts;
195 std::string progname_;
197 std::string username_;
198 std::string groupname_;
199 std::string chroot_dir_;
200 std::string pid_file_;
202 StringList log_targets_;
205 std::string file_name_;
208 ResolvAddrType resolv_addr_type_;
212 OptionHost local_sync_;
213 HostList remote_sync_hosts_;
215 std::string dev_name_;
216 std::string dev_type_;
217 OptionNetwork ifconfig_param_;
218 std::string post_up_script_;
221 sender_id_t sender_id_;
223 window_size_t seq_window_size_;
226 std::string auth_algo_;
227 uint32_t auth_tag_length_;
230 std::string passphrase_;
235 extern Options& gOpt;