aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llpacketring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmessage/llpacketring.cpp')
-rw-r--r--linden/indra/llmessage/llpacketring.cpp56
1 files changed, 51 insertions, 5 deletions
diff --git a/linden/indra/llmessage/llpacketring.cpp b/linden/indra/llmessage/llpacketring.cpp
index 7f9617f..e7dad79 100644
--- a/linden/indra/llmessage/llpacketring.cpp
+++ b/linden/indra/llmessage/llpacketring.cpp
@@ -43,6 +43,15 @@
43#include "llmessagelog.h" 43#include "llmessagelog.h"
44#include "message.h" 44#include "message.h"
45 45
46#include "llsocks5.h"
47
48#if LL_WINDOWS
49 #include <winsock2.h>
50#else
51 #include <sys/socket.h>
52 #include <netinet/in.h>
53#endif
54
46/////////////////////////////////////////////////////////// 55///////////////////////////////////////////////////////////
47LLPacketRing::LLPacketRing () : 56LLPacketRing::LLPacketRing () :
48 mUseInThrottle(FALSE), 57 mUseInThrottle(FALSE),
@@ -224,8 +233,25 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap)
224 else 233 else
225 { 234 {
226 // no delay, pull straight from net 235 // no delay, pull straight from net
227 packet_size = receive_packet(socket, datap); 236 if (LLSocks::isEnabled())
228 mLastSender = ::get_sender(); 237 {
238 proxywrap_t * header;
239 datap = datap-10;
240 header = (proxywrap_t *)datap;
241 packet_size = receive_packet(socket, datap);
242 mLastSender.setAddress(header->addr);
243 mLastSender.setPort(ntohs(header->port));
244 if (packet_size > 10)
245 {
246 packet_size -= 10;
247 }
248 }
249 else
250 {
251 packet_size = receive_packet(socket, datap);
252 mLastSender = ::get_sender();
253 }
254
229 mLastReceivingIF = ::get_receiving_interface(); 255 mLastReceivingIF = ::get_receiving_interface();
230 256
231 if (packet_size) // did we actually get a packet? 257 if (packet_size) // did we actually get a packet?
@@ -254,7 +280,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
254 BOOL status = TRUE; 280 BOOL status = TRUE;
255 if (!mUseOutThrottle) 281 if (!mUseOutThrottle)
256 { 282 {
257 return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort() ); 283 return doSendPacket(h_socket, send_buffer, buf_size, host );
258 } 284 }
259 else 285 else
260 { 286 {
@@ -275,7 +301,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
275 mOutBufferLength -= packetp->getSize(); 301 mOutBufferLength -= packetp->getSize();
276 packet_size = packetp->getSize(); 302 packet_size = packetp->getSize();
277 303
278 status = send_packet(h_socket, packetp->getData(), packet_size, packetp->getHost().getAddress(), packetp->getHost().getPort()); 304 status = doSendPacket(h_socket, packetp->getData(), packet_size, packetp->getHost());
279 305
280 delete packetp; 306 delete packetp;
281 // Update the throttle 307 // Update the throttle
@@ -284,7 +310,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
284 else 310 else
285 { 311 {
286 // If the queue's empty, we can just send this packet right away. 312 // If the queue's empty, we can just send this packet right away.
287 status = send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort() ); 313 status = doSendPacket(h_socket, send_buffer, buf_size, host );
288 packet_size = buf_size; 314 packet_size = buf_size;
289 315
290 // Update the throttle 316 // Update the throttle
@@ -322,3 +348,23 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
322 348
323 return status; 349 return status;
324} 350}
351
352BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
353{
354
355 if (!LLSocks::isEnabled())
356 {
357 return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort());
358 }
359
360 proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer;
361 socks_header->rsv = 0;
362 socks_header->addr = host.getAddress();
363 socks_header->port = htons(host.getPort());
364 socks_header->atype = ADDRESS_IPV4;
365 socks_header->frag = 0;
366
367 memcpy(mProxyWrappedSendBuffer+10, send_buffer, buf_size);
368
369 return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size+10, LLSocks::getInstance()->getUDPPproxy().getAddress(), LLSocks::getInstance()->getUDPPproxy().getPort());
370}