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/>.
33 #ifndef ANYTUN_options_h_INCLUDED
34 #define ANYTUN_options_h_INCLUDED
36 #include "datatypes.h"
38 #include "threadUtils.hpp"
41 class syntax_error : public std::runtime_error
44 syntax_error(std::string t, int32_t p) : runtime_error(t), pos(p) {};
47 std::ostream& operator<<(std::ostream& stream, syntax_error const& error);
52 OptionHost() : addr(""), port("") {};
53 OptionHost(std::string addrPort) { init(addrPort); };
54 OptionHost(std::string a, std::string p) : addr(a), port(p) {};
56 void init(std::string addrPort);
61 typedef std::list<OptionHost> HostList;
62 std::istream& operator>>(std::istream& stream, OptionHost& host);
67 OptionNetwork() : net_addr(""), prefix_length(0) {};
68 OptionNetwork(std::string network) { init(network); };
69 OptionNetwork(std::string n, u_int16_t p) : net_addr(n), prefix_length(p) {};
71 void init(std::string network);
74 u_int16_t prefix_length;
76 typedef std::list<OptionNetwork> NetworkList;
77 std::istream& operator>>(std::istream& stream, OptionNetwork& network);
79 typedef std::list<std::string> StringList;
81 typedef enum { ROLE_LEFT, ROLE_RIGHT } role_t;
82 std::ostream& operator<<(std::ostream& stream, role_t const& role);
87 static Options& instance();
89 bool parse(int argc, char* argv[]);
95 std::string getProgname();
96 Options& setProgname(std::string p);
98 Options& setDaemonize(bool d);
99 std::string getUsername();
100 Options& setUsername(std::string u);
101 std::string getGroupname();
102 Options& setGroupname(std::string g);
103 std::string getChrootDir();
104 Options& setChrootDir(std::string c);
105 std::string getPidFile();
106 Options& setPidFile(std::string p);
108 StringList getLogTargets();
110 Options& setDebug(bool d);
112 std::string getFileName();
113 Options& setFileName(std::string f);
114 std::string getBindToAddr();
115 Options& setBindToAddr(std::string b);
116 std::string getBindToPort();
117 Options& setBindToPort(std::string b);
119 ResolvAddrType getResolvAddrType();
120 Options& setResolvAddrType(ResolvAddrType r);
121 std::string getLocalAddr();
122 Options& setLocalAddr(std::string l);
123 std::string getLocalPort();
124 Options& setLocalPort(std::string l);
125 std::string getRemoteAddr();
126 Options& setRemoteAddr(std::string r);
127 std::string getRemotePort();
128 Options& setRemotePort(std::string r);
130 std::string getLocalSyncAddr();
131 Options& setLocalSyncAddr(std::string l);
132 std::string getLocalSyncPort();
133 Options& setLocalSyncPort(std::string l);
134 HostList getRemoteSyncHosts();
136 std::string getDevName();
137 Options& setDevName(std::string d);
138 std::string getDevType();
139 Options& setDevType(std::string d);
140 OptionNetwork getIfconfigParam();
141 Options& setIfconfigParam(OptionNetwork i);
142 std::string getPostUpScript();
143 Options& setPostUpScript(std::string p);
144 NetworkList getRoutes();
146 sender_id_t getSenderId();
147 Options& setSenderId(sender_id_t s);
149 Options& setMux(mux_t m);
150 window_size_t getSeqWindowSize();
151 Options& setSeqWindowSize(window_size_t s);
153 std::string getCipher();
154 Options& setCipher(std::string c);
155 std::string getAuthAlgo();
156 Options& setAuthAlgo(std::string a);
157 u_int32_t getAuthTagLength();
158 Options& setAuthTagLength(u_int32_t a);
159 std::string getKdPrf();
160 Options& setKdPrf(std::string k);
162 Options& setRole(role_t r);
163 std::string getPassphrase();
164 Options& setPassphrase(std::string p);
165 Options& setKey(std::string k);
167 Options& setSalt(std::string s);
174 Options(const Options &l);
175 void operator=(const Options &l);
177 static Options* inst;
178 static ::Mutex instMutex;
179 class instanceCleaner {
180 public: ~instanceCleaner() {
181 if(Options::inst != 0)
182 delete Options::inst;
185 friend class instanceCleaner;
191 bool connection_opts;
193 std::string progname_;
195 std::string username_;
196 std::string groupname_;
197 std::string chroot_dir_;
198 std::string pid_file_;
200 StringList log_targets_;
203 std::string file_name_;
206 ResolvAddrType resolv_addr_type_;
210 OptionHost local_sync_;
211 HostList remote_sync_hosts_;
213 std::string dev_name_;
214 std::string dev_type_;
215 OptionNetwork ifconfig_param_;
216 std::string post_up_script_;
219 sender_id_t sender_id_;
221 window_size_t seq_window_size_;
224 std::string auth_algo_;
225 u_int32_t auth_tag_length_;
228 std::string passphrase_;
233 extern Options& gOpt;