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[]);
94
std::string getProgname();
95
Options& setProgname(std::string p);
97
Options& setDaemonize(bool d);
98
std::string getUsername();
99
Options& setUsername(std::string u);
100
std::string getGroupname();
101
Options& setGroupname(std::string g);
102
std::string getChrootDir();
103
Options& setChrootDir(std::string c);
104
std::string getPidFile();
105
Options& setPidFile(std::string p);
107
StringList getLogTargets();
109
std::string getFileName();
110
Options& setFileName(std::string f);
111
std::string getBindToAddr();
112
Options& setBindToAddr(std::string b);
113
std::string getBindToPort();
114
Options& setBindToPort(std::string b);
116
ResolvAddrType getResolvAddrType();
117
Options& setResolvAddrType(ResolvAddrType r);
118
std::string getLocalAddr();
119
Options& setLocalAddr(std::string l);
120
std::string getLocalPort();
121
Options& setLocalPort(std::string l);
122
std::string getRemoteAddr();
123
Options& setRemoteAddr(std::string r);
124
std::string getRemotePort();
125
Options& setRemotePort(std::string r);
127
std::string getLocalSyncAddr();
128
Options& setLocalSyncAddr(std::string l);
129
std::string getLocalSyncPort();
130
Options& setLocalSyncPort(std::string l);
131
HostList getRemoteSyncHosts();
133
std::string getDevName();
134
Options& setDevName(std::string d);
135
std::string getDevType();
136
Options& setDevType(std::string d);
137
OptionNetwork getIfconfigParam();
138
Options& setIfconfigParam(OptionNetwork i);
139
std::string getPostUpScript();
140
Options& setPostUpScript(std::string p);
141
NetworkList getRoutes();
143
sender_id_t getSenderId();
144
Options& setSenderId(sender_id_t s);
146
Options& setMux(mux_t m);
147
window_size_t getSeqWindowSize();
148
Options& setSeqWindowSize(window_size_t s);
150
std::string getCipher();
151
Options& setCipher(std::string c);
152
std::string getAuthAlgo();
153
Options& setAuthAlgo(std::string a);
154
u_int32_t getAuthTagLength();
155
Options& setAuthTagLength(u_int32_t a);
156
std::string getKdPrf();
157
Options& setKdPrf(std::string k);
159
Options& setRole(role_t r);
160
std::string getPassphrase();
161
Options& setPassphrase(std::string p);
162
Options& setKey(std::string k);
164
Options& setSalt(std::string s);
171
Options(const Options &l);
172
void operator=(const Options &l);
174
static Options* inst;
175
static ::Mutex instMutex;
176
class instanceCleaner {
177
public: ~instanceCleaner() {
178
if(Options::inst != 0)
179
delete Options::inst;
182
friend class instanceCleaner;
188
bool connection_opts;
190
std::string progname_;
192
std::string username_;
193
std::string groupname_;
194
std::string chroot_dir_;
195
std::string pid_file_;
197
StringList log_targets_;
199
std::string file_name_;
202
ResolvAddrType resolv_addr_type_;
206
OptionHost local_sync_;
207
HostList remote_sync_hosts_;
209
std::string dev_name_;
210
std::string dev_type_;
211
OptionNetwork ifconfig_param_;
212
std::string post_up_script_;
215
sender_id_t sender_id_;
217
window_size_t seq_window_size_;
220
std::string auth_algo_;
221
u_int32_t auth_tag_length_;
224
std::string passphrase_;
229
extern Options& gOpt;