improved Makefile (clean now for -j *)
[anytun.git] / src / options.h
blob56518db50d04b2bdc84baf75c343a00b71a94ee4
1 /*
2 * anytun
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/>.
32 #ifndef _OPTIONS_H_
33 #define _OPTIONS_H_
35 #include "datatypes.h"
36 #include "buffer.h"
37 #include "threadUtils.hpp"
38 #include <list>
40 typedef struct
42 std::string host;
43 std::string port;
44 } OptionConnectTo;
46 typedef struct
48 std::string net_addr;
49 u_int16_t prefix_length;
50 } OptionRoute;
52 typedef std::list<OptionRoute> RouteList;
55 typedef std::list<OptionConnectTo> ConnectToList;
57 class Options
59 public:
60 static Options& instance();
62 bool parse(int argc, char* argv[]);
63 void printUsage();
64 void printOptions();
66 std::string getProgname();
67 Options& setProgname(std::string p);
68 bool getDaemonize();
69 Options& setDaemonize(bool d);
70 bool getChroot();
71 Options& setChroot(bool b);
72 std::string getUsername();
73 Options& setUsername(std::string u);
74 std::string getChrootDir();
75 Options& setChrootDir(std::string c);
76 std::string getPidFile();
77 Options& setPidFile(std::string p);
78 sender_id_t getSenderId();
79 Options& setSenderId(sender_id_t s);
80 std::string getLocalAddr();
81 Options& setLocalAddr(std::string l);
82 std::string getLocalSyncAddr();
83 Options& setLocalSyncAddr(std::string l);
84 std::string getRemoteSyncAddr();
85 Options& setRemoteSyncAddr(std::string l);
86 std::string getRemoteSyncPort();
87 Options& setRemoteSyncPort(std::string l);
88 std::string getLocalPort();
89 Options& setLocalPort(std::string l);
90 std::string getRemoteAddr();
91 Options& setRemoteAddr(std::string r);
92 std::string getLocalSyncPort();
93 Options& setLocalSyncPort(std::string l);
94 std::string getRemotePort();
95 Options& setRemotePort(std::string r);
96 Options& setRemoteAddrPort(std::string addr, std::string port);
97 std::string getDevName();
98 Options& setDevName(std::string d);
99 std::string getDevType();
100 Options& setDevType(std::string d);
101 std::string getIfconfigParamLocal();
102 Options& setIfconfigParamLocal(std::string i);
103 std::string getIfconfigParamRemoteNetmask();
104 Options& setIfconfigParamRemoteNetmask(std::string i);
105 std::string getPostUpScript();
106 Options& setPostUpScript(std::string p);
107 window_size_t getSeqWindowSize();
108 Options& setSeqWindowSize(window_size_t s);
109 std::string getCipher();
110 Options& setCipher(std::string c);
111 std::string getKdPrf();
112 Options& setKdPrf(std::string k);
113 std::string getAuthAlgo();
114 Options& setAuthAlgo(std::string a);
115 ConnectToList getConnectTo();
116 Options& setMux(mux_t m);
117 mux_t getMux();
118 Options& setKey(std::string k);
119 Buffer getKey();
120 Options& setSalt(std::string s);
121 Buffer getSalt();
122 RouteList getRoutes();
125 private:
126 Options();
127 ~Options();
128 Options(const Options &l);
129 void operator=(const Options &l);
131 static Options* inst;
132 static ::Mutex instMutex;
133 class instanceCleaner {
134 public: ~instanceCleaner() {
135 if(Options::inst != 0)
136 delete Options::inst;
139 friend class instanceCleaner;
141 static bool splitAndAddHostPort(std::string hostPort, ConnectToList& list);
143 ::Mutex mutex;
145 ConnectToList connect_to_;
146 std::string progname_;
147 bool daemonize_;
148 bool chroot_;
149 std::string username_;
150 std::string chroot_dir_;
151 std::string pid_file_;
152 sender_id_t sender_id_;
153 std::string local_addr_;
154 std::string local_sync_addr_;
155 std::string local_port_;
156 std::string local_sync_port_;
157 std::string remote_sync_addr_;
158 std::string remote_sync_port_;
159 std::string remote_addr_;
160 std::string remote_port_;
161 std::string dev_name_;
162 std::string dev_type_;
163 std::string ifconfig_param_local_;
164 std::string ifconfig_param_remote_netmask_;
165 std::string post_up_script_;
166 window_size_t seq_window_size_;
167 std::string cipher_;
168 std::string kd_prf_;
169 std::string auth_algo_;
170 mux_t mux_;
171 Buffer key_;
172 Buffer salt_;
173 RouteList routes_;
176 extern Options& gOpt;
178 #endif