summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@anytun.org>2008-11-24 20:53:39 +0000
committerOthmar Gsenger <otti@anytun.org>2008-11-24 20:53:39 +0000
commite82b5c1dd3420093c269d6d4e0bae80c6331e396 (patch)
tree1134c76b585d416472b726bad2dd92ed40fd7cb6
parentPacketSource changed to use endpoint instead of port and address (diff)
temp ceckin
-rw-r--r--src/anytun.cpp9
-rw-r--r--src/connectionParam.h5
-rw-r--r--src/syncClient.cpp6
-rw-r--r--src/syncClient.h4
4 files changed, 13 insertions, 11 deletions
diff --git a/src/anytun.cpp b/src/anytun.cpp
index 2b95b13..6f13723 100644
--- a/src/anytun.cpp
+++ b/src/anytun.cpp
@@ -80,14 +80,19 @@
#define SESSION_KEYLEN_ENCR 16 // TODO: hardcoded size
#define SESSION_KEYLEN_SALT 14 // TODO: hardcoded size
-void createConnection(const std::string & remote_host, u_int16_t remote_port, ConnectionList & cl, u_int16_t seqSize, SyncQueue & queue, mux_t mux)
+void createConnection(const std::string & remote_host, const std::string & remote_port, ConnectionList & cl, u_int16_t seqSize, SyncQueue & queue, mux_t mux)
{
SeqWindow * seq= new SeqWindow(seqSize);
seq_nr_t seq_nr_=0;
KeyDerivation * kd = KeyDerivationFactory::create(gOpt.getKdPrf());
kd->init(gOpt.getKey(), gOpt.getSalt());
cLog.msg(Log::PRIO_NOTICE) << "added connection remote host " << remote_host << ":" << remote_port;
- ConnectionParam connparam ( (*kd), (*seq), seq_nr_, remote_host, remote_port);
+ boost::asio::io_service io_service;
+ boost::asio::ip::udp::resolver resolver(io_service);
+ boost::asio::ip::udp::resolver::query query(remote_host, remote_port);
+ boost::asio::ip::udp::endpoint endpoint = *resolver.resolve(query);
+
+ ConnectionParam connparam ( (*kd), (*seq), seq_nr_, endpoint);
cl.addConnection(connparam,mux);
NetworkAddress addr(ipv4,gOpt.getIfconfigParamRemoteNetmask().c_str());
NetworkPrefix prefix(addr,32);
diff --git a/src/connectionParam.h b/src/connectionParam.h
index 337151c..8558c24 100644
--- a/src/connectionParam.h
+++ b/src/connectionParam.h
@@ -45,13 +45,12 @@ class ConnectionParam
{
public:
ConnectionParam(const ConnectionParam & src);
- ConnectionParam( KeyDerivation& kd, SeqWindow& seq_window, seq_nr_t seq_nr_, std::string remote_host, u_int16_t remote_port);
+ ConnectionParam( KeyDerivation& kd, SeqWindow& seq_window, seq_nr_t seq_nr_, boost::asio::ip::udp::endpoint endpoint);
KeyDerivation& kd_;
SeqWindow& seq_window_;
seq_nr_t seq_nr_;
- std::string remote_host_;
- u_int16_t remote_port_;
+ boost::asio::ip::udp::endpoint endpoint_;
private:
//TODO: check if this is ok
diff --git a/src/syncClient.cpp b/src/syncClient.cpp
index 48f8d27..5d4be45 100644
--- a/src/syncClient.cpp
+++ b/src/syncClient.cpp
@@ -43,7 +43,7 @@
#include <boost/array.hpp>
-SyncClient::SyncClient(std::string hostname,uint16_t port)
+SyncClient::SyncClient(std::string hostname,std::string port)
:hostname_( hostname),port_(port)
{
}
@@ -55,10 +55,8 @@ void SyncClient::run()
boost::asio::io_service io_service;
for(;;)
{
- std::stringstream portsrt;
- portsrt << port_;
boost::asio::ip::tcp::resolver resolver(io_service);
- boost::asio::ip::tcp::resolver::query query( hostname_, portsrt.str());
+ 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;
diff --git a/src/syncClient.h b/src/syncClient.h
index f36b869..0714e9b 100644
--- a/src/syncClient.h
+++ b/src/syncClient.h
@@ -41,13 +41,13 @@
class SyncClient
{
public:
- SyncClient(std::string hostname,uint16_t port);
+ SyncClient(std::string hostname,std::string port);
void run();
private:
void OnRawData(const char *buf,size_t len);
std::string hostname_;
- uint16_t port_;
+ std::string port_;
std::stringstream iss_;
int32_t missing_chars;
int32_t buffer_size_;