diff options
author | Christian Pointner <equinox@anytun.org> | 2010-01-08 04:41:56 +0000 |
---|---|---|
committer | Christian Pointner <equinox@anytun.org> | 2010-01-08 04:41:56 +0000 |
commit | 7448f4dc8245ca2512e088ba6f89ece9a38cb915 (patch) | |
tree | f35337dd8341bd403f78265efb5af7a8a5b9cd6e | |
parent | UDPPacketSource now opens one socket for each resolved endpoint (diff) |
dispatching right socket for send to function
-rw-r--r-- | src/packetSource.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/packetSource.cpp b/src/packetSource.cpp index 7c66d0f..3ab22c6 100644 --- a/src/packetSource.cpp +++ b/src/packetSource.cpp @@ -90,6 +90,13 @@ u_int32_t UDPPacketSource::recv(u_int8_t* buf, u_int32_t len, PacketSourceEndpoi void UDPPacketSource::send(u_int8_t* buf, u_int32_t len, PacketSourceEndpoint remote) { - sockets_.front()->send_to(boost::asio::buffer(buf, len), remote); + std::list<proto::socket*>::iterator it = sockets_.begin(); + for(;it != sockets_.end(); ++it) { + if((*it)->local_endpoint().protocol() == remote.protocol()) { + (*it)->send_to(boost::asio::buffer(buf, len), remote); + return; + } + } + cLog.msg(Log::PRIO_WARNING) << "no suitable socket found for remote endpoint protocol: " << remote; } |