diff options
author | Christian Pointner <equinox@anytun.org> | 2008-11-25 02:13:05 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2008-11-25 02:13:05 +0000 |
commit | 126e3621fa91a0b5907adc36f2dffc6c81208dc9 (patch) | |
tree | 4c86c513fbe8e388ce1aabcf6cf18e752f6ffb51 /src | |
parent | fixed readme (diff) |
small type cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/anytun-config.cpp | 6 | ||||
-rw-r--r-- | src/anytun-controld.cpp | 2 | ||||
-rw-r--r-- | src/anytun.cpp | 14 | ||||
-rw-r--r-- | src/connectionParam.h | 2 | ||||
-rw-r--r-- | src/packetSource.cpp | 15 | ||||
-rw-r--r-- | src/packetSource.h | 7 | ||||
-rw-r--r-- | src/syncClient.cpp | 11 | ||||
-rw-r--r-- | src/syncServer.cpp | 2 | ||||
-rw-r--r-- | src/syncServer.h | 6 | ||||
-rw-r--r-- | src/syncTcpConnection.cpp | 2 | ||||
-rw-r--r-- | src/syncTcpConnection.h | 8 |
11 files changed, 40 insertions, 35 deletions
diff --git a/src/anytun-config.cpp b/src/anytun-config.cpp index 9ac9321..7a1e9b1 100644 --- a/src/anytun-config.cpp +++ b/src/anytun-config.cpp @@ -100,12 +100,12 @@ int main(int argc, char* argv[]) ConnectionList cl; SyncQueue queue; - boost::asio::ip::udp::endpoint endpoint; + UDPPacketSource::proto::endpoint endpoint; if (gOpt.getRemoteAddr()!="" && gOpt.getRemotePort()!="") { boost::asio::io_service io_service; - boost::asio::ip::udp::resolver resolver(io_service); - boost::asio::ip::udp::resolver::query query(gOpt.getRemoteAddr(), gOpt.getRemotePort()); + UDPPacketSource::proto::resolver resolver(io_service); + UDPPacketSource::proto::resolver::query query(gOpt.getRemoteAddr(), gOpt.getRemotePort()); endpoint = *resolver.resolve(query); } createConnection(endpoint,cl,gOpt.getSeqWindowSize(), queue, gOpt.getMux()); diff --git a/src/anytun-controld.cpp b/src/anytun-controld.cpp index 5c5fbcc..f869553 100644 --- a/src/anytun-controld.cpp +++ b/src/anytun-controld.cpp @@ -78,7 +78,7 @@ void syncListener(void* p ) try { boost::asio::io_service io_service; - SyncServer server(io_service,boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), param->port)); + SyncServer server(io_service, SyncTcpConnection::proto::endpoint(SyncTcpConnection::proto::v6(), param->port)); server.onConnect=boost::bind(syncOnConnect,_1); io_service.run(); } diff --git a/src/anytun.cpp b/src/anytun.cpp index 012e233..a5ea52f 100644 --- a/src/anytun.cpp +++ b/src/anytun.cpp @@ -221,14 +221,14 @@ void syncListener(SyncQueue * queue ) try { boost::asio::io_service io_service; - boost::asio::ip::tcp::resolver resolver(io_service); - boost::asio::ip::tcp::endpoint e; + SyncTcpConnection::proto::resolver resolver(io_service); + SyncTcpConnection::proto::endpoint e; if(gOpt.getLocalSyncAddr()!="") { - boost::asio::ip::tcp::resolver::query query(gOpt.getLocalSyncAddr(), gOpt.getLocalSyncPort()); + SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncAddr(), gOpt.getLocalSyncPort()); e = *resolver.resolve(query); } else { - boost::asio::ip::tcp::resolver::query query(gOpt.getLocalSyncPort()); + SyncTcpConnection::proto::resolver::query query(gOpt.getLocalSyncPort()); e = *resolver.resolve(query); } @@ -534,9 +534,9 @@ int main(int argc, char* argv[]) if(gOpt.getRemoteAddr() != "") { boost::asio::io_service io_service; - boost::asio::ip::udp::resolver resolver(io_service); - boost::asio::ip::udp::resolver::query query(gOpt.getRemoteAddr(), gOpt.getRemotePort()); - boost::asio::ip::udp::endpoint endpoint = *resolver.resolve(query); + UDPPacketSource::proto::resolver resolver(io_service); + UDPPacketSource::proto::resolver::query query(gOpt.getRemoteAddr(), gOpt.getRemotePort()); + UDPPacketSource::proto::endpoint endpoint = *resolver.resolve(query); createConnection(endpoint,cl,gOpt.getSeqWindowSize(), queue, gOpt.getMux()); } diff --git a/src/connectionParam.h b/src/connectionParam.h index 9748a18..41df91c 100644 --- a/src/connectionParam.h +++ b/src/connectionParam.h @@ -69,7 +69,7 @@ private: ar & seq_nr_; ar & remote_host; ar & remote_port; - boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(remote_host), remote_port); + UDPPacketSource::proto::endpoint endpoint(boost::asio::ip::address::from_string(remote_host), remote_port); remote_end_ = endpoint; } }; diff --git a/src/packetSource.cpp b/src/packetSource.cpp index ee8951e..9a35cc3 100644 --- a/src/packetSource.cpp +++ b/src/packetSource.cpp @@ -32,24 +32,22 @@ #include <boost/asio.hpp> #include "datatypes.h" - #include "packetSource.h" -#include "buffer.h" UDPPacketSource::UDPPacketSource(std::string port) : sock_(io_service_) { - boost::asio::ip::udp::resolver resolver(io_service_); - boost::asio::ip::udp::resolver::query query(port); - boost::asio::ip::udp::endpoint e = *resolver.resolve(query); + proto::resolver resolver(io_service_); + proto::resolver::query query(port); + proto::endpoint e = *resolver.resolve(query); sock_.open(e.protocol()); sock_.bind(e); } UDPPacketSource::UDPPacketSource(std::string localaddr, std::string port) : sock_(io_service_) { - boost::asio::ip::udp::resolver resolver(io_service_); - boost::asio::ip::udp::resolver::query query(localaddr, port); - boost::asio::ip::udp::endpoint e = *resolver.resolve(query); + proto::resolver resolver(io_service_); + proto::resolver::query query(localaddr, port); + proto::endpoint e = *resolver.resolve(query); sock_.open(e.protocol()); sock_.bind(e); } @@ -63,3 +61,4 @@ void UDPPacketSource::send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint re { sock_.send_to(boost::asio::buffer(buf, len), remote); } + diff --git a/src/packetSource.h b/src/packetSource.h index f5cbd5d..ce6e997 100644 --- a/src/packetSource.h +++ b/src/packetSource.h @@ -35,8 +35,8 @@ #include <boost/asio.hpp> #include "datatypes.h" -#include "buffer.h" +// TODO: fix this typedef boost::asio::ip::udp::endpoint PacketSourceEndpoint; class PacketSource @@ -51,6 +51,8 @@ public: class UDPPacketSource : public PacketSource { public: + typedef boost::asio::ip::udp proto; + UDPPacketSource(std::string port); UDPPacketSource(std::string localaddr, std::string port); @@ -58,8 +60,9 @@ public: void send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint remote); private: + boost::asio::io_service io_service_; - boost::asio::ip::udp::socket sock_; + proto::socket sock_; }; #endif diff --git a/src/syncClient.cpp b/src/syncClient.cpp index d2c5ce7..6dceb00 100644 --- a/src/syncClient.cpp +++ b/src/syncClient.cpp @@ -39,6 +39,7 @@ #include "log.h" //#include "connectionParam.h" #include "syncClient.h" +#include "syncTcpConnection.h" #include "buffer.h" #include <boost/array.hpp> @@ -56,12 +57,12 @@ void SyncClient::run() try { boost::asio::io_service io_service; - boost::asio::ip::tcp::resolver resolver(io_service); - boost::asio::ip::tcp::resolver::query query( hostname_, port_); - boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(query); - boost::asio::ip::tcp::resolver::iterator end; + SyncTcpConnection::proto::resolver resolver(io_service); + SyncTcpConnection::proto::resolver::query query( hostname_, port_); + SyncTcpConnection::proto::resolver::iterator endpoint_iterator = resolver.resolve(query); + SyncTcpConnection::proto::resolver::iterator end; - boost::asio::ip::tcp::socket socket(io_service); + SyncTcpConnection::proto::socket socket(io_service); boost::system::error_code error = boost::asio::error::host_not_found; while (error && endpoint_iterator != end) { diff --git a/src/syncServer.cpp b/src/syncServer.cpp index 62b2cff..e39a11e 100644 --- a/src/syncServer.cpp +++ b/src/syncServer.cpp @@ -2,7 +2,7 @@ //using asio::ip::tcp; -SyncServer::SyncServer(boost::asio::io_service& io_service, boost::asio::ip::tcp::endpoint tcp_endpoint ) +SyncServer::SyncServer(boost::asio::io_service& io_service, SyncTcpConnection::proto::endpoint tcp_endpoint ) : acceptor_(io_service, tcp_endpoint) { start_accept(); diff --git a/src/syncServer.h b/src/syncServer.h index ed0d4fd..bb8f734 100644 --- a/src/syncServer.h +++ b/src/syncServer.h @@ -13,12 +13,10 @@ #include <list> #include "syncTcpConnection.h" -//using boost::asio::ip::tcp; - class SyncServer { public: - SyncServer(boost::asio::io_service& io_service, boost::asio::ip::tcp::endpoint tcp_endpoint ); + SyncServer(boost::asio::io_service& io_service, SyncTcpConnection::proto::endpoint tcp_endpoint ); boost::function<void(SyncTcpConnection *)> onConnect; std::list<SyncTcpConnection::pointer> conns_; void send(std::string message); @@ -27,6 +25,6 @@ private: void handle_accept(SyncTcpConnection::pointer new_connection, const boost::system::error_code& error); Mutex mutex_; //Mutex for list conns_ - boost::asio::ip::tcp::acceptor acceptor_; + SyncTcpConnection::proto::acceptor acceptor_; }; #endif diff --git a/src/syncTcpConnection.cpp b/src/syncTcpConnection.cpp index 5287468..df6f59f 100644 --- a/src/syncTcpConnection.cpp +++ b/src/syncTcpConnection.cpp @@ -14,7 +14,7 @@ #include "syncCommand.h" #include "buffer.h" -boost::asio::ip::tcp::socket& SyncTcpConnection::socket() +SyncTcpConnection::proto::socket& SyncTcpConnection::socket() { return socket_; } diff --git a/src/syncTcpConnection.h b/src/syncTcpConnection.h index 5af5276..bb0db46 100644 --- a/src/syncTcpConnection.h +++ b/src/syncTcpConnection.h @@ -12,12 +12,16 @@ class SyncTcpConnection { public: typedef boost::shared_ptr<SyncTcpConnection> pointer; + typedef boost::asio::ip::tcp proto; + static pointer create(boost::asio::io_service& io_service) { return pointer(new SyncTcpConnection(io_service)); }; + boost::function<void(SyncTcpConnection *)> onConnect; - boost::asio::ip::tcp::socket& socket(); + proto::socket& socket(); + void start(); void Send(std::string message); private: @@ -25,6 +29,6 @@ private: void handle_write(const boost::system::error_code & /*error*/, size_t /*bytes_transferred*/); - boost::asio::ip::tcp::socket socket_; + proto::socket socket_; }; #endif |