aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage
diff options
context:
space:
mode:
authorJacek Antonelli2008-09-28 17:21:23 -0500
committerJacek Antonelli2008-09-28 17:21:46 -0500
commit31e7c77a411d94bc87f0232588b339149bb29a49 (patch)
tree49e487700e91713e620e4d33f20b7f7afb5a2fa9 /linden/indra/llmessage
parentSecond Life viewer sources 1.21.2-RC (diff)
downloadmeta-impy-31e7c77a411d94bc87f0232588b339149bb29a49.zip
meta-impy-31e7c77a411d94bc87f0232588b339149bb29a49.tar.gz
meta-impy-31e7c77a411d94bc87f0232588b339149bb29a49.tar.bz2
meta-impy-31e7c77a411d94bc87f0232588b339149bb29a49.tar.xz
Second Life viewer sources 1.21.3-RC
Diffstat (limited to 'linden/indra/llmessage')
-rw-r--r--linden/indra/llmessage/llares.cpp11
-rw-r--r--linden/indra/llmessage/llares.h4
-rw-r--r--linden/indra/llmessage/llhttpclient.cpp4
-rw-r--r--linden/indra/llmessage/llmessagetemplate.h8
-rw-r--r--linden/indra/llmessage/llmessagetemplateparser.cpp4
-rw-r--r--linden/indra/llmessage/lltemplatemessagebuilder.cpp1
-rw-r--r--linden/indra/llmessage/lltemplatemessagereader.cpp6
-rw-r--r--linden/indra/llmessage/lltemplatemessagereader.h3
-rw-r--r--linden/indra/llmessage/llurlrequest.cpp78
-rw-r--r--linden/indra/llmessage/llurlrequest.h5
-rw-r--r--linden/indra/llmessage/message.cpp10
11 files changed, 96 insertions, 38 deletions
diff --git a/linden/indra/llmessage/llares.cpp b/linden/indra/llmessage/llares.cpp
index 5a310b3..7f573d2 100644
--- a/linden/indra/llmessage/llares.cpp
+++ b/linden/indra/llmessage/llares.cpp
@@ -100,9 +100,16 @@ void LLAres::QueryResponder::queryError(int code)
100 << LLAres::strerror(code) << llendl; 100 << LLAres::strerror(code) << llendl;
101} 101}
102 102
103LLAres::LLAres() 103LLAres::LLAres() :
104chan_(NULL), mInitSuccess(false)
104{ 105{
105 ares_init(&chan_); 106 if (ares_init(&chan_) != ARES_SUCCESS)
107 {
108 llwarns << "Could not succesfully initialize ares!" << llendl;
109 return;
110 }
111
112 mInitSuccess = true;
106} 113}
107 114
108LLAres::~LLAres() 115LLAres::~LLAres()
diff --git a/linden/indra/llmessage/llares.h b/linden/indra/llmessage/llares.h
index 5d72170..17f6085 100644
--- a/linden/indra/llmessage/llares.h
+++ b/linden/indra/llmessage/llares.h
@@ -437,9 +437,11 @@ public:
437 */ 437 */
438 static const char *strerror(int code); 438 static const char *strerror(int code);
439 439
440 bool isInitialized(void) { return mInitSuccess; }
441
440protected: 442protected:
441 ares_channel chan_; 443 ares_channel chan_;
442 444 bool mInitSuccess;
443}; 445};
444 446
445/** 447/**
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp
index caeaee1..fc2612f 100644
--- a/linden/indra/llmessage/llhttpclient.cpp
+++ b/linden/indra/llmessage/llhttpclient.cpp
@@ -56,7 +56,7 @@ namespace
56 { 56 {
57 public: 57 public:
58 LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder) 58 LLHTTPClientURLAdaptor(LLCurl::ResponderPtr responder)
59 : mResponder(responder), mStatus(499), 59 : LLURLRequestComplete(), mResponder(responder), mStatus(499),
60 mReason("LLURLRequest complete w/no status") 60 mReason("LLURLRequest complete w/no status")
61 { 61 {
62 } 62 }
@@ -67,6 +67,8 @@ namespace
67 67
68 virtual void httpStatus(U32 status, const std::string& reason) 68 virtual void httpStatus(U32 status, const std::string& reason)
69 { 69 {
70 LLURLRequestComplete::httpStatus(status,reason);
71
70 mStatus = status; 72 mStatus = status;
71 mReason = reason; 73 mReason = reason;
72 } 74 }
diff --git a/linden/indra/llmessage/llmessagetemplate.h b/linden/indra/llmessage/llmessagetemplate.h
index f92c4b7..716c618 100644
--- a/linden/indra/llmessage/llmessagetemplate.h
+++ b/linden/indra/llmessage/llmessagetemplate.h
@@ -265,6 +265,7 @@ enum EMsgDeprecation
265{ 265{
266 MD_NOTDEPRECATED, 266 MD_NOTDEPRECATED,
267 MD_UDPDEPRECATED, 267 MD_UDPDEPRECATED,
268 MD_UDPBLACKLISTED,
268 MD_DEPRECATED 269 MD_DEPRECATED
269}; 270};
270 271
@@ -299,7 +300,7 @@ public:
299 ~LLMessageTemplate() 300 ~LLMessageTemplate()
300 { 301 {
301 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePointer()); 302 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePointer());
302} 303 }
303 304
304 void addBlock(LLMessageBlock *blockp) 305 void addBlock(LLMessageBlock *blockp)
305 { 306 {
@@ -380,6 +381,11 @@ public:
380 return trustedSource ? mBanFromTrusted : mBanFromUntrusted; 381 return trustedSource ? mBanFromTrusted : mBanFromUntrusted;
381 } 382 }
382 383
384 bool isUdpBanned() const
385 {
386 return mDeprecation == MD_UDPBLACKLISTED;
387 }
388
383 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg); 389 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg);
384 390
385 const LLMessageBlock* getBlock(char* name) const 391 const LLMessageBlock* getBlock(char* name) const
diff --git a/linden/indra/llmessage/llmessagetemplateparser.cpp b/linden/indra/llmessage/llmessagetemplateparser.cpp
index d6adba8..9f6eeca 100644
--- a/linden/indra/llmessage/llmessagetemplateparser.cpp
+++ b/linden/indra/llmessage/llmessagetemplateparser.cpp
@@ -525,6 +525,10 @@ LLMessageTemplate * LLTemplateParser::parseMessage(LLTemplateTokenizer & tokens)
525 { 525 {
526 templatep->setDeprecation(MD_UDPDEPRECATED); 526 templatep->setDeprecation(MD_UDPDEPRECATED);
527 } 527 }
528 else if (tokens.want("UDPBlackListed"))
529 {
530 templatep->setDeprecation(MD_UDPBLACKLISTED);
531 }
528 else if (tokens.want("NotDeprecated")) 532 else if (tokens.want("NotDeprecated"))
529 { 533 {
530 // this is the default value, but it can't hurt to set it twice 534 // this is the default value, but it can't hurt to set it twice
diff --git a/linden/indra/llmessage/lltemplatemessagebuilder.cpp b/linden/indra/llmessage/lltemplatemessagebuilder.cpp
index cd06c07..6d3ff8f 100644
--- a/linden/indra/llmessage/lltemplatemessagebuilder.cpp
+++ b/linden/indra/llmessage/lltemplatemessagebuilder.cpp
@@ -60,7 +60,6 @@ LLTemplateMessageBuilder::~LLTemplateMessageBuilder()
60 mCurrentSMessageData = NULL; 60 mCurrentSMessageData = NULL;
61} 61}
62 62
63
64// virtual 63// virtual
65void LLTemplateMessageBuilder::newMessage(const char *name) 64void LLTemplateMessageBuilder::newMessage(const char *name)
66{ 65{
diff --git a/linden/indra/llmessage/lltemplatemessagereader.cpp b/linden/indra/llmessage/lltemplatemessagereader.cpp
index f5da14b..2c457e8 100644
--- a/linden/indra/llmessage/lltemplatemessagereader.cpp
+++ b/linden/indra/llmessage/lltemplatemessagereader.cpp
@@ -791,12 +791,16 @@ bool LLTemplateMessageReader::isTrusted() const
791 return mCurrentRMessageTemplate->getTrust() == MT_TRUST; 791 return mCurrentRMessageTemplate->getTrust() == MT_TRUST;
792} 792}
793 793
794//virtual
795bool LLTemplateMessageReader::isBanned(bool trustedSource) const 794bool LLTemplateMessageReader::isBanned(bool trustedSource) const
796{ 795{
797 return mCurrentRMessageTemplate->isBanned(trustedSource); 796 return mCurrentRMessageTemplate->isBanned(trustedSource);
798} 797}
799 798
799bool LLTemplateMessageReader::isUdpBanned() const
800{
801 return mCurrentRMessageTemplate->isUdpBanned();
802}
803
800//virtual 804//virtual
801void LLTemplateMessageReader::copyToBuilder(LLMessageBuilder& builder) const 805void LLTemplateMessageReader::copyToBuilder(LLMessageBuilder& builder) const
802{ 806{
diff --git a/linden/indra/llmessage/lltemplatemessagereader.h b/linden/indra/llmessage/lltemplatemessagereader.h
index 98f41ae..ff124f3 100644
--- a/linden/indra/llmessage/lltemplatemessagereader.h
+++ b/linden/indra/llmessage/lltemplatemessagereader.h
@@ -109,7 +109,8 @@ public:
109 109
110 bool isTrusted() const; 110 bool isTrusted() const;
111 bool isBanned(bool trusted_source) const; 111 bool isBanned(bool trusted_source) const;
112 112 bool isUdpBanned() const;
113
113private: 114private:
114 115
115 void getData(const char *blockname, const char *varname, void *datap, 116 void getData(const char *blockname, const char *varname, void *datap,
diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp
index 42f3f04..fbd002b 100644
--- a/linden/indra/llmessage/llurlrequest.cpp
+++ b/linden/indra/llmessage/llurlrequest.cpp
@@ -461,58 +461,76 @@ size_t LLURLRequest::upCallback(
461 461
462static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user) 462static size_t headerCallback(void* data, size_t size, size_t nmemb, void* user)
463{ 463{
464 const char* headerLine = (const char*)data; 464 const char* header_line = (const char*)data;
465 size_t headerLen = size * nmemb; 465 size_t header_len = size * nmemb;
466 LLURLRequestComplete* complete = (LLURLRequestComplete*)user; 466 LLURLRequestComplete* complete = (LLURLRequestComplete*)user;
467 467
468 if (!complete || !header_line)
469 {
470 return header_len;
471 }
472
468 // *TODO: This should be a utility in llstring.h: isascii() 473 // *TODO: This should be a utility in llstring.h: isascii()
469 for (size_t i = 0; i < headerLen; ++i) 474 for (size_t i = 0; i < header_len; ++i)
470 { 475 {
471 if (headerLine[i] < 0) 476 if (header_line[i] < 0)
472 { 477 {
473 return headerLen; 478 return header_len;
474 } 479 }
475 } 480 }
476 481
477 size_t sep; 482 std::string header(header_line, header_len);
478 for (sep = 0; sep < headerLen && headerLine[sep] != ':'; ++sep) { }
479
480 if (sep < headerLen && complete)
481 {
482 std::string key(headerLine, sep);
483 std::string value(headerLine + sep + 1, headerLen - sep - 1);
484
485 key = utf8str_tolower(utf8str_trim(key));
486 value = utf8str_trim(value);
487 483
488 complete->header(key, value); 484 // Per HTTP spec the first header line must be the status line.
489 } 485 if (!complete->haveHTTPStatus())
490 else
491 { 486 {
492 std::string s(headerLine, headerLen); 487 std::string::iterator end = header.end();
493 488 std::string::iterator pos1 = std::find(header.begin(), end, ' ');
494 std::string::iterator end = s.end();
495 std::string::iterator pos1 = std::find(s.begin(), end, ' ');
496 if (pos1 != end) ++pos1; 489 if (pos1 != end) ++pos1;
497 std::string::iterator pos2 = std::find(pos1, end, ' '); 490 std::string::iterator pos2 = std::find(pos1, end, ' ');
498 if (pos2 != end) ++pos2; 491 if (pos2 != end) ++pos2;
499 std::string::iterator pos3 = std::find(pos2, end, '\r'); 492 std::string::iterator pos3 = std::find(pos2, end, '\r');
500 493
501 std::string version(s.begin(), pos1); 494 std::string version(header.begin(), pos1);
502 std::string status(pos1, pos2); 495 std::string status(pos1, pos2);
503 std::string reason(pos2, pos3); 496 std::string reason(pos2, pos3);
504 497
505 int statusCode = atoi(status.c_str()); 498 int statusCode = atoi(status.c_str());
506 if (statusCode > 0) 499 if (statusCode > 0)
507 { 500 {
508 if (complete) 501 complete->httpStatus((U32)statusCode, reason);
509 { 502 }
510 complete->httpStatus((U32)statusCode, reason); 503 else
511 } 504 {
505 llwarns << "Unable to parse http response status line: "
506 << header << llendl;
507 complete->httpStatus(499,"Unable to parse status line.");
508 }
509 return header_len;
510 }
511
512 std::string::iterator sep = std::find(header.begin(),header.end(),':');
513
514 if (sep != header.end())
515 {
516 std::string key(header.begin(), sep);
517 std::string value(sep + 1, header.end());
518
519 key = utf8str_tolower(utf8str_trim(key));
520 value = utf8str_trim(value);
521
522 complete->header(key, value);
523 }
524 else
525 {
526 LLStringUtil::trim(header);
527 if (!header.empty())
528 {
529 llwarns << "Unable to parse header: " << header << llendl;
512 } 530 }
513 } 531 }
514 532
515 return headerLen; 533 return header_len;
516} 534}
517 535
518/** 536/**
@@ -553,7 +571,8 @@ LLIOPipe::EStatus LLContextURLExtractor::process_impl(
553 * LLURLRequestComplete 571 * LLURLRequestComplete
554 */ 572 */
555LLURLRequestComplete::LLURLRequestComplete() : 573LLURLRequestComplete::LLURLRequestComplete() :
556 mRequestStatus(LLIOPipe::STATUS_ERROR) 574 mRequestStatus(LLIOPipe::STATUS_ERROR),
575 mHaveHTTPStatus(false)
557{ 576{
558 LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST); 577 LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
559} 578}
@@ -572,6 +591,7 @@ void LLURLRequestComplete::header(const std::string& header, const std::string&
572//virtual 591//virtual
573void LLURLRequestComplete::httpStatus(U32 status, const std::string& reason) 592void LLURLRequestComplete::httpStatus(U32 status, const std::string& reason)
574{ 593{
594 mHaveHTTPStatus = true;
575} 595}
576 596
577//virtual 597//virtual
diff --git a/linden/indra/llmessage/llurlrequest.h b/linden/indra/llmessage/llurlrequest.h
index 888b962..f965dad 100644
--- a/linden/indra/llmessage/llurlrequest.h
+++ b/linden/indra/llmessage/llurlrequest.h
@@ -327,6 +327,9 @@ public:
327 LLURLRequestComplete(); 327 LLURLRequestComplete();
328 virtual ~LLURLRequestComplete(); 328 virtual ~LLURLRequestComplete();
329 329
330 // The first line of an http response must be the status line
331 // true if we have already parsed this line.
332 bool haveHTTPStatus() const { return mHaveHTTPStatus; }
330protected: 333protected:
331 /* @name LLIOPipe virtual implementations 334 /* @name LLIOPipe virtual implementations
332 */ 335 */
@@ -345,6 +348,8 @@ protected:
345 // value to note if we actually got the response. This value 348 // value to note if we actually got the response. This value
346 // depends on correct useage from the LLURLRequest instance. 349 // depends on correct useage from the LLURLRequest instance.
347 EStatus mRequestStatus; 350 EStatus mRequestStatus;
351
352 bool mHaveHTTPStatus;
348}; 353};
349 354
350 355
diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp
index 27f9d12..b20731a 100644
--- a/linden/indra/llmessage/message.cpp
+++ b/linden/indra/llmessage/message.cpp
@@ -754,11 +754,19 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
754 clearReceiveState(); 754 clearReceiveState();
755 valid_packet = FALSE; 755 valid_packet = FALSE;
756 } 756 }
757
758 if( valid_packet && mTemplateMessageReader->isUdpBanned())
759 {
760 llwarns << "Received UDP black listed message "
761 << mTemplateMessageReader->getMessageName()
762 << " from " << host << llendl;
763 clearReceiveState();
764 valid_packet = FALSE;
765 }
757 766
758 if( valid_packet ) 767 if( valid_packet )
759 { 768 {
760 logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) ); 769 logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) );
761
762 valid_packet = mTemplateMessageReader->readMessage(buffer, host); 770 valid_packet = mTemplateMessageReader->readMessage(buffer, host);
763 } 771 }
764 772