diff options
author | Christian Pointner <equinox@anytun.org> | 2009-01-30 23:29:03 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2009-01-30 23:29:03 +0000 |
commit | 12a70e5b4bfe6f4ac680eaa13863358761bda567 (patch) | |
tree | 03379916b38cfb2accf3083c53d3781303a6bcf0 | |
parent | droping privileges is now possible without chroot (diff) |
refactoring
-rw-r--r-- | src/anytun-config.cpp | 4 | ||||
-rw-r--r-- | src/anytun.cpp | 4 | ||||
-rw-r--r-- | src/options.cpp | 16 | ||||
-rw-r--r-- | src/options.h | 18 |
4 files changed, 21 insertions, 21 deletions
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp index e5cd8b1..9b94af9 100644 --- a/src/anytun-config.cpp +++ b/src/anytun-config.cpp @@ -66,8 +66,8 @@ void createConnection(const PacketSourceEndpoint & remote_end, ConnectionList & oa << scom; std::cout << std::setw(5) << std::setfill('0') << sout.str().size()<< ' ' << sout.str() << std::endl; - RouteList routes = gOpt.getRoutes(); - RouteList::const_iterator rit; + NetworkList routes = gOpt.getRoutes(); + NetworkList::const_iterator rit; for(rit = routes.begin(); rit != routes.end(); ++rit) { NetworkAddress addr( rit->net_addr.c_str() ); diff --git a/src/anytun.cpp b/src/anytun.cpp index 8f6a0c9..a5de1ff 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -394,8 +394,8 @@ int main(int argc, char* argv[]) } #ifndef NO_ROUTING - RouteList routes = gOpt.getRoutes(); - RouteList::const_iterator rit; + NetworkList routes = gOpt.getRoutes(); + NetworkList::const_iterator rit; for(rit = routes.begin(); rit != routes.end(); ++rit) { NetworkAddress addr( rit->net_addr ); diff --git a/src/options.cpp b/src/options.cpp index 690630b..b39790b 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -107,20 +107,20 @@ std::istream& operator>>(std::istream& stream, OptionHost& host) return stream; } -void OptionRoute::init(std::string route) +void OptionNetwork::init(std::string network) { - std::stringstream tmp_stream(route); + std::stringstream tmp_stream(network); getline(tmp_stream, net_addr, '/'); if(!tmp_stream.good()) - throw syntax_error(route, net_addr.length()); + throw syntax_error(network, net_addr.length()); tmp_stream >> prefix_length; } -std::istream& operator>>(std::istream& stream, OptionRoute& route) +std::istream& operator>>(std::istream& stream, OptionNetwork& network) { std::string tmp; stream >> tmp; - route.init(tmp); + network.init(tmp); return stream; } @@ -366,7 +366,7 @@ bool Options::parse(int argc, char* argv[]) #if defined(ANYTUN_OPTIONS) || defined(ANYCONF_OPTIONS) #ifndef NO_ROUTING - PARSE_CSLIST_PARAM("-R","--route", routes_, OptionRoute) + PARSE_CSLIST_PARAM("-R","--route", routes_, OptionNetwork) #endif PARSE_SCALAR_PARAM("-m","--mux", mux_) @@ -533,7 +533,7 @@ void Options::printOptions() std::cout << "ifconfig_param_remote_netmask = '" << ifconfig_param_remote_netmask_ << "'" << std::endl; std::cout << "post_up_script = '" << post_up_script_ << "'" << std::endl; std::cout << "routes:" << std::endl; - RouteList::const_iterator rit; + NetworkList::const_iterator rit; for(rit = routes_.begin(); rit != routes_.end(); ++rit) std::cout << " " << rit->net_addr << "/" << rit->prefix_length << std::endl; std::cout << std::endl; @@ -824,7 +824,7 @@ Options& Options::setPostUpScript(std::string p) return *this; } -RouteList Options::getRoutes() +NetworkList Options::getRoutes() { ReadersLock lock(mutex); return routes_; diff --git a/src/options.h b/src/options.h index e24655f..dda7b10 100644 --- a/src/options.h +++ b/src/options.h @@ -60,20 +60,20 @@ public: typedef std::list<OptionHost> HostList; std::istream& operator>>(std::istream& stream, OptionHost& host); -class OptionRoute +class OptionNetwork { public: - OptionRoute() : net_addr(""), prefix_length(0) {}; - OptionRoute(std::string route) { init(route); }; - OptionRoute(std::string n, u_int16_t p) : net_addr(n), prefix_length(p) {}; + OptionNetwork() : net_addr(""), prefix_length(0) {}; + OptionNetwork(std::string network) { init(network); }; + OptionNetwork(std::string n, u_int16_t p) : net_addr(n), prefix_length(p) {}; - void init(std::string route); + void init(std::string network); std::string net_addr; u_int16_t prefix_length; }; -typedef std::list<OptionRoute> RouteList; -std::istream& operator>>(std::istream& stream, OptionRoute& route); +typedef std::list<OptionNetwork> NetworkList; +std::istream& operator>>(std::istream& stream, OptionNetwork& network); class Options { @@ -129,7 +129,7 @@ public: Options& setIfconfigParamRemoteNetmask(std::string i); std::string getPostUpScript(); Options& setPostUpScript(std::string p); - RouteList getRoutes(); + NetworkList getRoutes(); sender_id_t getSenderId(); Options& setSenderId(sender_id_t s); @@ -193,7 +193,7 @@ private: std::string ifconfig_param_local_; std::string ifconfig_param_remote_netmask_; std::string post_up_script_; - RouteList routes_; + NetworkList routes_; sender_id_t sender_id_; mux_t mux_; |