X-Git-Url: https://git.syn-net.org/debian/?a=blobdiff_plain;f=src%2Fanyrtpproxy%2Foptions.cpp;h=55f5dcd41b654aa07e15b343b94c53e0984285da;hb=65944fb7a518dc659bacaf80cf235a0352fc6a7e;hp=e651770bf46362f9c3a0b5ed67a02917062437ee;hpb=bb834fe0ed7a38b724f49b944adb801634eb6194;p=anytun.git diff --git a/src/anyrtpproxy/options.cpp b/src/anyrtpproxy/options.cpp index e651770..55f5dcd 100644 --- a/src/anyrtpproxy/options.cpp +++ b/src/anyrtpproxy/options.cpp @@ -6,12 +6,12 @@ * tunnel endpoints. It has less protocol overhead than IPSec in Tunnel * mode and allows tunneling of every ETHER TYPE protocol (e.g. * ethernet, ip, arp ...). satp directly includes cryptography and - * message authentication based on the methodes used by SRTP. It is + * message authentication based on the methods used by SRTP. It is * intended to deliver a generic, scaleable and secure solution for * tunneling and relaying of packets of any protocol. * * - * Copyright (C) 2007-2009 Othmar Gsenger, Erwin Nindl, + * Copyright (C) 2007-2014 Markus Grüneis, Othmar Gsenger, Erwin Nindl, * Christian Pointner * * This file is part of Anytun. @@ -27,7 +27,20 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with anytun. If not, see . + * along with Anytun. If not, see . + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations + * including the two. + * You must obey the GNU General Public License in all respects + * for all of the code used other than OpenSSL. If you modify + * file(s) with this exception, you may extend this exception to your + * version of the file(s), but you are not obligated to do so. If you + * do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source + * files in the program, then also delete it here. */ #include @@ -45,9 +58,10 @@ Options& Options::instance() { Lock lock(instMutex); static instanceCleaner c; - if(!inst) + if(!inst) { inst = new Options(); - + } + return *inst; } @@ -56,34 +70,37 @@ void Host::splitAndSetAddrPort(std::string addr_port) if(addr_port.length() >= 2 && addr_port[0] == ':' && addr_port[1] != ':') { addr_ = ""; addr_port.erase(0,1); - std::stringstream tmp_stream(addr_port); + std::stringstream tmp_stream(addr_port); tmp_stream >> port_; return; } size_t pos = addr_port.find_first_of("["); - if(pos != std::string::npos && pos != 0) - return; // an [ was found but not at the beginning + if(pos != std::string::npos && pos != 0) { + return; // an [ was found but not at the beginning + } bool hasPort = false; if(pos != std::string::npos) { addr_port.erase(pos, 1); pos = addr_port.find_first_of("]"); - if(pos == std::string::npos) - return; // no trailing ] although an leading [ was found + if(pos == std::string::npos) { + return; // no trailing ] although an leading [ was found + } if(pos < addr_port.length()-2) { - if(addr_port[pos+1] != ':') - return; // wrong port delimieter + if(addr_port[pos+1] != ':') { + return; // wrong port delimieter + } addr_port[pos+1] = '/'; hasPort = true; + } else if(pos != addr_port.length()-1) { + return; // to few characters left } - else if(pos != addr_port.length()-1) - return; // to few characters left addr_port.erase(pos, 1); } @@ -92,12 +109,12 @@ void Host::splitAndSetAddrPort(std::string addr_port) std::stringstream tmp_stream(addr_port); getline(tmp_stream, addr_, '/'); - if(!tmp_stream.good()) + if(!tmp_stream.good()) { return; + } tmp_stream >> port_; - } - else { + } else { addr_ = addr_port; port_ = "2323"; // default sync port } @@ -114,11 +131,11 @@ Options::Options() : control_interface_("0.0.0.0", "22222") daemonize_ = true; pid_file_ = ""; local_addr_ = ""; - local_sync_port_ = ""; - rtp_start_port_ = 34000; - rtp_end_port_ = 35000; - no_nat_once_ = false; - nat_ = false; + local_sync_port_ = ""; + rtp_start_port_ = 34000; + rtp_end_port_ = 35000; + no_nat_once_ = false; + nat_ = false; } Options::~Options() @@ -205,13 +222,13 @@ bool Options::parse(int argc, char* argv[]) progname_ = argv[0]; std::queue host_port_queue; argc--; - for(int i=1; argc > 0; ++i) - { + for(int i=1; argc > 0; ++i) { std::string str(argv[i]); argc--; - if(str == "-h" || str == "--help") + if(str == "-h" || str == "--help") { return false; + } PARSE_BOOL_PARAM("-t","--chroot", chroot_) PARSE_BOOL_PARAM("-n","--nat", nat_) PARSE_BOOL_PARAM("-o","--no-nat-once", no_nat_once_) @@ -222,30 +239,31 @@ bool Options::parse(int argc, char* argv[]) PARSE_SCALAR_PARAM("-i","--interface", local_addr_) PARSE_STRING_PARAM("-s","--control", control_interface_) PARSE_SCALAR_PARAM2("-p","--port-range", rtp_start_port_, rtp_end_port_) - PARSE_CSLIST_PARAM("-M","--sync-hosts", host_port_queue) + PARSE_CSLIST_PARAM("-M","--sync-hosts", host_port_queue) PARSE_SCALAR_PARAM("-S","--sync-port", local_sync_port_) PARSE_SCALAR_PARAM("-I","--sync-interface", local_sync_addr_) - else + else { return false; + } } - while(!host_port_queue.empty()) - { + while(!host_port_queue.empty()) { std::stringstream tmp_stream(host_port_queue.front()); OptionConnectTo oct; getline(tmp_stream,oct.host,':'); - if(!tmp_stream.good()) + if(!tmp_stream.good()) { return false; + } tmp_stream >> oct.port; host_port_queue.pop(); connect_to_.push_back(oct); } - + return sanityCheck(); } bool Options::sanityCheck() { - if(control_interface_.port_ == "") control_interface_.port_ = "22222"; + if(control_interface_.port_ == "") { control_interface_.port_ = "22222"; } return true; } @@ -379,23 +397,23 @@ Options& Options::setLocalSyncPort(std::string l) return *this; } -u_int16_t Options::getRtpStartPort() +uint16_t Options::getRtpStartPort() { return rtp_start_port_; } -Options& Options::setRtpStartPort(u_int16_t l) +Options& Options::setRtpStartPort(uint16_t l) { rtp_start_port_ = l; return *this; } -u_int16_t Options::getRtpEndPort() +uint16_t Options::getRtpEndPort() { return rtp_end_port_; } -Options& Options::setRtpEndPort(u_int16_t l) +Options& Options::setRtpEndPort(uint16_t l) { rtp_end_port_ = l; return *this;