switched to endpoint @ anytun-config as well
[anytun.git] / src / options.h
blob4224640a7ba8be1e78ff13d3029f7e00639b8e13
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 std::list<OptionConnectTo> ConnectToList;
48 class Options
50 public:
51 static Options& instance();
53 bool parse(int argc, char* argv[]);
54 void printUsage();
55 void printOptions();
57 std::string getProgname();
58 Options& setProgname(std::string p);
59 bool getDaemonize();
60 Options& setDaemonize(bool d);
61 bool getChroot();
62 Options& setChroot(bool b);
63 std::string getUsername();
64 Options& setUsername(std::string u);
65 std::string getChrootDir();
66 Options& setChrootDir(std::string c);
67 std::string getPidFile();
68 Options& setPidFile(std::string p);
69 sender_id_t getSenderId();
70 Options& setSenderId(sender_id_t s);
71 std::string getLocalAddr();
72 Options& setLocalAddr(std::string l);
73 std::string getLocalSyncAddr();
74 Options& setLocalSyncAddr(std::string l);
75 std::string getRemoteSyncAddr();
76 Options& setRemoteSyncAddr(std::string l);
77 std::string getRemoteSyncPort();
78 Options& setRemoteSyncPort(std::string l);
79 std::string getLocalPort();
80 Options& setLocalPort(std::string l);
81 std::string getRemoteAddr();
82 Options& setRemoteAddr(std::string r);
83 std::string getLocalSyncPort();
84 Options& setLocalSyncPort(std::string l);
85 std::string getRemotePort();
86 Options& setRemotePort(std::string r);
87 Options& setRemoteAddrPort(std::string addr, std::string port);
88 std::string getDevName();
89 Options& setDevName(std::string d);
90 std::string getDevType();
91 Options& setDevType(std::string d);
92 std::string getIfconfigParamLocal();
93 Options& setIfconfigParamLocal(std::string i);
94 std::string getIfconfigParamRemoteNetmask();
95 Options& setIfconfigParamRemoteNetmask(std::string i);
96 std::string getPostUpScript();
97 Options& setPostUpScript(std::string p);
98 window_size_t getSeqWindowSize();
99 Options& setSeqWindowSize(window_size_t s);
100 std::string getCipher();
101 Options& setCipher(std::string c);
102 std::string getKdPrf();
103 Options& setKdPrf(std::string k);
104 std::string getAuthAlgo();
105 Options& setAuthAlgo(std::string a);
106 ConnectToList getConnectTo();
107 Options& setMux(u_int16_t m);
108 u_int16_t getMux();
109 Options& setKey(std::string k);
110 Buffer getKey();
111 Options& setSalt(std::string s);
112 Buffer getSalt();
114 private:
115 Options();
116 ~Options();
117 Options(const Options &l);
118 void operator=(const Options &l);
120 static Options* inst;
121 static ::Mutex instMutex;
122 class instanceCleaner {
123 public: ~instanceCleaner() {
124 if(Options::inst != 0)
125 delete Options::inst;
128 friend class instanceCleaner;
130 ::Mutex mutex;
132 ConnectToList connect_to_;
133 std::string progname_;
134 bool daemonize_;
135 bool chroot_;
136 std::string username_;
137 std::string chroot_dir_;
138 std::string pid_file_;
139 sender_id_t sender_id_;
140 std::string local_addr_;
141 std::string local_sync_addr_;
142 std::string local_port_;
143 std::string local_sync_port_;
144 std::string remote_sync_addr_;
145 std::string remote_sync_port_;
146 std::string remote_addr_;
147 std::string remote_port_;
148 std::string dev_name_;
149 std::string dev_type_;
150 std::string ifconfig_param_local_;
151 std::string ifconfig_param_remote_netmask_;
152 std::string post_up_script_;
153 window_size_t seq_window_size_;
154 std::string cipher_;
155 std::string kd_prf_;
156 std::string auth_algo_;
157 u_int16_t mux_;
158 Buffer key_;
159 Buffer salt_;
162 extern Options& gOpt;
164 #endif