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 anytun.org <satp@wirdorange.org>
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License version 2
18 * as published by the Free Software Foundation.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program (see the file COPYING included with this
27 * distribution); if not, write to the Free Software Foundation, Inc.,
28 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
36 #include "datatypes.h"
37 #include "anymuxOptions.h"
39 Options
* Options::inst
= NULL
;
40 Mutex
Options::instMutex
;
41 Options
& gOpt
= Options::instance();
43 Options
& Options::instance()
46 static instanceCleaner c
;
64 #define PARSE_BOOL_PARAM(SHORT, LONG, VALUE) \
65 else if(str == SHORT || str == LONG) \
68 #define PARSE_INVERSE_BOOL_PARAM(SHORT, LONG, VALUE) \
69 else if(str == SHORT || str == LONG) \
72 #define PARSE_SCALAR_PARAM(SHORT, LONG, VALUE) \
73 else if(str == SHORT || str == LONG) \
75 if(argc < 1 || argv[i+1][0] == '-') \
77 std::stringstream tmp; \
84 #define PARSE_SCALAR_PARAM2(SHORT, LONG, VALUE1, VALUE2) \
85 else if(str == SHORT || str == LONG) \
88 argv[i+1][0] == '-' || argv[i+2][0] == '-') \
90 std::stringstream tmp; \
91 tmp << argv[i+1] << " " << argv[i+2]; \
98 #define PARSE_HEXSTRING_PARAM(SHORT, LONG, VALUE) \
99 else if(str == SHORT || str == LONG) \
101 if(argc < 1 || argv[i+1][0] == '-') \
103 VALUE = Buffer(std::string(argv[i+1])); \
108 #define PARSE_CSLIST_PARAM(SHORT, LONG, LIST) \
109 else if(str == SHORT || str == LONG) \
111 if(argc < 1 || argv[i+1][0] == '-') \
113 std::stringstream tmp(argv[i+1]); \
116 std::string tmp_line; \
117 getline(tmp,tmp_line,','); \
118 LIST.push(tmp_line); \
124 bool Options::parse(int argc
, char* argv
[])
131 for(int i
=1; argc
> 0; ++i
)
133 std::string
str(argv
[i
]);
136 if(str
== "-h" || str
== "--help")
138 PARSE_SCALAR_PARAM("-p","--port", local_port_
)
139 PARSE_SCALAR_PARAM("-f","--file", file_name_
)
147 void Options::printUsage()
149 std::cout
<< "USAGE:" << std::endl
;
150 std::cout
<< "anymux [-h|--help] prints this..." << std::endl
;
151 std::cout
<< " [-p|--port] <port> local port to bind to" << std::endl
;
152 std::cout
<< " [-f|--file] <path> path to file" << std::endl
;
155 void Options::printOptions()
158 std::cout
<< "Options:" << std::endl
;
159 std::cout
<< "local_port='" << local_port_
<< "'" << std::endl
;
162 std::string
Options::getProgname()
169 Options
& Options::setProgname(std::string p
)
176 std::string
Options::getFileName()
183 Options
& Options::setFileName(std::string f
)
190 u_int16_t
Options::getLocalPort()
195 Options
& Options::setLocalPort(u_int16_t l
)