aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:54 -0500
committerJacek Antonelli2008-08-15 23:44:54 -0500
commitb2afb8800bb033a04bb3ecdf0363068d56648ef1 (patch)
tree3568129b5bbddb47cd39d622b4137a8fbff4abaf /linden/indra/llmessage
parentSecond Life viewer sources 1.14.0.1 (diff)
downloadmeta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.zip
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.gz
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.bz2
meta-impy-b2afb8800bb033a04bb3ecdf0363068d56648ef1.tar.xz
Second Life viewer sources 1.15.0.2
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/files.lst11
-rw-r--r--linden/indra/llmessage/llassetstorage.cpp16
-rw-r--r--linden/indra/llmessage/llassetstorage.h1
-rw-r--r--linden/indra/llmessage/llblowfishcipher.cpp49
-rw-r--r--linden/indra/llmessage/llblowfishcipher.h1
-rw-r--r--linden/indra/llmessage/llbuffer.cpp121
-rw-r--r--linden/indra/llmessage/llbuffer.h91
-rw-r--r--linden/indra/llmessage/llbufferstream.cpp96
-rw-r--r--linden/indra/llmessage/llbufferstream.h1
-rw-r--r--linden/indra/llmessage/llcachename.cpp1
-rw-r--r--linden/indra/llmessage/llcachename.h1
-rw-r--r--linden/indra/llmessage/llcallbacklisth.h1
-rw-r--r--linden/indra/llmessage/llchainio.cpp1
-rw-r--r--linden/indra/llmessage/llchainio.h1
-rw-r--r--linden/indra/llmessage/llcipher.h1
-rw-r--r--linden/indra/llmessage/llcircuit.cpp1
-rw-r--r--linden/indra/llmessage/llcircuit.h1
-rw-r--r--linden/indra/llmessage/llclassifiedflags.cpp1
-rw-r--r--linden/indra/llmessage/llclassifiedflags.h3
-rw-r--r--linden/indra/llmessage/lldatapacker.cpp221
-rw-r--r--linden/indra/llmessage/lldatapacker.h1
-rw-r--r--linden/indra/llmessage/lldbstrings.h1
-rw-r--r--linden/indra/llmessage/lldispatcher.cpp1
-rw-r--r--linden/indra/llmessage/lldispatcher.h1
-rw-r--r--linden/indra/llmessage/lleventflags.h1
-rw-r--r--linden/indra/llmessage/llfiltersd2xmlrpc.cpp1
-rw-r--r--linden/indra/llmessage/llfiltersd2xmlrpc.h1
-rw-r--r--linden/indra/llmessage/llfollowcamparams.h1
-rw-r--r--linden/indra/llmessage/llhost.cpp7
-rw-r--r--linden/indra/llmessage/llhost.h1
-rw-r--r--linden/indra/llmessage/llhttpassetstorage.cpp51
-rw-r--r--linden/indra/llmessage/llhttpassetstorage.h1
-rw-r--r--linden/indra/llmessage/llhttpclient.cpp65
-rw-r--r--linden/indra/llmessage/llhttpclient.h17
-rw-r--r--linden/indra/llmessage/llhttpnode.cpp1
-rw-r--r--linden/indra/llmessage/llhttpnode.h1
-rw-r--r--linden/indra/llmessage/llhttpsender.cpp90
-rw-r--r--linden/indra/llmessage/llhttpsender.h58
-rw-r--r--linden/indra/llmessage/llinstantmessage.cpp48
-rw-r--r--linden/indra/llmessage/llinstantmessage.h18
-rw-r--r--linden/indra/llmessage/llinvite.h1
-rw-r--r--linden/indra/llmessage/lliobuffer.cpp1
-rw-r--r--linden/indra/llmessage/lliobuffer.h1
-rw-r--r--linden/indra/llmessage/lliohttpserver.cpp27
-rw-r--r--linden/indra/llmessage/lliohttpserver.h4
-rw-r--r--linden/indra/llmessage/lliopipe.cpp1
-rw-r--r--linden/indra/llmessage/lliopipe.h3
-rw-r--r--linden/indra/llmessage/lliosocket.cpp14
-rw-r--r--linden/indra/llmessage/lliosocket.h1
-rw-r--r--linden/indra/llmessage/llioutil.cpp1
-rw-r--r--linden/indra/llmessage/llioutil.h1
-rw-r--r--linden/indra/llmessage/llloginflags.h1
-rw-r--r--linden/indra/llmessage/lllogtextmessage.cpp1
-rw-r--r--linden/indra/llmessage/lllogtextmessage.h1
-rw-r--r--linden/indra/llmessage/llmail.cpp1
-rw-r--r--linden/indra/llmessage/llmail.h1
-rw-r--r--linden/indra/llmessage/llmessage.vcproj52
-rw-r--r--linden/indra/llmessage/llmessagebuilder.cpp (renamed from linden/indra/newview/llviewerreputation.h)24
-rw-r--r--linden/indra/llmessage/llmessagebuilder.h70
-rw-r--r--linden/indra/llmessage/llmessageconfig.cpp230
-rw-r--r--linden/indra/llmessage/llmessageconfig.h51
-rw-r--r--linden/indra/llmessage/llmessagereader.cpp35
-rw-r--r--linden/indra/llmessage/llmessagereader.h59
-rw-r--r--linden/indra/llmessage/llmessagetemplate.cpp146
-rw-r--r--linden/indra/llmessage/llmessagetemplate.h356
-rw-r--r--linden/indra/llmessage/llmessagethrottle.cpp1
-rw-r--r--linden/indra/llmessage/llmessagethrottle.h1
-rw-r--r--linden/indra/llmessage/llmime.cpp1
-rw-r--r--linden/indra/llmessage/llmime.h1
-rw-r--r--linden/indra/llmessage/llmsgvariabletype.h33
-rw-r--r--linden/indra/llmessage/llnamevalue.cpp1
-rw-r--r--linden/indra/llmessage/llnamevalue.h1
-rw-r--r--linden/indra/llmessage/llnullcipher.cpp1
-rw-r--r--linden/indra/llmessage/llnullcipher.h1
-rw-r--r--linden/indra/llmessage/llpacketack.h19
-rw-r--r--linden/indra/llmessage/llpacketbuffer.cpp1
-rw-r--r--linden/indra/llmessage/llpacketbuffer.h1
-rw-r--r--linden/indra/llmessage/llpacketring.cpp1
-rw-r--r--linden/indra/llmessage/llpacketring.h1
-rw-r--r--linden/indra/llmessage/llpartdata.cpp1
-rw-r--r--linden/indra/llmessage/llpartdata.h1
-rw-r--r--linden/indra/llmessage/llpumpio.cpp9
-rw-r--r--linden/indra/llmessage/llpumpio.h2
-rw-r--r--linden/indra/llmessage/llqueryflags.h4
-rw-r--r--linden/indra/llmessage/llregionflags.h1
-rw-r--r--linden/indra/llmessage/llregionhandle.h1
-rw-r--r--linden/indra/llmessage/llsdappservices.cpp1
-rw-r--r--linden/indra/llmessage/llsdappservices.h1
-rw-r--r--linden/indra/llmessage/llsdhttpserver.cpp1
-rw-r--r--linden/indra/llmessage/llsdhttpserver.h1
-rwxr-xr-xlinden/indra/llmessage/llsdmessagebuilder.cpp281
-rwxr-xr-xlinden/indra/llmessage/llsdmessagebuilder.h98
-rwxr-xr-xlinden/indra/llmessage/llsdmessagereader.cpp264
-rwxr-xr-xlinden/indra/llmessage/llsdmessagereader.h79
-rw-r--r--linden/indra/llmessage/llsdmessagesystem.cpp176
-rw-r--r--linden/indra/llmessage/llsdmessagesystem.h73
-rw-r--r--linden/indra/llmessage/llsdrpcclient.cpp1
-rw-r--r--linden/indra/llmessage/llsdrpcclient.h1
-rw-r--r--linden/indra/llmessage/llsdrpcserver.cpp1
-rw-r--r--linden/indra/llmessage/llsdrpcserver.h1
-rw-r--r--linden/indra/llmessage/llservice.cpp1
-rw-r--r--linden/indra/llmessage/llservice.h3
-rw-r--r--linden/indra/llmessage/llservicebuilder.cpp135
-rw-r--r--linden/indra/llmessage/llservicebuilder.h93
-rw-r--r--linden/indra/llmessage/lltaskname.h1
-rw-r--r--linden/indra/llmessage/llteleportflags.h1
-rw-r--r--linden/indra/llmessage/lltemplatemessagebuilder.cpp856
-rw-r--r--linden/indra/llmessage/lltemplatemessagebuilder.h88
-rw-r--r--linden/indra/llmessage/lltemplatemessagereader.cpp750
-rw-r--r--linden/indra/llmessage/lltemplatemessagereader.h98
-rw-r--r--linden/indra/llmessage/llthrottle.cpp1
-rw-r--r--linden/indra/llmessage/llthrottle.h1
-rw-r--r--linden/indra/llmessage/lltransfermanager.cpp1
-rw-r--r--linden/indra/llmessage/lltransfermanager.h1
-rw-r--r--linden/indra/llmessage/lltransfersourceasset.cpp1
-rw-r--r--linden/indra/llmessage/lltransfersourceasset.h1
-rw-r--r--linden/indra/llmessage/lltransfersourcefile.cpp1
-rw-r--r--linden/indra/llmessage/lltransfersourcefile.h1
-rw-r--r--linden/indra/llmessage/lltransfertargetfile.cpp1
-rw-r--r--linden/indra/llmessage/lltransfertargetfile.h1
-rw-r--r--linden/indra/llmessage/lltransfertargetvfile.cpp1
-rw-r--r--linden/indra/llmessage/lltransfertargetvfile.h1
-rw-r--r--linden/indra/llmessage/llurlrequest.cpp1
-rw-r--r--linden/indra/llmessage/llurlrequest.h1
-rw-r--r--linden/indra/llmessage/lluseroperation.cpp1
-rw-r--r--linden/indra/llmessage/lluseroperation.h1
-rw-r--r--linden/indra/llmessage/llvehicleparams.h1
-rw-r--r--linden/indra/llmessage/llxfer.cpp1
-rw-r--r--linden/indra/llmessage/llxfer.h1
-rw-r--r--linden/indra/llmessage/llxfer_file.cpp3
-rw-r--r--linden/indra/llmessage/llxfer_file.h1
-rw-r--r--linden/indra/llmessage/llxfer_mem.cpp1
-rw-r--r--linden/indra/llmessage/llxfer_mem.h1
-rw-r--r--linden/indra/llmessage/llxfer_vfile.cpp1
-rw-r--r--linden/indra/llmessage/llxfer_vfile.h1
-rw-r--r--linden/indra/llmessage/llxfermanager.cpp1
-rw-r--r--linden/indra/llmessage/llxfermanager.h1
-rw-r--r--linden/indra/llmessage/llxorcipher.cpp1
-rw-r--r--linden/indra/llmessage/llxorcipher.h1
-rw-r--r--linden/indra/llmessage/machine.h1
-rw-r--r--linden/indra/llmessage/mean_collision_data.h1
-rw-r--r--linden/indra/llmessage/message.cpp3169
-rw-r--r--linden/indra/llmessage/message.h571
-rw-r--r--linden/indra/llmessage/message_prehash.cpp45
-rw-r--r--linden/indra/llmessage/message_prehash.h23
-rw-r--r--linden/indra/llmessage/message_string_table.cpp1
-rw-r--r--linden/indra/llmessage/net.cpp7
-rw-r--r--linden/indra/llmessage/net.h1
-rw-r--r--linden/indra/llmessage/network.cpp1
-rw-r--r--linden/indra/llmessage/network.h1
-rw-r--r--linden/indra/llmessage/partsyspacket.cpp1
-rw-r--r--linden/indra/llmessage/partsyspacket.h1
-rw-r--r--linden/indra/llmessage/patch_code.cpp1
-rw-r--r--linden/indra/llmessage/patch_code.h1
-rw-r--r--linden/indra/llmessage/patch_dct.cpp1
-rw-r--r--linden/indra/llmessage/patch_dct.h1
-rw-r--r--linden/indra/llmessage/patch_idct.cpp1
-rw-r--r--linden/indra/llmessage/sound_ids.h1
158 files changed, 5907 insertions, 3110 deletions
diff --git a/linden/indra/llmessage/files.lst b/linden/indra/llmessage/files.lst
index 2ff3771..456dffe 100644
--- a/linden/indra/llmessage/files.lst
+++ b/linden/indra/llmessage/files.lst
@@ -14,6 +14,7 @@ llmessage/llhost.cpp
14llmessage/llhttpassetstorage.cpp 14llmessage/llhttpassetstorage.cpp
15llmessage/llhttpclient.cpp 15llmessage/llhttpclient.cpp
16llmessage/llhttpnode.cpp 16llmessage/llhttpnode.cpp
17llmessage/llhttpsender.cpp
17llmessage/llinstantmessage.cpp 18llmessage/llinstantmessage.cpp
18llmessage/lliobuffer.cpp 19llmessage/lliobuffer.cpp
19llmessage/lliohttpserver.cpp 20llmessage/lliohttpserver.cpp
@@ -22,6 +23,10 @@ llmessage/lliosocket.cpp
22llmessage/llioutil.cpp 23llmessage/llioutil.cpp
23llmessage/lllogtextmessage.cpp 24llmessage/lllogtextmessage.cpp
24llmessage/llmail.cpp 25llmessage/llmail.cpp
26llmessage/llmessagebuilder.cpp
27llmessage/llmessageconfig.cpp
28llmessage/llmessagereader.cpp
29llmessage/llmessagetemplate.cpp
25llmessage/llmessagethrottle.cpp 30llmessage/llmessagethrottle.cpp
26llmessage/llmime.cpp 31llmessage/llmime.cpp
27llmessage/llnamevalue.cpp 32llmessage/llnamevalue.cpp
@@ -32,10 +37,14 @@ llmessage/llpartdata.cpp
32llmessage/llpumpio.cpp 37llmessage/llpumpio.cpp
33llmessage/llsdappservices.cpp 38llmessage/llsdappservices.cpp
34llmessage/llsdhttpserver.cpp 39llmessage/llsdhttpserver.cpp
35llmessage/llsdmessagesystem.cpp 40llmessage/llsdmessagereader.cpp
41llmessage/llsdmessagebuilder.cpp
36llmessage/llsdrpcclient.cpp 42llmessage/llsdrpcclient.cpp
37llmessage/llsdrpcserver.cpp 43llmessage/llsdrpcserver.cpp
38llmessage/llservice.cpp 44llmessage/llservice.cpp
45llmessage/llservicebuilder.cpp
46llmessage/lltemplatemessagebuilder.cpp
47llmessage/lltemplatemessagereader.cpp
39llmessage/llthrottle.cpp 48llmessage/llthrottle.cpp
40llmessage/lltransfermanager.cpp 49llmessage/lltransfermanager.cpp
41llmessage/lltransfersourceasset.cpp 50llmessage/lltransfersourceasset.cpp
diff --git a/linden/indra/llmessage/llassetstorage.cpp b/linden/indra/llmessage/llassetstorage.cpp
index a8cd0e5..4f4fc0c 100644
--- a/linden/indra/llmessage/llassetstorage.cpp
+++ b/linden/indra/llmessage/llassetstorage.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -434,20 +435,21 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo
434 if (callback == tmp->mDownCallback && user_data == tmp->mUserData) 435 if (callback == tmp->mDownCallback && user_data == tmp->mUserData)
435 { 436 {
436 // this is a duplicate from the same subsystem - throw it away 437 // this is a duplicate from the same subsystem - throw it away
437 llinfos << "Discarding duplicate request for UUID " << uuid << llendl; 438 llwarns << "Discarding duplicate request for asset " << uuid
439 << "." << LLAssetType::lookup(type) << llendl;
438 return; 440 return;
439 } 441 }
440 else
441 {
442 llinfos << "Adding additional non-duplicate request for UUID " << uuid << llendl;
443 }
444 442
445 // this is a duplicate request 443 // this is a duplicate request
446 // queue the request, but don't actually ask for it again 444 // queue the request, but don't actually ask for it again
447 duplicate = TRUE; 445 duplicate = TRUE;
448 break;
449 } 446 }
450 } 447 }
448 if (duplicate)
449 {
450 llinfos << "Adding additional non-duplicate request for asset " << uuid
451 << "." << LLAssetType::lookup(type) << llendl;
452 }
451 453
452 // This can be overridden by subclasses 454 // This can be overridden by subclasses
453 _queueDataRequest(uuid, type, callback, user_data, duplicate, is_priority); 455 _queueDataRequest(uuid, type, callback, user_data, duplicate, is_priority);
@@ -1272,7 +1274,7 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss
1272 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */ 1274 char uuid_str[UUID_STR_LENGTH]; /* Flawfinder: ignore */
1273 1275
1274 uuid.toString(uuid_str); 1276 uuid.toString(uuid_str);
1275 snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ 1277 snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */
1276 1278
1277 FILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ 1279 FILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */
1278 if (fp) 1280 if (fp)
diff --git a/linden/indra/llmessage/llassetstorage.h b/linden/indra/llmessage/llassetstorage.h
index 639ab59..3c7a709 100644
--- a/linden/indra/llmessage/llassetstorage.h
+++ b/linden/indra/llmessage/llassetstorage.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llblowfishcipher.cpp b/linden/indra/llmessage/llblowfishcipher.cpp
index f9a68ab..1772078 100644
--- a/linden/indra/llmessage/llblowfishcipher.cpp
+++ b/linden/indra/llmessage/llblowfishcipher.cpp
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright (c) 2007-2007, Linden Research, Inc. 8 * Copyright (c) 2007-2007, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0 12 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -84,27 +85,33 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
84 << " iv_len " << iv_length 85 << " iv_len " << iv_length
85 << llendl; 86 << llendl;
86 87
87 int output_len = 0; 88 int output_len = 0;
88 if (!EVP_EncryptUpdate(&context, 89 int temp_len = 0;
89 dst, 90 if (!EVP_EncryptUpdate(&context,
90 &output_len, 91 dst,
91 src, 92 &output_len,
92 src_len)) 93 src,
93 { 94 src_len))
94 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl; 95 {
95 return 0; 96 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl;
96 } 97 goto ERROR;
97 98 }
98 // There may be some final data left to encrypt if the input is 99
99 // not an exact multiple of the block size. 100 // There may be some final data left to encrypt if the input is
100 int temp_len = 0; 101 // not an exact multiple of the block size.
101 if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len)) 102 if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
102 { 103 {
103 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl; 104 llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl;
104 return 0; 105 goto ERROR;
105 } 106 }
106 output_len += temp_len; 107 output_len += temp_len;
107 return output_len; 108
109 EVP_CIPHER_CTX_cleanup(&context);
110 return output_len;
111
112ERROR:
113 EVP_CIPHER_CTX_cleanup(&context);
114 return 0;
108} 115}
109 116
110// virtual 117// virtual
diff --git a/linden/indra/llmessage/llblowfishcipher.h b/linden/indra/llmessage/llblowfishcipher.h
index 2557598..0ba1473 100644
--- a/linden/indra/llmessage/llblowfishcipher.h
+++ b/linden/indra/llmessage/llblowfishcipher.h
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright (c) 2007-2007, Linden Research, Inc. 8 * Copyright (c) 2007-2007, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0 12 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llbuffer.cpp b/linden/indra/llmessage/llbuffer.cpp
index 3dd34a0..ad822bc 100644
--- a/linden/indra/llmessage/llbuffer.cpp
+++ b/linden/indra/llmessage/llbuffer.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -84,24 +85,44 @@ S32 LLSegment::size() const
84 return mSize; 85 return mSize;
85} 86}
86 87
88bool LLSegment::operator==(const LLSegment& rhs) const
89{
90 if((mData != rhs.mData)||(mSize != rhs.mSize)||(mChannel != rhs.mChannel))
91 {
92 return false;
93 }
94 return true;
95}
87 96
88/** 97/**
89 * LLHeapBuffer 98 * LLHeapBuffer
90 */ 99 */
91LLHeapBuffer::LLHeapBuffer() 100LLHeapBuffer::LLHeapBuffer() :
101 mBuffer(NULL),
102 mSize(0),
103 mNextFree(NULL),
104 mReclaimedBytes(0)
92{ 105{
93 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 106 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
94 const S32 DEFAULT_HEAP_BUFFER_SIZE = 16384; 107 const S32 DEFAULT_HEAP_BUFFER_SIZE = 16384;
95 allocate(DEFAULT_HEAP_BUFFER_SIZE); 108 allocate(DEFAULT_HEAP_BUFFER_SIZE);
96} 109}
97 110
98LLHeapBuffer::LLHeapBuffer(S32 size) 111LLHeapBuffer::LLHeapBuffer(S32 size) :
112 mBuffer(NULL),
113 mSize(0),
114 mNextFree(NULL),
115 mReclaimedBytes(0)
99{ 116{
100 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 117 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
101 allocate(size); 118 allocate(size);
102} 119}
103 120
104LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) 121LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) :
122 mBuffer(NULL),
123 mSize(0),
124 mNextFree(NULL),
125 mReclaimedBytes(0)
105{ 126{
106 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 127 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
107 if((len > 0) && src) 128 if((len > 0) && src)
@@ -112,12 +133,6 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len)
112 memcpy(mBuffer, src, len); /*Flawfinder: ignore*/ 133 memcpy(mBuffer, src, len); /*Flawfinder: ignore*/
113 } 134 }
114 } 135 }
115 else
116 {
117 mBuffer = NULL;
118 mSize = 0;
119 mNextFree = NULL;
120 }
121} 136}
122 137
123// virtual 138// virtual
@@ -130,11 +145,10 @@ LLHeapBuffer::~LLHeapBuffer()
130 mNextFree = NULL; 145 mNextFree = NULL;
131} 146}
132 147
133// virtual 148S32 LLHeapBuffer::bytesLeft() const
134//S32 LLHeapBuffer::bytesLeft() const 149{
135//{ 150 return (mSize - (mNextFree - mBuffer));
136// return (mSize - (mNextFree - mBuffer)); 151}
137//}
138 152
139// virtual 153// virtual
140bool LLHeapBuffer::createSegment( 154bool LLHeapBuffer::createSegment(
@@ -158,9 +172,47 @@ bool LLHeapBuffer::createSegment(
158 return true; 172 return true;
159} 173}
160 174
175// virtual
176bool LLHeapBuffer::reclaimSegment(const LLSegment& segment)
177{
178 if(containsSegment(segment))
179 {
180 mReclaimedBytes += segment.size();
181 if(mReclaimedBytes == mSize)
182 {
183 // We have reclaimed all of the memory from this
184 // buffer. Therefore, we can reset the mNextFree to the
185 // start of the buffer, and reset the reclaimed bytes.
186 mReclaimedBytes = 0;
187 mNextFree = mBuffer;
188 }
189 else if(mReclaimedBytes > mSize)
190 {
191 llwarns << "LLHeapBuffer reclaimed more memory than allocated."
192 << " This is probably programmer error." << llendl;
193 }
194 return true;
195 }
196 return false;
197}
198
199// virtual
200bool LLHeapBuffer::containsSegment(const LLSegment& segment) const
201{
202 // *NOTE: this check is fairly simple because heap buffers are
203 // simple contiguous chunks of heap memory.
204 if((mBuffer > segment.data())
205 || ((mBuffer + mSize) < (segment.data() + segment.size())))
206 {
207 return false;
208 }
209 return true;
210}
211
161void LLHeapBuffer::allocate(S32 size) 212void LLHeapBuffer::allocate(S32 size)
162{ 213{
163 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 214 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
215 mReclaimedBytes = 0;
164 mBuffer = new U8[size]; 216 mBuffer = new U8[size];
165 if(mBuffer) 217 if(mBuffer)
166 { 218 {
@@ -199,6 +251,18 @@ LLChannelDescriptors LLBufferArray::nextChannel()
199 return rv; 251 return rv;
200} 252}
201 253
254S32 LLBufferArray::capacity() const
255{
256 S32 total = 0;
257 const_buffer_iterator_t iter = mBuffers.begin();
258 const_buffer_iterator_t end = mBuffers.end();
259 for(; iter != end; ++iter)
260 {
261 total += (*iter)->capacity();
262 }
263 return total;
264}
265
202bool LLBufferArray::append(S32 channel, const U8* src, S32 len) 266bool LLBufferArray::append(S32 channel, const U8* src, S32 len)
203{ 267{
204 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 268 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
@@ -703,14 +767,31 @@ LLBufferArray::segment_iterator_t LLBufferArray::makeSegment(
703 return send; 767 return send;
704} 768}
705 769
706bool LLBufferArray::eraseSegment(const segment_iterator_t& iter) 770bool LLBufferArray::eraseSegment(const segment_iterator_t& erase_iter)
707{ 771{
708 LLMemType m1(LLMemType::MTYPE_IO_BUFFER); 772 LLMemType m1(LLMemType::MTYPE_IO_BUFFER);
709 // *FIX: in theory, we could reclaim the memory. We are leaking a 773
710 // bit of buffered memory into an unusable but still referenced 774 // Find out which buffer contains the segment, and if it is found,
711 // location. 775 // ask it to reclaim the memory.
712 (void)mSegments.erase(iter); 776 bool rv = false;
713 return true; 777 LLSegment segment(*erase_iter);
778 buffer_iterator_t iter = mBuffers.begin();
779 buffer_iterator_t end = mBuffers.end();
780 for(; iter != end; ++iter)
781 {
782 // We can safely call reclaimSegment on every buffer, and once
783 // it returns true, the segment was found.
784 if((*iter)->reclaimSegment(segment))
785 {
786 rv = true;
787 break;
788 }
789 }
790
791 // No need to get the return value since we are not interested in
792 // the interator retured by the call.
793 (void)mSegments.erase(erase_iter);
794 return rv;
714} 795}
715 796
716 797
diff --git a/linden/indra/llmessage/llbuffer.h b/linden/indra/llmessage/llbuffer.h
index cd76c90..badbc9f 100644
--- a/linden/indra/llmessage/llbuffer.h
+++ b/linden/indra/llmessage/llbuffer.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -32,7 +33,7 @@
32 33
33/** 34/**
34 * Declaration of classes used for minimizing calls to new[], 35 * Declaration of classes used for minimizing calls to new[],
35 * memcpy(), and delete[]. Typically, you would create an LLHeapArray, 36 * memcpy(), and delete[]. Typically, you would create an LLBufferArray,
36 * feed it data, modify and add segments as you process it, and feed 37 * feed it data, modify and add segments as you process it, and feed
37 * it to a sink. 38 * it to a sink.
38 */ 39 */
@@ -108,6 +109,16 @@ public:
108 */ 109 */
109 S32 size() const; 110 S32 size() const;
110 111
112 /**
113 * @brief Check if two segments are the same.
114 *
115 * Two segments are considered equal if they are on the same
116 * channel and cover the exact same address range.
117 * @param rhs the segment to compare with this segment.
118 * @return Returns true if they are equal.
119 */
120 bool operator==(const LLSegment& rhs) const;
121
111protected: 122protected:
112 S32 mChannel; 123 S32 mChannel;
113 U8* mData; 124 U8* mData;
@@ -145,6 +156,35 @@ public:
145 * @return Returns true if a segment was found. 156 * @return Returns true if a segment was found.
146 */ 157 */
147 virtual bool createSegment(S32 channel, S32 size, LLSegment& segment) = 0; 158 virtual bool createSegment(S32 channel, S32 size, LLSegment& segment) = 0;
159
160 /**
161 * @brief Reclaim a segment from this buffer.
162 *
163 * This method is called on a buffer object when a caller is done
164 * with a contiguous segment of memory inside this buffer. Since
165 * segments can be cut arbitrarily outside of the control of the
166 * buffer, this segment may not match any segment returned from
167 * <code>createSegment()</code>.
168 * @param segment The contiguous buffer segment to reclaim.
169 * @return Returns true if the call was successful.
170 */
171 virtual bool reclaimSegment(const LLSegment& segment) = 0;
172
173 /**
174 * @brief Test if a segment is inside this buffer.
175 *
176 * @param segment The contiguous buffer segment to test.
177 * @return Returns true if the segment is in the bufffer.
178 */
179 virtual bool containsSegment(const LLSegment& segment) const = 0;
180
181 /**
182 * @brief Return the current number of bytes allocated.
183 *
184 * This was implemented as a debugging tool, and it is not
185 * necessarily a good idea to use it for anything else.
186 */
187 virtual S32 capacity() const = 0;
148}; 188};
149 189
150/** 190/**
@@ -186,9 +226,11 @@ public:
186 /** 226 /**
187 * @brief Get the number of bytes left in the buffer. 227 * @brief Get the number of bytes left in the buffer.
188 * 228 *
229 * Note that this is not a virtual function, and only available in
230 * the LLHeapBuffer as a debugging aid.
189 * @return Returns the number of bytes left. 231 * @return Returns the number of bytes left.
190 */ 232 */
191 //virtual S32 bytesLeft() const; 233 S32 bytesLeft() const;
192 234
193 /** 235 /**
194 * @brief Generate a segment for this buffer. 236 * @brief Generate a segment for this buffer.
@@ -205,10 +247,40 @@ public:
205 */ 247 */
206 virtual bool createSegment(S32 channel, S32 size, LLSegment& segment); 248 virtual bool createSegment(S32 channel, S32 size, LLSegment& segment);
207 249
250 /**
251 * @brief reclaim a segment from this buffer.
252 *
253 * This method is called on a buffer object when a caller is done
254 * with a contiguous segment of memory inside this buffer. Since
255 * segments can be cut arbitrarily outside of the control of the
256 * buffer, this segment may not match any segment returned from
257 * <code>createSegment()</code>.
258 * This call will fail if the segment passed in is note completely
259 * inside the buffer, eg, if the segment starts before this buffer
260 * in memory or ends after it.
261 * @param segment The contiguous buffer segment to reclaim.
262 * @return Returns true if the call was successful.
263 */
264 virtual bool reclaimSegment(const LLSegment& segment);
265
266 /**
267 * @brief Test if a segment is inside this buffer.
268 *
269 * @param segment The contiguous buffer segment to test.
270 * @return Returns true if the segment is in the bufffer.
271 */
272 virtual bool containsSegment(const LLSegment& segment) const;
273
274 /**
275 * @brief Return the current number of bytes allocated.
276 */
277 virtual S32 capacity() const { return mSize; }
278
208protected: 279protected:
209 U8* mBuffer; 280 U8* mBuffer;
210 S32 mSize; 281 S32 mSize;
211 U8* mNextFree; 282 U8* mNextFree;
283 S32 mReclaimedBytes;
212 284
213private: 285private:
214 /** 286 /**
@@ -223,13 +295,14 @@ private:
223 * @brief Class to represent scattered memory buffers and in-order segments 295 * @brief Class to represent scattered memory buffers and in-order segments
224 * of that buffered data. 296 * of that buffered data.
225 * 297 *
226 * NOTE: This class needs to have an iovec interface 298 * *NOTE: This class needs to have an iovec interface
227 */ 299 */
228class LLBufferArray 300class LLBufferArray
229{ 301{
230public: 302public:
231 typedef std::vector<LLBuffer*> buffer_list_t; 303 typedef std::vector<LLBuffer*> buffer_list_t;
232 typedef buffer_list_t::iterator buffer_iterator_t; 304 typedef buffer_list_t::iterator buffer_iterator_t;
305 typedef buffer_list_t::const_iterator const_buffer_iterator_t;
233 typedef std::list<LLSegment> segment_list_t; 306 typedef std::list<LLSegment> segment_list_t;
234 typedef segment_list_t::const_iterator const_segment_iterator_t; 307 typedef segment_list_t::const_iterator const_segment_iterator_t;
235 typedef segment_list_t::iterator segment_iterator_t; 308 typedef segment_list_t::iterator segment_iterator_t;
@@ -260,11 +333,16 @@ public:
260 */ 333 */
261 LLChannelDescriptors nextChannel(); 334 LLChannelDescriptors nextChannel();
262 //@} 335 //@}
263 336
264 /* @name Data methods 337 /* @name Data methods
265 */ 338 */
266 //@{ 339 //@{
267 340
341 /**
342 * @brief Return the sum of all allocated bytes.
343 */
344 S32 capacity() const;
345
268 // These methods will be useful once there is any kind of buffer 346 // These methods will be useful once there is any kind of buffer
269 // besides a heap buffer. 347 // besides a heap buffer.
270 //bool append(EBufferChannel channel, LLBuffer* data); 348 //bool append(EBufferChannel channel, LLBuffer* data);
@@ -294,7 +372,6 @@ public:
294 * new segment is created and put in the front of the array. This 372 * new segment is created and put in the front of the array. This
295 * object will internally allocate new buffers if necessary. 373 * object will internally allocate new buffers if necessary.
296 * @param channel The channel for this data 374 * @param channel The channel for this data
297
298 * @param src The start of memory for the data to be copied 375 * @param src The start of memory for the data to be copied
299 * @param len The number of bytes of data to copy 376 * @param len The number of bytes of data to copy
300 * @return Returns true if the method worked. 377 * @return Returns true if the method worked.
@@ -378,7 +455,7 @@ public:
378 bool takeContents(LLBufferArray& source); 455 bool takeContents(LLBufferArray& source);
379 //@} 456 //@}
380 457
381 /* @name Segment methods 458 /* @name Segment methods
382 */ 459 */
383 //@{ 460 //@{
384 /** 461 /**
@@ -468,7 +545,7 @@ public:
468 * endSegment() on failure. 545 * endSegment() on failure.
469 */ 546 */
470 segment_iterator_t makeSegment(S32 channel, S32 length); 547 segment_iterator_t makeSegment(S32 channel, S32 length);
471 548
472 /** 549 /**
473 * @brief Erase the segment if it is in the buffer array. 550 * @brief Erase the segment if it is in the buffer array.
474 * 551 *
diff --git a/linden/indra/llmessage/llbufferstream.cpp b/linden/indra/llmessage/llbufferstream.cpp
index 7d899d6..4a4d892 100644
--- a/linden/indra/llmessage/llbufferstream.cpp
+++ b/linden/indra/llmessage/llbufferstream.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -62,34 +63,64 @@ int LLBufferStreamBuf::underflow()
62 { 63 {
63 return EOF; 64 return EOF;
64 } 65 }
65 LLSegment segment;
66 LLBufferArray::segment_iterator_t it;
67 U8* last_pos = (U8*)gptr();
68 if(last_pos) --last_pos;
69
70 LLBufferArray::segment_iterator_t end = mBuffer->endSegment();
71 66
72 // Get iterator to full segment containing last_pos 67 LLBufferArray::segment_iterator_t iter;
73 // and construct sub-segment starting at last_pos. 68 LLBufferArray::segment_iterator_t end = mBuffer->endSegment();
74 // Note: segment may != *it at this point 69 U8* last_pos = (U8*)gptr();
75 it = mBuffer->constructSegmentAfter(last_pos, segment); 70 LLSegment segment;
76 if(it == end) 71 if(last_pos)
72 {
73 // Back up into a piece of memory we know that we have
74 // allocated so that calls for the next segment based on
75 // 'after' will succeed.
76 --last_pos;
77 iter = mBuffer->splitAfter(last_pos);
78 if(iter != end)
79 {
80 // We need to clear the read segment just in case we have
81 // an early exit in the function and never collect the
82 // next segment. Calling eraseSegment() with the same
83 // segment twice is just like double deleting -- nothing
84 // good comes from it.
85 mBuffer->eraseSegment(iter++);
86 if(iter != end) segment = (*iter);
87 }
88 else
89 {
90 // This should never really happen, but somehow, the
91 // istream is telling the buf that it just finished
92 // reading memory that is not in the buf. I think this
93 // would only happen if there were a bug in the c++ stream
94 // class. Just bail.
95 // *TODO: can we set the fail bit on the stream somehow?
96 return EOF;
97 }
98 }
99 else
100 {
101 // Get iterator to full segment containing last_pos
102 // and construct sub-segment starting at last_pos.
103 // Note: segment may != *it at this point
104 iter = mBuffer->constructSegmentAfter(last_pos, segment);
105 }
106 if(iter == end)
77 { 107 {
78 return EOF; 108 return EOF;
79 } 109 }
80 110
81 // Iterate through segments to find a non-empty segment on input channel. 111 // Iterate through segments to find a non-empty segment on input channel.
82 while((!segment.isOnChannel(mChannels.in()) || (segment.size() == 0))) 112 while((!segment.isOnChannel(mChannels.in()) || (segment.size() == 0)))
83 { 113 {
84 ++it; 114 ++iter;
85 if(it == end) 115 if(iter == end)
86 { 116 {
87 return EOF; 117 return EOF;
88 } 118 }
89 119
90 segment = *it; 120 segment = *(iter);
91 } 121 }
92 122
123 // set up the stream to read from the next segment.
93 char* start = (char*)segment.data(); 124 char* start = (char*)segment.data();
94 setg(start, start, start + segment.size()); 125 setg(start, start, start + segment.size());
95 return *gptr(); 126 return *gptr();
@@ -144,12 +175,43 @@ int LLBufferStreamBuf::sync()
144 return return_value; 175 return return_value;
145 } 176 }
146 177
178 // This chunk of code is not necessary because typically, users of
179 // the stream will read until EOF. Therefore, underflow was called
180 // and the segment was discarded before the sync() was called in
181 // the destructor. Theoretically, we could keep some more data
182 // around and detect the rare case where an istream was deleted
183 // before reading to the end, but that will only leave behind some
184 // unavailable but still referenced memory. Also, if another
185 // istream is constructed, it will re-read that segment, and then
186 // discard it.
187 //U8* last_pos = (U8*)gptr();
188 //if(last_pos)
189 //{
190 // // Looks like we read something. Discard what we have read.
191 // // gptr() actually returns the currrent position, but we call
192 // // it last_pos because of how it is used in the split call
193 // // below.
194 // --last_pos;
195 // LLBufferArray::segment_iterator_t iter;
196 // iter = mBuffer->splitAfter(last_pos);
197 // if(iter != mBuffer->endSegment())
198 // {
199 // // We need to clear the read segment just in case we have
200 // // an early exit in the function and never collect the
201 // // next segment. Calling eraseSegment() with the same
202 // // segment twice is just like double deleting -- nothing
203 // // good comes from it.
204 // mBuffer->eraseSegment(iter);
205 // }
206 //}
207
147 // set the put pointer so that we force an overflow on the next 208 // set the put pointer so that we force an overflow on the next
148 // write. 209 // write.
149 U8* address = (U8*)pptr(); 210 U8* address = (U8*)pptr();
150 setp(NULL, NULL); 211 setp(NULL, NULL);
151 212
152 // *NOTE: I bet we could just --address. Need to think about that. 213 // *NOTE: I bet we could just --address if address is not NULL.
214 // Need to think about that.
153 address = mBuffer->seek(mChannels.out(), address, -1); 215 address = mBuffer->seek(mChannels.out(), address, -1);
154 if(address) 216 if(address)
155 { 217 {
diff --git a/linden/indra/llmessage/llbufferstream.h b/linden/indra/llmessage/llbufferstream.h
index 0a4ad40..5447a80 100644
--- a/linden/indra/llmessage/llbufferstream.h
+++ b/linden/indra/llmessage/llbufferstream.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp
index e92c72f..5df62b3 100644
--- a/linden/indra/llmessage/llcachename.cpp
+++ b/linden/indra/llmessage/llcachename.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcachename.h b/linden/indra/llmessage/llcachename.h
index 9987f11..9009b1f 100644
--- a/linden/indra/llmessage/llcachename.h
+++ b/linden/indra/llmessage/llcachename.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcallbacklisth.h b/linden/indra/llmessage/llcallbacklisth.h
index d1cacbd..74dbcc8 100644
--- a/linden/indra/llmessage/llcallbacklisth.h
+++ b/linden/indra/llmessage/llcallbacklisth.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2002-2007, Linden Research, Inc. 6 * Copyright (c) 2002-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llchainio.cpp b/linden/indra/llmessage/llchainio.cpp
index 2ca53e0..47352d1 100644
--- a/linden/indra/llmessage/llchainio.cpp
+++ b/linden/indra/llmessage/llchainio.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llchainio.h b/linden/indra/llmessage/llchainio.h
index c65b3c2..ef2747a 100644
--- a/linden/indra/llmessage/llchainio.h
+++ b/linden/indra/llmessage/llchainio.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcipher.h b/linden/indra/llmessage/llcipher.h
index c1f88ff..1860277 100644
--- a/linden/indra/llmessage/llcipher.h
+++ b/linden/indra/llmessage/llcipher.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcircuit.cpp b/linden/indra/llmessage/llcircuit.cpp
index d73cc22..5e93e0a 100644
--- a/linden/indra/llmessage/llcircuit.cpp
+++ b/linden/indra/llmessage/llcircuit.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llcircuit.h b/linden/indra/llmessage/llcircuit.h
index 8021685..e3a5779 100644
--- a/linden/indra/llmessage/llcircuit.h
+++ b/linden/indra/llmessage/llcircuit.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llclassifiedflags.cpp b/linden/indra/llmessage/llclassifiedflags.cpp
index 3422802..ed595b1 100644
--- a/linden/indra/llmessage/llclassifiedflags.cpp
+++ b/linden/indra/llmessage/llclassifiedflags.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llclassifiedflags.h b/linden/indra/llmessage/llclassifiedflags.h
index 7c448a3..a2a93d8 100644
--- a/linden/indra/llmessage/llclassifiedflags.h
+++ b/linden/indra/llmessage/llclassifiedflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2005-2007, Linden Research, Inc. 5 * Copyright (c) 2005-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -41,6 +42,8 @@ const U8 CLASSIFIED_QUERY_FILTER_MATURE = 1 << 1;
41const U8 CLASSIFIED_QUERY_FILTER_ENABLED = 1 << 2; 42const U8 CLASSIFIED_QUERY_FILTER_ENABLED = 1 << 2;
42const U8 CLASSIFIED_QUERY_FILTER_PRICE = 1 << 3; 43const U8 CLASSIFIED_QUERY_FILTER_PRICE = 1 << 3;
43 44
45const S32 MAX_CLASSIFIEDS = 100;
46
44ClassifiedFlags pack_classified_flags(BOOL is_mature, BOOL auto_renew); 47ClassifiedFlags pack_classified_flags(BOOL is_mature, BOOL auto_renew);
45bool is_cf_mature(ClassifiedFlags flags); 48bool is_cf_mature(ClassifiedFlags flags);
46//bool is_cf_enabled(ClassifiedFlags flags); 49//bool is_cf_enabled(ClassifiedFlags flags);
diff --git a/linden/indra/llmessage/lldatapacker.cpp b/linden/indra/llmessage/lldatapacker.cpp
index d4c8704..2448c40 100644
--- a/linden/indra/llmessage/lldatapacker.cpp
+++ b/linden/indra/llmessage/lldatapacker.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -557,7 +558,7 @@ void LLDataPackerBinaryBuffer::dumpBufferToLog()
557 S32 cur_line = 0; 558 S32 cur_line = 0;
558 for (i = 0; i < mBufferSize; i++) 559 for (i = 0; i < mBufferSize; i++)
559 { 560 {
560 snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer) - cur_line_pos*3, "%02x ", mBufferp[i]); /*Flawfinder: ignore*/ 561 snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer) - cur_line_pos*3, "%02x ", mBufferp[i]); /* Flawfinder: ignore */
561 cur_line_pos++; 562 cur_line_pos++;
562 if (cur_line_pos >= 16) 563 if (cur_line_pos >= 16)
563 { 564 {
@@ -582,7 +583,7 @@ BOOL LLDataPackerAsciiBuffer::packString(const char *value, const char *name)
582 int numCopied = 0; 583 int numCopied = 0;
583 if (mWriteEnabled) 584 if (mWriteEnabled)
584 { 585 {
585 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value); /*Flawfinder: ignore*/ 586 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\n", value); /* Flawfinder: ignore */
586 } 587 }
587 else 588 else
588 { 589 {
@@ -591,14 +592,15 @@ BOOL LLDataPackerAsciiBuffer::packString(const char *value, const char *name)
591 592
592 // snprintf returns number of bytes that would have been written 593 // snprintf returns number of bytes that would have been written
593 // had the output not being truncated. In that case, it will 594 // had the output not being truncated. In that case, it will
594 // return >= passed in size value. so a check needs to be added 595 // return either -1 or value >= passed in size value . So a check needs to be added
595 // to detect truncation, and if there is any, only account for the 596 // to detect truncation, and if there is any, only account for the
596 // actual number of bytes written..and not what could have been 597 // actual number of bytes written..and not what could have been
597 // written. 598 // written.
598 if (numCopied > getBufferSize()-getCurrentSize()) 599 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
599 { 600 {
600 // *NOTE: I believe we need to mark a failure bit at this point. 601 // *NOTE: I believe we need to mark a failure bit at this point.
601 numCopied = getBufferSize()-getCurrentSize(); 602 numCopied = getBufferSize()-getCurrentSize();
603 llwarns << "LLDataPackerAsciiBuffer::packString: string truncated: " << value << llendl;
602 } 604 }
603 mCurBufferp += numCopied; 605 mCurBufferp += numCopied;
604 return success; 606 return success;
@@ -626,7 +628,7 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
626 int numCopied = 0; 628 int numCopied = 0;
627 if (mWriteEnabled) 629 if (mWriteEnabled)
628 { 630 {
629 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%010d ", size); /*Flawfinder: ignore*/ 631 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%010d ", size); /* Flawfinder: ignore */
630 632
631 // snprintf returns number of bytes that would have been 633 // snprintf returns number of bytes that would have been
632 // written had the output not being truncated. In that case, 634 // written had the output not being truncated. In that case,
@@ -634,9 +636,10 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
634 // to be added to detect truncation, and if there is any, only 636 // to be added to detect truncation, and if there is any, only
635 // account for the actual number of bytes written..and not 637 // account for the actual number of bytes written..and not
636 // what could have been written. 638 // what could have been written.
637 if (numCopied > getBufferSize()-getCurrentSize()) 639 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
638 { 640 {
639 numCopied = getBufferSize()-getCurrentSize(); 641 numCopied = getBufferSize()-getCurrentSize();
642 llwarns << "LLDataPackerAsciiBuffer::packBinaryData: number truncated: " << size << llendl;
640 } 643 }
641 mCurBufferp += numCopied; 644 mCurBufferp += numCopied;
642 645
@@ -645,10 +648,11 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
645 BOOL bBufferFull = FALSE; 648 BOOL bBufferFull = FALSE;
646 for (i = 0; i < size && !bBufferFull; i++) 649 for (i = 0; i < size && !bBufferFull; i++)
647 { 650 {
648 numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]); /* Flawfinder: ignore */ 651 numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]); /* Flawfinder: ignore */
649 if (numCopied > getBufferSize()-getCurrentSize()) 652 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
650 { 653 {
651 numCopied = getBufferSize()-getCurrentSize(); 654 numCopied = getBufferSize()-getCurrentSize();
655 llwarns << "LLDataPackerAsciiBuffer::packBinaryData: data truncated: " << llendl;
652 bBufferFull = TRUE; 656 bBufferFull = TRUE;
653 } 657 }
654 mCurBufferp += numCopied; 658 mCurBufferp += numCopied;
@@ -656,10 +660,11 @@ BOOL LLDataPackerAsciiBuffer::packBinaryData(const U8 *value, S32 size, const ch
656 660
657 if (!bBufferFull) 661 if (!bBufferFull)
658 { 662 {
659 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n"); /* Flawfinder: ignore */ 663 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n"); /* Flawfinder: ignore */
660 if (numCopied > getBufferSize()-getCurrentSize()) 664 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
661 { 665 {
662 numCopied = getBufferSize()-getCurrentSize(); 666 numCopied = getBufferSize()-getCurrentSize();
667 llwarns << "LLDataPackerAsciiBuffer::packBinaryData: newline truncated: " << llendl;
663 } 668 }
664 mCurBufferp += numCopied; 669 mCurBufferp += numCopied;
665 } 670 }
@@ -717,10 +722,11 @@ BOOL LLDataPackerAsciiBuffer::packBinaryDataFixed(const U8 *value, S32 size, con
717 BOOL bBufferFull = FALSE; 722 BOOL bBufferFull = FALSE;
718 for (i = 0; i < size && !bBufferFull; i++) 723 for (i = 0; i < size && !bBufferFull; i++)
719 { 724 {
720 numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]); /* Flawfinder: ignore */ 725 numCopied = snprintf(mCurBufferp, getBufferSize()-getCurrentSize(), "%02x ", value[i]); /* Flawfinder: ignore */
721 if (numCopied > getBufferSize()-getCurrentSize()) 726 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
722 { 727 {
723 numCopied = getBufferSize()-getCurrentSize(); 728 numCopied = getBufferSize()-getCurrentSize();
729 llwarns << "LLDataPackerAsciiBuffer::packBinaryDataFixed: data truncated: " << llendl;
724 bBufferFull = TRUE; 730 bBufferFull = TRUE;
725 } 731 }
726 mCurBufferp += numCopied; 732 mCurBufferp += numCopied;
@@ -728,10 +734,11 @@ BOOL LLDataPackerAsciiBuffer::packBinaryDataFixed(const U8 *value, S32 size, con
728 } 734 }
729 if (!bBufferFull) 735 if (!bBufferFull)
730 { 736 {
731 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n"); /* Flawfinder: ignore */ 737 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(), "\n"); /* Flawfinder: ignore */
732 if (numCopied > getBufferSize()-getCurrentSize()) 738 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
733 { 739 {
734 numCopied = getBufferSize()-getCurrentSize(); 740 numCopied = getBufferSize()-getCurrentSize();
741 llwarns << "LLDataPackerAsciiBuffer::packBinaryDataFixed: newline truncated: " << llendl;
735 } 742 }
736 743
737 mCurBufferp += numCopied; 744 mCurBufferp += numCopied;
@@ -781,21 +788,24 @@ BOOL LLDataPackerAsciiBuffer::packU8(const U8 value, const char *name)
781 int numCopied = 0; 788 int numCopied = 0;
782 if (mWriteEnabled) 789 if (mWriteEnabled)
783 { 790 {
784 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /*Flawfinder: ignore*/ 791 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /* Flawfinder: ignore */
785 } 792 }
786 else 793 else
787 { 794 {
788 // just do the write to a temp buffer to get the length 795 // just do the write to a temp buffer to get the length
789 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */ 796 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */
790 } 797 }
791 798
792 // snprintf returns number of bytes that would have been written had the 799 // snprintf returns number of bytes that would have been written
793 // output not being truncated. In that case, it will retuen >= passed in size value. 800 // had the output not being truncated. In that case, it will
794 // so a check needs to be added to detect truncation, and if there is any, 801 // return either -1 or value >= passed in size value . So a check needs to be added
795 // only account for the actual number of bytes written..and not what could have been written. 802 // to detect truncation, and if there is any, only account for the
796 if (numCopied > getBufferSize()-getCurrentSize()) 803 // actual number of bytes written..and not what could have been
804 // written.
805 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
797 { 806 {
798 numCopied = getBufferSize()-getCurrentSize(); 807 numCopied = getBufferSize()-getCurrentSize();
808 llwarns << "LLDataPackerAsciiBuffer::packU8: val truncated: " << llendl;
799 } 809 }
800 810
801 mCurBufferp += numCopied; 811 mCurBufferp += numCopied;
@@ -826,20 +836,23 @@ BOOL LLDataPackerAsciiBuffer::packU16(const U16 value, const char *name)
826 int numCopied = 0; 836 int numCopied = 0;
827 if (mWriteEnabled) 837 if (mWriteEnabled)
828 { 838 {
829 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /*Flawfinder: ignore*/ 839 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /* Flawfinder: ignore */
830 } 840 }
831 else 841 else
832 { 842 {
833 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */ 843 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */
834 } 844 }
835 845
836 // snprintf returns number of bytes that would have been written had the 846 // snprintf returns number of bytes that would have been written
837 // output not being truncated. In that case, it will retuen >= passed in size value. 847 // had the output not being truncated. In that case, it will
838 // so a check needs to be added to detect truncation, and if there is any, 848 // return either -1 or value >= passed in size value . So a check needs to be added
839 // only account for the actual number of bytes written..and not what could have been written. 849 // to detect truncation, and if there is any, only account for the
840 if (numCopied > getBufferSize()-getCurrentSize()) 850 // actual number of bytes written..and not what could have been
851 // written.
852 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
841 { 853 {
842 numCopied = getBufferSize()-getCurrentSize(); 854 numCopied = getBufferSize()-getCurrentSize();
855 llwarns << "LLDataPackerAsciiBuffer::packU16: val truncated: " << llendl;
843 } 856 }
844 857
845 mCurBufferp += numCopied; 858 mCurBufferp += numCopied;
@@ -871,19 +884,22 @@ BOOL LLDataPackerAsciiBuffer::packU32(const U32 value, const char *name)
871 int numCopied = 0; 884 int numCopied = 0;
872 if (mWriteEnabled) 885 if (mWriteEnabled)
873 { 886 {
874 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%u\n", value); /* Flawfinder: ignore */ 887 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%u\n", value); /* Flawfinder: ignore */
875 } 888 }
876 else 889 else
877 { 890 {
878 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%u\n", value); /* Flawfinder: ignore */ 891 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%u\n", value); /* Flawfinder: ignore */
879 } 892 }
880 // snprintf returns number of bytes that would have been written had the 893 // snprintf returns number of bytes that would have been written
881 // output not being truncated. In that case, it will retuen >= passed in size value. 894 // had the output not being truncated. In that case, it will
882 // so a check needs to be added to detect truncation, and if there is any, 895 // return either -1 or value >= passed in size value . So a check needs to be added
883 // only account for the actual number of bytes written..and not what could have been written. 896 // to detect truncation, and if there is any, only account for the
884 if (numCopied > getBufferSize()-getCurrentSize()) 897 // actual number of bytes written..and not what could have been
898 // written.
899 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
885 { 900 {
886 numCopied = getBufferSize()-getCurrentSize(); 901 numCopied = getBufferSize()-getCurrentSize();
902 llwarns << "LLDataPackerAsciiBuffer::packU32: val truncated: " << llendl;
887 } 903 }
888 904
889 mCurBufferp += numCopied; 905 mCurBufferp += numCopied;
@@ -912,19 +928,22 @@ BOOL LLDataPackerAsciiBuffer::packS32(const S32 value, const char *name)
912 int numCopied = 0; 928 int numCopied = 0;
913 if (mWriteEnabled) 929 if (mWriteEnabled)
914 { 930 {
915 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /* Flawfinder: ignore */ 931 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d\n", value); /* Flawfinder: ignore */
916 } 932 }
917 else 933 else
918 { 934 {
919 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */ 935 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%d\n", value); /* Flawfinder: ignore */
920 } 936 }
921 // snprintf returns number of bytes that would have been written had the 937 // snprintf returns number of bytes that would have been written
922 // output not being truncated. In that case, it will retuen >= passed in size value. 938 // had the output not being truncated. In that case, it will
923 // so a check needs to be added to detect truncation, and if there is any, 939 // return either -1 or value >= passed in size value . So a check needs to be added
924 // only account for the actual number of bytes written..and not what could have been written. 940 // to detect truncation, and if there is any, only account for the
925 if (numCopied > getBufferSize()-getCurrentSize()) 941 // actual number of bytes written..and not what could have been
942 // written.
943 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
926 { 944 {
927 numCopied = getBufferSize()-getCurrentSize(); 945 numCopied = getBufferSize()-getCurrentSize();
946 llwarns << "LLDataPackerAsciiBuffer::packS32: val truncated: " << llendl;
928 } 947 }
929 948
930 mCurBufferp += numCopied; 949 mCurBufferp += numCopied;
@@ -953,19 +972,22 @@ BOOL LLDataPackerAsciiBuffer::packF32(const F32 value, const char *name)
953 int numCopied = 0; 972 int numCopied = 0;
954 if (mWriteEnabled) 973 if (mWriteEnabled)
955 { 974 {
956 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g\n", value); /* Flawfinder: ignore */ 975 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g\n", value); /* Flawfinder: ignore */
957 } 976 }
958 else 977 else
959 { 978 {
960 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%g\n", value); /* Flawfinder: ignore */ 979 numCopied = snprintf(DUMMY_BUFFER, sizeof(DUMMY_BUFFER), "%g\n", value); /* Flawfinder: ignore */
961 } 980 }
962 // snprintf returns number of bytes that would have been written had the 981 // snprintf returns number of bytes that would have been written
963 // output not being truncated. In that case, it will retuen >= passed in size value. 982 // had the output not being truncated. In that case, it will
964 // so a check needs to be added to detect truncation, and if there is any, 983 // return either -1 or value >= passed in size value . So a check needs to be added
965 // only account for the actual number of bytes written..and not what could have been written. 984 // to detect truncation, and if there is any, only account for the
966 if (numCopied > getBufferSize()-getCurrentSize()) 985 // actual number of bytes written..and not what could have been
986 // written.
987 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
967 { 988 {
968 numCopied = getBufferSize()-getCurrentSize(); 989 numCopied = getBufferSize()-getCurrentSize();
990 llwarns << "LLDataPackerAsciiBuffer::packF32: val truncated: " << llendl;
969 } 991 }
970 992
971 mCurBufferp += numCopied; 993 mCurBufferp += numCopied;
@@ -994,19 +1016,22 @@ BOOL LLDataPackerAsciiBuffer::packColor4(const LLColor4 &value, const char *name
994 int numCopied = 0; 1016 int numCopied = 0;
995 if (mWriteEnabled) 1017 if (mWriteEnabled)
996 { 1018 {
997 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ 1019 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */
998 } 1020 }
999 else 1021 else
1000 { 1022 {
1001 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ 1023 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */
1002 } 1024 }
1003 // snprintf returns number of bytes that would have been written had the 1025 // snprintf returns number of bytes that would have been written
1004 // output not being truncated. In that case, it will retuen >= passed in size value. 1026 // had the output not being truncated. In that case, it will
1005 // so a check needs to be added to detect truncation, and if there is any, 1027 // return either -1 or value >= passed in size value . So a check needs to be added
1006 // only account for the actual number of bytes written..and not what could have been written. 1028 // to detect truncation, and if there is any, only account for the
1007 if (numCopied > getBufferSize()-getCurrentSize()) 1029 // actual number of bytes written..and not what could have been
1030 // written.
1031 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1008 { 1032 {
1009 numCopied = getBufferSize()-getCurrentSize(); 1033 numCopied = getBufferSize()-getCurrentSize();
1034 llwarns << "LLDataPackerAsciiBuffer::packColor4: truncated: " << llendl;
1010 } 1035 }
1011 1036
1012 mCurBufferp += numCopied; 1037 mCurBufferp += numCopied;
@@ -1034,19 +1059,22 @@ BOOL LLDataPackerAsciiBuffer::packColor4U(const LLColor4U &value, const char *na
1034 int numCopied = 0; 1059 int numCopied = 0;
1035 if (mWriteEnabled) 1060 if (mWriteEnabled)
1036 { 1061 {
1037 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ 1062 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */
1038 } 1063 }
1039 else 1064 else
1040 { 1065 {
1041 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ 1066 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%d %d %d %d\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */
1042 } 1067 }
1043 // snprintf returns number of bytes that would have been written had the 1068 // snprintf returns number of bytes that would have been written
1044 // output not being truncated. In that case, it will retuen >= passed in size value. 1069 // had the output not being truncated. In that case, it will
1045 // so a check needs to be added to detect truncation, and if there is any, 1070 // return either -1 or value >= passed in size value . So a check needs to be added
1046 // only account for the actual number of bytes written..and not what could have been written. 1071 // to detect truncation, and if there is any, only account for the
1047 if (numCopied > getBufferSize()-getCurrentSize()) 1072 // actual number of bytes written..and not what could have been
1073 // written.
1074 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1048 { 1075 {
1049 numCopied = getBufferSize()-getCurrentSize(); 1076 numCopied = getBufferSize()-getCurrentSize();
1077 llwarns << "LLDataPackerAsciiBuffer::packColor4U: truncated: " << llendl;
1050 } 1078 }
1051 1079
1052 mCurBufferp += numCopied; 1080 mCurBufferp += numCopied;
@@ -1085,15 +1113,18 @@ BOOL LLDataPackerAsciiBuffer::packVector2(const LLVector2 &value, const char *na
1085 } 1113 }
1086 else 1114 else
1087 { 1115 {
1088 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */ 1116 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g\n", value.mV[0], value.mV[1]); /* Flawfinder: ignore */
1089 } 1117 }
1090 // snprintf returns number of bytes that would have been written had the 1118 // snprintf returns number of bytes that would have been written
1091 // output not being truncated. In that case, it will retuen >= passed in size value. 1119 // had the output not being truncated. In that case, it will
1092 // so a check needs to be added to detect truncation, and if there is any, 1120 // return either -1 or value >= passed in size value . So a check needs to be added
1093 // only account for the actual number of bytes written..and not what could have been written. 1121 // to detect truncation, and if there is any, only account for the
1094 if (numCopied > getBufferSize()-getCurrentSize()) 1122 // actual number of bytes written..and not what could have been
1123 // written.
1124 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1095 { 1125 {
1096 numCopied = getBufferSize()-getCurrentSize(); 1126 numCopied = getBufferSize()-getCurrentSize();
1127 llwarns << "LLDataPackerAsciiBuffer::packVector2: truncated: " << llendl;
1097 } 1128 }
1098 1129
1099 mCurBufferp += numCopied; 1130 mCurBufferp += numCopied;
@@ -1128,13 +1159,16 @@ BOOL LLDataPackerAsciiBuffer::packVector3(const LLVector3 &value, const char *na
1128 { 1159 {
1129 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */ 1160 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g\n", value.mV[0], value.mV[1], value.mV[2]); /* Flawfinder: ignore */
1130 } 1161 }
1131 // snprintf returns number of bytes that would have been written had the 1162 // snprintf returns number of bytes that would have been written
1132 // output not being truncated. In that case, it will retuen >= passed in size value. 1163 // had the output not being truncated. In that case, it will
1133 // so a check needs to be added to detect truncation, and if there is any, 1164 // return either -1 or value >= passed in size value . So a check needs to be added
1134 // only account for the actual number of bytes written..and not what could have been written. 1165 // to detect truncation, and if there is any, only account for the
1135 if (numCopied > getBufferSize()-getCurrentSize()) 1166 // actual number of bytes written..and not what could have been
1167 // written.
1168 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1136 { 1169 {
1137 numCopied = getBufferSize()-getCurrentSize(); 1170 numCopied = getBufferSize()-getCurrentSize();
1171 llwarns << "LLDataPackerAsciiBuffer::packVector3: truncated: " << llendl;
1138 } 1172 }
1139 1173
1140 mCurBufferp += numCopied; 1174 mCurBufferp += numCopied;
@@ -1168,13 +1202,16 @@ BOOL LLDataPackerAsciiBuffer::packVector4(const LLVector4 &value, const char *na
1168 { 1202 {
1169 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */ 1203 numCopied = snprintf(DUMMY_BUFFER,sizeof(DUMMY_BUFFER),"%g %g %g %g\n", value.mV[0], value.mV[1], value.mV[2], value.mV[3]); /* Flawfinder: ignore */
1170 } 1204 }
1171 // snprintf returns number of bytes that would have been written had the 1205 // snprintf returns number of bytes that would have been written
1172 // output not being truncated. In that case, it will retuen >= passed in size value. 1206 // had the output not being truncated. In that case, it will
1173 // so a check needs to be added to detect truncation, and if there is any, 1207 // return either -1 or value >= passed in size value . So a check needs to be added
1174 // only account for the actual number of bytes written..and not what could have been written. 1208 // to detect truncation, and if there is any, only account for the
1175 if (numCopied > getBufferSize()-getCurrentSize()) 1209 // actual number of bytes written..and not what could have been
1210 // written.
1211 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1176 { 1212 {
1177 numCopied = getBufferSize()-getCurrentSize(); 1213 numCopied = getBufferSize()-getCurrentSize();
1214 llwarns << "LLDataPackerAsciiBuffer::packVector4: truncated: " << llendl;
1178 } 1215 }
1179 1216
1180 mCurBufferp += numCopied; 1217 mCurBufferp += numCopied;
@@ -1212,13 +1249,16 @@ BOOL LLDataPackerAsciiBuffer::packUUID(const LLUUID &value, const char *name)
1212 { 1249 {
1213 numCopied = 64 + 1; // UUID + newline 1250 numCopied = 64 + 1; // UUID + newline
1214 } 1251 }
1215 // snprintf returns number of bytes that would have been written had the 1252 // snprintf returns number of bytes that would have been written
1216 // output not being truncated. In that case, it will retuen >= passed in size value. 1253 // had the output not being truncated. In that case, it will
1217 // so a check needs to be added to detect truncation, and if there is any, 1254 // return either -1 or value >= passed in size value . So a check needs to be added
1218 // only account for the actual number of bytes written..and not what could have been written. 1255 // to detect truncation, and if there is any, only account for the
1219 if (numCopied > getBufferSize()-getCurrentSize()) 1256 // actual number of bytes written..and not what could have been
1257 // written.
1258 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1220 { 1259 {
1221 numCopied = getBufferSize()-getCurrentSize(); 1260 numCopied = getBufferSize()-getCurrentSize();
1261 llwarns << "LLDataPackerAsciiBuffer::packUUID: truncated: " << llendl;
1222 success = FALSE; 1262 success = FALSE;
1223 } 1263 }
1224 mCurBufferp += numCopied; 1264 mCurBufferp += numCopied;
@@ -1254,21 +1294,26 @@ void LLDataPackerAsciiBuffer::writeIndentedName(const char *name)
1254 int numCopied = 0; 1294 int numCopied = 0;
1255 if (mWriteEnabled) 1295 if (mWriteEnabled)
1256 { 1296 {
1257 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\t", name); /* Flawfinder: ignore */ 1297 numCopied = snprintf(mCurBufferp,getBufferSize()-getCurrentSize(),"%s\t", name); /* Flawfinder: ignore */
1258 } 1298 }
1259 else 1299 else
1260 { 1300 {
1261 numCopied = (S32)strlen(name) + 1; /* Flawfinder: ignore */ //name + tab 1301 numCopied = (S32)strlen(name) + 1; /* Flawfinder: ignore */ //name + tab
1262 } 1302 }
1263 1303
1264 // snprintf returns number of bytes that would have been written had the 1304 // snprintf returns number of bytes that would have been written
1265 // output not being truncated. In that case, it will retuen >= passed in size value. 1305 // had the output not being truncated. In that case, it will
1266 // so a check needs to be added to detect truncation, and if there is any, 1306 // return either -1 or value >= passed in size value . So a check needs to be added
1267 // only account for the actual number of bytes written..and not what could have been written. 1307 // to detect truncation, and if there is any, only account for the
1268 if (numCopied > getBufferSize()-getCurrentSize()) 1308 // actual number of bytes written..and not what could have been
1309 // written.
1310 if (numCopied < 0 || numCopied > getBufferSize()-getCurrentSize())
1269 { 1311 {
1270 numCopied = getBufferSize()-getCurrentSize(); 1312 numCopied = getBufferSize()-getCurrentSize();
1313 llwarns << "LLDataPackerAsciiBuffer::writeIndentedName: truncated: " << llendl;
1271 } 1314 }
1315
1316 mCurBufferp += numCopied;
1272 } 1317 }
1273} 1318}
1274 1319
@@ -1424,7 +1469,7 @@ BOOL LLDataPackerAsciiFile::packBinaryDataFixed(const U8 *value, S32 size, const
1424 S32 i; 1469 S32 i;
1425 for (i = 0; i < size; i++) 1470 for (i = 0; i < size; i++)
1426 { 1471 {
1427 snprintf(buffer, sizeof(buffer), "%02x ", value[i]); /*Flawfinder: ignore*/ 1472 snprintf(buffer, sizeof(buffer), "%02x ", value[i]); /* Flawfinder: ignore */
1428 *mOutputStream << buffer; 1473 *mOutputStream << buffer;
1429 } 1474 }
1430 *mOutputStream << "\n"; 1475 *mOutputStream << "\n";
diff --git a/linden/indra/llmessage/lldatapacker.h b/linden/indra/llmessage/lldatapacker.h
index 4e0b4cd..700f8fb 100644
--- a/linden/indra/llmessage/lldatapacker.h
+++ b/linden/indra/llmessage/lldatapacker.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lldbstrings.h b/linden/indra/llmessage/lldbstrings.h
index 122e45b..dd249b1 100644
--- a/linden/indra/llmessage/lldbstrings.h
+++ b/linden/indra/llmessage/lldbstrings.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lldispatcher.cpp b/linden/indra/llmessage/lldispatcher.cpp
index 7ba9f44..2e775f9 100644
--- a/linden/indra/llmessage/lldispatcher.cpp
+++ b/linden/indra/llmessage/lldispatcher.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lldispatcher.h b/linden/indra/llmessage/lldispatcher.h
index 2a103f0..374ee0d 100644
--- a/linden/indra/llmessage/lldispatcher.h
+++ b/linden/indra/llmessage/lldispatcher.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lleventflags.h b/linden/indra/llmessage/lleventflags.h
index 755e5a9..f6b89e3 100644
--- a/linden/indra/llmessage/lleventflags.h
+++ b/linden/indra/llmessage/lleventflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llfiltersd2xmlrpc.cpp b/linden/indra/llmessage/llfiltersd2xmlrpc.cpp
index 63913d5..34a4621 100644
--- a/linden/indra/llmessage/llfiltersd2xmlrpc.cpp
+++ b/linden/indra/llmessage/llfiltersd2xmlrpc.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2005-2007, Linden Research, Inc. 6 * Copyright (c) 2005-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llfiltersd2xmlrpc.h b/linden/indra/llmessage/llfiltersd2xmlrpc.h
index 622ab90..8b2f066 100644
--- a/linden/indra/llmessage/llfiltersd2xmlrpc.h
+++ b/linden/indra/llmessage/llfiltersd2xmlrpc.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2005-2007, Linden Research, Inc. 6 * Copyright (c) 2005-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llfollowcamparams.h b/linden/indra/llmessage/llfollowcamparams.h
index aa14ab2..0979474 100644
--- a/linden/indra/llmessage/llfollowcamparams.h
+++ b/linden/indra/llmessage/llfollowcamparams.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2005-2007, Linden Research, Inc. 5 * Copyright (c) 2005-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llhost.cpp b/linden/indra/llmessage/llhost.cpp
index c1ca4b0..50ef301 100644
--- a/linden/indra/llmessage/llhost.cpp
+++ b/linden/indra/llmessage/llhost.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -47,7 +48,7 @@ LLHost LLHost::invalid(INVALID_PORT,INVALID_HOST_IP_ADDRESS);
47LLHost::LLHost(const std::string& ip_and_port) 48LLHost::LLHost(const std::string& ip_and_port)
48{ 49{
49 std::string::size_type colon_index = ip_and_port.find(":"); 50 std::string::size_type colon_index = ip_and_port.find(":");
50 if (colon_index != std::string::npos) 51 if (colon_index == std::string::npos)
51 { 52 {
52 mIP = ip_string_to_u32(ip_and_port.c_str()); 53 mIP = ip_string_to_u32(ip_and_port.c_str());
53 mPort = 0; 54 mPort = 0;
@@ -70,7 +71,7 @@ void LLHost::getString(char* buffer, S32 length) const
70 return; 71 return;
71 } 72 }
72 73
73 snprintf(buffer, length, "%s:%u", u32_to_ip_string(mIP), mPort); /*Flawfinder: ignore*/ 74 snprintf(buffer, length, "%s:%u", u32_to_ip_string(mIP), mPort); /* Flawfinder: ignore */
74} 75}
75 76
76void LLHost::getIPString(char* buffer, S32 length) const 77void LLHost::getIPString(char* buffer, S32 length) const
@@ -81,7 +82,7 @@ void LLHost::getIPString(char* buffer, S32 length) const
81 return; 82 return;
82 } 83 }
83 84
84 snprintf(buffer, length, "%s", u32_to_ip_string(mIP)); /*Flawfinder: ignore*/ 85 snprintf(buffer, length, "%s", u32_to_ip_string(mIP)); /* Flawfinder: ignore */
85} 86}
86 87
87 88
diff --git a/linden/indra/llmessage/llhost.h b/linden/indra/llmessage/llhost.h
index 894e2de..5b477e0 100644
--- a/linden/indra/llmessage/llhost.h
+++ b/linden/indra/llmessage/llhost.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2000-2007, Linden Research, Inc. 6 * Copyright (c) 2000-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp
index 6c57499..8e328ce 100644
--- a/linden/indra/llmessage/llhttpassetstorage.cpp
+++ b/linden/indra/llmessage/llhttpassetstorage.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2003-2007, Linden Research, Inc. 6 * Copyright (c) 2003-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -38,7 +39,7 @@
38 39
39#include "zlib/zlib.h" 40#include "zlib/zlib.h"
40 41
41const U32 MAX_RUNNING_REQUESTS = 4; 42const U32 MAX_RUNNING_REQUESTS = 1;
42const F32 MAX_PROCESSING_TIME = 0.005f; 43const F32 MAX_PROCESSING_TIME = 0.005f;
43const S32 CURL_XFER_BUFFER_SIZE = 65536; 44const S32 CURL_XFER_BUFFER_SIZE = 65536;
44// Try for 30 minutes for now. 45// Try for 30 minutes for now.
@@ -77,6 +78,7 @@ public:
77 virtual ~LLHTTPAssetRequest(); 78 virtual ~LLHTTPAssetRequest();
78 79
79 void setupCurlHandle(); 80 void setupCurlHandle();
81 void cleanupCurlHandle();
80 82
81 void prepareCompressedUpload(); 83 void prepareCompressedUpload();
82 void finishCompressedUpload(); 84 void finishCompressedUpload();
@@ -140,16 +142,7 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest()
140 if (mCurlHandle) 142 if (mCurlHandle)
141 { 143 {
142 curl_multi_remove_handle(mCurlMultiHandle, mCurlHandle); 144 curl_multi_remove_handle(mCurlMultiHandle, mCurlHandle);
143 curl_easy_cleanup(mCurlHandle); 145 cleanupCurlHandle();
144 if (mAssetStoragep)
145 {
146 // Terminating a request. Thus upload or download is no longer pending.
147 mAssetStoragep->removeRunningRequest(mRequestType, this);
148 }
149 else
150 {
151 llerrs << "LLHTTPAssetRequest::~LLHTTPAssetRequest - No asset storage associated with this request!" << llendl;
152 }
153 } 146 }
154 if (mHTTPHeaders) 147 if (mHTTPHeaders)
155 { 148 {
@@ -274,6 +267,21 @@ void LLHTTPAssetRequest::setupCurlHandle()
274 } 267 }
275} 268}
276 269
270void LLHTTPAssetRequest::cleanupCurlHandle()
271{
272 curl_easy_cleanup(mCurlHandle);
273 if (mAssetStoragep)
274 {
275 // Terminating a request. Thus upload or download is no longer pending.
276 mAssetStoragep->removeRunningRequest(mRequestType, this);
277 }
278 else
279 {
280 llerrs << "LLHTTPAssetRequest::~LLHTTPAssetRequest - No asset storage associated with this request!" << llendl;
281 }
282 mCurlHandle = NULL;
283}
284
277void LLHTTPAssetRequest::prepareCompressedUpload() 285void LLHTTPAssetRequest::prepareCompressedUpload()
278{ 286{
279 mZStream.next_in = Z_NULL; 287 mZStream.next_in = Z_NULL;
@@ -682,7 +690,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
682{ 690{
683 CURLMcode mcode; 691 CURLMcode mcode;
684 LLAssetRequest *req; 692 LLAssetRequest *req;
685 while (req = findNextRequest(mPendingDownloads, mRunningDownloads)) 693 while ( (req = findNextRequest(mPendingDownloads, mRunningDownloads)) )
686 { 694 {
687 // Setup this curl download request 695 // Setup this curl download request
688 // We need to generate a new request here 696 // We need to generate a new request here
@@ -691,7 +699,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
691 char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/ 699 char uuid_str[UUID_STR_LENGTH]; /*Flawfinder: ignore*/
692 req->getUUID().toString(uuid_str); 700 req->getUUID().toString(uuid_str);
693 std::string base_url = getBaseURL(req->getUUID(), req->getType()); 701 std::string base_url = getBaseURL(req->getUUID(), req->getType());
694 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ 702 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */
695 703
696 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), 704 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(),
697 req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); 705 req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle);
@@ -708,7 +716,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
708 { 716 {
709 // Failure. Deleting the pending request will remove it from the running 717 // Failure. Deleting the pending request will remove it from the running
710 // queue, and push it to the end of the pending queue. 718 // queue, and push it to the end of the pending queue.
711 deletePendingRequest(RT_DOWNLOAD, req->getType(), req->getUUID()); 719 new_req->cleanupCurlHandle();
720 deletePendingRequest(RT_DOWNLOAD, new_req->getType(), new_req->getUUID());
712 break; 721 break;
713 } 722 }
714 else 723 else
@@ -717,7 +726,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
717 } 726 }
718 } 727 }
719 728
720 while (req = findNextRequest(mPendingUploads, mRunningUploads)) 729 while ( (req = findNextRequest(mPendingUploads, mRunningUploads)) )
721 { 730 {
722 // setup this curl upload request 731 // setup this curl upload request
723 732
@@ -726,7 +735,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
726 char tmp_url[MAX_STRING];/*Flawfinder: ignore*/ 735 char tmp_url[MAX_STRING];/*Flawfinder: ignore*/
727 char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/ 736 char uuid_str[UUID_STR_LENGTH];/*Flawfinder: ignore*/
728 req->getUUID().toString(uuid_str); 737 req->getUUID().toString(uuid_str);
729 snprintf(tmp_url, sizeof(tmp_url), /*Flawfinder: ignore*/ 738 snprintf(tmp_url, sizeof(tmp_url), /* Flawfinder: ignore */
730 do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", 739 do_compress ? "%s/%s.%s.gz" : "%s/%s.%s",
731 mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); 740 mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType()));
732 741
@@ -761,7 +770,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
761 { 770 {
762 // Failure. Deleting the pending request will remove it from the running 771 // Failure. Deleting the pending request will remove it from the running
763 // queue, and push it to the end of the pending queue. 772 // queue, and push it to the end of the pending queue.
764 deletePendingRequest(RT_UPLOAD, req->getType(), req->getUUID()); 773 new_req->cleanupCurlHandle();
774 deletePendingRequest(RT_UPLOAD, new_req->getType(), new_req->getUUID());
765 break; 775 break;
766 } 776 }
767 else 777 else
@@ -771,7 +781,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
771 // Pending upload will have been flagged by the request 781 // Pending upload will have been flagged by the request
772 } 782 }
773 783
774 while (req = findNextRequest(mPendingLocalUploads, mRunningLocalUploads)) 784 while ( (req = findNextRequest(mPendingLocalUploads, mRunningLocalUploads)) )
775 { 785 {
776 // setup this curl upload request 786 // setup this curl upload request
777 LLVFile file(mVFS, req->getUUID(), req->getType()); 787 LLVFile file(mVFS, req->getUUID(), req->getType());
@@ -781,7 +791,7 @@ void LLHTTPAssetStorage::checkForTimeouts()
781 req->getUUID().toString(uuid_str); 791 req->getUUID().toString(uuid_str);
782 792
783 // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" 793 // KLW - All temporary uploads are saved locally "http://localhost:12041/asset"
784 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ 794 snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /* Flawfinder: ignore */
785 795
786 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), 796 LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(),
787 req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); 797 req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle);
@@ -800,7 +810,8 @@ void LLHTTPAssetStorage::checkForTimeouts()
800 { 810 {
801 // Failure. Deleting the pending request will remove it from the running 811 // Failure. Deleting the pending request will remove it from the running
802 // queue, and push it to the end of the pending queue. 812 // queue, and push it to the end of the pending queue.
803 deletePendingRequest(RT_LOCALUPLOAD, req->getType(), req->getUUID()); 813 new_req->cleanupCurlHandle();
814 deletePendingRequest(RT_LOCALUPLOAD, new_req->getType(), new_req->getUUID());
804 break; 815 break;
805 } 816 }
806 else 817 else
diff --git a/linden/indra/llmessage/llhttpassetstorage.h b/linden/indra/llmessage/llhttpassetstorage.h
index d98af45..b5ab56b 100644
--- a/linden/indra/llmessage/llhttpassetstorage.h
+++ b/linden/indra/llmessage/llhttpassetstorage.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp
index 3755ae0..1d38a13 100644
--- a/linden/indra/llmessage/llhttpclient.cpp
+++ b/linden/indra/llmessage/llhttpclient.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -37,9 +38,10 @@
37#include "llvfile.h" 38#include "llvfile.h"
38#include "llvfs.h" 39#include "llvfs.h"
39 40
41#include "message.h"
40#include <curl/curl.h> 42#include <curl/curl.h>
41 43
42static const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; 44const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f;
43 45
44static std::string gCABundle; 46static std::string gCABundle;
45 47
@@ -111,6 +113,14 @@ namespace
111 if (200 <= mStatus && mStatus < 300) 113 if (200 <= mStatus && mStatus < 300)
112 { 114 {
113 LLSDSerialize::fromXML(content, istr); 115 LLSDSerialize::fromXML(content, istr);
116/*
117 const S32 parseError = -1;
118 if(LLSDSerialize::fromXML(content, istr) == parseError)
119 {
120 mStatus = 498;
121 mReason = "Client Parse Error";
122 }
123*/
114 } 124 }
115 125
116 if (mResponder.get()) 126 if (mResponder.get())
@@ -233,7 +243,7 @@ namespace
233} 243}
234 244
235static void request(const std::string& url, LLURLRequest::ERequestAction method, 245static void request(const std::string& url, LLURLRequest::ERequestAction method,
236 Injector* body_injector, LLHTTPClient::ResponderPtr responder) 246 Injector* body_injector, LLHTTPClient::ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS)
237{ 247{
238 if (!LLHTTPClient::hasPump()) 248 if (!LLHTTPClient::hasPump())
239 { 249 {
@@ -251,19 +261,26 @@ static void request(const std::string& url, LLURLRequest::ERequestAction method,
251 } 261 }
252 req->setCallback(new LLHTTPClientURLAdaptor(responder)); 262 req->setCallback(new LLHTTPClientURLAdaptor(responder));
253 263
264 if (method == LLURLRequest::HTTP_POST && gMessageSystem) {
265 req->addHeader(llformat("X-SecondLife-UDP-Listen-Port: %d",
266 gMessageSystem->mPort).c_str());
267 }
268
254 if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST) 269 if (method == LLURLRequest::HTTP_PUT || method == LLURLRequest::HTTP_POST)
255 { 270 {
256 req->addHeader(llformat("Content-Type: %s", body_injector->contentType()).c_str()); 271 req->addHeader(llformat("Content-Type: %s",
257 chain.push_back(LLIOPipe::ptr_t(body_injector)); 272 body_injector->contentType()).c_str());
273
274 chain.push_back(LLIOPipe::ptr_t(body_injector));
258 } 275 }
259 chain.push_back(LLIOPipe::ptr_t(req)); 276 chain.push_back(LLIOPipe::ptr_t(req));
260 277
261 theClientPump->addChain(chain, HTTP_REQUEST_EXPIRY_SECS); 278 theClientPump->addChain(chain, timeout);
262} 279}
263 280
264void LLHTTPClient::get(const std::string& url, ResponderPtr responder) 281void LLHTTPClient::get(const std::string& url, ResponderPtr responder, const F32 timeout)
265{ 282{
266 request(url, LLURLRequest::HTTP_GET, NULL, responder); 283 request(url, LLURLRequest::HTTP_GET, NULL, responder, timeout);
267} 284}
268 285
269// A simple class for managing data returned from a curl http request. 286// A simple class for managing data returned from a curl http request.
@@ -312,6 +329,14 @@ LLSD LLHTTPClient::blockingGet(const std::string& url)
312 329
313 LLHTTPBuffer http_buffer; 330 LLHTTPBuffer http_buffer;
314 331
332 // Without this timeout, blockingGet() calls have been observed to take
333 // up to 90 seconds to complete. Users of blockingGet() already must
334 // check the HTTP return code for validity, so this will not introduce
335 // new errors. A 5 second timeout will succeed > 95% of the time (and
336 // probably > 99% of the time) based on my statistics. JC
337 curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts
338 curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds
339
315 curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, LLHTTPBuffer::curl_write); 340 curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, LLHTTPBuffer::curl_write);
316 curl_easy_setopt(curlp, CURLOPT_WRITEDATA, &http_buffer); 341 curl_easy_setopt(curlp, CURLOPT_WRITEDATA, &http_buffer);
317 curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); 342 curl_easy_setopt(curlp, CURLOPT_URL, url.c_str());
@@ -344,36 +369,36 @@ LLSD LLHTTPClient::blockingGet(const std::string& url)
344 return response; 369 return response;
345} 370}
346 371
347void LLHTTPClient::put(const std::string& url, const LLSD& body, ResponderPtr responder) 372void LLHTTPClient::put(const std::string& url, const LLSD& body, ResponderPtr responder, const F32 timeout)
348{ 373{
349 request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder); 374 request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder, timeout);
350} 375}
351 376
352void LLHTTPClient::post(const std::string& url, const LLSD& body, ResponderPtr responder) 377void LLHTTPClient::post(const std::string& url, const LLSD& body, ResponderPtr responder, const F32 timeout)
353{ 378{
354 request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder); 379 request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder, timeout);
355} 380}
356 381
357void LLHTTPClient::post(const std::string& url, const U8* data, S32 size, ResponderPtr responder) 382void LLHTTPClient::post(const std::string& url, const U8* data, S32 size, ResponderPtr responder, const F32 timeout)
358{ 383{
359 request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder); 384 request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder, timeout);
360} 385}
361 386
362void LLHTTPClient::del(const std::string& url, ResponderPtr responder) 387void LLHTTPClient::del(const std::string& url, ResponderPtr responder, const F32 timeout)
363{ 388{
364 request(url, LLURLRequest::HTTP_DELETE, NULL, responder); 389 request(url, LLURLRequest::HTTP_DELETE, NULL, responder, timeout);
365} 390}
366 391
367#if 1 392#if 1
368void LLHTTPClient::postFile(const std::string& url, const std::string& filename, ResponderPtr responder) 393void LLHTTPClient::postFile(const std::string& url, const std::string& filename, ResponderPtr responder, const F32 timeout)
369{ 394{
370 request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder); 395 request(url, LLURLRequest::HTTP_POST, new FileInjector(filename), responder, timeout);
371} 396}
372 397
373void LLHTTPClient::postFile(const std::string& url, const LLUUID& uuid, 398void LLHTTPClient::postFile(const std::string& url, const LLUUID& uuid,
374 LLAssetType::EType asset_type, ResponderPtr responder) 399 LLAssetType::EType asset_type, ResponderPtr responder, const F32 timeout)
375{ 400{
376 request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder); 401 request(url, LLURLRequest::HTTP_POST, new VFileInjector(uuid, asset_type), responder, timeout);
377} 402}
378#endif 403#endif
379 404
@@ -401,7 +426,7 @@ namespace boost
401 426
402 void intrusive_ptr_release(LLHTTPClient::Responder* p) 427 void intrusive_ptr_release(LLHTTPClient::Responder* p)
403 { 428 {
404 if(0 == --p->mReferenceCount) 429 if(p && 0 == --p->mReferenceCount)
405 { 430 {
406 delete p; 431 delete p;
407 } 432 }
diff --git a/linden/indra/llmessage/llhttpclient.h b/linden/indra/llmessage/llhttpclient.h
index 93859eb..136577c 100644
--- a/linden/indra/llmessage/llhttpclient.h
+++ b/linden/indra/llmessage/llhttpclient.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -38,6 +39,8 @@
38 39
39#include "llassettype.h" 40#include "llassettype.h"
40 41
42extern const F32 HTTP_REQUEST_EXPIRY_SECS;
43
41class LLUUID; 44class LLUUID;
42class LLPumpIO; 45class LLPumpIO;
43class LLSD; 46class LLSD;
@@ -69,19 +72,19 @@ public:
69 72
70 typedef boost::intrusive_ptr<Responder> ResponderPtr; 73 typedef boost::intrusive_ptr<Responder> ResponderPtr;
71 74
72 static void get(const std::string& url, ResponderPtr); 75 static void get(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
73 static void put(const std::string& url, const LLSD& body, ResponderPtr); 76 static void put(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
74 ///< non-blocking 77 ///< non-blocking
75 static void post(const std::string& url, const LLSD& body, ResponderPtr); 78 static void post(const std::string& url, const LLSD& body, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
76 static void post(const std::string& url, const U8* data, S32 size, ResponderPtr responder); 79 static void post(const std::string& url, const U8* data, S32 size, ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
77 static void postFile(const std::string& url, const std::string& filename, ResponderPtr); 80 static void postFile(const std::string& url, const std::string& filename, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
78 static void postFile(const std::string& url, const LLUUID& uuid, 81 static void postFile(const std::string& url, const LLUUID& uuid,
79 LLAssetType::EType asset_type, ResponderPtr responder); 82 LLAssetType::EType asset_type, ResponderPtr responder, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
80 83
81 // Blocking HTTP get that returns an LLSD map of status and body. 84 // Blocking HTTP get that returns an LLSD map of status and body.
82 static LLSD blockingGet(const std::string& url); 85 static LLSD blockingGet(const std::string& url);
83 86
84 static void del(const std::string& url, ResponderPtr); 87 static void del(const std::string& url, ResponderPtr, const F32 timeout=HTTP_REQUEST_EXPIRY_SECS);
85 ///< sends a DELETE method, but we can't call it delete in c++ 88 ///< sends a DELETE method, but we can't call it delete in c++
86 89
87 90
diff --git a/linden/indra/llmessage/llhttpnode.cpp b/linden/indra/llmessage/llhttpnode.cpp
index e997415..97064a1 100644
--- a/linden/indra/llmessage/llhttpnode.cpp
+++ b/linden/indra/llmessage/llhttpnode.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llhttpnode.h b/linden/indra/llmessage/llhttpnode.h
index bbce091..ae64a63 100644
--- a/linden/indra/llmessage/llhttpnode.h
+++ b/linden/indra/llmessage/llhttpnode.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llhttpsender.cpp b/linden/indra/llmessage/llhttpsender.cpp
new file mode 100644
index 0000000..f96e6d2
--- /dev/null
+++ b/linden/indra/llmessage/llhttpsender.cpp
@@ -0,0 +1,90 @@
1/**
2 * @file llhttpsender.cpp
3 * @brief Abstracts details of sending messages via HTTP.
4 *
5 * Copyright (c) 2007-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "linden_common.h"
30
31#include "llhttpsender.h"
32
33#include <map>
34#include <sstream>
35
36#include "llhost.h"
37#include "llsd.h"
38
39namespace
40{
41 typedef std::map<LLHost, LLHTTPSender*> SenderMap;
42 static SenderMap senderMap;
43}
44
45//virtual
46LLHTTPSender::~LLHTTPSender()
47{
48}
49
50//virtual
51void LLHTTPSender::send(const LLHost& host, const char* name,
52 const LLSD& body,
53 LLHTTPClient::ResponderPtr response) const
54{
55 // Default implementation inserts sender, message and sends HTTP POST
56 std::ostringstream stream;
57 stream << "http://" << host << "/trusted-message/" << name;
58 llinfos << "LLHTTPSender::send: POST to " << stream.str() << llendl;
59 LLHTTPClient::post(stream.str(), body, response);
60}
61
62//static
63void LLHTTPSender::setSender(const LLHost& host, LLHTTPSender* sender)
64{
65 llinfos << "LLHTTPSender::setSender " << host << llendl;
66 senderMap[host] = sender;
67}
68
69//static
70const LLHTTPSender& LLHTTPSender::getSender(const LLHost& host)
71{
72 static LLHTTPSender defaultSender;
73 SenderMap::const_iterator iter = senderMap.find(host);
74 if(iter == senderMap.end())
75 {
76 return defaultSender;
77 }
78 return *(iter->second);
79}
80
81//static
82void LLHTTPSender::clearSender(const LLHost& host)
83{
84 SenderMap::iterator iter = senderMap.find(host);
85 if(iter != senderMap.end())
86 {
87 delete iter->second;
88 senderMap.erase(iter);
89 }
90}
diff --git a/linden/indra/llmessage/llhttpsender.h b/linden/indra/llmessage/llhttpsender.h
new file mode 100644
index 0000000..650a0e9
--- /dev/null
+++ b/linden/indra/llmessage/llhttpsender.h
@@ -0,0 +1,58 @@
1/**
2 * @file llhttpsender.h
3 * @brief Abstracts details of sending messages via HTTP.
4 *
5 * Copyright (c) 2007-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_HTTP_SENDER_H
30#define LL_HTTP_SENDER_H
31
32#include "llhttpclient.h"
33
34class LLHost;
35class LLSD;
36
37class LLHTTPSender
38{
39 public:
40
41 virtual ~LLHTTPSender();
42
43 /** @brief Send message to host with body, call response when done */
44 virtual void send(const LLHost& host,
45 const char* message, const LLSD& body,
46 LLHTTPClient::ResponderPtr response) const;
47
48 /** @brief Set sender for host, takes ownership of sender. */
49 static void setSender(const LLHost& host, LLHTTPSender* sender);
50
51 /** @brief Get sender for host, retains ownership of returned sender. */
52 static const LLHTTPSender& getSender(const LLHost& host);
53
54 /** @brief Clear sender for host. */
55 static void clearSender(const LLHost& host);
56};
57
58#endif // LL_HTTP_SENDER_H
diff --git a/linden/indra/llmessage/llinstantmessage.cpp b/linden/indra/llmessage/llinstantmessage.cpp
index 6f6e022..0ba7629 100644
--- a/linden/indra/llmessage/llinstantmessage.cpp
+++ b/linden/indra/llmessage/llinstantmessage.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -35,6 +36,7 @@
35#include "lluuid.h" 36#include "lluuid.h"
36#include "llsd.h" 37#include "llsd.h"
37#include "llsdserialize.h" 38#include "llsdserialize.h"
39#include "llsdutil.h"
38#include "llmemory.h" 40#include "llmemory.h"
39#include "message.h" 41#include "message.h"
40 42
@@ -226,8 +228,21 @@ void pack_instant_message_block(
226 S32 bytes_left = MTUBYTES; 228 S32 bytes_left = MTUBYTES;
227 if(message) 229 if(message)
228 { 230 {
229 char buffer[MTUBYTES]; /*Flawfinder: ignore*/ 231 char buffer[MTUBYTES];
230 bytes_left -= snprintf(buffer, MTUBYTES, "%s", message); /*Flawfinder: ignore*/ 232 int num_written = snprintf(buffer, MTUBYTES, "%s", message); /* Flawfinder: ignore */
233 // snprintf returns number of bytes that would have been written
234 // had the output not being truncated. In that case, it will
235 // return either -1 or value >= passed in size value . So a check needs to be added
236 // to detect truncation, and if there is any, only account for the
237 // actual number of bytes written..and not what could have been
238 // written.
239 if (num_written < 0 || num_written >= MTUBYTES)
240 {
241 num_written = MTUBYTES - 1;
242 llwarns << "pack_instant_message_block: message truncated: " << message << llendl;
243 }
244
245 bytes_left -= num_written;
231 bytes_left = llmax(0, bytes_left); 246 bytes_left = llmax(0, bytes_left);
232 msg->addStringFast(_PREHASH_Message, buffer); 247 msg->addStringFast(_PREHASH_Message, buffer);
233 } 248 }
@@ -296,6 +311,35 @@ void LLIMInfo::unpackMessageBlock(LLMessageSystem* msg)
296 } 311 }
297} 312}
298 313
314LLSD im_info_to_llsd(LLPointer<LLIMInfo> im_info)
315{
316 LLSD param_version;
317 param_version["version"] = 1;
318 LLSD param_message;
319 param_message["from_id"] = im_info->mFromID;
320 param_message["from_group"] = im_info->mFromGroup;
321 param_message["to_id"] = im_info->mToID;
322 param_message["from_name"] = im_info->mName;
323 param_message["message"] = im_info->mMessage;
324 param_message["type"] = (S32)im_info->mIMType;
325 param_message["id"] = im_info->mID;
326 param_message["timestamp"] = (S32)im_info->mTimeStamp;
327 param_message["offline"] = (S32)im_info->mOffline;
328 param_message["parent_estate_id"] = (S32)im_info->mParentEstateID;
329 param_message["region_id"] = im_info->mRegionID;
330 param_message["position"] = ll_sd_from_vector3(im_info->mPosition);
331 if (im_info->mData) param_message["data"] = im_info->mData;
332 LLSD param_agent;
333 param_agent["agent_id"] = im_info->mFromID;
334
335 LLSD params;
336 params.append(param_version);
337 params.append(param_message);
338 params.append(param_agent);
339
340 return params;
341}
342
299LLPointer<LLIMInfo> LLIMInfo::clone() 343LLPointer<LLIMInfo> LLIMInfo::clone()
300{ 344{
301 return new LLIMInfo( 345 return new LLIMInfo(
diff --git a/linden/indra/llmessage/llinstantmessage.h b/linden/indra/llmessage/llinstantmessage.h
index a7074a2..0b2de19 100644
--- a/linden/indra/llmessage/llinstantmessage.h
+++ b/linden/indra/llmessage/llinstantmessage.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -93,17 +94,19 @@ enum EInstantMessage
93 // communicate with each other. 94 // communicate with each other.
94 // 95 //
95 96
96 // Start a session, or add users to a session. 97 // Add users to a session.
97 IM_SESSION_ADD = 13, 98 IM_SESSION_ADD = 13,
98 99
99 // Start a session, but don't prune offline users 100 // IM sent automatically on call for help,
100 IM_SESSION_OFFLINE_ADD = 14, 101 // sets up a way for each Helper reached to teleport to the
102 // helpee
103 IM_SESSION_911_SEND = 14,
101 104
102 // start a session with your gruop 105 // start a session with your gruop
103 IM_SESSION_GROUP_START = 15, 106 IM_SESSION_GROUP_START = 15,
104 107
105 // start a session without a calling card (finder or objects) 108 // start a session without a calling card (finder or objects)
106 IM_SESSION_CARDLESS_START = 16, 109 IM_SESSION_CONFERENCE_START = 16,
107 110
108 // send a message to a session. 111 // send a message to a session.
109 IM_SESSION_SEND = 17, 112 IM_SESSION_SEND = 17,
@@ -142,9 +145,9 @@ enum EInstantMessage
142 // Binary bucket contains the name of the session. 145 // Binary bucket contains the name of the session.
143 IM_SESSION_911_START = 29, 146 IM_SESSION_911_START = 29,
144 147
145 // IM sent automatically on call for help, 148 // IM for requesting to teleport to the creator
146 // sends a lure to each Helper reached 149 // of a livehelp session (assuming they are verified first)
147 IM_LURE_911 = 30, 150 IM_TELEPORT_911 = 30,
148 151
149 // a message generated by a script which we don't want to 152 // a message generated by a script which we don't want to
150 // be sent through e-mail. Similar to IM_FROM_TASK, but 153 // be sent through e-mail. Similar to IM_FROM_TASK, but
@@ -285,6 +288,7 @@ public:
285 S32 mTTL; 288 S32 mTTL;
286}; 289};
287 290
291LLSD im_info_to_llsd(LLPointer<LLIMInfo> im_info);
288 292
289void pack_instant_message( 293void pack_instant_message(
290 LLMessageSystem* msgsystem, 294 LLMessageSystem* msgsystem,
diff --git a/linden/indra/llmessage/llinvite.h b/linden/indra/llmessage/llinvite.h
index ac54058..d3774c4 100644
--- a/linden/indra/llmessage/llinvite.h
+++ b/linden/indra/llmessage/llinvite.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lliobuffer.cpp b/linden/indra/llmessage/lliobuffer.cpp
index 506bd76..7dea578 100644
--- a/linden/indra/llmessage/lliobuffer.cpp
+++ b/linden/indra/llmessage/lliobuffer.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lliobuffer.h b/linden/indra/llmessage/lliobuffer.h
index 59d7074..ac24576 100644
--- a/linden/indra/llmessage/lliobuffer.h
+++ b/linden/indra/llmessage/lliobuffer.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lliohttpserver.cpp b/linden/indra/llmessage/lliohttpserver.cpp
index 25c1aef..9ea7272 100644
--- a/linden/indra/llmessage/lliohttpserver.cpp
+++ b/linden/indra/llmessage/lliohttpserver.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -46,6 +47,8 @@
46#include "llsdserialize_xml.h" 47#include "llsdserialize_xml.h"
47#include "llstl.h" 48#include "llstl.h"
48 49
50#include <sstream>
51
49static const char HTTP_VERSION_STR[] = "HTTP/1.0"; 52static const char HTTP_VERSION_STR[] = "HTTP/1.0";
50static const std::string CONTEXT_REQUEST("request"); 53static const std::string CONTEXT_REQUEST("request");
51static const std::string HTTP_VERB_GET("GET"); 54static const std::string HTTP_VERB_GET("GET");
@@ -393,7 +396,7 @@ LLIOPipe::EStatus LLHTTPResponseHeader::process_impl(
393class LLHTTPResponder : public LLIOPipe 396class LLHTTPResponder : public LLIOPipe
394{ 397{
395public: 398public:
396 LLHTTPResponder(const LLHTTPNode& tree); 399 LLHTTPResponder(const LLHTTPNode& tree, const LLSD& ctx);
397 ~LLHTTPResponder(); 400 ~LLHTTPResponder();
398 401
399protected: 402protected:
@@ -454,6 +457,7 @@ protected:
454 STATE_SHORT_CIRCUIT 457 STATE_SHORT_CIRCUIT
455 }; 458 };
456 459
460 LLSD mBuildContext;
457 EState mState; 461 EState mState;
458 U8* mLastRead; 462 U8* mLastRead;
459 std::string mVerb; 463 std::string mVerb;
@@ -462,12 +466,14 @@ protected:
462 std::string mQuery; 466 std::string mQuery;
463 std::string mVersion; 467 std::string mVersion;
464 S32 mContentLength; 468 S32 mContentLength;
469 LLSD mHeaders;
465 470
466 // handle the urls 471 // handle the urls
467 const LLHTTPNode& mRootNode; 472 const LLHTTPNode& mRootNode;
468}; 473};
469 474
470LLHTTPResponder::LLHTTPResponder(const LLHTTPNode& tree) : 475LLHTTPResponder::LLHTTPResponder(const LLHTTPNode& tree, const LLSD& ctx) :
476 mBuildContext(ctx),
471 mState(STATE_NOTHING), 477 mState(STATE_NOTHING),
472 mLastRead(NULL), 478 mLastRead(NULL),
473 mContentLength(0), 479 mContentLength(0),
@@ -655,6 +661,11 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
655 lldebugs << "Content-Length: " << value << llendl; 661 lldebugs << "Content-Length: " << value << llendl;
656 mContentLength = atoi(value.c_str()); 662 mContentLength = atoi(value.c_str());
657 } 663 }
664 else
665 {
666 LLString::trimTail(value);
667 mHeaders[name] = value;
668 }
658 } 669 }
659 } 670 }
660 } 671 }
@@ -720,6 +731,11 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
720 chain.push_back(LLIOPipe::ptr_t(new LLIOFlush)); 731 chain.push_back(LLIOPipe::ptr_t(new LLIOFlush));
721 context[CONTEXT_REQUEST]["path"] = mPath; 732 context[CONTEXT_REQUEST]["path"] = mPath;
722 context[CONTEXT_REQUEST]["query-string"] = mQuery; 733 context[CONTEXT_REQUEST]["query-string"] = mQuery;
734 context[CONTEXT_REQUEST]["remote-host"]
735 = mBuildContext["remote-host"];
736 context[CONTEXT_REQUEST]["remote-port"]
737 = mBuildContext["remote-port"];
738 context[CONTEXT_REQUEST]["headers"] = mHeaders;
723 739
724 const LLChainIOFactory* protocolHandler 740 const LLChainIOFactory* protocolHandler
725 = node->getProtocolHandler(); 741 = node->getProtocolHandler();
@@ -804,9 +820,10 @@ LLIOPipe::EStatus LLHTTPResponder::process_impl(
804 820
805 821
806 822
807void LLCreateHTTPPipe(LLPumpIO::chain_t& chain, const LLHTTPNode& root) 823void LLCreateHTTPPipe(LLPumpIO::chain_t& chain,
824 const LLHTTPNode& root, const LLSD& ctx)
808{ 825{
809 chain.push_back(LLIOPipe::ptr_t(new LLHTTPResponder(root))); 826 chain.push_back(LLIOPipe::ptr_t(new LLHTTPResponder(root, ctx)));
810} 827}
811 828
812 829
@@ -815,7 +832,7 @@ class LLHTTPResponseFactory : public LLChainIOFactory
815public: 832public:
816 bool build(LLPumpIO::chain_t& chain, LLSD ctx) const 833 bool build(LLPumpIO::chain_t& chain, LLSD ctx) const
817 { 834 {
818 LLCreateHTTPPipe(chain, mTree); 835 LLCreateHTTPPipe(chain, mTree, ctx);
819 return true; 836 return true;
820 } 837 }
821 838
diff --git a/linden/indra/llmessage/lliohttpserver.h b/linden/indra/llmessage/lliohttpserver.h
index efbd7db..64dce63 100644
--- a/linden/indra/llmessage/lliohttpserver.h
+++ b/linden/indra/llmessage/lliohttpserver.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2005-2007, Linden Research, Inc. 6 * Copyright (c) 2005-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -50,7 +51,8 @@ LLHTTPNode& LLCreateHTTPServer(apr_pool_t* pool, LLPumpIO& pump, U16 port);
50 * for example), use the helper templates below. 51 * for example), use the helper templates below.
51 */ 52 */
52 53
53void LLCreateHTTPPipe(LLPumpIO::chain_t& chain, const LLHTTPNode& root); 54void LLCreateHTTPPipe(LLPumpIO::chain_t& chain,
55 const LLHTTPNode& root, const LLSD& ctx);
54 /**< Create a pipe on the chain that handles HTTP requests. 56 /**< Create a pipe on the chain that handles HTTP requests.
55 * The requests are served by the node tree given at root. 57 * The requests are served by the node tree given at root.
56 * 58 *
diff --git a/linden/indra/llmessage/lliopipe.cpp b/linden/indra/llmessage/lliopipe.cpp
index 86a36d8..a37b046 100644
--- a/linden/indra/llmessage/lliopipe.cpp
+++ b/linden/indra/llmessage/lliopipe.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lliopipe.h b/linden/indra/llmessage/lliopipe.h
index f419703..38a98a6 100644
--- a/linden/indra/llmessage/lliopipe.h
+++ b/linden/indra/llmessage/lliopipe.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -256,7 +257,7 @@ namespace boost
256 } 257 }
257 inline void intrusive_ptr_release(LLIOPipe* p) 258 inline void intrusive_ptr_release(LLIOPipe* p)
258 { 259 {
259 if(0 == --p->mReferenceCount) 260 if(p && 0 == --p->mReferenceCount)
260 { 261 {
261 delete p; 262 delete p;
262 } 263 }
diff --git a/linden/indra/llmessage/lliosocket.cpp b/linden/indra/llmessage/lliosocket.cpp
index 628f884..af22180 100644
--- a/linden/indra/llmessage/lliosocket.cpp
+++ b/linden/indra/llmessage/lliosocket.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -538,9 +539,20 @@ LLIOPipe::EStatus LLIOServerSocket::process_impl(
538 if(llsocket) 539 if(llsocket)
539 { 540 {
540 PUMP_DEBUG; 541 PUMP_DEBUG;
542
543 apr_sockaddr_t* remote_addr;
544 apr_socket_addr_get(&remote_addr, APR_REMOTE, socket);
545
546 char* remote_host_string;
547 apr_sockaddr_ip_get(&remote_host_string, remote_addr);
548
549 LLSD context;
550 context["remote-host"] = remote_host_string;
551 context["remote-port"] = remote_addr->port;
552
541 LLPumpIO::chain_t chain; 553 LLPumpIO::chain_t chain;
542 chain.push_back(LLIOPipe::ptr_t(new LLIOSocketReader(llsocket))); 554 chain.push_back(LLIOPipe::ptr_t(new LLIOSocketReader(llsocket)));
543 if(mReactor->build(chain, LLSD())) 555 if(mReactor->build(chain, context))
544 { 556 {
545 chain.push_back(LLIOPipe::ptr_t(new LLIOSocketWriter(llsocket))); 557 chain.push_back(LLIOPipe::ptr_t(new LLIOSocketWriter(llsocket)));
546 pump->addChain(chain, mResponseTimeout); 558 pump->addChain(chain, mResponseTimeout);
diff --git a/linden/indra/llmessage/lliosocket.h b/linden/indra/llmessage/lliosocket.h
index f994404..0f5eae8 100644
--- a/linden/indra/llmessage/lliosocket.h
+++ b/linden/indra/llmessage/lliosocket.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llioutil.cpp b/linden/indra/llmessage/llioutil.cpp
index 76eeb02..21e36fa 100644
--- a/linden/indra/llmessage/llioutil.cpp
+++ b/linden/indra/llmessage/llioutil.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llioutil.h b/linden/indra/llmessage/llioutil.h
index 54b3d39..27cd39a 100644
--- a/linden/indra/llmessage/llioutil.h
+++ b/linden/indra/llmessage/llioutil.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llloginflags.h b/linden/indra/llmessage/llloginflags.h
index b518849..7725419 100644
--- a/linden/indra/llmessage/llloginflags.h
+++ b/linden/indra/llmessage/llloginflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lllogtextmessage.cpp b/linden/indra/llmessage/lllogtextmessage.cpp
index 06cc9c8..06c88b9 100644
--- a/linden/indra/llmessage/lllogtextmessage.cpp
+++ b/linden/indra/llmessage/lllogtextmessage.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lllogtextmessage.h b/linden/indra/llmessage/lllogtextmessage.h
index 2413376..89fb90c 100644
--- a/linden/indra/llmessage/lllogtextmessage.h
+++ b/linden/indra/llmessage/lllogtextmessage.h
@@ -7,6 +7,7 @@
7 * 7 *
8 * Copyright (c) 2005-2007, Linden Research, Inc. 8 * Copyright (c) 2005-2007, Linden Research, Inc.
9 * 9 *
10 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 11 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0 12 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement 13 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmail.cpp b/linden/indra/llmessage/llmail.cpp
index aea3689..793cb19 100644
--- a/linden/indra/llmessage/llmail.cpp
+++ b/linden/indra/llmessage/llmail.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmail.h b/linden/indra/llmessage/llmail.h
index b1dc3b5..26aaa3a 100644
--- a/linden/indra/llmessage/llmail.h
+++ b/linden/indra/llmessage/llmail.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmessage.vcproj b/linden/indra/llmessage/llmessage.vcproj
index 11f4dbf..ac16f52 100644
--- a/linden/indra/llmessage/llmessage.vcproj
+++ b/linden/indra/llmessage/llmessage.vcproj
@@ -201,6 +201,9 @@
201 RelativePath=".\llhttpnode.cpp"> 201 RelativePath=".\llhttpnode.cpp">
202 </File> 202 </File>
203 <File 203 <File
204 RelativePath=".\llhttpsender.cpp">
205 </File>
206 <File
204 RelativePath=".\llinstantmessage.cpp"> 207 RelativePath=".\llinstantmessage.cpp">
205 </File> 208 </File>
206 <File 209 <File
@@ -225,6 +228,18 @@
225 RelativePath=".\llmail.cpp"> 228 RelativePath=".\llmail.cpp">
226 </File> 229 </File>
227 <File 230 <File
231 RelativePath=".\llmessagebuilder.cpp">
232 </File>
233 <File
234 RelativePath=".\llmessageconfig.cpp">
235 </File>
236 <File
237 RelativePath=".\llmessagereader.cpp">
238 </File>
239 <File
240 RelativePath=".\llmessagetemplate.cpp">
241 </File>
242 <File
228 RelativePath=".\llmessagethrottle.cpp"> 243 RelativePath=".\llmessagethrottle.cpp">
229 </File> 244 </File>
230 <File 245 <File
@@ -255,7 +270,10 @@
255 RelativePath=".\llsdhttpserver.cpp"> 270 RelativePath=".\llsdhttpserver.cpp">
256 </File> 271 </File>
257 <File 272 <File
258 RelativePath=".\llsdmessagesystem.cpp"> 273 RelativePath=".\llsdmessagebuilder.cpp">
274 </File>
275 <File
276 RelativePath=".\llsdmessagereader.cpp">
259 </File> 277 </File>
260 <File 278 <File
261 RelativePath=".\llsdrpcclient.cpp"> 279 RelativePath=".\llsdrpcclient.cpp">
@@ -267,6 +285,15 @@
267 RelativePath=".\llservice.cpp"> 285 RelativePath=".\llservice.cpp">
268 </File> 286 </File>
269 <File 287 <File
288 RelativePath=".\llservicebuilder.cpp">
289 </File>
290 <File
291 RelativePath=".\lltemplatemessagebuilder.cpp">
292 </File>
293 <File
294 RelativePath=".\lltemplatemessagereader.cpp">
295 </File>
296 <File
270 RelativePath=".\llthrottle.cpp"> 297 RelativePath=".\llthrottle.cpp">
271 </File> 298 </File>
272 <File 299 <File
@@ -410,6 +437,9 @@
410 RelativePath=".\llhttpclient.h"> 437 RelativePath=".\llhttpclient.h">
411 </File> 438 </File>
412 <File 439 <File
440 RelativePath=".\llhttpsender.h">
441 </File>
442 <File
413 RelativePath=".\llinstantmessage.h"> 443 RelativePath=".\llinstantmessage.h">
414 </File> 444 </File>
415 <File 445 <File
@@ -443,6 +473,12 @@
443 RelativePath=".\llmail.h"> 473 RelativePath=".\llmail.h">
444 </File> 474 </File>
445 <File 475 <File
476 RelativePath=".\llmessageconfig.h">
477 </File>
478 <File
479 RelativePath=".\llmessagetemplate.h">
480 </File>
481 <File
446 RelativePath=".\llmessagethrottle.h"> 482 RelativePath=".\llmessagethrottle.h">
447 </File> 483 </File>
448 <File 484 <File
@@ -485,7 +521,10 @@
485 RelativePath=".\llsdhttpserver.h"> 521 RelativePath=".\llsdhttpserver.h">
486 </File> 522 </File>
487 <File 523 <File
488 RelativePath=".\llsdmessagesystem.h"> 524 RelativePath=".\llsdmessagebuilder.h">
525 </File>
526 <File
527 RelativePath=".\llsdmessagereader.h">
489 </File> 528 </File>
490 <File 529 <File
491 RelativePath=".\llsdrpcclient.h"> 530 RelativePath=".\llsdrpcclient.h">
@@ -497,12 +536,21 @@
497 RelativePath=".\llservice.h"> 536 RelativePath=".\llservice.h">
498 </File> 537 </File>
499 <File 538 <File
539 RelativePath=".\llservicebuilder.h">
540 </File>
541 <File
500 RelativePath=".\lltaskname.h"> 542 RelativePath=".\lltaskname.h">
501 </File> 543 </File>
502 <File 544 <File
503 RelativePath=".\llteleportflags.h"> 545 RelativePath=".\llteleportflags.h">
504 </File> 546 </File>
505 <File 547 <File
548 RelativePath=".\lltemplatemessagebuilder.h">
549 </File>
550 <File
551 RelativePath=".\lltemplatemessagereader.h">
552 </File>
553 <File
506 RelativePath=".\llthrottle.h"> 554 RelativePath=".\llthrottle.h">
507 </File> 555 </File>
508 <File 556 <File
diff --git a/linden/indra/newview/llviewerreputation.h b/linden/indra/llmessage/llmessagebuilder.cpp
index 04c8fd3..364e417 100644
--- a/linden/indra/newview/llviewerreputation.h
+++ b/linden/indra/llmessage/llmessagebuilder.cpp
@@ -1,9 +1,10 @@
1/** 1/**
2 * @file llviewerreputation.h 2 * @file llmessagebuilder.cpp
3 * @brief Viewer-side handling of reputation system 3 * @brief LLMessageBuilder class implementation
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -25,16 +26,13 @@
25 * COMPLETENESS OR PERFORMANCE. 26 * COMPLETENESS OR PERFORMANCE.
26 */ 27 */
27 28
28#ifndef LLVIEWERREPUTATION_H 29#include "linden_common.h"
29#define LLVIEWERREPUTATION_H
30 30
31class LLMessageSystem; 31#include "llmessagebuilder.h"
32class LLUUID;
33 32
33//virtual
34LLMessageBuilder::~LLMessageBuilder()
35{
36 // even abstract base classes need a concrete destructor
37}
34 38
35// messaging
36void send_reputation_agent_assign( const LLUUID& rator, const LLUUID& ratee, F32 behavior, F32 appearance, F32 building, const char* text = NULL);
37void send_reputation_agent_request(const LLUUID& ratee_id);
38
39
40#endif
diff --git a/linden/indra/llmessage/llmessagebuilder.h b/linden/indra/llmessage/llmessagebuilder.h
new file mode 100644
index 0000000..7ae09c5
--- /dev/null
+++ b/linden/indra/llmessage/llmessagebuilder.h
@@ -0,0 +1,70 @@
1#ifndef LL_LLMESSAGEBUILDER_H
2#define LL_LLMESSAGEBUILDER_H
3
4#include <string>
5
6#include "stdtypes.h"
7
8class LLMsgData;
9class LLQuaternion;
10class LLSD;
11class LLUUID;
12class LLVector3;
13class LLVector3d;
14class LLVector4;
15
16class LLMessageBuilder
17{
18public:
19
20 //CLASS_LOG_TYPE(LLMessageBuilder);
21
22 virtual ~LLMessageBuilder();
23 virtual void newMessage(const char *name) = 0;
24
25 virtual void nextBlock(const char* blockname) = 0;
26 virtual BOOL removeLastBlock() = 0; // TODO: babbage: remove this horror
27
28 /** All add* methods expect pointers to canonical strings. */
29 virtual void addBinaryData(const char *varname, const void *data,
30 S32 size) = 0;
31 virtual void addBOOL(const char* varname, BOOL b) = 0;
32 virtual void addS8(const char *varname, S8 s) = 0;
33 virtual void addU8(const char *varname, U8 u) = 0;
34 virtual void addS16(const char *varname, S16 i) = 0;
35 virtual void addU16(const char *varname, U16 i) = 0;
36 virtual void addF32(const char *varname, F32 f) = 0;
37 virtual void addS32(const char *varname, S32 s) = 0;
38 virtual void addU32(const char *varname, U32 u) = 0;
39 virtual void addU64(const char *varname, U64 lu) = 0;
40 virtual void addF64(const char *varname, F64 d) = 0;
41 virtual void addVector3(const char *varname, const LLVector3& vec) = 0;
42 virtual void addVector4(const char *varname, const LLVector4& vec) = 0;
43 virtual void addVector3d(const char *varname, const LLVector3d& vec) = 0;
44 virtual void addQuat(const char *varname, const LLQuaternion& quat) = 0;
45 virtual void addUUID(const char *varname, const LLUUID& uuid) = 0;
46 virtual void addIPAddr(const char *varname, const U32 ip) = 0;
47 virtual void addIPPort(const char *varname, const U16 port) = 0;
48 virtual void addString(const char* varname, const char* s) = 0;
49 virtual void addString(const char* varname, const std::string& s) = 0;
50
51 virtual BOOL isMessageFull(const char* blockname) const = 0;
52 virtual void compressMessage(U8*& buf_ptr, U32& buffer_length) = 0;
53 virtual S32 getMessageSize() = 0;
54
55 virtual BOOL isBuilt() const = 0;
56 virtual BOOL isClear() const = 0;
57 virtual U32 buildMessage(U8* buffer, U32 buffer_size) = 0;
58 /**< Return built message size */
59 virtual void clearMessage() = 0;
60
61 // TODO: babbage: remove this horror
62 virtual void setBuilt(BOOL b) = 0;
63
64 virtual const char* getMessageName() const = 0;
65
66 virtual void copyFromMessageData(const LLMsgData& data) = 0;
67 virtual void copyFromLLSD(const LLSD& data) = 0;
68};
69
70#endif // LL_LLMESSAGEBUILDER_H
diff --git a/linden/indra/llmessage/llmessageconfig.cpp b/linden/indra/llmessage/llmessageconfig.cpp
new file mode 100644
index 0000000..a0566ea
--- /dev/null
+++ b/linden/indra/llmessage/llmessageconfig.cpp
@@ -0,0 +1,230 @@
1/**
2 * @file llmessageconfig.cpp
3 * @brief Live file handling for messaging
4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#include "linden_common.h"
30
31#include "llmessageconfig.h"
32#include "llfile.h"
33#include "lllivefile.h"
34#include "llsd.h"
35#include "llsdserialize.h"
36
37static const char messageConfigFileName[] = "message.xml";
38static const F32 messageConfigRefreshRate = 5.0; // seconds
39static std::string sServerName = "";
40static std::string sConfigDir = "";
41
42class LLMessageConfigFile : public LLLiveFile
43{
44private:
45 LLMessageConfigFile()
46 : LLLiveFile(fileName(), messageConfigRefreshRate),
47 mChanged(false)
48 { }
49
50 static std::string fileName();
51
52public:
53 static LLMessageConfigFile& instance();
54 // return the singleton configuration file
55
56protected:
57 /* virtual */ void loadFile();
58 void loadServerDefaults(const LLSD& data);
59 void loadMessages(const LLSD& data);
60
61public:
62 bool mChanged;
63
64 std::string mServerDefault;
65 LLSD mMessages;
66};
67
68std::string LLMessageConfigFile::fileName()
69{
70 std::ostringstream ostr;
71 ostr << sConfigDir//gAppSimp->getOption("configdir").asString()
72 << "/" << messageConfigFileName;
73 return ostr.str();
74}
75
76LLMessageConfigFile& LLMessageConfigFile::instance()
77{
78 static LLMessageConfigFile the_file;
79 the_file.checkAndReload();
80 return the_file;
81}
82
83// virtual
84void LLMessageConfigFile::loadFile()
85{
86 LLSD data;
87 {
88 llifstream file(filename().c_str());
89 if (file.is_open())
90 {
91 llinfos << "Loading message.xml file at " << fileName() << llendl;
92 LLSDSerialize::fromXML(data, file);
93 }
94
95 if (data.isUndefined())
96 {
97 llinfos << "LLMessageConfigFile::loadFile: file missing,"
98 " ill-formed, or simply undefined; not changing the"
99 " file" << llendl;
100 return;
101 }
102 }
103 loadServerDefaults(data);
104 loadMessages(data);
105}
106
107void LLMessageConfigFile::loadServerDefaults(const LLSD& data)
108{
109 mServerDefault = data["serverDefaults"][sServerName].asString();
110 lldebugs << "loading default " << mServerDefault << llendl;
111}
112
113void LLMessageConfigFile::loadMessages(const LLSD& data)
114{
115 mMessages = data["messages"];
116 std::ostringstream out;
117 LLSDXMLFormatter *formatter = new LLSDXMLFormatter;
118 formatter->format(mMessages, out);
119 lldebugs << "loading ... " << out.str()
120 << " LLMessageConfigFile::loadMessages loaded "
121 << mMessages.size() << " messages" << llendl;
122}
123
124
125//---------------------------------------------------------------
126// LLMessageConfig
127//---------------------------------------------------------------
128
129//static
130void LLMessageConfig::initClass(const std::string& server_name,
131 const std::string& config_dir)
132{
133 sServerName = server_name;
134 sConfigDir = config_dir;
135 (void) LLMessageConfigFile::instance();
136 llinfos << "LLMessageConfig::intiClass config file "
137 << config_dir << "/" << messageConfigFileName << llendl;
138}
139
140//static
141bool LLMessageConfig::isServerDefaultBuilderLLSD()
142{
143 if (sServerName.empty())
144 {
145 llerrs << "LLMessageConfig::isServerDefaultBuilderLLSD() before"
146 << " LLMessageConfig::initClass()" << llendl;
147 }
148 LLMessageConfigFile& file = LLMessageConfigFile::instance();
149 return (file.mServerDefault == "llsd");
150}
151
152//static
153bool LLMessageConfig::isServerDefaultBuilderTemplate()
154{
155 if (sServerName.empty())
156 {
157 llerrs << "LLMessageConfig::isServerDefaultBuilderTemplate() before"
158 << " LLMessageConfig::initClass()" << llendl;
159 }
160 LLMessageConfigFile& file = LLMessageConfigFile::instance();
161 return (file.mServerDefault == "template");
162}
163
164//static
165bool LLMessageConfig::isMessageBuiltLLSD(const std::string& msg_name)
166{
167 if (sServerName.empty())
168 {
169 llerrs << "LLMessageConfig::isMessageBuiltLLSD(name) before"
170 << " LLMessageConfig::initClass()" << llendl;
171 }
172 LLMessageConfigFile& file = LLMessageConfigFile::instance();
173 LLSD config = file.mMessages[msg_name];
174 if (!config.has("builder"))
175 {
176 return isServerDefaultBuilderLLSD();
177 }
178 return (config["builder"].asString() == "llsd");
179}
180
181//static
182bool LLMessageConfig::isMessageBuiltTemplate(const std::string& msg_name)
183{
184 if (sServerName.empty())
185 {
186 llerrs << "LLMessageConfig::isMessageBuiltTemplate(name) before"
187 << " LLMessageConfig::initClass()" << llendl;
188 }
189 LLMessageConfigFile& file = LLMessageConfigFile::instance();
190 LLSD config = file.mMessages[msg_name];
191 if (!config.has("builder"))
192 {
193 return isServerDefaultBuilderTemplate();
194 }
195 return (config["builder"].asString() == "template");
196}
197
198//static
199bool LLMessageConfig::isMessageTrusted(const std::string& msg_name)
200{
201 if (sServerName.empty())
202 {
203 llerrs << "LLMessageConfig::isMessageTrusted(name) before"
204 << " LLMessageConfig::initClass()" << llendl;
205 }
206 LLMessageConfigFile& file = LLMessageConfigFile::instance();
207 LLSD config = file.mMessages[msg_name];
208 if (!config.has("trusted-sender"))
209 {
210 return false;
211 }
212 return config["trusted-sender"].asBoolean();
213}
214
215//static
216bool LLMessageConfig::isValidUntrustedMessage(const std::string& msg_name)
217{
218 if (sServerName.empty())
219 {
220 llerrs << "LLMessageConfig::isMessageTrusted(name) before"
221 << " LLMessageConfig::initClass()" << llendl;
222 }
223 LLMessageConfigFile& file = LLMessageConfigFile::instance();
224 LLSD config = file.mMessages[msg_name];
225 if (!config.has("trusted-sender"))
226 {
227 return false;
228 }
229 return !(config["trusted-sender"].asBoolean());
230}
diff --git a/linden/indra/llmessage/llmessageconfig.h b/linden/indra/llmessage/llmessageconfig.h
new file mode 100644
index 0000000..1664ce6
--- /dev/null
+++ b/linden/indra/llmessage/llmessageconfig.h
@@ -0,0 +1,51 @@
1/**
2 * @file llmessageconfig.h
3 * @brief Live file handling for messaging
4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 *
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_MESSAGECONFIG_H
30#define LL_MESSAGECONFIG_H
31
32#include <string>
33
34class LLMessageConfig
35{
36public:
37 static void initClass(const std::string& server_name,
38 const std::string& config_dir);
39 // force loading of config file during startup process
40 // so it can be used for startup features
41
42 static bool isServerDefaultBuilderLLSD();
43 static bool isServerDefaultBuilderTemplate();
44
45 // For individual messages
46 static bool isMessageBuiltLLSD(const std::string& msg_name);
47 static bool isMessageBuiltTemplate(const std::string& msg_name);
48 static bool isMessageTrusted(const std::string& msg_name);
49 static bool isValidUntrustedMessage(const std::string& msg_name);
50};
51#endif // LL_MESSAGECONFIG_H
diff --git a/linden/indra/llmessage/llmessagereader.cpp b/linden/indra/llmessage/llmessagereader.cpp
new file mode 100644
index 0000000..4824480
--- /dev/null
+++ b/linden/indra/llmessage/llmessagereader.cpp
@@ -0,0 +1,35 @@
1#include "llmessagereader.h"
2
3static BOOL sTimeDecodes = FALSE;
4
5static F32 sTimeDecodesSpamThreshold = 0.05f;
6
7//virtual
8LLMessageReader::~LLMessageReader()
9{
10 // even abstract base classes need a concrete destructor
11}
12
13//static
14void LLMessageReader::setTimeDecodes(BOOL b)
15{
16 sTimeDecodes = b;
17}
18
19//static
20void LLMessageReader::setTimeDecodesSpamThreshold(F32 seconds)
21{
22 sTimeDecodesSpamThreshold = seconds;
23}
24
25//static
26BOOL LLMessageReader::getTimeDecodes()
27{
28 return sTimeDecodes;
29}
30
31//static
32F32 LLMessageReader::getTimeDecodesSpamThreshold()
33{
34 return sTimeDecodesSpamThreshold;
35}
diff --git a/linden/indra/llmessage/llmessagereader.h b/linden/indra/llmessage/llmessagereader.h
new file mode 100644
index 0000000..33ce928
--- /dev/null
+++ b/linden/indra/llmessage/llmessagereader.h
@@ -0,0 +1,59 @@
1#ifndef LL_LLMESSAGEREADER_H
2#define LL_LLMESSAGEREADER_H
3
4#include "stdtypes.h"
5
6class LLHost;
7class LLMessageBuilder;
8class LLMsgData;
9class LLQuaternion;
10class LLUUID;
11class LLVector3;
12class LLVector3d;
13class LLVector4;
14
15class LLMessageReader
16{
17 public:
18
19 virtual ~LLMessageReader();
20
21 /** All get* methods expect pointers to canonical strings. */
22 virtual void getBinaryData(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX) = 0;
23 virtual void getBOOL(const char *block, const char *var, BOOL &data, S32 blocknum = 0) = 0;
24 virtual void getS8(const char *block, const char *var, S8 &data, S32 blocknum = 0) = 0;
25 virtual void getU8(const char *block, const char *var, U8 &data, S32 blocknum = 0) = 0;
26 virtual void getS16(const char *block, const char *var, S16 &data, S32 blocknum = 0) = 0;
27 virtual void getU16(const char *block, const char *var, U16 &data, S32 blocknum = 0) = 0;
28 virtual void getS32(const char *block, const char *var, S32 &data, S32 blocknum = 0) = 0;
29 virtual void getF32(const char *block, const char *var, F32 &data, S32 blocknum = 0) = 0;
30 virtual void getU32(const char *block, const char *var, U32 &data, S32 blocknum = 0) = 0;
31 virtual void getU64(const char *block, const char *var, U64 &data, S32 blocknum = 0) = 0;
32 virtual void getF64(const char *block, const char *var, F64 &data, S32 blocknum = 0) = 0;
33 virtual void getVector3(const char *block, const char *var, LLVector3 &vec, S32 blocknum = 0) = 0;
34 virtual void getVector4(const char *block, const char *var, LLVector4 &vec, S32 blocknum = 0) = 0;
35 virtual void getVector3d(const char *block, const char *var, LLVector3d &vec, S32 blocknum = 0) = 0;
36 virtual void getQuat(const char *block, const char *var, LLQuaternion &q, S32 blocknum = 0) = 0;
37 virtual void getUUID(const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0) = 0;
38 virtual void getIPAddr(const char *block, const char *var, U32 &ip, S32 blocknum = 0) = 0;
39 virtual void getIPPort(const char *block, const char *var, U16 &port, S32 blocknum = 0) = 0;
40 virtual void getString(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0) = 0;
41
42 virtual S32 getNumberOfBlocks(const char *blockname) = 0;
43 virtual S32 getSize(const char *blockname, const char *varname) = 0;
44 virtual S32 getSize(const char *blockname, S32 blocknum, const char *varname) = 0;
45
46 virtual void clearMessage() = 0;
47
48 virtual const char* getMessageName() const = 0;
49 virtual S32 getMessageSize() const = 0;
50
51 virtual void copyToBuilder(LLMessageBuilder&) const = 0;
52
53 static void setTimeDecodes(BOOL b);
54 static BOOL getTimeDecodes();
55 static void setTimeDecodesSpamThreshold(F32 seconds);
56 static F32 getTimeDecodesSpamThreshold();
57};
58
59#endif // LL_LLMESSAGEREADER_H
diff --git a/linden/indra/llmessage/llmessagetemplate.cpp b/linden/indra/llmessage/llmessagetemplate.cpp
new file mode 100644
index 0000000..026843d
--- /dev/null
+++ b/linden/indra/llmessage/llmessagetemplate.cpp
@@ -0,0 +1,146 @@
1#include "linden_common.h"
2
3#include "llmessagetemplate.h"
4
5#include "message.h"
6
7void LLMsgVarData::addData(const void *data, S32 size, EMsgVariableType type, S32 data_size)
8{
9 mSize = size;
10 mDataSize = data_size;
11 if ( (type != MVT_VARIABLE) && (type != MVT_FIXED)
12 && (mType != MVT_VARIABLE) && (mType != MVT_FIXED))
13 {
14 if (mType != type)
15 {
16 llwarns << "Type mismatch in LLMsgVarData::addData for " << mName
17 << llendl;
18 }
19 }
20 if(size)
21 {
22 delete mData; // Delete it if it already exists
23 mData = new U8[size];
24 htonmemcpy(mData, data, mType, size);
25 }
26}
27
28void LLMsgData::addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size)
29{
30 // remember that if the blocknumber is > 0 then the number is appended to the name
31 char *namep = (char *)blockname;
32 LLMsgBlkData* block_data = mMemberBlocks[namep];
33 if (block_data->mBlockNumber)
34 {
35 namep += block_data->mBlockNumber;
36 block_data->addData(varname, data, size, type, data_size);
37 }
38 else
39 {
40 block_data->addData(varname, data, size, type, data_size);
41 }
42}
43
44// LLMessageVariable functions and friends
45
46std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg)
47{
48 s << "\t\t" << msg.mName << " (";
49 switch (msg.mType)
50 {
51 case MVT_FIXED:
52 s << "Fixed, " << msg.mSize << " bytes total)\n";
53 break;
54 case MVT_VARIABLE:
55 s << "Variable, " << msg.mSize << " bytes of size info)\n";
56 break;
57 default:
58 s << "Unknown\n";
59 break;
60 }
61 return s;
62}
63
64// LLMessageBlock functions and friends
65
66std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg)
67{
68 s << "\t" << msg.mName << " (";
69 switch (msg.mType)
70 {
71 case MBT_SINGLE:
72 s << "Fixed";
73 break;
74 case MBT_MULTIPLE:
75 s << "Multiple - " << msg.mNumber << " copies";
76 break;
77 case MBT_VARIABLE:
78 s << "Variable";
79 break;
80 default:
81 s << "Unknown";
82 break;
83 }
84 if (msg.mTotalSize != -1)
85 {
86 s << ", " << msg.mTotalSize << " bytes each, " << msg.mNumber*msg.mTotalSize << " bytes total)\n";
87 }
88 else
89 {
90 s << ")\n";
91 }
92
93
94 for (LLMessageBlock::message_variable_map_t::iterator iter = msg.mMemberVariables.begin();
95 iter != msg.mMemberVariables.end(); iter++)
96 {
97 LLMessageVariable& ci = *(iter->second);
98 s << ci;
99 }
100
101 return s;
102}
103
104// LLMessageTemplate functions and friends
105
106std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg)
107{
108 switch (msg.mFrequency)
109 {
110 case MFT_HIGH:
111 s << "========================================\n" << "Message #" << msg.mMessageNumber << "\n" << msg.mName << " (";
112 s << "High";
113 break;
114 case MFT_MEDIUM:
115 s << "========================================\n" << "Message #";
116 s << (msg.mMessageNumber & 0xFF) << "\n" << msg.mName << " (";
117 s << "Medium";
118 break;
119 case MFT_LOW:
120 s << "========================================\n" << "Message #";
121 s << (msg.mMessageNumber & 0xFFFF) << "\n" << msg.mName << " (";
122 s << "Low";
123 break;
124 default:
125 s << "Unknown";
126 break;
127 }
128
129 if (msg.mTotalSize != -1)
130 {
131 s << ", " << msg.mTotalSize << " bytes total)\n";
132 }
133 else
134 {
135 s << ")\n";
136 }
137
138 for (LLMessageTemplate::message_block_map_t::iterator iter = msg.mMemberBlocks.begin();
139 iter != msg.mMemberBlocks.end(); iter++)
140 {
141 LLMessageBlock* ci = iter->second;
142 s << *ci;
143 }
144
145 return s;
146}
diff --git a/linden/indra/llmessage/llmessagetemplate.h b/linden/indra/llmessage/llmessagetemplate.h
new file mode 100644
index 0000000..8847ddc
--- /dev/null
+++ b/linden/indra/llmessage/llmessagetemplate.h
@@ -0,0 +1,356 @@
1#ifndef LL_LLMESSAGETEMPLATE_H
2#define LL_LLMESSAGETEMPLATE_H
3
4#include "lldarray.h"
5#include "message.h" // TODO: babbage: Remove...
6#include "llstl.h"
7
8class LLMsgVarData
9{
10public:
11 LLMsgVarData() : mName(NULL), mSize(-1), mDataSize(-1), mData(NULL), mType(MVT_U8)
12 {
13 }
14
15 LLMsgVarData(const char *name, EMsgVariableType type) : mSize(-1), mDataSize(-1), mData(NULL), mType(type)
16 {
17 mName = (char *)name;
18 }
19
20 ~LLMsgVarData()
21 {
22 // copy constructor just copies the mData pointer, so only delete mData explicitly
23 }
24
25 void deleteData()
26 {
27 delete[] mData;
28 mData = NULL;
29 }
30
31 void addData(const void *indata, S32 size, EMsgVariableType type, S32 data_size = -1);
32
33 char *getName() const { return mName; }
34 S32 getSize() const { return mSize; }
35 void *getData() { return (void*)mData; }
36 const void *getData() const { return (const void*)mData; }
37 S32 getDataSize() const { return mDataSize; }
38 EMsgVariableType getType() const { return mType; }
39
40protected:
41 char *mName;
42 S32 mSize;
43 S32 mDataSize;
44
45 U8 *mData;
46 EMsgVariableType mType;
47};
48
49class LLMsgBlkData
50{
51public:
52 LLMsgBlkData(const char *name, S32 blocknum) : mOffset(-1), mBlockNumber(blocknum), mTotalSize(-1)
53 {
54 mName = (char *)name;
55 }
56
57 ~LLMsgBlkData()
58 {
59 for (msg_var_data_map_t::iterator iter = mMemberVarData.begin();
60 iter != mMemberVarData.end(); iter++)
61 {
62 iter->deleteData();
63 }
64 }
65
66 void addVariable(const char *name, EMsgVariableType type)
67 {
68 LLMsgVarData tmp(name,type);
69 mMemberVarData[name] = tmp;
70 }
71
72 void addData(char *name, const void *data, S32 size, EMsgVariableType type, S32 data_size = -1)
73 {
74 LLMsgVarData* temp = &mMemberVarData[name]; // creates a new entry if one doesn't exist
75 temp->addData(data, size, type, data_size);
76 }
77
78 S32 mOffset;
79 S32 mBlockNumber;
80 typedef LLDynamicArrayIndexed<LLMsgVarData, const char *, 8> msg_var_data_map_t;
81 msg_var_data_map_t mMemberVarData;
82 char *mName;
83 S32 mTotalSize;
84};
85
86class LLMsgData
87{
88public:
89 LLMsgData(const char *name) : mTotalSize(-1)
90 {
91 mName = (char *)name;
92 }
93 ~LLMsgData()
94 {
95 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePairedPointer());
96 }
97
98 void addBlock(LLMsgBlkData *blockp)
99 {
100 mMemberBlocks[blockp->mName] = blockp;
101 }
102
103 void addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size = -1);
104
105public:
106 S32 mOffset;
107 typedef std::map<char*, LLMsgBlkData*> msg_blk_data_map_t;
108 msg_blk_data_map_t mMemberBlocks;
109 char *mName;
110 S32 mTotalSize;
111};
112
113// LLMessage* classes store the template of messages
114class LLMessageVariable
115{
116public:
117 LLMessageVariable() : mName(NULL), mType(MVT_NULL), mSize(-1)
118 {
119 }
120
121 LLMessageVariable(char *name) : mType(MVT_NULL), mSize(-1)
122 {
123 mName = name;
124 }
125
126 LLMessageVariable(char *name, const EMsgVariableType type, const S32 size) : mType(type), mSize(size)
127 {
128 mName = gMessageStringTable.getString(name);
129 }
130
131 ~LLMessageVariable() {}
132
133 friend std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg);
134
135 EMsgVariableType getType() const { return mType; }
136 S32 getSize() const { return mSize; }
137 char *getName() const { return mName; }
138protected:
139 char *mName;
140 EMsgVariableType mType;
141 S32 mSize;
142};
143
144
145typedef enum e_message_block_type
146{
147 MBT_NULL,
148 MBT_SINGLE,
149 MBT_MULTIPLE,
150 MBT_VARIABLE,
151 MBT_EOF
152} EMsgBlockType;
153
154class LLMessageBlock
155{
156public:
157 LLMessageBlock(char *name, EMsgBlockType type, S32 number = 1) : mType(type), mNumber(number), mTotalSize(0)
158 {
159 mName = gMessageStringTable.getString(name);
160 }
161
162 ~LLMessageBlock()
163 {
164 for_each(mMemberVariables.begin(), mMemberVariables.end(), DeletePairedPointer());
165 }
166
167 void addVariable(char *name, const EMsgVariableType type, const S32 size)
168 {
169 LLMessageVariable** varp = &mMemberVariables[name];
170 if (*varp != NULL)
171 {
172 llerrs << name << " has already been used as a variable name!" << llendl;
173 }
174 *varp = new LLMessageVariable(name, type, size);
175 if (((*varp)->getType() != MVT_VARIABLE)
176 &&(mTotalSize != -1))
177 {
178 mTotalSize += (*varp)->getSize();
179 }
180 else
181 {
182 mTotalSize = -1;
183 }
184 }
185
186 EMsgVariableType getVariableType(char *name)
187 {
188 return (mMemberVariables[name])->getType();
189 }
190
191 S32 getVariableSize(char *name)
192 {
193 return (mMemberVariables[name])->getSize();
194 }
195
196 friend std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg);
197
198 typedef std::map<const char *, LLMessageVariable*> message_variable_map_t;
199 message_variable_map_t mMemberVariables;
200 char *mName;
201 EMsgBlockType mType;
202 S32 mNumber;
203 S32 mTotalSize;
204};
205
206
207enum EMsgFrequency
208{
209 MFT_NULL = 0, // value is size of message number in bytes
210 MFT_HIGH = 1,
211 MFT_MEDIUM = 2,
212 MFT_LOW = 4
213};
214
215typedef enum e_message_trust
216{
217 MT_TRUST,
218 MT_NOTRUST
219} EMsgTrust;
220
221enum EMsgEncoding
222{
223 ME_UNENCODED,
224 ME_ZEROCODED
225};
226
227class LLMessageTemplate
228{
229public:
230 LLMessageTemplate(const char *name, U32 message_number, EMsgFrequency freq)
231 :
232 //mMemberBlocks(),
233 mName(NULL),
234 mFrequency(freq),
235 mTrust(MT_NOTRUST),
236 mEncoding(ME_ZEROCODED),
237 mMessageNumber(message_number),
238 mTotalSize(0),
239 mReceiveCount(0),
240 mReceiveBytes(0),
241 mReceiveInvalid(0),
242 mDecodeTimeThisFrame(0.f),
243 mTotalDecoded(0),
244 mTotalDecodeTime(0.f),
245 mMaxDecodeTimePerMsg(0.f),
246 mBanFromTrusted(false),
247 mBanFromUntrusted(false),
248 mHandlerFunc(NULL),
249 mUserData(NULL)
250 {
251 mName = gMessageStringTable.getString(name);
252 }
253
254 ~LLMessageTemplate()
255 {
256 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePairedPointer());
257 }
258
259 void addBlock(LLMessageBlock *blockp)
260 {
261 LLMessageBlock** member_blockp = &mMemberBlocks[blockp->mName];
262 if (*member_blockp != NULL)
263 {
264 llerrs << "Block " << blockp->mName
265 << "has already been used as a block name!" << llendl;
266 }
267 *member_blockp = blockp;
268 if ( (mTotalSize != -1)
269 &&(blockp->mTotalSize != -1)
270 &&( (blockp->mType == MBT_SINGLE)
271 ||(blockp->mType == MBT_MULTIPLE)))
272 {
273 mTotalSize += blockp->mNumber*blockp->mTotalSize;
274 }
275 else
276 {
277 mTotalSize = -1;
278 }
279 }
280
281 LLMessageBlock *getBlock(char *name)
282 {
283 return mMemberBlocks[name];
284 }
285
286 // Trusted messages can only be recieved on trusted circuits.
287 void setTrust(EMsgTrust t)
288 {
289 mTrust = t;
290 }
291
292 EMsgTrust getTrust(void)
293 {
294 return mTrust;
295 }
296
297 // controls for how the message should be encoded
298 void setEncoding(EMsgEncoding e)
299 {
300 mEncoding = e;
301 }
302 EMsgEncoding getEncoding()
303 {
304 return mEncoding;
305 }
306
307 void setHandlerFunc(void (*handler_func)(LLMessageSystem *msgsystem, void **user_data), void **user_data)
308 {
309 mHandlerFunc = handler_func;
310 mUserData = user_data;
311 }
312
313 BOOL callHandlerFunc(LLMessageSystem *msgsystem)
314 {
315 if (mHandlerFunc)
316 {
317 mHandlerFunc(msgsystem, mUserData);
318 return TRUE;
319 }
320 return FALSE;
321 }
322
323 bool isBanned(bool trustedSource)
324 {
325 return trustedSource ? mBanFromTrusted : mBanFromUntrusted;
326 }
327
328 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg);
329
330public:
331 typedef std::map<char*, LLMessageBlock*> message_block_map_t;
332 message_block_map_t mMemberBlocks;
333 char *mName;
334 EMsgFrequency mFrequency;
335 EMsgTrust mTrust;
336 EMsgEncoding mEncoding;
337 U32 mMessageNumber;
338 S32 mTotalSize;
339 U32 mReceiveCount; // how many of this template have been received since last reset
340 U32 mReceiveBytes; // How many bytes received
341 U32 mReceiveInvalid; // How many "invalid" packets
342 F32 mDecodeTimeThisFrame; // Total seconds spent decoding this frame
343 U32 mTotalDecoded; // Total messages successfully decoded
344 F32 mTotalDecodeTime; // Total time successfully decoding messages
345 F32 mMaxDecodeTimePerMsg;
346
347 bool mBanFromTrusted;
348 bool mBanFromUntrusted;
349
350private:
351 // message handler function (this is set by each application)
352 void (*mHandlerFunc)(LLMessageSystem *msgsystem, void **user_data);
353 void **mUserData;
354};
355
356#endif // LL_LLMESSAGETEMPLATE_H
diff --git a/linden/indra/llmessage/llmessagethrottle.cpp b/linden/indra/llmessage/llmessagethrottle.cpp
index 309a1d9..07c22a5 100644
--- a/linden/indra/llmessage/llmessagethrottle.cpp
+++ b/linden/indra/llmessage/llmessagethrottle.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmessagethrottle.h b/linden/indra/llmessage/llmessagethrottle.h
index 80d4ca3..522358c 100644
--- a/linden/indra/llmessage/llmessagethrottle.h
+++ b/linden/indra/llmessage/llmessagethrottle.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2004-2007, Linden Research, Inc. 5 * Copyright (c) 2004-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmime.cpp b/linden/indra/llmessage/llmime.cpp
index 2786ea8..6938ed7 100644
--- a/linden/indra/llmessage/llmime.cpp
+++ b/linden/indra/llmessage/llmime.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmime.h b/linden/indra/llmessage/llmime.h
index 7cb2b74..307a33d 100644
--- a/linden/indra/llmessage/llmime.h
+++ b/linden/indra/llmessage/llmime.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llmsgvariabletype.h b/linden/indra/llmessage/llmsgvariabletype.h
new file mode 100644
index 0000000..360d949
--- /dev/null
+++ b/linden/indra/llmessage/llmsgvariabletype.h
@@ -0,0 +1,33 @@
1#ifndef LL_LLMSGVARIABLETYPE_H
2#define LL_LLMSGVARIABLETYPE_H
3
4typedef enum e_message_variable_type
5{
6 MVT_NULL,
7 MVT_FIXED,
8 MVT_VARIABLE,
9 MVT_U8,
10 MVT_U16,
11 MVT_U32,
12 MVT_U64,
13 MVT_S8,
14 MVT_S16,
15 MVT_S32,
16 MVT_S64,
17 MVT_F32,
18 MVT_F64,
19 MVT_LLVector3,
20 MVT_LLVector3d,
21 MVT_LLVector4,
22 MVT_LLQuaternion,
23 MVT_LLUUID,
24 MVT_BOOL,
25 MVT_IP_ADDR,
26 MVT_IP_PORT,
27 MVT_U16Vec3,
28 MVT_U16Quat,
29 MVT_S16Array,
30 MVT_EOL
31} EMsgVariableType;
32
33#endif // LL_LLMSGVARIABLETYPE_H
diff --git a/linden/indra/llmessage/llnamevalue.cpp b/linden/indra/llmessage/llnamevalue.cpp
index 1304923..6e449ed 100644
--- a/linden/indra/llmessage/llnamevalue.cpp
+++ b/linden/indra/llmessage/llnamevalue.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llnamevalue.h b/linden/indra/llmessage/llnamevalue.h
index 89fe71b..fe733fa 100644
--- a/linden/indra/llmessage/llnamevalue.h
+++ b/linden/indra/llmessage/llnamevalue.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llnullcipher.cpp b/linden/indra/llmessage/llnullcipher.cpp
index ad2b25f..eddadeb 100644
--- a/linden/indra/llmessage/llnullcipher.cpp
+++ b/linden/indra/llmessage/llnullcipher.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llnullcipher.h b/linden/indra/llmessage/llnullcipher.h
index 75d022d..2e41063 100644
--- a/linden/indra/llmessage/llnullcipher.h
+++ b/linden/indra/llmessage/llnullcipher.h
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (c) 2003-2007, Linden Research, Inc. 4 * Copyright (c) 2003-2007, Linden Research, Inc.
5 * 5 *
6 * Second Life Viewer Source Code
6 * The source code in this file ("Source Code") is provided by Linden Lab 7 * The source code in this file ("Source Code") is provided by Linden Lab
7 * to you under the terms of the GNU General Public License, version 2.0 8 * to you under the terms of the GNU General Public License, version 2.0
8 * ("GPL"), unless you have obtained a separate licensing agreement 9 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpacketack.h b/linden/indra/llmessage/llpacketack.h
index e8d598a..c86fb0f 100644
--- a/linden/indra/llmessage/llpacketack.h
+++ b/linden/indra/llmessage/llpacketack.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -63,6 +64,14 @@ public:
63public: 64public:
64 LLReliablePacketParams() 65 LLReliablePacketParams()
65 { 66 {
67 clear();
68 };
69
70 ~LLReliablePacketParams() { };
71
72 void clear()
73 {
74 mHost.invalidate();
66 mRetries = 0; 75 mRetries = 0;
67 mPingBasedRetry = TRUE; 76 mPingBasedRetry = TRUE;
68 mTimeout = 0.f; 77 mTimeout = 0.f;
@@ -71,8 +80,6 @@ public:
71 mMessageName = NULL; 80 mMessageName = NULL;
72 }; 81 };
73 82
74 ~LLReliablePacketParams() { };
75
76 void set ( const LLHost &host, S32 retries, BOOL ping_based_retry, 83 void set ( const LLHost &host, S32 retries, BOOL ping_based_retry,
77 F32 timeout, 84 F32 timeout,
78 void (*callback)(void **,S32), void **callback_data, char *name ) 85 void (*callback)(void **,S32), void **callback_data, char *name )
@@ -136,7 +143,13 @@ public:
136 143
137 } 144 }
138 }; 145 };
139 ~LLReliablePacket(){ delete [] mBuffer; }; 146
147 ~LLReliablePacket()
148 {
149 mCallback = NULL;
150 delete [] mBuffer;
151 mBuffer = NULL;
152 };
140 153
141 friend class LLCircuitData; 154 friend class LLCircuitData;
142protected: 155protected:
diff --git a/linden/indra/llmessage/llpacketbuffer.cpp b/linden/indra/llmessage/llpacketbuffer.cpp
index 855fb40..69144f5 100644
--- a/linden/indra/llmessage/llpacketbuffer.cpp
+++ b/linden/indra/llmessage/llpacketbuffer.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpacketbuffer.h b/linden/indra/llmessage/llpacketbuffer.h
index 613418a..17fe446 100644
--- a/linden/indra/llmessage/llpacketbuffer.h
+++ b/linden/indra/llmessage/llpacketbuffer.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpacketring.cpp b/linden/indra/llmessage/llpacketring.cpp
index a2e6eb9..e07c754 100644
--- a/linden/indra/llmessage/llpacketring.cpp
+++ b/linden/indra/llmessage/llpacketring.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpacketring.h b/linden/indra/llmessage/llpacketring.h
index 27b830e..1a0c0c6 100644
--- a/linden/indra/llmessage/llpacketring.h
+++ b/linden/indra/llmessage/llpacketring.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpartdata.cpp b/linden/indra/llmessage/llpartdata.cpp
index de0cb13..f46481e 100644
--- a/linden/indra/llmessage/llpartdata.cpp
+++ b/linden/indra/llmessage/llpartdata.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpartdata.h b/linden/indra/llmessage/llpartdata.h
index 55d22d5..3177e84 100644
--- a/linden/indra/llmessage/llpartdata.h
+++ b/linden/indra/llmessage/llpartdata.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llpumpio.cpp b/linden/indra/llmessage/llpumpio.cpp
index 4ce15b9..e76f3ea 100644
--- a/linden/indra/llmessage/llpumpio.cpp
+++ b/linden/indra/llmessage/llpumpio.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -333,6 +334,12 @@ bool LLPumpIO::copyCurrentLinkInfo(links_t& links) const
333 334
334void LLPumpIO::pump() 335void LLPumpIO::pump()
335{ 336{
337 pump(DEFAULT_POLL_TIMEOUT);
338}
339
340//timeout is in microseconds
341void LLPumpIO::pump(const S32& poll_timeout)
342{
336 LLMemType m1(LLMemType::MTYPE_IO_PUMP); 343 LLMemType m1(LLMemType::MTYPE_IO_PUMP);
337 LLFastTimer t1(LLFastTimer::FTM_PUMP); 344 LLFastTimer t1(LLFastTimer::FTM_PUMP);
338 //llinfos << "LLPumpIO::pump()" << llendl; 345 //llinfos << "LLPumpIO::pump()" << llendl;
@@ -414,7 +421,7 @@ void LLPumpIO::pump()
414 S32 count = 0; 421 S32 count = 0;
415 S32 client_id = 0; 422 S32 client_id = 0;
416 const apr_pollfd_t* poll_fd = NULL; 423 const apr_pollfd_t* poll_fd = NULL;
417 apr_pollset_poll(mPollset, DEFAULT_POLL_TIMEOUT, &count, &poll_fd); 424 apr_pollset_poll(mPollset, poll_timeout, &count, &poll_fd);
418 PUMP_DEBUG; 425 PUMP_DEBUG;
419 for(S32 i = 0; i < count; ++i) 426 for(S32 i = 0; i < count; ++i)
420 { 427 {
diff --git a/linden/indra/llmessage/llpumpio.h b/linden/indra/llmessage/llpumpio.h
index d90d6b0..0f2bd48 100644
--- a/linden/indra/llmessage/llpumpio.h
+++ b/linden/indra/llmessage/llpumpio.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -246,6 +247,7 @@ public:
246 * chain has a file descriptor ready, <code>process()</code> will 247 * chain has a file descriptor ready, <code>process()</code> will
247 * be called for all pipes which have requested it. 248 * be called for all pipes which have requested it.
248 */ 249 */
250 void pump(const S32& poll_timeout);
249 void pump(); 251 void pump();
250 252
251 /** 253 /**
diff --git a/linden/indra/llmessage/llqueryflags.h b/linden/indra/llmessage/llqueryflags.h
index 69ba95a..9143995 100644
--- a/linden/indra/llmessage/llqueryflags.h
+++ b/linden/indra/llmessage/llqueryflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -57,6 +58,9 @@ const U32 DFQ_NAME_SORT = 0x1 << 19;
57const U32 DFQ_LIMIT_BY_PRICE = 0x1 << 20; 58const U32 DFQ_LIMIT_BY_PRICE = 0x1 << 20;
58const U32 DFQ_LIMIT_BY_AREA = 0x1 << 21; 59const U32 DFQ_LIMIT_BY_AREA = 0x1 << 21;
59 60
61const U32 DFQ_FILTER_MATURE = 0x1 << 22;
62const U32 DFQ_PG_PARCELS_ONLY = 0x1 << 23;
63
60// Sell Type flags 64// Sell Type flags
61const U32 ST_AUCTION = 0x1 << 1; 65const U32 ST_AUCTION = 0x1 << 1;
62const U32 ST_NEWBIE = 0x1 << 2; 66const U32 ST_NEWBIE = 0x1 << 2;
diff --git a/linden/indra/llmessage/llregionflags.h b/linden/indra/llmessage/llregionflags.h
index 6a8f72a..6a23544 100644
--- a/linden/indra/llmessage/llregionflags.h
+++ b/linden/indra/llmessage/llregionflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llregionhandle.h b/linden/indra/llmessage/llregionhandle.h
index d943374..ad4cf61 100644
--- a/linden/indra/llmessage/llregionhandle.h
+++ b/linden/indra/llmessage/llregionhandle.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdappservices.cpp b/linden/indra/llmessage/llsdappservices.cpp
index 8574f87..ae1505b 100644
--- a/linden/indra/llmessage/llsdappservices.cpp
+++ b/linden/indra/llmessage/llsdappservices.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdappservices.h b/linden/indra/llmessage/llsdappservices.h
index 8e6e868..0075b2e 100644
--- a/linden/indra/llmessage/llsdappservices.h
+++ b/linden/indra/llmessage/llsdappservices.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2006-2007, Linden Research, Inc. 7 * Copyright (c) 2006-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdhttpserver.cpp b/linden/indra/llmessage/llsdhttpserver.cpp
index 4054680..8ca7f14 100644
--- a/linden/indra/llmessage/llsdhttpserver.cpp
+++ b/linden/indra/llmessage/llsdhttpserver.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdhttpserver.h b/linden/indra/llmessage/llsdhttpserver.h
index 904852f..b6904f3 100644
--- a/linden/indra/llmessage/llsdhttpserver.h
+++ b/linden/indra/llmessage/llsdhttpserver.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdmessagebuilder.cpp b/linden/indra/llmessage/llsdmessagebuilder.cpp
new file mode 100755
index 0000000..b7deb48
--- /dev/null
+++ b/linden/indra/llmessage/llsdmessagebuilder.cpp
@@ -0,0 +1,281 @@
1#include "linden_common.h"
2
3#include "llsdmessagebuilder.h"
4
5#include "llmessagetemplate.h"
6#include "llquaternion.h"
7#include "llsdutil.h"
8#include "llsdserialize.h"
9#include "u64.h"
10#include "v3dmath.h"
11#include "v3math.h"
12#include "v4math.h"
13
14LLSDMessageBuilder::LLSDMessageBuilder() :
15 mCurrentMessage(LLSD::emptyMap()),
16 mCurrentBlock(NULL),
17 mCurrentMessageName(""),
18 mCurrentBlockName(""),
19 mbSBuilt(FALSE),
20 mbSClear(TRUE)
21{
22}
23
24//virtual
25LLSDMessageBuilder::~LLSDMessageBuilder()
26{
27}
28
29
30// virtual
31void LLSDMessageBuilder::newMessage(const char *name)
32{
33 mbSBuilt = FALSE;
34 mbSClear = FALSE;
35
36 mCurrentMessage = LLSD::emptyMap();
37 mCurrentMessageName = (char *)name;
38}
39
40// virtual
41void LLSDMessageBuilder::clearMessage()
42{
43 mbSBuilt = FALSE;
44 mbSClear = TRUE;
45
46 mCurrentMessage = LLSD::emptyMap();
47 mCurrentMessageName = "";
48}
49
50// virtual
51void LLSDMessageBuilder::nextBlock(const char* blockname)
52{
53 LLSD& block = mCurrentMessage[blockname];
54 if(block.isUndefined())
55 {
56 block[0] = LLSD::emptyMap();
57 mCurrentBlock = &(block[0]);
58 }
59 else if(block.isArray())
60 {
61 block[block.size()] = LLSD::emptyMap();
62 mCurrentBlock = &(block[block.size() - 1]);
63 }
64 else
65 {
66 llerrs << "existing block not array" << llendl;
67 }
68}
69
70// TODO: Remove this horror...
71BOOL LLSDMessageBuilder::removeLastBlock()
72{
73 /* TODO: finish implementing this */
74 return FALSE;
75}
76
77void LLSDMessageBuilder::addBinaryData(const char *varname,
78 const void *data, S32 size)
79{
80 std::vector<U8> v;
81 v.resize(size);
82 memcpy(&(v[0]), reinterpret_cast<const U8*>(data), size);
83 (*mCurrentBlock)[varname] = v;
84}
85
86void LLSDMessageBuilder::addS8(const char *varname, S8 v)
87{
88 (*mCurrentBlock)[varname] = v;
89}
90
91void LLSDMessageBuilder::addU8(const char *varname, U8 v)
92{
93 (*mCurrentBlock)[varname] = v;
94}
95
96void LLSDMessageBuilder::addS16(const char *varname, S16 v)
97{
98 (*mCurrentBlock)[varname] = v;
99}
100
101void LLSDMessageBuilder::addU16(const char *varname, U16 v)
102{
103 (*mCurrentBlock)[varname] = v;
104}
105
106void LLSDMessageBuilder::addF32(const char *varname, F32 v)
107{
108 (*mCurrentBlock)[varname] = v;
109}
110
111void LLSDMessageBuilder::addS32(const char *varname, S32 v)
112{
113 (*mCurrentBlock)[varname] = v;
114}
115
116void LLSDMessageBuilder::addU32(const char *varname, U32 v)
117{
118 (*mCurrentBlock)[varname] = ll_sd_from_U32(v);
119}
120
121void LLSDMessageBuilder::addU64(const char *varname, U64 v)
122{
123 (*mCurrentBlock)[varname] = ll_sd_from_U64(v);
124}
125
126void LLSDMessageBuilder::addF64(const char *varname, F64 v)
127{
128 (*mCurrentBlock)[varname] = v;
129}
130
131void LLSDMessageBuilder::addIPAddr(const char *varname, U32 v)
132{
133 (*mCurrentBlock)[varname] = ll_sd_from_ipaddr(v);
134}
135
136void LLSDMessageBuilder::addIPPort(const char *varname, U16 v)
137{
138 (*mCurrentBlock)[varname] = v;
139}
140
141void LLSDMessageBuilder::addBOOL(const char* varname, BOOL v)
142{
143 (*mCurrentBlock)[varname] = (v == TRUE);
144}
145
146void LLSDMessageBuilder::addString(const char* varname, const char* v)
147{
148 if (v)
149 (*mCurrentBlock)[varname] = v; /* Flawfinder: ignore */
150 else
151 (*mCurrentBlock)[varname] = "";
152}
153
154void LLSDMessageBuilder::addString(const char* varname, const std::string& v)
155{
156 if (v.size())
157 (*mCurrentBlock)[varname] = v;
158 else
159 (*mCurrentBlock)[varname] = "";
160}
161
162void LLSDMessageBuilder::addVector3(const char *varname, const LLVector3& v)
163{
164 (*mCurrentBlock)[varname] = ll_sd_from_vector3(v);
165}
166
167void LLSDMessageBuilder::addVector4(const char *varname, const LLVector4& v)
168{
169 (*mCurrentBlock)[varname] = ll_sd_from_vector4(v);
170}
171
172void LLSDMessageBuilder::addVector3d(const char *varname, const LLVector3d& v)
173{
174 (*mCurrentBlock)[varname] = ll_sd_from_vector3d(v);
175}
176
177void LLSDMessageBuilder::addQuat(const char *varname, const LLQuaternion& v)
178{
179 (*mCurrentBlock)[varname] = ll_sd_from_quaternion(v);
180}
181
182void LLSDMessageBuilder::addUUID(const char *varname, const LLUUID& v)
183{
184 (*mCurrentBlock)[varname] = v;
185}
186
187void LLSDMessageBuilder::compressMessage(U8*& buf_ptr, U32& buffer_length)
188{
189}
190
191BOOL LLSDMessageBuilder::isMessageFull(const char* blockname) const
192{
193 return FALSE;
194}
195
196// make sure that all the desired data is in place and then copy the data
197// into MAX_BUFFER_SIZEd buffer
198U32 LLSDMessageBuilder::buildMessage(U8* buffer, U32 buffer_size)
199{
200 return 0;
201}
202
203void LLSDMessageBuilder::copyFromMessageData(const LLMsgData& data)
204{
205 // copy the blocks
206 // counting variables used to encode multiple block info
207 S32 block_count = 0;
208 char *block_name = NULL;
209
210 // loop through msg blocks to loop through variables, totalling up size
211 // data and filling the new (send) message
212 LLMsgData::msg_blk_data_map_t::const_iterator iter =
213 data.mMemberBlocks.begin();
214 LLMsgData::msg_blk_data_map_t::const_iterator end =
215 data.mMemberBlocks.end();
216 for(; iter != end; ++iter)
217 {
218 const LLMsgBlkData* mbci = iter->second;
219 if(!mbci) continue;
220
221 // do we need to encode a block code?
222 if (block_count == 0)
223 {
224 block_count = mbci->mBlockNumber;
225 block_name = (char *)mbci->mName;
226 }
227
228 // counting down mutliple blocks
229 block_count--;
230
231 nextBlock(block_name);
232
233 // now loop through the variables
234 LLMsgBlkData::msg_var_data_map_t::const_iterator dit = mbci->mMemberVarData.begin();
235 LLMsgBlkData::msg_var_data_map_t::const_iterator dend = mbci->mMemberVarData.end();
236
237 for(; dit != dend; ++dit)
238 {
239 //const LLMsgVarData& mvci = *dit;
240
241 // TODO: Copy mvci data in to block:
242 // (*mCurrentBlock)[varname] = v;
243 }
244 }
245}
246
247//virtual
248void LLSDMessageBuilder::copyFromLLSD(const LLSD& msg)
249{
250 mCurrentMessage = msg;
251 llinfos << LLSDXMLStreamer(mCurrentMessage) << llendl;
252}
253
254const LLSD& LLSDMessageBuilder::getMessage() const
255{
256 return mCurrentMessage;
257}
258
259//virtual
260void LLSDMessageBuilder::setBuilt(BOOL b) { mbSBuilt = b; }
261
262//virtual
263BOOL LLSDMessageBuilder::isBuilt() const {return mbSBuilt;}
264
265//virtual
266BOOL LLSDMessageBuilder::isClear() const {return mbSClear;}
267
268//virtual
269S32 LLSDMessageBuilder::getMessageSize()
270{
271 // babbage: size is unknown as message stored as LLSD.
272 // return non-zero if pending data, as send can be skipped for 0 size.
273 // return 1 to encourage senders checking size against splitting message.
274 return mCurrentMessage.size()? 1 : 0;
275}
276
277//virtual
278const char* LLSDMessageBuilder::getMessageName() const
279{
280 return mCurrentMessageName.c_str();
281}
diff --git a/linden/indra/llmessage/llsdmessagebuilder.h b/linden/indra/llmessage/llsdmessagebuilder.h
new file mode 100755
index 0000000..f04194d
--- /dev/null
+++ b/linden/indra/llmessage/llsdmessagebuilder.h
@@ -0,0 +1,98 @@
1#ifndef LL_LLSDMESSAGEBUILDER_H
2#define LL_LLSDMESSAGEBUILDER_H
3
4#include <map>
5
6#include "llmessagebuilder.h"
7#include "llmsgvariabletype.h"
8#include "llsd.h"
9
10class LLMessageTemplate;
11class LLMsgData;
12
13class LLSDMessageBuilder : public LLMessageBuilder
14{
15public:
16
17 //CLASS_LOG_TYPE(LLSDMessageBuilder);
18
19 LLSDMessageBuilder();
20 virtual ~LLSDMessageBuilder();
21
22 virtual void newMessage(const char *name);
23
24 virtual void nextBlock(const char* blockname);
25 virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
26
27 /** All add* methods expect pointers to canonical varname strings. */
28 virtual void addBinaryData(const char *varname, const void *data,
29 S32 size);
30 virtual void addBOOL(const char* varname, BOOL b);
31 virtual void addS8(const char *varname, S8 s);
32 virtual void addU8(const char *varname, U8 u);
33 virtual void addS16(const char *varname, S16 i);
34 virtual void addU16(const char *varname, U16 i);
35 virtual void addF32(const char *varname, F32 f);
36 virtual void addS32(const char *varname, S32 s);
37 virtual void addU32(const char *varname, U32 u);
38 virtual void addU64(const char *varname, U64 lu);
39 virtual void addF64(const char *varname, F64 d);
40 virtual void addVector3(const char *varname, const LLVector3& vec);
41 virtual void addVector4(const char *varname, const LLVector4& vec);
42 virtual void addVector3d(const char *varname, const LLVector3d& vec);
43 virtual void addQuat(const char *varname, const LLQuaternion& quat);
44 virtual void addUUID(const char *varname, const LLUUID& uuid);
45 virtual void addIPAddr(const char *varname, const U32 ip);
46 virtual void addIPPort(const char *varname, const U16 port);
47 virtual void addString(const char* varname, const char* s);
48 virtual void addString(const char* varname, const std::string& s);
49
50 virtual BOOL isMessageFull(const char* blockname) const;
51 virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
52
53 virtual BOOL isBuilt() const;
54 virtual BOOL isClear() const;
55 virtual U32 buildMessage(U8* buffer, U32 buffer_size);
56 /**< Return built message size */
57
58 virtual void clearMessage();
59
60 // TODO: babbage: remove this horror.
61 virtual void setBuilt(BOOL b);
62
63 virtual S32 getMessageSize();
64 virtual const char* getMessageName() const;
65
66 virtual void copyFromMessageData(const LLMsgData& data);
67
68 virtual void copyFromLLSD(const LLSD& msg);
69
70 const LLSD& getMessage() const;
71private:
72
73 /* mCurrentMessage is of the following format:
74 mCurrentMessage = { 'block_name1' : [ { 'block1_field1' : 'b1f1_data',
75 'block1_field2' : 'b1f2_data',
76 ...
77 'block1_fieldn' : 'b1fn_data'},
78 { 'block2_field1' : 'b2f1_data',
79 'block2_field2' : 'b2f2_data',
80 ...
81 'block2_fieldn' : 'b2fn_data'},
82 ...
83 { 'blockm_field1' : 'bmf1_data',
84 'blockm_field2' : 'bmf2_data',
85 ...
86 'blockm_fieldn' : 'bmfn_data'} ],
87 'block_name2' : ...,
88 ...
89 'block_namem' } */
90 LLSD mCurrentMessage;
91 LLSD* mCurrentBlock;
92 std::string mCurrentMessageName;
93 std::string mCurrentBlockName;
94 BOOL mbSBuilt;
95 BOOL mbSClear;
96};
97
98#endif // LL_LLSDMESSAGEBUILDER_H
diff --git a/linden/indra/llmessage/llsdmessagereader.cpp b/linden/indra/llmessage/llsdmessagereader.cpp
new file mode 100755
index 0000000..6312bee
--- /dev/null
+++ b/linden/indra/llmessage/llsdmessagereader.cpp
@@ -0,0 +1,264 @@
1#include "llsdmessagereader.h"
2#include "llsdutil.h"
3#include "llmessagebuilder.h"
4#include "llsdmessagebuilder.h"
5
6LLSDMessageReader::LLSDMessageReader()
7{
8}
9
10//virtual
11LLSDMessageReader::~LLSDMessageReader()
12{
13}
14
15
16LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum)
17{
18 if(input[block].isArray())
19 {
20 return input[block][blocknum][var];
21 }
22 return LLSD();
23}
24
25//virtual
26void LLSDMessageReader::getBinaryData(const char *block, const char *var,
27 void *datap, S32 size, S32 blocknum,
28 S32 max_size)
29{
30 std::vector<U8> data = getLLSD(mMessage, block, var, blocknum);
31 S32 data_size = (S32)data.size();
32
33 if (size && data_size != size)
34 {
35 return;
36 }
37
38 if (max_size < data_size)
39 {
40 data_size = max_size;
41 }
42
43 memcpy(datap, &(data[0]), data_size);
44}
45
46//virtual
47void LLSDMessageReader::getBOOL(const char *block, const char *var,
48 BOOL &data,
49 S32 blocknum)
50{
51 data = getLLSD(mMessage, block, var, blocknum);
52}
53
54//virtual
55void LLSDMessageReader::getS8(const char *block, const char *var, S8 &data,
56 S32 blocknum)
57{
58 data = getLLSD(mMessage, block, var, blocknum).asInteger();
59}
60
61//virtual
62void LLSDMessageReader::getU8(const char *block, const char *var, U8 &data,
63 S32 blocknum)
64{
65 data = getLLSD(mMessage, block, var, blocknum).asInteger();
66}
67
68//virtual
69void LLSDMessageReader::getS16(const char *block, const char *var, S16 &data,
70 S32 blocknum)
71{
72 data = getLLSD(mMessage, block, var, blocknum).asInteger();
73}
74
75//virtual
76void LLSDMessageReader::getU16(const char *block, const char *var, U16 &data,
77 S32 blocknum)
78{
79 data = getLLSD(mMessage, block, var, blocknum).asInteger();
80}
81
82//virtual
83void LLSDMessageReader::getS32(const char *block, const char *var, S32 &data,
84 S32 blocknum)
85{
86 data = getLLSD(mMessage, block, var, blocknum);
87}
88
89//virtual
90void LLSDMessageReader::getF32(const char *block, const char *var, F32 &data,
91 S32 blocknum)
92{
93 data = (F32)getLLSD(mMessage, block, var, blocknum).asReal();
94}
95
96//virtual
97void LLSDMessageReader::getU32(const char *block, const char *var, U32 &data,
98 S32 blocknum)
99{
100 data = ll_U32_from_sd(getLLSD(mMessage, block, var, blocknum));
101}
102
103//virtual
104void LLSDMessageReader::getU64(const char *block, const char *var,
105 U64 &data, S32 blocknum)
106{
107 data = ll_U64_from_sd(getLLSD(mMessage, block, var, blocknum));
108}
109
110//virtual
111void LLSDMessageReader::getF64(const char *block, const char *var,
112 F64 &data, S32 blocknum)
113{
114 data = getLLSD(mMessage, block, var, blocknum);
115}
116
117//virtual
118void LLSDMessageReader::getVector3(const char *block, const char *var,
119 LLVector3 &vec, S32 blocknum)
120{
121 vec = ll_vector3_from_sd(getLLSD(mMessage, block, var, blocknum));
122}
123
124//virtual
125void LLSDMessageReader::getVector4(const char *block, const char *var,
126 LLVector4 &vec, S32 blocknum)
127{
128 vec = ll_vector4_from_sd(getLLSD(mMessage, block, var, blocknum));
129}
130
131//virtual
132void LLSDMessageReader::getVector3d(const char *block, const char *var,
133 LLVector3d &vec, S32 blocknum)
134{
135 vec = ll_vector3d_from_sd(getLLSD(mMessage, block, var, blocknum));
136}
137
138//virtual
139void LLSDMessageReader::getQuat(const char *block, const char *var,
140 LLQuaternion &q, S32 blocknum)
141{
142 q = ll_quaternion_from_sd(getLLSD(mMessage, block, var, blocknum));
143}
144
145//virtual
146void LLSDMessageReader::getUUID(const char *block, const char *var,
147 LLUUID &uuid, S32 blocknum)
148{
149 uuid = getLLSD(mMessage, block, var, blocknum);
150}
151
152//virtual
153void LLSDMessageReader::getIPAddr(const char *block, const char *var,
154 U32 &ip, S32 blocknum)
155{
156 ip = ll_ipaddr_from_sd(getLLSD(mMessage, block, var, blocknum));
157}
158
159//virtual
160void LLSDMessageReader::getIPPort(const char *block, const char *var,
161 U16 &port, S32 blocknum)
162{
163 port = getLLSD(mMessage, block, var, blocknum).asInteger();
164}
165
166//virtual
167void LLSDMessageReader::getString(const char *block, const char *var,
168 S32 buffer_size, char *buffer, S32 blocknum)
169{
170 std::string data = getLLSD(mMessage, block, var, blocknum);
171
172 S32 data_size = data.size();
173 if (data_size >= buffer_size)
174 {
175 data_size = buffer_size - 1;
176 }
177 memcpy(buffer, data.data(), data_size);
178 buffer[data_size] = '\0';
179}
180
181
182//virtual
183S32 LLSDMessageReader::getNumberOfBlocks(const char *blockname)
184{
185 return mMessage[blockname].size();
186}
187
188S32 getElementSize(const LLSD& llsd)
189{
190 LLSD::Type type = llsd.type();
191 switch(type)
192 {
193 case LLSD::TypeBoolean:
194 return sizeof(bool);
195 case LLSD::TypeInteger:
196 return sizeof(S32);
197 case LLSD::TypeReal:
198 return sizeof(F64);
199 case LLSD::TypeString:
200 return llsd.asString().size();
201 case LLSD::TypeUUID:
202 return sizeof(LLUUID);
203 case LLSD::TypeDate:
204 return sizeof(LLDate);
205 case LLSD::TypeURI:
206 return sizeof(LLURI);
207 case LLSD::TypeBinary:
208 {
209 std::vector<U8> data = llsd;
210 return data.size() * sizeof(U8);
211 }
212 case LLSD::TypeMap:
213 case LLSD::TypeArray:
214 case LLSD::TypeUndefined:
215 return 0;
216 }
217 return 0;
218}
219
220//virtual
221//Mainly used to find size of binary block of data
222S32 LLSDMessageReader::getSize(const char *blockname, const char *varname)
223{
224 return getElementSize(mMessage[blockname][0][varname]);
225}
226
227
228//virtual
229S32 LLSDMessageReader::getSize(const char *blockname, S32 blocknum,
230 const char *varname)
231{
232 return getElementSize(mMessage[blockname][blocknum][varname]);
233}
234
235//virtual
236void LLSDMessageReader::clearMessage()
237{
238 mMessage = LLSD();
239}
240
241//virtual
242const char* LLSDMessageReader::getMessageName() const
243{
244 return mMessageName.c_str();
245}
246
247// virtual
248S32 LLSDMessageReader::getMessageSize() const
249{
250 return 0;
251}
252
253//virtual
254void LLSDMessageReader::copyToBuilder(LLMessageBuilder& builder) const
255{
256 builder.copyFromLLSD(mMessage);
257}
258
259void LLSDMessageReader::setMessage(const std::string& name, const LLSD& message)
260{
261 mMessageName = name;
262 // TODO: Validate
263 mMessage = message;
264}
diff --git a/linden/indra/llmessage/llsdmessagereader.h b/linden/indra/llmessage/llsdmessagereader.h
new file mode 100755
index 0000000..5785194
--- /dev/null
+++ b/linden/indra/llmessage/llsdmessagereader.h
@@ -0,0 +1,79 @@
1#ifndef LL_LLSDMESSAGEREADER_H
2#define LL_LLSDMESSAGEREADER_H
3
4#include "llmessagereader.h"
5#include "llsd.h"
6
7#include <map>
8
9class LLMessageTemplate;
10class LLMsgData;
11
12class LLSDMessageReader : public LLMessageReader
13{
14public:
15
16 LLSDMessageReader();
17 virtual ~LLSDMessageReader();
18
19 /** All get* methods expect pointers to canonical strings. */
20 virtual void getBinaryData(const char *block, const char *var,
21 void *datap, S32 size, S32 blocknum = 0,
22 S32 max_size = S32_MAX);
23 virtual void getBOOL(const char *block, const char *var, BOOL &data,
24 S32 blocknum = 0);
25 virtual void getS8(const char *block, const char *var, S8 &data,
26 S32 blocknum = 0);
27 virtual void getU8(const char *block, const char *var, U8 &data,
28 S32 blocknum = 0);
29 virtual void getS16(const char *block, const char *var, S16 &data,
30 S32 blocknum = 0);
31 virtual void getU16(const char *block, const char *var, U16 &data,
32 S32 blocknum = 0);
33 virtual void getS32(const char *block, const char *var, S32 &data,
34 S32 blocknum = 0);
35 virtual void getF32(const char *block, const char *var, F32 &data,
36 S32 blocknum = 0);
37 virtual void getU32(const char *block, const char *var, U32 &data,
38 S32 blocknum = 0);
39 virtual void getU64(const char *block, const char *var, U64 &data,
40 S32 blocknum = 0);
41 virtual void getF64(const char *block, const char *var, F64 &data,
42 S32 blocknum = 0);
43 virtual void getVector3(const char *block, const char *var,
44 LLVector3 &vec, S32 blocknum = 0);
45 virtual void getVector4(const char *block, const char *var,
46 LLVector4 &vec, S32 blocknum = 0);
47 virtual void getVector3d(const char *block, const char *var,
48 LLVector3d &vec, S32 blocknum = 0);
49 virtual void getQuat(const char *block, const char *var, LLQuaternion &q,
50 S32 blocknum = 0);
51 virtual void getUUID(const char *block, const char *var, LLUUID &uuid,
52 S32 blocknum = 0);
53 virtual void getIPAddr(const char *block, const char *var, U32 &ip,
54 S32 blocknum = 0);
55 virtual void getIPPort(const char *block, const char *var, U16 &port,
56 S32 blocknum = 0);
57 virtual void getString(const char *block, const char *var,
58 S32 buffer_size, char *buffer, S32 blocknum = 0);
59
60 virtual S32 getNumberOfBlocks(const char *blockname);
61 virtual S32 getSize(const char *blockname, const char *varname);
62 virtual S32 getSize(const char *blockname, S32 blocknum,
63 const char *varname);
64
65 virtual void clearMessage();
66
67 virtual const char* getMessageName() const;
68 virtual S32 getMessageSize() const;
69
70 virtual void copyToBuilder(LLMessageBuilder&) const;
71
72 void setMessage(const std::string& name, const LLSD& msg);
73
74private:
75 std::string mMessageName;
76 LLSD mMessage;
77};
78
79#endif // LL_LLSDMESSAGEREADER_H
diff --git a/linden/indra/llmessage/llsdmessagesystem.cpp b/linden/indra/llmessage/llsdmessagesystem.cpp
deleted file mode 100644
index 66382ea..0000000
--- a/linden/indra/llmessage/llsdmessagesystem.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
1/**
2 * @file llsdmessagesystem.cpp
3 * @brief LLSDMessageSystem class implementation
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29#include "llsdmessagesystem.h"
30
31#include "llhttpnode.h"
32#include "llsdutil.h"
33
34LLSDMessageSystem::LLSDMessageSystem() : mMsg(* new LLMessageSystem())
35{
36}
37
38LLSDMessageSystem::LLSDMessageSystem(LLMessageSystem& delegateSystem) : mMsg(delegateSystem)
39{
40}
41
42LLSDMessageSystem::~LLSDMessageSystem()
43{
44}
45
46bool LLSDMessageSystem::handleMessage(std::string name, const LLSD& message)
47{
48 setInput(message);
49 return mMsg.callHandler(name.c_str(), false, this);
50}
51
52void LLSDMessageSystem::setInput(const LLSD& input)
53{
54 mInput = input;
55}
56
57LLSD getLLSD(const LLSD& input, const char* block, const char* var, S32 blocknum)
58{
59 if(input[block].isArray())
60 {
61 return input[block][blocknum][var];
62 }
63 return input[block][var];
64}
65
66//virtual
67void LLSDMessageSystem::getU32Fast(const char *block, const char *var, U32 &data, S32 blocknum)
68{
69 data = ll_U32_from_sd(getLLSD(mInput, block, var, blocknum));
70}
71
72//virtual
73void LLSDMessageSystem::getUUIDFast(const char *block, const char *var, LLUUID &uuid, S32 blocknum)
74{
75 uuid = getLLSD(mInput, block, var, blocknum).asUUID();
76}
77
78//virtual
79void LLSDMessageSystem::getIPAddrFast(const char *block, const char *var, U32 &ip, S32 blocknum)
80{
81 ip = ll_ipaddr_from_sd(getLLSD(mInput, block, var, blocknum));
82}
83
84//virtual
85void LLSDMessageSystem::getIPPortFast(const char *block, const char *var, U16 &port, S32 blocknum)
86{
87 port = getLLSD(mInput, block, var, blocknum).asInteger();
88}
89
90//virtual
91void LLSDMessageSystem::getU64Fast(const char *block, const char *var, U64 &data, S32 blocknum)
92{
93 data = ll_U64_from_sd(getLLSD(mInput, block, var, blocknum));
94}
95
96//virtual
97void LLSDMessageSystem::getStringFast(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum)
98{
99 std::string data = getLLSD(mInput, block, var, blocknum).asString();
100 S32 length = data.length();
101 memset(buffer, 0, buffer_size);
102 strncpy(buffer, data.c_str(), llmin(length, buffer_size)); /* Flawfinder: ignore */
103}
104
105//virtual
106void LLSDMessageSystem::newMessageFast(const char *name)
107{
108 mMsg.newMessageFast(name);
109}
110
111//virtual
112void LLSDMessageSystem::nextBlockFast(const char *blockname)
113{
114 mMsg.nextBlockFast(blockname);
115}
116
117//virtual
118void LLSDMessageSystem::addU32Fast(const char *varname, U32 u)
119{
120 mMsg.addU32Fast(varname, u);
121}
122
123//virtual
124void LLSDMessageSystem::addUUIDFast( const char *varname, const LLUUID& uuid)
125{
126 mMsg.addUUIDFast(varname, uuid);
127}
128
129//virtual
130S32 LLSDMessageSystem::sendReliable(const LLHost &host)
131{
132 return mMsg.sendReliable(host);
133}
134
135//virtual
136U32 LLSDMessageSystem::getOurCircuitCode()
137{
138 return mMsg.getOurCircuitCode();
139}
140
141void LLSDMessageSystem::useServices()
142{
143 /*
144 Having this function body here, causes the classes and globals in this
145 file to be linked into any program that uses the llmessage library.
146 */
147}
148
149class LLMessageService : public LLHTTPNode
150{
151 virtual bool validate(const std::string& name, LLSD& context) const
152 { return true; }
153
154 virtual void post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const;
155};
156
157//virtual
158void LLMessageService::post(LLHTTPNode::ResponsePtr response, const LLSD& context, const LLSD& input) const
159{
160 static LLSDMessageSystem msg(*gMessageSystem);
161
162 std::string name = context["request"]["wildcard"]["message-name"];
163
164 if (msg.handleMessage(name, input))
165 {
166 response->result(LLSD());
167 }
168 else
169 {
170 response->notFound();
171 }
172}
173
174
175LLHTTPRegistration<LLMessageService>
176 gHTTPRegistrationMessageService("/message/<message-name>");
diff --git a/linden/indra/llmessage/llsdmessagesystem.h b/linden/indra/llmessage/llsdmessagesystem.h
deleted file mode 100644
index b114a49..0000000
--- a/linden/indra/llmessage/llsdmessagesystem.h
+++ /dev/null
@@ -1,73 +0,0 @@
1/**
2 * @file llsdmessagesystem.h
3 * @brief LLSDMessageSystem class header file
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LLSD_MESSAGE_SYSTEM_H
29#define LLSD_MESSAGE_SYSTEM_H
30
31#include "message.h"
32#include "llsd.h"
33
34class LLSDMessageSystem : public LLMessageSystem
35{
36public:
37 LLSDMessageSystem(); // Testing only.
38 LLSDMessageSystem(LLMessageSystem& delegateSystem);
39 virtual ~LLSDMessageSystem();
40
41 bool handleMessage(std::string name, const LLSD& message);
42
43 void setInput(const LLSD& input); // Testing only.
44
45 // Input methods, read from input LLSD.
46 virtual void getU32Fast(const char *block, const char *var, U32 &data, S32 blocknum = 0);
47 virtual void getUUIDFast(const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0);
48 virtual void getIPAddrFast(const char *block, const char *var, U32 &ip, S32 blocknum = 0);
49 virtual void getIPPortFast(const char *block, const char *var, U16 &port, S32 blocknum = 0);
50 virtual void getU64Fast(const char *block, const char *var, U64 &data, S32 blocknum = 0);
51 virtual void getStringFast(const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0);
52
53 // Output methods, routed to delegate message system.
54 virtual void newMessageFast(const char *name);
55 virtual void nextBlockFast(const char *blockname);
56
57 virtual void addU32Fast(const char *varname, U32 u);
58 virtual void addUUIDFast( const char *varname, const LLUUID& uuid);
59
60 virtual S32 sendReliable(const LLHost &host);
61
62 // Global Information messages, routed to delegate message system
63 virtual U32 getOurCircuitCode();
64
65 static void useServices();
66 // call this from any application, when you set up the http tree
67
68private:
69 LLMessageSystem& mMsg;
70 LLSD mInput;
71};
72
73#endif // LLSD_MESSAGE_SYSTEM_H
diff --git a/linden/indra/llmessage/llsdrpcclient.cpp b/linden/indra/llmessage/llsdrpcclient.cpp
index a9ff722..64d4b98 100644
--- a/linden/indra/llmessage/llsdrpcclient.cpp
+++ b/linden/indra/llmessage/llsdrpcclient.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdrpcclient.h b/linden/indra/llmessage/llsdrpcclient.h
index 8de7f12..52439b9 100644
--- a/linden/indra/llmessage/llsdrpcclient.h
+++ b/linden/indra/llmessage/llsdrpcclient.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdrpcserver.cpp b/linden/indra/llmessage/llsdrpcserver.cpp
index 67eaf33..ed37181 100644
--- a/linden/indra/llmessage/llsdrpcserver.cpp
+++ b/linden/indra/llmessage/llsdrpcserver.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llsdrpcserver.h b/linden/indra/llmessage/llsdrpcserver.h
index 35d91ee..4007d6e 100644
--- a/linden/indra/llmessage/llsdrpcserver.h
+++ b/linden/indra/llmessage/llsdrpcserver.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llservice.cpp b/linden/indra/llmessage/llservice.cpp
index 0ffff95..052524d 100644
--- a/linden/indra/llmessage/llservice.cpp
+++ b/linden/indra/llmessage/llservice.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2005-2007, Linden Research, Inc. 6 * Copyright (c) 2005-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llservice.h b/linden/indra/llmessage/llservice.h
index 3866dbc..5744f75 100644
--- a/linden/indra/llmessage/llservice.h
+++ b/linden/indra/llmessage/llservice.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2004-2007, Linden Research, Inc. 7 * Copyright (c) 2004-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -90,7 +91,7 @@ namespace boost
90 } 91 }
91 inline void intrusive_ptr_release(LLServiceCreator* p) 92 inline void intrusive_ptr_release(LLServiceCreator* p)
92 { 93 {
93 if(0 == --p->mReferenceCount) 94 if(p && 0 == --p->mReferenceCount)
94 { 95 {
95 delete p; 96 delete p;
96 } 97 }
diff --git a/linden/indra/llmessage/llservicebuilder.cpp b/linden/indra/llmessage/llservicebuilder.cpp
new file mode 100644
index 0000000..86b7d9d
--- /dev/null
+++ b/linden/indra/llmessage/llservicebuilder.cpp
@@ -0,0 +1,135 @@
1/**
2* @file llservicebuilder.cpp
3* @brief Implementation of the LLServiceBuilder class.
4*
5* Copyright (c) 2007-2007, Linden Research, Inc.
6*
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27*/
28
29#include "llapp.h"
30#include "llfile.h"
31#include "llservicebuilder.h"
32#include "llsd.h"
33#include "llsdserialize.h"
34
35void LLServiceBuilder::loadServiceDefinitionsFromFile(
36 const std::string& service_filename)
37{
38 llifstream service_file(service_filename.c_str(), std::ios::binary);
39 if(service_file.is_open())
40 {
41 LLSD service_data;
42 LLSDSerialize::fromXML(service_data, service_file);
43 service_file.close();
44 // Load service
45 LLSD service_map = service_data["services"];
46 for(LLSD::array_iterator array_itr = service_map.beginArray();
47 array_itr != service_map.endArray();
48 ++array_itr)
49 {
50 LLSD service_llsd = (*array_itr)["service-builder"];
51 std::string service_name = (*array_itr)["name"].asString();
52 createServiceDefinition(service_name, service_llsd);
53 }
54 llinfos << "loaded config file: " << service_filename << llendl;
55 }
56 else
57 {
58 llwarns << "unable to find config file: " << service_filename << llendl;
59 }
60}
61
62void LLServiceBuilder::createServiceDefinition(
63 const std::string& service_name,
64 LLSD& service_llsd)
65{
66 if(service_llsd.isString())
67 {
68 mServiceMap[ service_name ] = service_llsd.asString();
69 }
70 else if(service_llsd.isMap())
71 {
72 for(LLSD::map_iterator map_itr = service_llsd.beginMap();
73 map_itr != service_llsd.endMap();
74 ++map_itr)
75 {
76 std::string compound_builder_name = service_name;
77 compound_builder_name.append("-");
78 compound_builder_name.append((*map_itr).first);
79 mServiceMap[ compound_builder_name ] = (*map_itr).second.asString();
80 }
81 }
82}
83
84std::string LLServiceBuilder::buildServiceURI(const std::string& service_name)
85{
86 std::ostringstream service_url;
87 // Find the service builder
88 if(mServiceMap.find(service_name) != mServiceMap.end())
89 {
90 // construct the service builder url
91 LLApp* app = LLApp::instance();
92 if(app)
93 {
94 LLSD base_url = app->getOption("services-base-url");
95 service_url << base_url.asString();
96 }
97 service_url << mServiceMap[service_name];
98 }
99 else
100 {
101 llwarns << "Cannot find service " << service_name << llendl;
102 }
103 return service_url.str();
104}
105
106std::string LLServiceBuilder::buildServiceURI(
107 const std::string& service_name,
108 const LLSD& option_map)
109{
110 std::string service_url = buildServiceURI(service_name);
111
112 // Find the Service Name
113 if(!service_url.empty() && option_map.isMap())
114 {
115 // Do brace replacements - NOT CURRENTLY RECURSIVE
116 for(LLSD::map_const_iterator option_itr = option_map.beginMap();
117 option_itr != option_map.endMap();
118 ++option_itr)
119 {
120 std::string variable_name = "{$";
121 variable_name.append((*option_itr).first);
122 variable_name.append("}");
123 std::string::size_type find_pos = service_url.find(variable_name);
124 if(find_pos != std::string::npos)
125 {
126 service_url.replace(
127 find_pos,
128 variable_name.length(),
129 (*option_itr).second.asString());
130 }
131 }
132 }
133
134 return service_url;
135}
diff --git a/linden/indra/llmessage/llservicebuilder.h b/linden/indra/llmessage/llservicebuilder.h
new file mode 100644
index 0000000..817ea0c
--- /dev/null
+++ b/linden/indra/llmessage/llservicebuilder.h
@@ -0,0 +1,93 @@
1/**
2* @file llservicebuilder.h
3* @brief Declaration of the LLServiceBuilder class.
4*
5* Copyright (c) 2007-2007, Linden Research, Inc.
6*
7 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27*/
28
29#ifndef LLSERVICEBUILDER_H
30#define LLSERVICEBUILDER_H
31
32#include <string>
33#include <map>
34#include "llerror.h"
35
36class LLSD;
37
38/**
39 * @class LLServiceBuilder
40 * @brief This class builds urls for us to use when making web service calls.
41 */
42
43class LLServiceBuilder
44{
45 LOG_CLASS(LLServiceBuilder);
46public:
47 LLServiceBuilder(void) {}
48 ~LLServiceBuilder(void) {}
49
50 /**
51 * @brief Initialize this object with the service definitions.
52 *
53 * @param service_filename The services definition files -- services.xml.
54 */
55 void loadServiceDefinitionsFromFile(const std::string& service_filename);
56
57 /**
58 * @brief Build a service url if the url needs no construction parameters.
59 *
60 * @param service_name The name of the service you want to call.
61 */
62 std::string buildServiceURI(const std::string& service_name);
63
64 /**
65 * @brief Build a service url if the url with construction parameters.
66 *
67 * The parameter substitution supports string substituition from RUSS:
68 * [[Recursive_URL_Substitution_Syntax]]
69 * @param service_name The name of the service you want to call.
70 * @param option_map The parameters in a map of name:value for the service.
71 */
72 std::string buildServiceURI(
73 const std::string& service_name,
74 const LLSD& option_map);
75
76public:
77 /**
78 * @brief Helper method which builds construction state for a service
79 *
80 * This method should probably be protected, but we need to test this
81 * method.
82 */
83 void createServiceDefinition(
84 const std::string& service_name,
85 LLSD& service_url);
86
87protected:
88 std::map<std::string, std::string> mServiceMap;
89};
90
91
92
93#endif
diff --git a/linden/indra/llmessage/lltaskname.h b/linden/indra/llmessage/lltaskname.h
index e4e5c66..ac4fbd5 100644
--- a/linden/indra/llmessage/lltaskname.h
+++ b/linden/indra/llmessage/lltaskname.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2000-2007, Linden Research, Inc. 6 * Copyright (c) 2000-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llteleportflags.h b/linden/indra/llmessage/llteleportflags.h
index e52491a..25aac14 100644
--- a/linden/indra/llmessage/llteleportflags.h
+++ b/linden/indra/llmessage/llteleportflags.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltemplatemessagebuilder.cpp b/linden/indra/llmessage/lltemplatemessagebuilder.cpp
new file mode 100644
index 0000000..806f034
--- /dev/null
+++ b/linden/indra/llmessage/lltemplatemessagebuilder.cpp
@@ -0,0 +1,856 @@
1#include "linden_common.h"
2
3#include "lltemplatemessagebuilder.h"
4
5#include "llmessagetemplate.h"
6#include "llquaternion.h"
7#include "u64.h"
8#include "v3dmath.h"
9#include "v3math.h"
10#include "v4math.h"
11
12LLTemplateMessageBuilder::LLTemplateMessageBuilder(message_template_name_map_t& name_template_map) :
13 mCurrentSMessageData(NULL),
14 mCurrentSMessageTemplate(NULL),
15 mCurrentSDataBlock(NULL),
16 mCurrentSMessageName(NULL),
17 mCurrentSBlockName(NULL),
18 mbSBuilt(FALSE),
19 mbSClear(TRUE),
20 mCurrentSendTotal(0),
21 mMessageTemplates(name_template_map)
22{
23}
24
25//virtual
26LLTemplateMessageBuilder::~LLTemplateMessageBuilder()
27{
28 delete mCurrentSMessageData;
29 mCurrentSMessageData = NULL;
30}
31
32
33// virtual
34void LLTemplateMessageBuilder::newMessage(const char *name)
35{
36 mbSBuilt = FALSE;
37 mbSClear = FALSE;
38
39 mCurrentSendTotal = 0;
40
41 delete mCurrentSMessageData;
42 mCurrentSMessageData = NULL;
43
44 char *namep = (char *)name;
45
46 if (mMessageTemplates.count(namep) > 0)
47 {
48 mCurrentSMessageTemplate = mMessageTemplates[namep];
49 if (mCurrentSMessageData)
50 {
51 delete mCurrentSMessageData;
52 }
53 mCurrentSMessageData = new LLMsgData(namep);
54 mCurrentSMessageName = namep;
55 mCurrentSDataBlock = NULL;
56 mCurrentSBlockName = NULL;
57
58 // add at one of each block
59 LLMessageTemplate* msg_template = mMessageTemplates[namep];
60 for (LLMessageTemplate::message_block_map_t::iterator iter = msg_template->mMemberBlocks.begin();
61 iter != msg_template->mMemberBlocks.end(); iter++)
62 {
63 LLMessageBlock* ci = iter->second;
64 LLMsgBlkData *tblockp;
65 tblockp = new LLMsgBlkData(ci->mName, 0);
66 mCurrentSMessageData->addBlock(tblockp);
67 }
68 }
69 else
70 {
71 llerrs << "newMessage - Message " << name << " not registered" << llendl;
72 }
73}
74
75// virtual
76void LLTemplateMessageBuilder::clearMessage()
77{
78 mbSBuilt = FALSE;
79 mbSClear = TRUE;
80
81 mCurrentSendTotal = 0;
82
83 mCurrentSMessageTemplate = NULL;
84
85 delete mCurrentSMessageData;
86 mCurrentSMessageData = NULL;
87
88 mCurrentSMessageName = NULL;
89 mCurrentSDataBlock = NULL;
90 mCurrentSBlockName = NULL;
91}
92
93// virtual
94void LLTemplateMessageBuilder::nextBlock(const char* blockname)
95{
96 char *bnamep = (char *)blockname;
97
98 if (!mCurrentSMessageTemplate)
99 {
100 llerrs << "newMessage not called prior to setBlock" << llendl;
101 return;
102 }
103
104 // now, does this block exist?
105 LLMessageTemplate::message_block_map_t::iterator temp_iter = mCurrentSMessageTemplate->mMemberBlocks.find(bnamep);
106 if (temp_iter == mCurrentSMessageTemplate->mMemberBlocks.end())
107 {
108 llerrs << "LLTemplateMessageBuilder::nextBlock " << bnamep
109 << " not a block in " << mCurrentSMessageTemplate->mName << llendl;
110 return;
111 }
112
113 LLMessageBlock* template_data = temp_iter->second;
114
115 // ok, have we already set this block?
116 LLMsgBlkData* block_data = mCurrentSMessageData->mMemberBlocks[bnamep];
117 if (block_data->mBlockNumber == 0)
118 {
119 // nope! set this as the current block
120 block_data->mBlockNumber = 1;
121 mCurrentSDataBlock = block_data;
122 mCurrentSBlockName = bnamep;
123
124 // add placeholders for each of the variables
125 for (LLMessageBlock::message_variable_map_t::iterator iter = template_data->mMemberVariables.begin();
126 iter != template_data->mMemberVariables.end(); iter++)
127 {
128 LLMessageVariable& ci = *(iter->second);
129 mCurrentSDataBlock->addVariable(ci.getName(), ci.getType());
130 }
131 return;
132 }
133 else
134 {
135 // already have this block. . .
136 // are we supposed to have a new one?
137
138 // if the block is type MBT_SINGLE this is bad!
139 if (template_data->mType == MBT_SINGLE)
140 {
141 llerrs << "LLTemplateMessageBuilder::nextBlock called multiple times"
142 << " for " << bnamep << " but is type MBT_SINGLE" << llendl;
143 return;
144 }
145
146
147 // if the block is type MBT_MULTIPLE then we need a known number,
148 // make sure that we're not exceeding it
149 if ( (template_data->mType == MBT_MULTIPLE)
150 &&(mCurrentSDataBlock->mBlockNumber == template_data->mNumber))
151 {
152 llerrs << "LLTemplateMessageBuilder::nextBlock called "
153 << mCurrentSDataBlock->mBlockNumber << " times for " << bnamep
154 << " exceeding " << template_data->mNumber
155 << " specified in type MBT_MULTIPLE." << llendl;
156 return;
157 }
158
159 // ok, we can make a new one
160 // modify the name to avoid name collision by adding number to end
161 S32 count = block_data->mBlockNumber;
162
163 // incrememt base name's count
164 block_data->mBlockNumber++;
165
166 if (block_data->mBlockNumber > MAX_BLOCKS)
167 {
168 llerrs << "Trying to pack too many blocks into MBT_VARIABLE type "
169 << "(limited to " << MAX_BLOCKS << ")" << llendl;
170 }
171
172 // create new name
173 // Nota Bene: if things are working correctly,
174 // mCurrentMessageData->mMemberBlocks[blockname]->mBlockNumber ==
175 // mCurrentDataBlock->mBlockNumber + 1
176
177 char *nbnamep = bnamep + count;
178
179 mCurrentSDataBlock = new LLMsgBlkData(bnamep, count);
180 mCurrentSDataBlock->mName = nbnamep;
181 mCurrentSMessageData->mMemberBlocks[nbnamep] = mCurrentSDataBlock;
182
183 // add placeholders for each of the variables
184 for (LLMessageBlock::message_variable_map_t::iterator
185 iter = template_data->mMemberVariables.begin(),
186 end = template_data->mMemberVariables.end();
187 iter != end; iter++)
188 {
189 LLMessageVariable& ci = *(iter->second);
190 mCurrentSDataBlock->addVariable(ci.getName(), ci.getType());
191 }
192 return;
193 }
194}
195
196// TODO: Remove this horror...
197BOOL LLTemplateMessageBuilder::removeLastBlock()
198{
199 if (mCurrentSBlockName)
200 {
201 if ( (mCurrentSMessageData)
202 &&(mCurrentSMessageTemplate))
203 {
204 if (mCurrentSMessageData->mMemberBlocks[mCurrentSBlockName]->mBlockNumber >= 1)
205 {
206 // At least one block for the current block name.
207
208 // Store the current block name for future reference.
209 char *block_name = mCurrentSBlockName;
210
211 // Decrement the sent total by the size of the
212 // data in the message block that we're currently building.
213
214 LLMessageBlock* template_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName];
215
216 for (LLMessageBlock::message_variable_map_t::iterator iter = template_data->mMemberVariables.begin();
217 iter != template_data->mMemberVariables.end(); iter++)
218 {
219 LLMessageVariable& ci = *(iter->second);
220 mCurrentSendTotal -= ci.getSize();
221 }
222
223
224 // Now we want to find the block that we're blowing away.
225
226 // Get the number of blocks.
227 LLMsgBlkData* block_data = mCurrentSMessageData->mMemberBlocks[block_name];
228 S32 num_blocks = block_data->mBlockNumber;
229
230 // Use the same (suspect?) algorithm that's used to generate
231 // the names in the nextBlock method to find it.
232 char *block_getting_whacked = block_name + num_blocks - 1;
233 LLMsgBlkData* whacked_data = mCurrentSMessageData->mMemberBlocks[block_getting_whacked];
234 delete whacked_data;
235 mCurrentSMessageData->mMemberBlocks.erase(block_getting_whacked);
236
237 if (num_blocks <= 1)
238 {
239 // we just blew away the last one, so return FALSE
240 llwarns << "not blowing away the only block of message "
241 << mCurrentSMessageName
242 << ". Block: " << block_name
243 << ". Number: " << num_blocks
244 << llendl;
245 return FALSE;
246 }
247 else
248 {
249 // Decrement the counter.
250 block_data->mBlockNumber--;
251 return TRUE;
252 }
253 }
254 }
255 }
256 return FALSE;
257}
258
259// add data to variable in current block
260void LLTemplateMessageBuilder::addData(const char *varname, const void *data, EMsgVariableType type, S32 size)
261{
262 char *vnamep = (char *)varname;
263
264 // do we have a current message?
265 if (!mCurrentSMessageTemplate)
266 {
267 llerrs << "newMessage not called prior to addData" << llendl;
268 return;
269 }
270
271 // do we have a current block?
272 if (!mCurrentSDataBlock)
273 {
274 llerrs << "setBlock not called prior to addData" << llendl;
275 return;
276 }
277
278 // kewl, add the data if it exists
279 LLMessageVariable* var_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName]->mMemberVariables[vnamep];
280 if (!var_data || !var_data->getName())
281 {
282 llerrs << vnamep << " not a variable in block " << mCurrentSBlockName << " of " << mCurrentSMessageTemplate->mName << llendl;
283 return;
284 }
285
286 // ok, it seems ok. . . are we the correct size?
287 if (var_data->getType() == MVT_VARIABLE)
288 {
289 // Variable 1 can only store 255 bytes, make sure our data is smaller
290 if ((var_data->getSize() == 1) &&
291 (size > 255))
292 {
293 llwarns << "Field " << varname << " is a Variable 1 but program "
294 << "attempted to stuff more than 255 bytes in "
295 << "(" << size << "). Clamping size and truncating data." << llendl;
296 size = 255;
297 char *truncate = (char *)data;
298 truncate[255] = 0;
299 }
300
301 // no correct size for MVT_VARIABLE, instead we need to tell how many bytes the size will be encoded as
302 mCurrentSDataBlock->addData(vnamep, data, size, type, var_data->getSize());
303 mCurrentSendTotal += size;
304 }
305 else
306 {
307 if (size != var_data->getSize())
308 {
309 llerrs << varname << " is type MVT_FIXED but request size " << size << " doesn't match template size "
310 << var_data->getSize() << llendl;
311 return;
312 }
313 // alright, smash it in
314 mCurrentSDataBlock->addData(vnamep, data, size, type);
315 mCurrentSendTotal += size;
316 }
317}
318
319// add data to variable in current block - fails if variable isn't MVT_FIXED
320void LLTemplateMessageBuilder::addData(const char *varname, const void *data, EMsgVariableType type)
321{
322 char *vnamep = (char *)varname;
323
324 // do we have a current message?
325 if (!mCurrentSMessageTemplate)
326 {
327 llerrs << "newMessage not called prior to addData" << llendl;
328 return;
329 }
330
331 // do we have a current block?
332 if (!mCurrentSDataBlock)
333 {
334 llerrs << "setBlock not called prior to addData" << llendl;
335 return;
336 }
337
338 // kewl, add the data if it exists
339 LLMessageVariable* var_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName]->mMemberVariables[vnamep];
340 if (!var_data->getName())
341 {
342 llerrs << vnamep << " not a variable in block " << mCurrentSBlockName << " of " << mCurrentSMessageTemplate->mName << llendl;
343 return;
344 }
345
346 // ok, it seems ok. . . are we MVT_VARIABLE?
347 if (var_data->getType() == MVT_VARIABLE)
348 {
349 // nope
350 llerrs << vnamep << " is type MVT_VARIABLE. Call using addData(name, data, size)" << llendl;
351 return;
352 }
353 else
354 {
355 mCurrentSDataBlock->addData(vnamep, data, var_data->getSize(), type);
356 mCurrentSendTotal += var_data->getSize();
357 }
358}
359
360void LLTemplateMessageBuilder::addBinaryData(const char *varname,
361 const void *data, S32 size)
362{
363 addData(varname, data, MVT_FIXED, size);
364}
365
366void LLTemplateMessageBuilder::addS8(const char *varname, S8 s)
367{
368 addData(varname, &s, MVT_S8, sizeof(s));
369}
370
371void LLTemplateMessageBuilder::addU8(const char *varname, U8 u)
372{
373 addData(varname, &u, MVT_U8, sizeof(u));
374}
375
376void LLTemplateMessageBuilder::addS16(const char *varname, S16 i)
377{
378 addData(varname, &i, MVT_S16, sizeof(i));
379}
380
381void LLTemplateMessageBuilder::addU16(const char *varname, U16 i)
382{
383 addData(varname, &i, MVT_U16, sizeof(i));
384}
385
386void LLTemplateMessageBuilder::addF32(const char *varname, F32 f)
387{
388 addData(varname, &f, MVT_F32, sizeof(f));
389}
390
391void LLTemplateMessageBuilder::addS32(const char *varname, S32 s)
392{
393 addData(varname, &s, MVT_S32, sizeof(s));
394}
395
396void LLTemplateMessageBuilder::addU32(const char *varname, U32 u)
397{
398 addData(varname, &u, MVT_U32, sizeof(u));
399}
400
401void LLTemplateMessageBuilder::addU64(const char *varname, U64 lu)
402{
403 addData(varname, &lu, MVT_U64, sizeof(lu));
404}
405
406void LLTemplateMessageBuilder::addF64(const char *varname, F64 d)
407{
408 addData(varname, &d, MVT_F64, sizeof(d));
409}
410
411void LLTemplateMessageBuilder::addIPAddr(const char *varname, U32 u)
412{
413 addData(varname, &u, MVT_IP_ADDR, sizeof(u));
414}
415
416void LLTemplateMessageBuilder::addIPPort(const char *varname, U16 u)
417{
418 u = htons(u);
419 addData(varname, &u, MVT_IP_PORT, sizeof(u));
420}
421
422void LLTemplateMessageBuilder::addBOOL(const char* varname, BOOL b)
423{
424 // Can't just cast a BOOL (actually a U32) to a U8.
425 // In some cases the low order bits will be zero.
426 U8 temp = (b != 0);
427 addData(varname, &temp, MVT_BOOL, sizeof(temp));
428}
429
430void LLTemplateMessageBuilder::addString(const char* varname, const char* s)
431{
432 if (s)
433 addData( varname, (void *)s, MVT_VARIABLE, (S32)strlen(s) + 1); /* Flawfinder: ignore */
434 else
435 addData( varname, NULL, MVT_VARIABLE, 0);
436}
437
438void LLTemplateMessageBuilder::addString(const char* varname, const std::string& s)
439{
440 if (s.size())
441 addData( varname, (void *)s.c_str(), MVT_VARIABLE, (S32)(s.size()) + 1);
442 else
443 addData( varname, NULL, MVT_VARIABLE, 0);
444}
445
446void LLTemplateMessageBuilder::addVector3(const char *varname, const LLVector3& vec)
447{
448 addData(varname, vec.mV, MVT_LLVector3, sizeof(vec.mV));
449}
450
451void LLTemplateMessageBuilder::addVector4(const char *varname, const LLVector4& vec)
452{
453 addData(varname, vec.mV, MVT_LLVector4, sizeof(vec.mV));
454}
455
456void LLTemplateMessageBuilder::addVector3d(const char *varname, const LLVector3d& vec)
457{
458 addData(varname, vec.mdV, MVT_LLVector3d, sizeof(vec.mdV));
459}
460
461void LLTemplateMessageBuilder::addQuat(const char *varname, const LLQuaternion& quat)
462{
463 addData(varname, quat.packToVector3().mV, MVT_LLQuaternion, sizeof(LLVector3));
464}
465
466void LLTemplateMessageBuilder::addUUID(const char *varname, const LLUUID& uuid)
467{
468 addData(varname, uuid.mData, MVT_LLUUID, sizeof(uuid.mData));
469}
470
471static S32 zero_code(U8 **data, U32 *data_size)
472{
473 // Encoded send buffer needs to be slightly larger since the zero
474 // coding can potentially increase the size of the send data.
475 static U8 encodedSendBuffer[2 * MAX_BUFFER_SIZE];
476
477 S32 count = *data_size;
478
479 S32 net_gain = 0;
480 U8 num_zeroes = 0;
481
482 U8 *inptr = (U8 *)*data;
483 U8 *outptr = (U8 *)encodedSendBuffer;
484
485// skip the packet id field
486
487 for (U32 i=0;i<LL_PACKET_ID_SIZE;i++)
488 {
489 count--;
490 *outptr++ = *inptr++;
491 }
492
493// build encoded packet, keeping track of net size gain
494
495// sequential zero bytes are encoded as 0 [U8 count]
496// with 0 0 [count] representing wrap (>256 zeroes)
497
498 while (count--)
499 {
500 if (!(*inptr)) // in a zero count
501 {
502 if (num_zeroes)
503 {
504 if (++num_zeroes > 254)
505 {
506 *outptr++ = num_zeroes;
507 num_zeroes = 0;
508 }
509 net_gain--; // subseqent zeroes save one
510 }
511 else
512 {
513 *outptr++ = 0;
514 net_gain++; // starting a zero count adds one
515 num_zeroes = 1;
516 }
517 inptr++;
518 }
519 else
520 {
521 if (num_zeroes)
522 {
523 *outptr++ = num_zeroes;
524 num_zeroes = 0;
525 }
526 *outptr++ = *inptr++;
527 }
528 }
529
530 if (num_zeroes)
531 {
532 *outptr++ = num_zeroes;
533 }
534
535 if (net_gain < 0)
536 {
537 // TODO: babbage: reinstate stat collecting...
538 //mCompressedPacketsOut++;
539 //mUncompressedBytesOut += *data_size;
540
541 *data = encodedSendBuffer;
542 *data_size += net_gain;
543 encodedSendBuffer[0] |= LL_ZERO_CODE_FLAG; // set the head bit to indicate zero coding
544
545 //mCompressedBytesOut += *data_size;
546
547 }
548 //mTotalBytesOut += *data_size;
549
550 return(net_gain);
551}
552
553void LLTemplateMessageBuilder::compressMessage(U8*& buf_ptr, U32& buffer_length)
554{
555 if(ME_ZEROCODED == mCurrentSMessageTemplate->getEncoding())
556 {
557 zero_code(&buf_ptr, &buffer_length);
558 }
559}
560
561BOOL LLTemplateMessageBuilder::isMessageFull(const char* blockname) const
562{
563 if(mCurrentSendTotal > MTUBYTES)
564 {
565 return TRUE;
566 }
567 if(!blockname)
568 {
569 return FALSE;
570 }
571 char* bnamep = (char*)blockname;
572 S32 max;
573
574 LLMessageBlock* template_data = mCurrentSMessageTemplate->mMemberBlocks[bnamep];
575
576 switch(template_data->mType)
577 {
578 case MBT_SINGLE:
579 max = 1;
580 break;
581 case MBT_MULTIPLE:
582 max = template_data->mNumber;
583 break;
584 case MBT_VARIABLE:
585 default:
586 max = MAX_BLOCKS;
587 break;
588 }
589 if(mCurrentSMessageData->mMemberBlocks[bnamep]->mBlockNumber >= max)
590 {
591 return TRUE;
592 }
593 return FALSE;
594}
595
596
597// make sure that all the desired data is in place and then copy the data into MAX_BUFFER_SIZEd buffer
598U32 LLTemplateMessageBuilder::buildMessage(U8* buffer, U32 buffer_size)
599{
600 // basic algorithm is to loop through the various pieces, building
601 // size and offset info if we encounter a -1 for mSize at any
602 // point that variable wasn't given data
603
604 // do we have a current message?
605 if (!mCurrentSMessageTemplate)
606 {
607 llerrs << "newMessage not called prior to buildMessage" << llendl;
608 return 0;
609 }
610
611 // zero out some useful values
612
613 // leave room for circuit counter
614 U32 result = LL_PACKET_ID_SIZE;
615
616 // encode message number and adjust total_offset
617 if (mCurrentSMessageTemplate->mFrequency == MFT_HIGH)
618 {
619// old, endian-dependant way
620// memcpy(&buffer[result], &mCurrentMessageTemplate->mMessageNumber, sizeof(U8));
621
622// new, independant way
623 buffer[result] = (U8)mCurrentSMessageTemplate->mMessageNumber;
624 result += sizeof(U8);
625 }
626 else if (mCurrentSMessageTemplate->mFrequency == MFT_MEDIUM)
627 {
628 U8 temp = 255;
629 memcpy(&buffer[result], &temp, sizeof(U8)); /*Flawfinder: ignore*/
630 result += sizeof(U8);
631
632 // mask off unsightly bits
633 temp = mCurrentSMessageTemplate->mMessageNumber & 255;
634 memcpy(&buffer[result], &temp, sizeof(U8)); /*Flawfinder: ignore*/
635 result += sizeof(U8);
636 }
637 else if (mCurrentSMessageTemplate->mFrequency == MFT_LOW)
638 {
639 U8 temp = 255;
640 U16 message_num;
641 memcpy(&buffer[result], &temp, sizeof(U8)); /*Flawfinder: ignore*/
642 result += sizeof(U8);
643 memcpy(&buffer[result], &temp, sizeof(U8)); /*Flawfinder: ignore*/
644 result += sizeof(U8);
645
646 // mask off unsightly bits
647 message_num = mCurrentSMessageTemplate->mMessageNumber & 0xFFFF;
648
649 // convert to network byte order
650 message_num = htons(message_num);
651 memcpy(&buffer[result], &message_num, sizeof(U16)); /*Flawfinder: ignore*/
652 result += sizeof(U16);
653 }
654 else
655 {
656 llerrs << "unexpected message frequency in buildMessage" << llendl;
657 return 0;
658 }
659
660 // counting variables used to encode multiple block info
661 S32 block_count = 0;
662 U8 temp_block_number;
663
664 // loop through msg blocks to loop through variables,
665 // totalling up size data and copying into buffer
666 for (LLMsgData::msg_blk_data_map_t::iterator
667 iter = mCurrentSMessageData->mMemberBlocks.begin(),
668 end = mCurrentSMessageData->mMemberBlocks.end();
669 iter != end; iter++)
670 {
671 LLMsgBlkData* mbci = iter->second;
672 // do we need to encode a block code?
673 if (block_count == 0)
674 {
675 block_count = mbci->mBlockNumber;
676
677 LLMessageBlock* template_data =
678 mCurrentSMessageTemplate->mMemberBlocks[mbci->mName];
679
680 // ok, if this is the first block of a repeating pack, set
681 // block_count and, if it's type MBT_VARIABLE encode a byte
682 // for how many there are
683 if (template_data->mType == MBT_VARIABLE)
684 {
685 // remember that mBlockNumber is a S32
686 temp_block_number = (U8)mbci->mBlockNumber;
687 if ((S32)(result + sizeof(U8)) < MAX_BUFFER_SIZE)
688 {
689 memcpy(&buffer[result], &temp_block_number, sizeof(U8));
690 result += sizeof(U8);
691 }
692 else
693 {
694 // Just reporting error is likely not enough. Need
695 // to check how to abort or error out gracefully
696 // from this function. XXXTBD
697 llerrs << "buildMessage failed. Message excedding "
698 << "sendBuffersize." << llendl;
699 }
700 }
701 else if (template_data->mType == MBT_MULTIPLE)
702 {
703 if (block_count != template_data->mNumber)
704 {
705 // nope! need to fill it in all the way!
706 llerrs << "Block " << mbci->mName
707 << " is type MBT_MULTIPLE but only has data for "
708 << block_count << " out of its "
709 << template_data->mNumber << " blocks" << llendl;
710 }
711 }
712 }
713
714 // counting down multiple blocks
715 block_count--;
716
717 // now loop through the variables
718 for (LLMsgBlkData::msg_var_data_map_t::iterator iter = mbci->mMemberVarData.begin();
719 iter != mbci->mMemberVarData.end(); iter++)
720 {
721 LLMsgVarData& mvci = *iter;
722 if (mvci.getSize() == -1)
723 {
724 // oops, this variable wasn't ever set!
725 llerrs << "The variable " << mvci.getName() << " in block "
726 << mbci->mName << " of message "
727 << mCurrentSMessageData->mName
728 << " wasn't set prior to buildMessage call" << llendl;
729 }
730 else
731 {
732 S32 data_size = mvci.getDataSize();
733 if(data_size > 0)
734 {
735 // The type is MVT_VARIABLE, which means that we
736 // need to encode a size argument. Otherwise,
737 // there is no need.
738 S32 size = mvci.getSize();
739 U8 sizeb;
740 U16 sizeh;
741 switch(data_size)
742 {
743 case 1:
744 sizeb = size;
745 htonmemcpy(&buffer[result], &sizeb, MVT_U8, 1);
746 break;
747 case 2:
748 sizeh = size;
749 htonmemcpy(&buffer[result], &sizeh, MVT_U16, 2);
750 break;
751 case 4:
752 htonmemcpy(&buffer[result], &size, MVT_S32, 4);
753 break;
754 default:
755 llerrs << "Attempting to build variable field with unknown size of " << size << llendl;
756 break;
757 }
758 result += mvci.getDataSize();
759 }
760
761 // if there is any data to pack, pack it
762 if((mvci.getData() != NULL) && mvci.getSize())
763 {
764 if(result + mvci.getSize() < buffer_size)
765 {
766 memcpy(
767 &buffer[result],
768 mvci.getData(),
769 mvci.getSize());
770 result += mvci.getSize();
771 }
772 else
773 {
774 // Just reporting error is likely not
775 // enough. Need to check how to abort or error
776 // out gracefully from this function. XXXTBD
777 llerrs << "LLMessageSystem::buildMessage failed. "
778 << "Attempted to pack "
779 << result + mvci.getSize()
780 << " bytes into a buffer with size "
781 << buffer_size << "." << llendl
782 }
783 }
784 }
785 }
786 }
787 mbSBuilt = TRUE;
788
789 return result;
790}
791
792void LLTemplateMessageBuilder::copyFromMessageData(const LLMsgData& data)
793{
794 // copy the blocks
795 // counting variables used to encode multiple block info
796 S32 block_count = 0;
797 char *block_name = NULL;
798
799 // loop through msg blocks to loop through variables, totalling up size
800 // data and filling the new (send) message
801 LLMsgData::msg_blk_data_map_t::const_iterator iter =
802 data.mMemberBlocks.begin();
803 LLMsgData::msg_blk_data_map_t::const_iterator end =
804 data.mMemberBlocks.end();
805 for(; iter != end; ++iter)
806 {
807 const LLMsgBlkData* mbci = iter->second;
808 if(!mbci) continue;
809
810 // do we need to encode a block code?
811 if (block_count == 0)
812 {
813 block_count = mbci->mBlockNumber;
814 block_name = (char *)mbci->mName;
815 }
816
817 // counting down mutliple blocks
818 block_count--;
819
820 nextBlock(block_name);
821
822 // now loop through the variables
823 LLMsgBlkData::msg_var_data_map_t::const_iterator dit = mbci->mMemberVarData.begin();
824 LLMsgBlkData::msg_var_data_map_t::const_iterator dend = mbci->mMemberVarData.end();
825
826 for(; dit != dend; ++dit)
827 {
828 const LLMsgVarData& mvci = *dit;
829 addData(mvci.getName(), mvci.getData(), mvci.getType(), mvci.getSize());
830 }
831 }
832}
833
834//virtual
835void LLTemplateMessageBuilder::copyFromLLSD(const LLSD&)
836{
837 // TODO
838}
839
840//virtual
841void LLTemplateMessageBuilder::setBuilt(BOOL b) { mbSBuilt = b; }
842
843//virtual
844BOOL LLTemplateMessageBuilder::isBuilt() const {return mbSBuilt;}
845
846//virtual
847BOOL LLTemplateMessageBuilder::isClear() const {return mbSClear;}
848
849//virtual
850S32 LLTemplateMessageBuilder::getMessageSize() {return mCurrentSendTotal;}
851
852//virtual
853const char* LLTemplateMessageBuilder::getMessageName() const
854{
855 return mCurrentSMessageName;
856}
diff --git a/linden/indra/llmessage/lltemplatemessagebuilder.h b/linden/indra/llmessage/lltemplatemessagebuilder.h
new file mode 100644
index 0000000..ae53328
--- /dev/null
+++ b/linden/indra/llmessage/lltemplatemessagebuilder.h
@@ -0,0 +1,88 @@
1#ifndef LL_LLTEMPLATEMESSAGEBUILDER_H
2#define LL_LLTEMPLATEMESSAGEBUILDER_H
3
4#include <map>
5
6#include "llmessagebuilder.h"
7#include "llmsgvariabletype.h"
8
9class LLMsgData;
10class LLMessageTemplate;
11class LLMsgBlkData;
12class LLMessageTemplate;
13
14class LLTemplateMessageBuilder : public LLMessageBuilder
15{
16public:
17
18 typedef std::map<const char *, LLMessageTemplate*> message_template_name_map_t;
19
20 LLTemplateMessageBuilder(message_template_name_map_t&);
21 virtual ~LLTemplateMessageBuilder();
22
23 virtual void newMessage(const char *name);
24
25 virtual void nextBlock(const char* blockname);
26 virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
27
28 /** All add* methods expect pointers to canonical varname strings. */
29 virtual void addBinaryData(const char *varname, const void *data,
30 S32 size);
31 virtual void addBOOL(const char* varname, BOOL b);
32 virtual void addS8(const char *varname, S8 s);
33 virtual void addU8(const char *varname, U8 u);
34 virtual void addS16(const char *varname, S16 i);
35 virtual void addU16(const char *varname, U16 i);
36 virtual void addF32(const char *varname, F32 f);
37 virtual void addS32(const char *varname, S32 s);
38 virtual void addU32(const char *varname, U32 u);
39 virtual void addU64(const char *varname, U64 lu);
40 virtual void addF64(const char *varname, F64 d);
41 virtual void addVector3(const char *varname, const LLVector3& vec);
42 virtual void addVector4(const char *varname, const LLVector4& vec);
43 virtual void addVector3d(const char *varname, const LLVector3d& vec);
44 virtual void addQuat(const char *varname, const LLQuaternion& quat);
45 virtual void addUUID(const char *varname, const LLUUID& uuid);
46 virtual void addIPAddr(const char *varname, const U32 ip);
47 virtual void addIPPort(const char *varname, const U16 port);
48 virtual void addString(const char* varname, const char* s);
49 virtual void addString(const char* varname, const std::string& s);
50
51 virtual BOOL isMessageFull(const char* blockname) const;
52 virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
53
54 virtual BOOL isBuilt() const;
55 virtual BOOL isClear() const;
56 virtual U32 buildMessage(U8* buffer, U32 buffer_size);
57 /**< Return built message size */
58
59 virtual void clearMessage();
60
61 // TODO: babbage: remove this horror.
62 virtual void setBuilt(BOOL b);
63
64 virtual S32 getMessageSize();
65 virtual const char* getMessageName() const;
66
67 virtual void copyFromMessageData(const LLMsgData& data);
68 virtual void copyFromLLSD(const LLSD&);
69
70private:
71 void addData(const char *varname, const void *data,
72 EMsgVariableType type, S32 size);
73
74 void addData(const char *varname, const void *data,
75 EMsgVariableType type);
76
77 LLMsgData* mCurrentSMessageData;
78 LLMessageTemplate* mCurrentSMessageTemplate;
79 LLMsgBlkData* mCurrentSDataBlock;
80 char* mCurrentSMessageName;
81 char* mCurrentSBlockName;
82 BOOL mbSBuilt;
83 BOOL mbSClear;
84 S32 mCurrentSendTotal;
85 message_template_name_map_t& mMessageTemplates;
86};
87
88#endif // LL_LLTEMPLATEMESSAGEBUILDER_H
diff --git a/linden/indra/llmessage/lltemplatemessagereader.cpp b/linden/indra/llmessage/lltemplatemessagereader.cpp
new file mode 100644
index 0000000..892efb8
--- /dev/null
+++ b/linden/indra/llmessage/lltemplatemessagereader.cpp
@@ -0,0 +1,750 @@
1#include "lltemplatemessagereader.h"
2
3#include "llfasttimer.h"
4#include "llmessagebuilder.h"
5#include "llmessagetemplate.h"
6#include "llquaternion.h"
7#include "message.h"
8#include "u64.h"
9#include "v3dmath.h"
10#include "v3math.h"
11#include "v4math.h"
12
13LLTemplateMessageReader::LLTemplateMessageReader(message_template_number_map_t&
14 number_template_map) :
15 mReceiveSize(0),
16 mCurrentRMessageTemplate(NULL),
17 mCurrentRMessageData(NULL),
18 mMessageNumbers(number_template_map)
19{
20}
21
22//virtual
23LLTemplateMessageReader::~LLTemplateMessageReader()
24{
25 delete mCurrentRMessageData;
26 mCurrentRMessageData = NULL;
27}
28
29//virtual
30void LLTemplateMessageReader::clearMessage()
31{
32 mReceiveSize = -1;
33 mCurrentRMessageTemplate = NULL;
34 delete mCurrentRMessageData;
35 mCurrentRMessageData = NULL;
36}
37
38void LLTemplateMessageReader::getData(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum, S32 max_size)
39{
40 // is there a message ready to go?
41 if (mReceiveSize == -1)
42 {
43 llerrs << "No message waiting for decode 2!" << llendl;
44 return;
45 }
46
47 if (!mCurrentRMessageData)
48 {
49 llerrs << "Invalid mCurrentMessageData in getData!" << llendl;
50 return;
51 }
52
53 char *bnamep = (char *)blockname + blocknum; // this works because it's just a hash. The bnamep is never derefference
54 char *vnamep = (char *)varname;
55
56 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
57
58 if (iter == mCurrentRMessageData->mMemberBlocks.end())
59 {
60 llerrs << "Block " << blockname << " #" << blocknum
61 << " not in message " << mCurrentRMessageData->mName << llendl;
62 return;
63 }
64
65 LLMsgBlkData *msg_block_data = iter->second;
66 LLMsgVarData& vardata = msg_block_data->mMemberVarData[vnamep];
67
68 if (!vardata.getName())
69 {
70 llerrs << "Variable "<< vnamep << " not in message "
71 << mCurrentRMessageData->mName<< " block " << bnamep << llendl;
72 return;
73 }
74
75 if (size && size != vardata.getSize())
76 {
77 llerrs << "Msg " << mCurrentRMessageData->mName
78 << " variable " << vnamep
79 << " is size " << vardata.getSize()
80 << " but copying into buffer of size " << size
81 << llendl;
82 return;
83 }
84
85
86 const S32 vardata_size = vardata.getSize();
87 if( max_size >= vardata_size )
88 {
89 switch( vardata_size )
90 {
91 case 1:
92 *((U8*)datap) = *((U8*)vardata.getData());
93 break;
94 case 2:
95 *((U16*)datap) = *((U16*)vardata.getData());
96 break;
97 case 4:
98 *((U32*)datap) = *((U32*)vardata.getData());
99 break;
100 case 8:
101 ((U32*)datap)[0] = ((U32*)vardata.getData())[0];
102 ((U32*)datap)[1] = ((U32*)vardata.getData())[1];
103 break;
104 default:
105 memcpy(datap, vardata.getData(), vardata_size);
106 break;
107 }
108 }
109 else
110 {
111 llwarns << "Msg " << mCurrentRMessageData->mName
112 << " variable " << vnamep
113 << " is size " << vardata.getSize()
114 << " but truncated to max size of " << max_size
115 << llendl;
116
117 memcpy(datap, vardata.getData(), max_size);
118 }
119}
120
121S32 LLTemplateMessageReader::getNumberOfBlocks(const char *blockname)
122{
123 // is there a message ready to go?
124 if (mReceiveSize == -1)
125 {
126 llerrs << "No message waiting for decode 3!" << llendl;
127 return -1;
128 }
129
130 if (!mCurrentRMessageData)
131 {
132 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
133 return -1;
134 }
135
136 char *bnamep = (char *)blockname;
137
138 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
139
140 if (iter == mCurrentRMessageData->mMemberBlocks.end())
141 {
142// sprintf(errmsg, "Block %s not in message %s", bnamep, mCurrentRMessageData->mName);
143// llerrs << errmsg << llendl;
144// return -1;
145 return 0;
146 }
147
148 return (iter->second)->mBlockNumber;
149}
150
151S32 LLTemplateMessageReader::getSize(const char *blockname, const char *varname)
152{
153 // is there a message ready to go?
154 if (mReceiveSize == -1)
155 {
156 llerrs << "No message waiting for decode 4!" << llendl;
157 return -1;
158 }
159
160 if (!mCurrentRMessageData)
161 {
162 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
163 return -1;
164 }
165
166 char *bnamep = (char *)blockname;
167
168 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
169
170 if (iter == mCurrentRMessageData->mMemberBlocks.end())
171 {
172 llerrs << "Block " << bnamep << " not in message "
173 << mCurrentRMessageData->mName << llendl;
174 return -1;
175 }
176
177 char *vnamep = (char *)varname;
178
179 LLMsgBlkData* msg_data = iter->second;
180 LLMsgVarData& vardata = msg_data->mMemberVarData[vnamep];
181
182 if (!vardata.getName())
183 {
184 llerrs << "Variable " << varname << " not in message "
185 << mCurrentRMessageData->mName << " block " << bnamep << llendl;
186 return -1;
187 }
188
189 if (mCurrentRMessageTemplate->mMemberBlocks[bnamep]->mType != MBT_SINGLE)
190 {
191 llerrs << "Block " << bnamep << " isn't type MBT_SINGLE,"
192 " use getSize with blocknum argument!" << llendl;
193 return -1;
194 }
195
196 return vardata.getSize();
197}
198
199S32 LLTemplateMessageReader::getSize(const char *blockname, S32 blocknum, const char *varname)
200{
201 // is there a message ready to go?
202 if (mReceiveSize == -1)
203 {
204 llerrs << "No message waiting for decode 5!" << llendl;
205 return -1;
206 }
207
208 if (!mCurrentRMessageData)
209 {
210 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
211 return -1;
212 }
213
214 char *bnamep = (char *)blockname + blocknum;
215 char *vnamep = (char *)varname;
216
217 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
218
219 if (iter == mCurrentRMessageData->mMemberBlocks.end())
220 {
221 llerrs << "Block " << bnamep << " not in message "
222 << mCurrentRMessageData->mName << llendl;
223 return -1;
224 }
225
226 LLMsgBlkData* msg_data = iter->second;
227 LLMsgVarData& vardata = msg_data->mMemberVarData[vnamep];
228
229 if (!vardata.getName())
230 {
231 llerrs << "Variable " << vnamep << " not in message "
232 << mCurrentRMessageData->mName << " block " << bnamep << llendl;
233 return -1;
234 }
235
236 return vardata.getSize();
237}
238
239void LLTemplateMessageReader::getBinaryData(const char *blockname,
240 const char *varname, void *datap,
241 S32 size, S32 blocknum,
242 S32 max_size)
243{
244 getData(blockname, varname, datap, size, blocknum, max_size);
245}
246
247void LLTemplateMessageReader::getS8(const char *block, const char *var,
248 S8 &u, S32 blocknum)
249{
250 getData(block, var, &u, sizeof(S8), blocknum);
251}
252
253void LLTemplateMessageReader::getU8(const char *block, const char *var,
254 U8 &u, S32 blocknum)
255{
256 getData(block, var, &u, sizeof(U8), blocknum);
257}
258
259void LLTemplateMessageReader::getBOOL(const char *block, const char *var,
260 BOOL &b, S32 blocknum )
261{
262 U8 value;
263 getData(block, var, &value, sizeof(U8), blocknum);
264 b = (BOOL) value;
265}
266
267void LLTemplateMessageReader::getS16(const char *block, const char *var,
268 S16 &d, S32 blocknum)
269{
270 getData(block, var, &d, sizeof(S16), blocknum);
271}
272
273void LLTemplateMessageReader::getU16(const char *block, const char *var,
274 U16 &d, S32 blocknum)
275{
276 getData(block, var, &d, sizeof(U16), blocknum);
277}
278
279void LLTemplateMessageReader::getS32(const char *block, const char *var,
280 S32 &d, S32 blocknum)
281{
282 getData(block, var, &d, sizeof(S32), blocknum);
283}
284
285void LLTemplateMessageReader::getU32(const char *block, const char *var,
286 U32 &d, S32 blocknum)
287{
288 getData(block, var, &d, sizeof(U32), blocknum);
289}
290
291void LLTemplateMessageReader::getU64(const char *block, const char *var,
292 U64 &d, S32 blocknum)
293{
294 getData(block, var, &d, sizeof(U64), blocknum);
295}
296
297void LLTemplateMessageReader::getF32(const char *block, const char *var,
298 F32 &d, S32 blocknum)
299{
300 getData(block, var, &d, sizeof(F32), blocknum);
301
302 if( !llfinite( d ) )
303 {
304 llwarns << "non-finite in getF32Fast " << block << " " << var
305 << llendl;
306 d = 0;
307 }
308}
309
310void LLTemplateMessageReader::getF64(const char *block, const char *var,
311 F64 &d, S32 blocknum)
312{
313 getData(block, var, &d, sizeof(F64), blocknum);
314
315 if( !llfinite( d ) )
316 {
317 llwarns << "non-finite in getF64Fast " << block << " " << var
318 << llendl;
319 d = 0;
320 }
321}
322
323void LLTemplateMessageReader::getVector3(const char *block, const char *var,
324 LLVector3 &v, S32 blocknum )
325{
326 getData(block, var, v.mV, sizeof(v.mV), blocknum);
327
328 if( !v.isFinite() )
329 {
330 llwarns << "non-finite in getVector3Fast " << block << " "
331 << var << llendl;
332 v.zeroVec();
333 }
334}
335
336void LLTemplateMessageReader::getVector4(const char *block, const char *var,
337 LLVector4 &v, S32 blocknum)
338{
339 getData(block, var, v.mV, sizeof(v.mV), blocknum);
340
341 if( !v.isFinite() )
342 {
343 llwarns << "non-finite in getVector4Fast " << block << " "
344 << var << llendl;
345 v.zeroVec();
346 }
347}
348
349void LLTemplateMessageReader::getVector3d(const char *block, const char *var,
350 LLVector3d &v, S32 blocknum )
351{
352 getData(block, var, v.mdV, sizeof(v.mdV), blocknum);
353
354 if( !v.isFinite() )
355 {
356 llwarns << "non-finite in getVector3dFast " << block << " "
357 << var << llendl;
358 v.zeroVec();
359 }
360
361}
362
363void LLTemplateMessageReader::getQuat(const char *block, const char *var,
364 LLQuaternion &q, S32 blocknum)
365{
366 LLVector3 vec;
367 getData(block, var, vec.mV, sizeof(vec.mV), blocknum);
368 if( vec.isFinite() )
369 {
370 q.unpackFromVector3( vec );
371 }
372 else
373 {
374 llwarns << "non-finite in getQuatFast " << block << " " << var
375 << llendl;
376 q.loadIdentity();
377 }
378}
379
380void LLTemplateMessageReader::getUUID(const char *block, const char *var,
381 LLUUID &u, S32 blocknum)
382{
383 getData(block, var, u.mData, sizeof(u.mData), blocknum);
384}
385
386inline void LLTemplateMessageReader::getIPAddr(const char *block, const char *var, U32 &u, S32 blocknum)
387{
388 getData(block, var, &u, sizeof(U32), blocknum);
389}
390
391inline void LLTemplateMessageReader::getIPPort(const char *block, const char *var, U16 &u, S32 blocknum)
392{
393 getData(block, var, &u, sizeof(U16), blocknum);
394 u = ntohs(u);
395}
396
397inline void LLTemplateMessageReader::getString(const char *block, const char *var, S32 buffer_size, char *s, S32 blocknum )
398{
399 s[0] = '\0';
400 getData(block, var, s, 0, blocknum, buffer_size);
401 s[buffer_size - 1] = '\0';
402}
403
404//virtual
405S32 LLTemplateMessageReader::getMessageSize() const
406{
407 return mReceiveSize;
408}
409
410// Returns template for the message contained in buffer
411BOOL LLTemplateMessageReader::decodeTemplate(
412 const U8* buffer, S32 buffer_size, // inputs
413 LLMessageTemplate** msg_template ) // outputs
414{
415 const U8* header = buffer + LL_PACKET_ID_SIZE;
416
417 // is there a message ready to go?
418 if (buffer_size <= 0)
419 {
420 llwarns << "No message waiting for decode!" << llendl;
421 return(FALSE);
422 }
423
424 U32 num = 0;
425
426 if (header[0] != 255)
427 {
428 // high frequency message
429 num = header[0];
430 }
431 else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 1)) && (header[1] != 255))
432 {
433 // medium frequency message
434 num = (255 << 8) | header[1];
435 }
436 else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 3)) && (header[1] == 255))
437 {
438 // low frequency message
439 U16 message_id_U16 = 0;
440 // I think this check busts the message system.
441 // it appears that if there is a NULL in the message #, it won't copy it....
442 // what was the goal?
443 //if(header[2])
444 memcpy(&message_id_U16, &header[2], 2);
445
446 // dependant on endian-ness:
447 // U32 temp = (255 << 24) | (255 << 16) | header[2];
448
449 // independant of endian-ness:
450 message_id_U16 = ntohs(message_id_U16);
451 num = 0xFFFF0000 | message_id_U16;
452 }
453 else // bogus packet received (too short)
454 {
455 llwarns << "Packet with unusable length received (too short): "
456 << buffer_size << llendl;
457 return(FALSE);
458 }
459
460 LLMessageTemplate* temp = get_ptr_in_map(mMessageNumbers,num);
461 if (temp)
462 {
463 *msg_template = temp;
464 }
465 else
466 {
467 llwarns << "Message #" << std::hex << num << std::dec
468 << " received but not registered!" << llendl;
469 gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE);
470 return(FALSE);
471 }
472
473 return(TRUE);
474}
475
476void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host )
477{
478 // we've run off the end of the packet!
479 llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName
480// << " with id " << mCurrentRecvPacketID
481 << " from " << host
482 << llendl;
483 if(gMessageSystem->mVerboseLog)
484 {
485 llinfos << "MSG: -> " << host << "\tREAD PAST END:\t"
486// << mCurrentRecvPacketID << " "
487 << getMessageName() << llendl;
488 }
489 gMessageSystem->callExceptionFunc(MX_RAN_OFF_END_OF_PACKET);
490}
491
492// decode a given message
493BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender )
494{
495 llassert( mReceiveSize >= 0 );
496 llassert( mCurrentRMessageTemplate);
497 llassert( !mCurrentRMessageData );
498 delete mCurrentRMessageData; // just to make sure
499
500 S32 decode_pos = LL_PACKET_ID_SIZE + (S32)(mCurrentRMessageTemplate->mFrequency);
501
502 // create base working data set
503 mCurrentRMessageData = new LLMsgData(mCurrentRMessageTemplate->mName);
504
505 // loop through the template building the data structure as we go
506 for (LLMessageTemplate::message_block_map_t::iterator iter = mCurrentRMessageTemplate->mMemberBlocks.begin();
507 iter != mCurrentRMessageTemplate->mMemberBlocks.end(); iter++)
508 {
509 LLMessageBlock* mbci = iter->second;
510 U8 repeat_number;
511 S32 i;
512
513 // how many of this block?
514
515 if (mbci->mType == MBT_SINGLE)
516 {
517 // just one
518 repeat_number = 1;
519 }
520 else if (mbci->mType == MBT_MULTIPLE)
521 {
522 // a known number
523 repeat_number = mbci->mNumber;
524 }
525 else if (mbci->mType == MBT_VARIABLE)
526 {
527 // need to read the number from the message
528 // repeat number is a single byte
529 if (decode_pos >= mReceiveSize)
530 {
531 logRanOffEndOfPacket( sender );
532 return FALSE;
533 }
534 repeat_number = buffer[decode_pos];
535 decode_pos++;
536 }
537 else
538 {
539 llerrs << "Unknown block type" << llendl;
540 return FALSE;
541 }
542
543 LLMsgBlkData* cur_data_block = NULL;
544
545 // now loop through the block
546 for (i = 0; i < repeat_number; i++)
547 {
548 if (i)
549 {
550 // build new name to prevent collisions
551 // TODO: This should really change to a vector
552 cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
553 cur_data_block->mName = mbci->mName + i;
554 }
555 else
556 {
557 cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
558 }
559
560 // add the block to the message
561 mCurrentRMessageData->addBlock(cur_data_block);
562
563 // now read the variables
564 for (LLMessageBlock::message_variable_map_t::iterator iter = mbci->mMemberVariables.begin();
565 iter != mbci->mMemberVariables.end(); iter++)
566 {
567 LLMessageVariable& mvci = *(iter->second);
568 // ok, build out the variables
569 // add variable block
570 cur_data_block->addVariable(mvci.getName(), mvci.getType());
571
572 // what type of variable?
573 if (mvci.getType() == MVT_VARIABLE)
574 {
575 // variable, get the number of bytes to read from the template
576 S32 data_size = mvci.getSize();
577 U8 tsizeb = 0;
578 U16 tsizeh = 0;
579 U32 tsize = 0;
580
581 if ((decode_pos + data_size) > mReceiveSize)
582 {
583 logRanOffEndOfPacket( sender );
584 return FALSE;
585 }
586 switch(data_size)
587 {
588 case 1:
589 htonmemcpy(&tsizeb, &buffer[decode_pos], MVT_U8, 1);
590 tsize = tsizeb;
591 break;
592 case 2:
593 htonmemcpy(&tsizeh, &buffer[decode_pos], MVT_U16, 2);
594 tsize = tsizeh;
595 break;
596 case 4:
597 htonmemcpy(&tsizeb, &buffer[decode_pos], MVT_U32, 4);
598 break;
599 default:
600 llerrs << "Attempting to read variable field with unknown size of " << data_size << llendl;
601 break;
602
603 }
604 decode_pos += data_size;
605
606 if ((decode_pos + (S32)tsize) > mReceiveSize)
607 {
608 logRanOffEndOfPacket( sender );
609 return FALSE;
610 }
611 cur_data_block->addData(mvci.getName(), &buffer[decode_pos], tsize, mvci.getType());
612 decode_pos += tsize;
613 }
614 else
615 {
616 // fixed!
617 // so, copy data pointer and set data size to fixed size
618
619 if ((decode_pos + mvci.getSize()) > mReceiveSize)
620 {
621 logRanOffEndOfPacket( sender );
622 return FALSE;
623 }
624
625 cur_data_block->addData(mvci.getName(), &buffer[decode_pos], mvci.getSize(), mvci.getType());
626 decode_pos += mvci.getSize();
627 }
628 }
629 }
630 }
631
632 if (mCurrentRMessageData->mMemberBlocks.empty()
633 && !mCurrentRMessageTemplate->mMemberBlocks.empty())
634 {
635 lldebugs << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << llendl;
636 return FALSE;
637 }
638
639 {
640 static LLTimer decode_timer;
641
642 if(LLMessageReader::getTimeDecodes() || gMessageSystem->getTimingCallback())
643 {
644 decode_timer.reset();
645 }
646
647 // if( mCurrentRMessageTemplate->mName == _PREHASH_AgentToNewRegion )
648 // {
649 // VTResume(); // VTune
650 // }
651
652 {
653 LLFastTimer t(LLFastTimer::FTM_PROCESS_MESSAGES);
654 if( !mCurrentRMessageTemplate->callHandlerFunc(gMessageSystem) )
655 {
656 llwarns << "Message from " << sender << " with no handler function received: " << mCurrentRMessageTemplate->mName << llendl;
657 }
658 }
659
660 // if( mCurrentRMessageTemplate->mName == _PREHASH_AgentToNewRegion )
661 // {
662 // VTPause(); // VTune
663 // }
664
665 if(LLMessageReader::getTimeDecodes() || gMessageSystem->getTimingCallback())
666 {
667 F32 decode_time = decode_timer.getElapsedTimeF32();
668
669 if (gMessageSystem->getTimingCallback())
670 {
671 (gMessageSystem->getTimingCallback())(mCurrentRMessageTemplate->mName,
672 decode_time,
673 gMessageSystem->getTimingCallbackData());
674 }
675
676 if (LLMessageReader::getTimeDecodes())
677 {
678 mCurrentRMessageTemplate->mDecodeTimeThisFrame += decode_time;
679
680 mCurrentRMessageTemplate->mTotalDecoded++;
681 mCurrentRMessageTemplate->mTotalDecodeTime += decode_time;
682
683 if( mCurrentRMessageTemplate->mMaxDecodeTimePerMsg < decode_time )
684 {
685 mCurrentRMessageTemplate->mMaxDecodeTimePerMsg = decode_time;
686 }
687
688
689 if(decode_time > LLMessageReader::getTimeDecodesSpamThreshold())
690 {
691 lldebugs << "--------- Message " << mCurrentRMessageTemplate->mName << " decode took " << decode_time << " seconds. (" <<
692 mCurrentRMessageTemplate->mMaxDecodeTimePerMsg << " max, " <<
693 (mCurrentRMessageTemplate->mTotalDecodeTime / mCurrentRMessageTemplate->mTotalDecoded) << " avg)" << llendl;
694 }
695 }
696 }
697 }
698 return TRUE;
699}
700
701BOOL LLTemplateMessageReader::validateMessage(const U8* buffer,
702 S32 buffer_size,
703 const LLHost& sender)
704{
705 mReceiveSize = buffer_size;
706 BOOL result = decodeTemplate(buffer, buffer_size, &mCurrentRMessageTemplate );
707 if(result)
708 {
709 mCurrentRMessageTemplate->mReceiveCount++;
710 lldebugst(LLERR_MESSAGE) << "MessageRecvd:"
711 << mCurrentRMessageTemplate->mName
712 << " from " << sender << llendl;
713 }
714 return result;
715}
716
717BOOL LLTemplateMessageReader::readMessage(const U8* buffer,
718 const LLHost& sender)
719{
720 return decodeData(buffer, sender);
721}
722
723//virtual
724const char* LLTemplateMessageReader::getMessageName() const
725{
726 static char empty_string[] = "";
727 return mCurrentRMessageTemplate ? mCurrentRMessageTemplate->mName : empty_string;
728}
729
730//virtual
731bool LLTemplateMessageReader::isTrusted() const
732{
733 return mCurrentRMessageTemplate->getTrust() == MT_TRUST;
734}
735
736//virtual
737bool LLTemplateMessageReader::isBanned(bool trustedSource) const
738{
739 return mCurrentRMessageTemplate->isBanned(trustedSource);
740}
741
742//virtual
743void LLTemplateMessageReader::copyToBuilder(LLMessageBuilder& builder) const
744{
745 if(NULL == mCurrentRMessageTemplate)
746 {
747 return;
748 }
749 builder.copyFromMessageData(*mCurrentRMessageData);
750}
diff --git a/linden/indra/llmessage/lltemplatemessagereader.h b/linden/indra/llmessage/lltemplatemessagereader.h
new file mode 100644
index 0000000..dd5ee39
--- /dev/null
+++ b/linden/indra/llmessage/lltemplatemessagereader.h
@@ -0,0 +1,98 @@
1#ifndef LL_LLTEMPLATEMESSAGEREADER_H
2#define LL_LLTEMPLATEMESSAGEREADER_H
3
4#include "llmessagereader.h"
5
6#include <map>
7
8class LLMessageTemplate;
9class LLMsgData;
10
11class LLTemplateMessageReader : public LLMessageReader
12{
13public:
14
15 typedef std::map<U32, LLMessageTemplate*> message_template_number_map_t;
16
17 LLTemplateMessageReader(message_template_number_map_t&);
18 virtual ~LLTemplateMessageReader();
19
20 /** All get* methods expect pointers to canonical strings. */
21 virtual void getBinaryData(const char *blockname, const char *varname,
22 void *datap, S32 size, S32 blocknum = 0,
23 S32 max_size = S32_MAX);
24 virtual void getBOOL(const char *block, const char *var, BOOL &data,
25 S32 blocknum = 0);
26 virtual void getS8(const char *block, const char *var, S8 &data,
27 S32 blocknum = 0);
28 virtual void getU8(const char *block, const char *var, U8 &data,
29 S32 blocknum = 0);
30 virtual void getS16(const char *block, const char *var, S16 &data,
31 S32 blocknum = 0);
32 virtual void getU16(const char *block, const char *var, U16 &data,
33 S32 blocknum = 0);
34 virtual void getS32(const char *block, const char *var, S32 &data,
35 S32 blocknum = 0);
36 virtual void getF32(const char *block, const char *var, F32 &data,
37 S32 blocknum = 0);
38 virtual void getU32(const char *block, const char *var, U32 &data,
39 S32 blocknum = 0);
40 virtual void getU64(const char *block, const char *var, U64 &data,
41 S32 blocknum = 0);
42 virtual void getF64(const char *block, const char *var, F64 &data,
43 S32 blocknum = 0);
44 virtual void getVector3(const char *block, const char *var,
45 LLVector3 &vec, S32 blocknum = 0);
46 virtual void getVector4(const char *block, const char *var,
47 LLVector4 &vec, S32 blocknum = 0);
48 virtual void getVector3d(const char *block, const char *var,
49 LLVector3d &vec, S32 blocknum = 0);
50 virtual void getQuat(const char *block, const char *var, LLQuaternion &q,
51 S32 blocknum = 0);
52 virtual void getUUID(const char *block, const char *var, LLUUID &uuid,
53 S32 blocknum = 0);
54 virtual void getIPAddr(const char *block, const char *var, U32 &ip,
55 S32 blocknum = 0);
56 virtual void getIPPort(const char *block, const char *var, U16 &port,
57 S32 blocknum = 0);
58 virtual void getString(const char *block, const char *var,
59 S32 buffer_size, char *buffer, S32 blocknum = 0);
60
61 virtual S32 getNumberOfBlocks(const char *blockname);
62 virtual S32 getSize(const char *blockname, const char *varname);
63 virtual S32 getSize(const char *blockname, S32 blocknum,
64 const char *varname);
65
66 virtual void clearMessage();
67
68 virtual const char* getMessageName() const;
69 virtual S32 getMessageSize() const;
70
71 virtual void copyToBuilder(LLMessageBuilder&) const;
72
73 BOOL validateMessage(const U8* buffer, S32 buffer_size,
74 const LLHost& sender);
75 BOOL readMessage(const U8* buffer, const LLHost& sender);
76
77 bool isTrusted() const;
78 bool isBanned(bool trusted_source) const;
79
80private:
81
82 void getData(const char *blockname, const char *varname, void *datap,
83 S32 size = 0, S32 blocknum = 0, S32 max_size = S32_MAX);
84
85 BOOL decodeTemplate(const U8* buffer, S32 buffer_size, // inputs
86 LLMessageTemplate** msg_template ); // outputs
87
88 void logRanOffEndOfPacket( const LLHost& host );
89
90 BOOL decodeData(const U8* buffer, const LLHost& sender );
91
92 S32 mReceiveSize;
93 LLMessageTemplate* mCurrentRMessageTemplate;
94 LLMsgData* mCurrentRMessageData;
95 message_template_number_map_t& mMessageNumbers;
96};
97
98#endif // LL_LLTEMPLATEMESSAGEREADER_H
diff --git a/linden/indra/llmessage/llthrottle.cpp b/linden/indra/llmessage/llthrottle.cpp
index 87dc929..de80dd0 100644
--- a/linden/indra/llmessage/llthrottle.cpp
+++ b/linden/indra/llmessage/llthrottle.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llthrottle.h b/linden/indra/llmessage/llthrottle.h
index 8fc2725..a87834b 100644
--- a/linden/indra/llmessage/llthrottle.h
+++ b/linden/indra/llmessage/llthrottle.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfermanager.cpp b/linden/indra/llmessage/lltransfermanager.cpp
index 43afa78..12e1728 100644
--- a/linden/indra/llmessage/lltransfermanager.cpp
+++ b/linden/indra/llmessage/lltransfermanager.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2004-2007, Linden Research, Inc. 6 * Copyright (c) 2004-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfermanager.h b/linden/indra/llmessage/lltransfermanager.h
index 6d9d172..81a0221 100644
--- a/linden/indra/llmessage/lltransfermanager.h
+++ b/linden/indra/llmessage/lltransfermanager.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2006-2007, Linden Research, Inc. 6 * Copyright (c) 2006-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfersourceasset.cpp b/linden/indra/llmessage/lltransfersourceasset.cpp
index 0285896..31094c1 100644
--- a/linden/indra/llmessage/lltransfersourceasset.cpp
+++ b/linden/indra/llmessage/lltransfersourceasset.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfersourceasset.h b/linden/indra/llmessage/lltransfersourceasset.h
index 7859de7..7b1aa63 100644
--- a/linden/indra/llmessage/lltransfersourceasset.h
+++ b/linden/indra/llmessage/lltransfersourceasset.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfersourcefile.cpp b/linden/indra/llmessage/lltransfersourcefile.cpp
index a8625b0..392349e 100644
--- a/linden/indra/llmessage/lltransfersourcefile.cpp
+++ b/linden/indra/llmessage/lltransfersourcefile.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfersourcefile.h b/linden/indra/llmessage/lltransfersourcefile.h
index f615e86..21661b5 100644
--- a/linden/indra/llmessage/lltransfersourcefile.h
+++ b/linden/indra/llmessage/lltransfersourcefile.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfertargetfile.cpp b/linden/indra/llmessage/lltransfertargetfile.cpp
index bb039d7..00af3ff 100644
--- a/linden/indra/llmessage/lltransfertargetfile.cpp
+++ b/linden/indra/llmessage/lltransfertargetfile.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfertargetfile.h b/linden/indra/llmessage/lltransfertargetfile.h
index 9e249f9..50d617f 100644
--- a/linden/indra/llmessage/lltransfertargetfile.h
+++ b/linden/indra/llmessage/lltransfertargetfile.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfertargetvfile.cpp b/linden/indra/llmessage/lltransfertargetvfile.cpp
index 5a1acf3..79919b8 100644
--- a/linden/indra/llmessage/lltransfertargetvfile.cpp
+++ b/linden/indra/llmessage/lltransfertargetvfile.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lltransfertargetvfile.h b/linden/indra/llmessage/lltransfertargetvfile.h
index 4c915dc..6ba8745 100644
--- a/linden/indra/llmessage/lltransfertargetvfile.h
+++ b/linden/indra/llmessage/lltransfertargetvfile.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2006-2007, Linden Research, Inc. 5 * Copyright (c) 2006-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llurlrequest.cpp b/linden/indra/llmessage/llurlrequest.cpp
index 8ac8d94..b3dfb52 100644
--- a/linden/indra/llmessage/llurlrequest.cpp
+++ b/linden/indra/llmessage/llurlrequest.cpp
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llurlrequest.h b/linden/indra/llmessage/llurlrequest.h
index 788b0e4..9088244 100644
--- a/linden/indra/llmessage/llurlrequest.h
+++ b/linden/indra/llmessage/llurlrequest.h
@@ -6,6 +6,7 @@
6 * 6 *
7 * Copyright (c) 2005-2007, Linden Research, Inc. 7 * Copyright (c) 2005-2007, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code
9 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
10 * to you under the terms of the GNU General Public License, version 2.0 11 * to you under the terms of the GNU General Public License, version 2.0
11 * ("GPL"), unless you have obtained a separate licensing agreement 12 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lluseroperation.cpp b/linden/indra/llmessage/lluseroperation.cpp
index c3ce63c..29146ea 100644
--- a/linden/indra/llmessage/lluseroperation.cpp
+++ b/linden/indra/llmessage/lluseroperation.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/lluseroperation.h b/linden/indra/llmessage/lluseroperation.h
index 18459f5..325567c 100644
--- a/linden/indra/llmessage/lluseroperation.h
+++ b/linden/indra/llmessage/lluseroperation.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2002-2007, Linden Research, Inc. 6 * Copyright (c) 2002-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llvehicleparams.h b/linden/indra/llmessage/llvehicleparams.h
index 7725406..946f88c 100644
--- a/linden/indra/llmessage/llvehicleparams.h
+++ b/linden/indra/llmessage/llvehicleparams.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2003-2007, Linden Research, Inc. 6 * Copyright (c) 2003-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer.cpp b/linden/indra/llmessage/llxfer.cpp
index 507b820..e12996d 100644
--- a/linden/indra/llmessage/llxfer.cpp
+++ b/linden/indra/llmessage/llxfer.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer.h b/linden/indra/llmessage/llxfer.h
index b070c87..51d7731 100644
--- a/linden/indra/llmessage/llxfer.h
+++ b/linden/indra/llmessage/llxfer.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer_file.cpp b/linden/indra/llmessage/llxfer_file.cpp
index 2fec06b..297d163 100644
--- a/linden/indra/llmessage/llxfer_file.cpp
+++ b/linden/indra/llmessage/llxfer_file.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -133,7 +134,7 @@ S32 LLXfer_File::initializeRequest(U64 xfer_id,
133 mRemoteHost = remote_host; 134 mRemoteHost = remote_host;
134 mDeleteRemoteOnCompletion = delete_remote_on_completion; 135 mDeleteRemoteOnCompletion = delete_remote_on_completion;
135 136
136 snprintf(mTempFilename, sizeof(mTempFilename), "%s",gDirUtilp->getTempFilename().c_str()); /* Flawfinder : ignore */ 137 snprintf(mTempFilename, sizeof(mTempFilename), "%s",gDirUtilp->getTempFilename().c_str()); /* Flawfinder: ignore */
137 138
138 mCallback = callback; 139 mCallback = callback;
139 mCallbackDataHandle = user_data; 140 mCallbackDataHandle = user_data;
diff --git a/linden/indra/llmessage/llxfer_file.h b/linden/indra/llmessage/llxfer_file.h
index 2a92e00..6a9ee51 100644
--- a/linden/indra/llmessage/llxfer_file.h
+++ b/linden/indra/llmessage/llxfer_file.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer_mem.cpp b/linden/indra/llmessage/llxfer_mem.cpp
index e9d7bf8..e9b4224 100644
--- a/linden/indra/llmessage/llxfer_mem.cpp
+++ b/linden/indra/llmessage/llxfer_mem.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer_mem.h b/linden/indra/llmessage/llxfer_mem.h
index bda7893..b80807a 100644
--- a/linden/indra/llmessage/llxfer_mem.h
+++ b/linden/indra/llmessage/llxfer_mem.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer_vfile.cpp b/linden/indra/llmessage/llxfer_vfile.cpp
index 3a2a4a2..0d0d5fe 100644
--- a/linden/indra/llmessage/llxfer_vfile.cpp
+++ b/linden/indra/llmessage/llxfer_vfile.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfer_vfile.h b/linden/indra/llmessage/llxfer_vfile.h
index 51b64db..e71a0e8 100644
--- a/linden/indra/llmessage/llxfer_vfile.h
+++ b/linden/indra/llmessage/llxfer_vfile.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc. 5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfermanager.cpp b/linden/indra/llmessage/llxfermanager.cpp
index afeeef3..914488e 100644
--- a/linden/indra/llmessage/llxfermanager.cpp
+++ b/linden/indra/llmessage/llxfermanager.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxfermanager.h b/linden/indra/llmessage/llxfermanager.h
index b6e3ee2..7b529ad 100644
--- a/linden/indra/llmessage/llxfermanager.h
+++ b/linden/indra/llmessage/llxfermanager.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc. 6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxorcipher.cpp b/linden/indra/llmessage/llxorcipher.cpp
index 3c3f690..042fbd4 100644
--- a/linden/indra/llmessage/llxorcipher.cpp
+++ b/linden/indra/llmessage/llxorcipher.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/llxorcipher.h b/linden/indra/llmessage/llxorcipher.h
index fbb879e..16579a6 100644
--- a/linden/indra/llmessage/llxorcipher.h
+++ b/linden/indra/llmessage/llxorcipher.h
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (c) 2003-2007, Linden Research, Inc. 4 * Copyright (c) 2003-2007, Linden Research, Inc.
5 * 5 *
6 * Second Life Viewer Source Code
6 * The source code in this file ("Source Code") is provided by Linden Lab 7 * The source code in this file ("Source Code") is provided by Linden Lab
7 * to you under the terms of the GNU General Public License, version 2.0 8 * to you under the terms of the GNU General Public License, version 2.0
8 * ("GPL"), unless you have obtained a separate licensing agreement 9 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/machine.h b/linden/indra/llmessage/machine.h
index 72caadc..490ddc5 100644
--- a/linden/indra/llmessage/machine.h
+++ b/linden/indra/llmessage/machine.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/mean_collision_data.h b/linden/indra/llmessage/mean_collision_data.h
index 2d60159..a319640 100644
--- a/linden/indra/llmessage/mean_collision_data.h
+++ b/linden/indra/llmessage/mean_collision_data.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2000-2007, Linden Research, Inc. 6 * Copyright (c) 2000-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp
index 2e7cb6a..ef22b63 100644
--- a/linden/indra/llmessage/message.cpp
+++ b/linden/indra/llmessage/message.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -52,11 +53,23 @@
52 53
53// linden library headers 54// linden library headers
54#include "indra_constants.h" 55#include "indra_constants.h"
56#include "lldarray.h"
55#include "lldir.h" 57#include "lldir.h"
56#include "llerror.h" 58#include "llerror.h"
59#include "llerrorlegacy.h"
57#include "llfasttimer.h" 60#include "llfasttimer.h"
61#include "llhttpclient.h"
62#include "llhttpsender.h"
58#include "llmd5.h" 63#include "llmd5.h"
64#include "llmessagebuilder.h"
65#include "llmessageconfig.h"
66#include "llpumpio.h"
67#include "lltemplatemessagebuilder.h"
68#include "lltemplatemessagereader.h"
69#include "llmessagetemplate.h"
59#include "llsd.h" 70#include "llsd.h"
71#include "llsdmessagebuilder.h"
72#include "llsdmessagereader.h"
60#include "lltransfermanager.h" 73#include "lltransfermanager.h"
61#include "lluuid.h" 74#include "lluuid.h"
62#include "llxfermanager.h" 75#include "llxfermanager.h"
@@ -73,406 +86,6 @@
73static const F32 CIRCUIT_DUMP_TIMEOUT = 30.f; 86static const F32 CIRCUIT_DUMP_TIMEOUT = 30.f;
74static const S32 TRUST_TIME_WINDOW = 3; 87static const S32 TRUST_TIME_WINDOW = 3;
75 88
76class LLMsgVarData
77{
78public:
79 LLMsgVarData() : mName(NULL), mSize(-1), mDataSize(-1), mData(NULL), mType(MVT_U8)
80 {
81 }
82
83 LLMsgVarData(const char *name, EMsgVariableType type) : mSize(-1), mDataSize(-1), mData(NULL), mType(type)
84 {
85 mName = (char *)name;
86 }
87
88 ~LLMsgVarData()
89 {
90 // copy constructor just copies the mData pointer, so only delete mData explicitly
91 }
92
93 void deleteData()
94 {
95 delete[] mData;
96 mData = NULL;
97 }
98
99 void addData(const void *indata, S32 size, EMsgVariableType type, S32 data_size = -1);
100
101 char *getName() const { return mName; }
102 S32 getSize() const { return mSize; }
103 void *getData() { return (void*)mData; }
104 S32 getDataSize() const { return mDataSize; }
105 EMsgVariableType getType() const { return mType; }
106
107protected:
108 char *mName;
109 S32 mSize;
110 S32 mDataSize;
111
112 U8 *mData;
113 EMsgVariableType mType;
114};
115
116
117class LLMsgBlkData
118{
119public:
120 LLMsgBlkData(const char *name, S32 blocknum) : mOffset(-1), mBlockNumber(blocknum), mTotalSize(-1)
121 {
122 mName = (char *)name;
123 }
124
125 ~LLMsgBlkData()
126 {
127 for (msg_var_data_map_t::iterator iter = mMemberVarData.begin();
128 iter != mMemberVarData.end(); iter++)
129 {
130 iter->deleteData();
131 }
132 }
133
134 void addVariable(const char *name, EMsgVariableType type)
135 {
136 LLMsgVarData tmp(name,type);
137 mMemberVarData[name] = tmp;
138 }
139
140 void addData(char *name, const void *data, S32 size, EMsgVariableType type, S32 data_size = -1)
141 {
142 LLMsgVarData* temp = &mMemberVarData[name]; // creates a new entry if one doesn't exist
143 temp->addData(data, size, type, data_size);
144 }
145
146 S32 mOffset;
147 S32 mBlockNumber;
148 typedef LLDynamicArrayIndexed<LLMsgVarData, const char *, 8> msg_var_data_map_t;
149 msg_var_data_map_t mMemberVarData;
150 char *mName;
151 S32 mTotalSize;
152};
153
154
155class LLMsgData
156{
157public:
158 LLMsgData(const char *name) : mTotalSize(-1)
159 {
160 mName = (char *)name;
161 }
162 ~LLMsgData()
163 {
164 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePairedPointer());
165 }
166
167 void addBlock(LLMsgBlkData *blockp)
168 {
169 mMemberBlocks[blockp->mName] = blockp;
170 }
171
172 void addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size = -1);
173
174public:
175 S32 mOffset;
176 typedef std::map<char*, LLMsgBlkData*> msg_blk_data_map_t;
177 msg_blk_data_map_t mMemberBlocks;
178 char *mName;
179 S32 mTotalSize;
180};
181
182inline void LLMsgVarData::addData(const void *data, S32 size, EMsgVariableType type, S32 data_size)
183{
184 mSize = size;
185 mDataSize = data_size;
186 if ( (type != MVT_VARIABLE) && (type != MVT_FIXED)
187 && (mType != MVT_VARIABLE) && (mType != MVT_FIXED))
188 {
189 if (mType != type)
190 {
191 llwarns << "Type mismatch in addData for " << mName
192 << " message: " << gMessageSystem->getCurrentSMessageName()
193 << " block: " << gMessageSystem->getCurrentSBlockName()
194 << llendl;
195 }
196 }
197 if(size)
198 {
199 delete mData; // Delete it if it already exists
200 mData = new U8[size];
201 htonmemcpy(mData, data, mType, size);
202 }
203}
204
205
206
207inline void LLMsgData::addDataFast(char *blockname, char *varname, const void *data, S32 size, EMsgVariableType type, S32 data_size)
208{
209 // remember that if the blocknumber is > 0 then the number is appended to the name
210 char *namep = (char *)blockname;
211 LLMsgBlkData* block_data = mMemberBlocks[namep];
212 if (block_data->mBlockNumber)
213 {
214 namep += block_data->mBlockNumber;
215 block_data->addData(varname, data, size, type, data_size);
216 }
217 else
218 {
219 block_data->addData(varname, data, size, type, data_size);
220 }
221}
222
223// LLMessage* classes store the template of messages
224
225
226class LLMessageVariable
227{
228public:
229 LLMessageVariable() : mName(NULL), mType(MVT_NULL), mSize(-1)
230 {
231 }
232
233 LLMessageVariable(char *name) : mType(MVT_NULL), mSize(-1)
234 {
235 mName = name;
236 }
237
238 LLMessageVariable(char *name, const EMsgVariableType type, const S32 size) : mType(type), mSize(size)
239 {
240 mName = gMessageStringTable.getString(name);
241 }
242
243 ~LLMessageVariable() {}
244
245 friend std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg);
246
247 EMsgVariableType getType() const { return mType; }
248 S32 getSize() const { return mSize; }
249 char *getName() const { return mName; }
250protected:
251 char *mName;
252 EMsgVariableType mType;
253 S32 mSize;
254};
255
256
257typedef enum e_message_block_type
258{
259 MBT_NULL,
260 MBT_SINGLE,
261 MBT_MULTIPLE,
262 MBT_VARIABLE,
263 MBT_EOF
264} EMsgBlockType;
265
266class LLMessageBlock
267{
268public:
269 LLMessageBlock(char *name, EMsgBlockType type, S32 number = 1) : mType(type), mNumber(number), mTotalSize(0)
270 {
271 mName = gMessageStringTable.getString(name);
272 }
273
274 ~LLMessageBlock()
275 {
276 for_each(mMemberVariables.begin(), mMemberVariables.end(), DeletePairedPointer());
277 }
278
279 void addVariable(char *name, const EMsgVariableType type, const S32 size)
280 {
281 LLMessageVariable** varp = &mMemberVariables[name];
282 if (*varp != NULL)
283 {
284 llerrs << name << " has already been used as a variable name!" << llendl;
285 }
286 *varp = new LLMessageVariable(name, type, size);
287 if (((*varp)->getType() != MVT_VARIABLE)
288 &&(mTotalSize != -1))
289 {
290 mTotalSize += (*varp)->getSize();
291 }
292 else
293 {
294 mTotalSize = -1;
295 }
296 }
297
298 EMsgVariableType getVariableType(char *name)
299 {
300 return (mMemberVariables[name])->getType();
301 }
302
303 S32 getVariableSize(char *name)
304 {
305 return (mMemberVariables[name])->getSize();
306 }
307
308 friend std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg);
309
310 typedef std::map<const char *, LLMessageVariable*> message_variable_map_t;
311 message_variable_map_t mMemberVariables;
312 char *mName;
313 EMsgBlockType mType;
314 S32 mNumber;
315 S32 mTotalSize;
316};
317
318
319enum EMsgFrequency
320{
321 MFT_NULL = 0, // value is size of message number in bytes
322 MFT_HIGH = 1,
323 MFT_MEDIUM = 2,
324 MFT_LOW = 4
325};
326
327typedef enum e_message_trust
328{
329 MT_TRUST,
330 MT_NOTRUST
331} EMsgTrust;
332
333enum EMsgEncoding
334{
335 ME_UNENCODED,
336 ME_ZEROCODED
337};
338
339class LLMessageTemplate
340{
341public:
342 LLMessageTemplate(const char *name, U32 message_number, EMsgFrequency freq)
343 :
344 //mMemberBlocks(),
345 mName(NULL),
346 mFrequency(freq),
347 mTrust(MT_NOTRUST),
348 mEncoding(ME_ZEROCODED),
349 mMessageNumber(message_number),
350 mTotalSize(0),
351 mReceiveCount(0),
352 mReceiveBytes(0),
353 mReceiveInvalid(0),
354 mDecodeTimeThisFrame(0.f),
355 mTotalDecoded(0),
356 mTotalDecodeTime(0.f),
357 mMaxDecodeTimePerMsg(0.f),
358 mBanFromTrusted(false),
359 mBanFromUntrusted(false),
360 mHandlerFunc(NULL),
361 mUserData(NULL)
362 {
363 mName = gMessageStringTable.getString(name);
364 }
365
366 ~LLMessageTemplate()
367 {
368 for_each(mMemberBlocks.begin(), mMemberBlocks.end(), DeletePairedPointer());
369 }
370
371 void addBlock(LLMessageBlock *blockp)
372 {
373 LLMessageBlock** member_blockp = &mMemberBlocks[blockp->mName];
374 if (*member_blockp != NULL)
375 {
376 llerrs << "Block " << blockp->mName
377 << "has already been used as a block name!" << llendl;
378 }
379 *member_blockp = blockp;
380 if ( (mTotalSize != -1)
381 &&(blockp->mTotalSize != -1)
382 &&( (blockp->mType == MBT_SINGLE)
383 ||(blockp->mType == MBT_MULTIPLE)))
384 {
385 mTotalSize += blockp->mNumber*blockp->mTotalSize;
386 }
387 else
388 {
389 mTotalSize = -1;
390 }
391 }
392
393 LLMessageBlock *getBlock(char *name)
394 {
395 return mMemberBlocks[name];
396 }
397
398 // Trusted messages can only be recieved on trusted circuits.
399 void setTrust(EMsgTrust t)
400 {
401 mTrust = t;
402 }
403
404 EMsgTrust getTrust(void)
405 {
406 return mTrust;
407 }
408
409 // controls for how the message should be encoded
410 void setEncoding(EMsgEncoding e)
411 {
412 mEncoding = e;
413 }
414 EMsgEncoding getEncoding()
415 {
416 return mEncoding;
417 }
418
419 void setHandlerFunc(void (*handler_func)(LLMessageSystem *msgsystem, void **user_data), void **user_data)
420 {
421 mHandlerFunc = handler_func;
422 mUserData = user_data;
423 }
424
425 BOOL callHandlerFunc(LLMessageSystem *msgsystem)
426 {
427 if (mHandlerFunc)
428 {
429 mHandlerFunc(msgsystem, mUserData);
430 return TRUE;
431 }
432 return FALSE;
433 }
434
435 bool isBanned(bool trustedSource)
436 {
437 return trustedSource ? mBanFromTrusted : mBanFromUntrusted;
438 }
439
440 friend std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg);
441
442public:
443 typedef std::map<char*, LLMessageBlock*> message_block_map_t;
444 message_block_map_t mMemberBlocks;
445 char *mName;
446 EMsgFrequency mFrequency;
447 EMsgTrust mTrust;
448 EMsgEncoding mEncoding;
449 U32 mMessageNumber;
450 S32 mTotalSize;
451 U32 mReceiveCount; // how many of this template have been received since last reset
452 U32 mReceiveBytes; // How many bytes received
453 U32 mReceiveInvalid; // How many "invalid" packets
454 F32 mDecodeTimeThisFrame; // Total seconds spent decoding this frame
455 U32 mTotalDecoded; // Total messages successfully decoded
456 F32 mTotalDecodeTime; // Total time successfully decoding messages
457 F32 mMaxDecodeTimePerMsg;
458
459 bool mBanFromTrusted;
460 bool mBanFromUntrusted;
461
462private:
463 // message handler function (this is set by each application)
464 void (*mHandlerFunc)(LLMessageSystem *msgsystem, void **user_data);
465 void **mUserData;
466};
467
468
469
470// static
471BOOL LLMessageSystem::mTimeDecodes = FALSE;
472
473// static, 50ms per message decode
474F32 LLMessageSystem::mTimeDecodesSpamThreshold = 0.05f;
475
476// *NOTE: This needs to be moved into a seperate file so that it never gets 89// *NOTE: This needs to be moved into a seperate file so that it never gets
477// included in the viewer. 30 Sep 2002 mark 90// included in the viewer. 30 Sep 2002 mark
478// *NOTE: I don't think it's important that the messgage system tracks 91// *NOTE: I don't think it's important that the messgage system tracks
@@ -487,113 +100,6 @@ public:
487 apr_pollfd_t mPollFD; 100 apr_pollfd_t mPollFD;
488}; 101};
489 102
490
491// LLMessageVariable functions and friends
492
493std::ostream& operator<<(std::ostream& s, LLMessageVariable &msg)
494{
495 s << "\t\t" << msg.mName << " (";
496 switch (msg.mType)
497 {
498 case MVT_FIXED:
499 s << "Fixed, " << msg.mSize << " bytes total)\n";
500 break;
501 case MVT_VARIABLE:
502 s << "Variable, " << msg.mSize << " bytes of size info)\n";
503 break;
504 default:
505 s << "Unknown\n";
506 break;
507 }
508 return s;
509}
510
511// LLMessageBlock functions and friends
512
513std::ostream& operator<<(std::ostream& s, LLMessageBlock &msg)
514{
515 s << "\t" << msg.mName << " (";
516 switch (msg.mType)
517 {
518 case MBT_SINGLE:
519 s << "Fixed";
520 break;
521 case MBT_MULTIPLE:
522 s << "Multiple - " << msg.mNumber << " copies";
523 break;
524 case MBT_VARIABLE:
525 s << "Variable";
526 break;
527 default:
528 s << "Unknown";
529 break;
530 }
531 if (msg.mTotalSize != -1)
532 {
533 s << ", " << msg.mTotalSize << " bytes each, " << msg.mNumber*msg.mTotalSize << " bytes total)\n";
534 }
535 else
536 {
537 s << ")\n";
538 }
539
540
541 for (LLMessageBlock::message_variable_map_t::iterator iter = msg.mMemberVariables.begin();
542 iter != msg.mMemberVariables.end(); iter++)
543 {
544 LLMessageVariable& ci = *(iter->second);
545 s << ci;
546 }
547
548 return s;
549}
550
551// LLMessageTemplate functions and friends
552
553std::ostream& operator<<(std::ostream& s, LLMessageTemplate &msg)
554{
555 switch (msg.mFrequency)
556 {
557 case MFT_HIGH:
558 s << "========================================\n" << "Message #" << msg.mMessageNumber << "\n" << msg.mName << " (";
559 s << "High";
560 break;
561 case MFT_MEDIUM:
562 s << "========================================\n" << "Message #";
563 s << (msg.mMessageNumber & 0xFF) << "\n" << msg.mName << " (";
564 s << "Medium";
565 break;
566 case MFT_LOW:
567 s << "========================================\n" << "Message #";
568 s << (msg.mMessageNumber & 0xFFFF) << "\n" << msg.mName << " (";
569 s << "Low";
570 break;
571 default:
572 s << "Unknown";
573 break;
574 }
575
576 if (msg.mTotalSize != -1)
577 {
578 s << ", " << msg.mTotalSize << " bytes total)\n";
579 }
580 else
581 {
582 s << ")\n";
583 }
584
585 for (LLMessageTemplate::message_block_map_t::iterator iter = msg.mMemberBlocks.begin();
586 iter != msg.mMemberBlocks.end(); iter++)
587 {
588 LLMessageBlock* ci = iter->second;
589 s << *ci;
590 }
591
592 return s;
593}
594
595// LLMessageList functions and friends
596
597// Lets support a small subset of regular expressions here 103// Lets support a small subset of regular expressions here
598// Syntax is a string made up of: 104// Syntax is a string made up of:
599// a - checks against alphanumeric ([A-Za-z0-9]) 105// a - checks against alphanumeric ([A-Za-z0-9])
@@ -795,6 +301,106 @@ BOOL b_positive_integer_ok(char *token)
795 return TRUE; 301 return TRUE;
796} 302}
797 303
304namespace
305{
306 class LLFnPtrResponder : public LLHTTPClient::Responder
307 {
308 public:
309 LLFnPtrResponder(void (*callback)(void **,S32), void **callbackData) :
310 mCallback(callback),
311 mCallbackData(callbackData)
312 {
313 }
314
315 virtual void error(U32 status, const std::string& reason)
316 {
317 // TODO: Map status in to useful error code.
318 if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_TCP_TIMEOUT);
319 }
320
321 virtual void result(const LLSD& content)
322 {
323 if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_NOERR);
324 }
325
326 private:
327
328 void (*mCallback)(void **,S32);
329 void **mCallbackData;
330 };
331}
332
333
334class LLTrustedMessageService : public LLHTTPNode
335{
336 virtual bool validate(const std::string& name, LLSD& context) const
337 { return true; }
338
339 virtual void post(LLHTTPNode::ResponsePtr response,
340 const LLSD& context,
341 const LLSD& input) const;
342};
343
344//virtual
345void LLTrustedMessageService::post(LLHTTPNode::ResponsePtr response,
346 const LLSD& context,
347 const LLSD& input) const
348{
349 std::string name = context["request"]["wildcard"]["message-name"];
350 std::string senderIP = context["request"]["remote-host"];
351 std::string senderPort = context["request"]["headers"]
352 ["x-secondlife-udp-listen-port"];
353
354 LLSD message_data;
355 message_data["sender"] = senderIP + ":" + senderPort;
356 message_data["body"] = input;
357
358 LLMessageSystem::dispatch(name, message_data, response);
359}
360
361class LLMessageHandlerBridge : public LLHTTPNode
362{
363 virtual bool validate(const std::string& name, LLSD& context) const
364 { return true; }
365
366 virtual void post(LLHTTPNode::ResponsePtr response, const LLSD& context,
367 const LLSD& input) const;
368};
369
370//virtual
371void LLMessageHandlerBridge::post(LLHTTPNode::ResponsePtr response,
372 const LLSD& context, const LLSD& input) const
373{
374 std::string name = context["request"]["wildcard"]["message-name"];
375
376 lldebugs << "Setting mLastSender " << input["sender"].asString() << llendl;
377 gMessageSystem->mLastSender = LLHost(input["sender"].asString());
378 gMessageSystem->mPacketsIn += 1;
379 gMessageSystem->mLLSDMessageReader->setMessage(name, input["body"]);
380 gMessageSystem->mMessageReader = gMessageSystem->mLLSDMessageReader;
381
382 if(gMessageSystem->callHandler(name.c_str(), false, gMessageSystem))
383 {
384 response->result(LLSD());
385 }
386 else
387 {
388 response->notFound();
389 }
390}
391
392LLHTTPRegistration<LLMessageHandlerBridge>
393 gHTTPRegistrationMessageWildcard("/message/<message-name>");
394
395LLHTTPRegistration<LLTrustedMessageService>
396 gHTTPRegistrationTrustedMessageWildcard("/trusted-message/<message-name>");
397
398//virtual
399LLUseCircuitCodeResponder::~LLUseCircuitCodeResponder()
400{
401 // even abstract base classes need a concrete destructor
402}
403
798void LLMessageSystem::init() 404void LLMessageSystem::init()
799{ 405{
800 // initialize member variables 406 // initialize member variables
@@ -802,25 +408,12 @@ void LLMessageSystem::init()
802 408
803 mbError = FALSE; 409 mbError = FALSE;
804 mErrorCode = 0; 410 mErrorCode = 0;
805 mIncomingCompressedSize = 0;
806 mSendReliable = FALSE; 411 mSendReliable = FALSE;
807 412
808 mbSBuilt = FALSE;
809 mbSClear = TRUE;
810
811 mUnackedListDepth = 0; 413 mUnackedListDepth = 0;
812 mUnackedListSize = 0; 414 mUnackedListSize = 0;
813 mDSMaxListDepth = 0; 415 mDSMaxListDepth = 0;
814 416
815 mCurrentRMessageData = NULL;
816 mCurrentRMessageTemplate = NULL;
817
818 mCurrentSMessageData = NULL;
819 mCurrentSMessageTemplate = NULL;
820 mCurrentSMessageName = NULL;
821
822 mCurrentRecvPacketID = 0;
823
824 mNumberHighFreqMessages = 0; 417 mNumberHighFreqMessages = 0;
825 mNumberMediumFreqMessages = 0; 418 mNumberMediumFreqMessages = 0;
826 mNumberLowFreqMessages = 0; 419 mNumberLowFreqMessages = 0;
@@ -844,54 +437,26 @@ void LLMessageSystem::init()
844 437
845 mOurCircuitCode = 0; 438 mOurCircuitCode = 0;
846 439
440 mIncomingCompressedSize = 0;
441 mCurrentRecvPacketID = 0;
442
847 mMessageFileChecksum = 0; 443 mMessageFileChecksum = 0;
848 mMessageFileVersionNumber = 0.f; 444 mMessageFileVersionNumber = 0.f;
849}
850
851LLMessageSystem::LLMessageSystem()
852{
853 init();
854 445
855 mSystemVersionMajor = 0; 446 mTimingCallback = NULL;
856 mSystemVersionMinor = 0; 447 mTimingCallbackData = NULL;
857 mSystemVersionPatch = 0;
858 mSystemVersionServer = 0;
859 mVersionFlags = 0x0;
860
861 // default to not accepting packets from not alive circuits
862 mbProtected = TRUE;
863 448
864 mSendPacketFailureCount = 0; 449 mMessageBuilder = NULL;
865 mCircuitPrintFreq = 0.f; // seconds 450 mMessageReader = NULL;
866
867 // initialize various bits of net info
868 mSocket = 0;
869 mPort = 0;
870
871 mPollInfop = NULL;
872
873 mResendDumpTime = 0;
874 mMessageCountTime = 0;
875 mCircuitPrintTime = 0;
876 mCurrentMessageTimeSeconds = 0;
877
878 // Constants for dumping output based on message processing time/count
879 mNumMessageCounts = 0;
880 mMaxMessageCounts = 0; // >= 0 means dump warnings
881 mMaxMessageTime = 0.f;
882
883 mTrueReceiveSize = 0;
884
885 // Error if checking this state, subclass methods which aren't implemented are delegated
886 // to properly constructed message system.
887 mbError = TRUE;
888} 451}
889 452
890// Read file and build message templates 453// Read file and build message templates
891LLMessageSystem::LLMessageSystem(const char *filename, U32 port, 454LLMessageSystem::LLMessageSystem(const char *filename, U32 port,
892 S32 version_major, 455 S32 version_major,
893 S32 version_minor, 456 S32 version_minor,
894 S32 version_patch) 457 S32 version_patch) :
458 mTemplateConfirmed(FALSE),
459 mTemplateMatches(FALSE)
895{ 460{
896 init(); 461 init();
897 462
@@ -910,6 +475,14 @@ LLMessageSystem::LLMessageSystem(const char *filename, U32 port,
910 475
911 loadTemplateFile(filename); 476 loadTemplateFile(filename);
912 477
478 mTemplateMessageBuilder = new LLTemplateMessageBuilder(mMessageTemplates);
479 mLLSDMessageBuilder = new LLSDMessageBuilder();
480 mMessageBuilder = NULL;
481
482 mTemplateMessageReader = new LLTemplateMessageReader(mMessageNumbers);
483 mLLSDMessageReader = new LLSDMessageReader();
484 mMessageReader = NULL;
485
913 // initialize various bits of net info 486 // initialize various bits of net info
914 mSocket = 0; 487 mSocket = 0;
915 mPort = port; 488 mPort = port;
@@ -1728,25 +1301,25 @@ LLMessageSystem::~LLMessageSystem()
1728 end_net(); 1301 end_net();
1729 } 1302 }
1730 1303
1731 delete mCurrentRMessageData; 1304 delete mMessageReader;
1732 mCurrentRMessageData = NULL; 1305 mMessageReader = NULL;
1733 1306
1734 delete mCurrentSMessageData; 1307 delete mMessageBuilder;
1735 mCurrentSMessageData = NULL; 1308 mMessageBuilder = NULL;
1736 1309
1737 delete mPollInfop; 1310 delete mPollInfop;
1738 mPollInfop = NULL; 1311 mPollInfop = NULL;
1312
1313 mIncomingCompressedSize = 0;
1314 mCurrentRecvPacketID = 0;
1739} 1315}
1740 1316
1741void LLMessageSystem::clearReceiveState() 1317void LLMessageSystem::clearReceiveState()
1742{ 1318{
1743 mReceiveSize = -1;
1744 mCurrentRecvPacketID = 0; 1319 mCurrentRecvPacketID = 0;
1745 mCurrentRMessageTemplate = NULL;
1746 delete mCurrentRMessageData;
1747 mCurrentRMessageData = NULL;
1748 mIncomingCompressedSize = 0; 1320 mIncomingCompressedSize = 0;
1749 mLastSender.invalidate(); 1321 mLastSender.invalidate();
1322 mMessageReader->clearMessage();
1750} 1323}
1751 1324
1752 1325
@@ -1773,20 +1346,23 @@ BOOL LLMessageSystem::poll(F32 seconds)
1773// Returns TRUE if a valid, on-circuit message has been received. 1346// Returns TRUE if a valid, on-circuit message has been received.
1774BOOL LLMessageSystem::checkMessages( S64 frame_count ) 1347BOOL LLMessageSystem::checkMessages( S64 frame_count )
1775{ 1348{
1349 // Pump
1776 BOOL valid_packet = FALSE; 1350 BOOL valid_packet = FALSE;
1351 mMessageReader = mTemplateMessageReader;
1777 1352
1778 LLTransferTargetVFile::updateQueue(); 1353 LLTransferTargetVFile::updateQueue();
1779 1354
1780 if (!mNumMessageCounts) 1355 if (!mNumMessageCounts)
1781 { 1356 {
1782 // This is the first message being handled after a resetReceiveCounts, we must be starting 1357 // This is the first message being handled after a resetReceiveCounts,
1783 // the message processing loop. Reset the timers. 1358 // we must be starting the message processing loop. Reset the timers.
1784 mCurrentMessageTimeSeconds = totalTime() * SEC_PER_USEC; 1359 mCurrentMessageTimeSeconds = totalTime() * SEC_PER_USEC;
1785 mMessageCountTime = getMessageTimeSeconds(); 1360 mMessageCountTime = getMessageTimeSeconds();
1786 } 1361 }
1787 1362
1788 // loop until either no packets or a valid packet 1363 // loop until either no packets or a valid packet
1789 // i.e., burn through packets from unregistered circuits 1364 // i.e., burn through packets from unregistered circuits
1365 S32 receive_size = 0;
1790 do 1366 do
1791 { 1367 {
1792 clearReceiveState(); 1368 clearReceiveState();
@@ -1802,16 +1378,16 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
1802 // If you want to dump all received packets into SecondLife.log, uncomment this 1378 // If you want to dump all received packets into SecondLife.log, uncomment this
1803 //dumpPacketToLog(); 1379 //dumpPacketToLog();
1804 1380
1805 mReceiveSize = mTrueReceiveSize; 1381 receive_size = mTrueReceiveSize;
1806 mLastSender = mPacketRing.getLastSender(); 1382 mLastSender = mPacketRing.getLastSender();
1807 1383
1808 if (mReceiveSize < (S32) LL_MINIMUM_VALID_PACKET_SIZE) 1384 if (receive_size < (S32) LL_MINIMUM_VALID_PACKET_SIZE)
1809 { 1385 {
1810 // A receive size of zero is OK, that means that there are no more packets available. 1386 // A receive size of zero is OK, that means that there are no more packets available.
1811 // Ones that are non-zero but below the minimum packet size are worrisome. 1387 // Ones that are non-zero but below the minimum packet size are worrisome.
1812 if (mReceiveSize > 0) 1388 if (receive_size > 0)
1813 { 1389 {
1814 llwarns << "Invalid (too short) packet discarded " << mReceiveSize << llendl; 1390 llwarns << "Invalid (too short) packet discarded " << receive_size << llendl;
1815 callExceptionFunc(MX_PACKET_TOO_SHORT); 1391 callExceptionFunc(MX_PACKET_TOO_SHORT);
1816 } 1392 }
1817 // no data in packet receive buffer 1393 // no data in packet receive buffer
@@ -1825,18 +1401,18 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
1825 // note if packet acks are appended. 1401 // note if packet acks are appended.
1826 if(buffer[0] & LL_ACK_FLAG) 1402 if(buffer[0] & LL_ACK_FLAG)
1827 { 1403 {
1828 acks += buffer[--mReceiveSize]; 1404 acks += buffer[--receive_size];
1829 true_rcv_size = mReceiveSize; 1405 true_rcv_size = receive_size;
1830 if(mReceiveSize >= ((S32)(acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE))) 1406 if(receive_size >= ((S32)(acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE)))
1831 { 1407 {
1832 mReceiveSize -= acks * sizeof(TPACKETID); 1408 receive_size -= acks * sizeof(TPACKETID);
1833 } 1409 }
1834 else 1410 else
1835 { 1411 {
1836 // mal-formed packet. ignore it and continue with 1412 // mal-formed packet. ignore it and continue with
1837 // the next one 1413 // the next one
1838 llwarns << "Malformed packet received. Packet size " 1414 llwarns << "Malformed packet received. Packet size "
1839 << mReceiveSize << " with invalid no. of acks " << acks 1415 << receive_size << " with invalid no. of acks " << acks
1840 << llendl; 1416 << llendl;
1841 valid_packet = FALSE; 1417 valid_packet = FALSE;
1842 continue; 1418 continue;
@@ -1845,7 +1421,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
1845 1421
1846 // process the message as normal 1422 // process the message as normal
1847 1423
1848 mIncomingCompressedSize = zeroCodeExpand(&buffer,&mReceiveSize); 1424 mIncomingCompressedSize = zeroCodeExpand(&buffer,&receive_size);
1849 mCurrentRecvPacketID = buffer[1] + ((buffer[0] & 0x0f ) * 256); 1425 mCurrentRecvPacketID = buffer[1] + ((buffer[0] & 0x0f ) * 256);
1850 if (sizeof(TPACKETID) == 4) 1426 if (sizeof(TPACKETID) == 4)
1851 { 1427 {
@@ -1969,7 +1545,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
1969 std::ostringstream str; 1545 std::ostringstream str;
1970 str << "MSG: <- " << host; 1546 str << "MSG: <- " << host;
1971 char buffer[MAX_STRING]; /* Flawfinder: ignore*/ 1547 char buffer[MAX_STRING]; /* Flawfinder: ignore*/
1972 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mReceiveSize, (mIncomingCompressedSize ? mIncomingCompressedSize : mReceiveSize), mCurrentRecvPacketID);/* Flawfinder: ignore*/ 1548 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", receive_size, (mIncomingCompressedSize ? mIncomingCompressedSize : receive_size), mCurrentRecvPacketID); /* Flawfinder: ignore */
1973 str << buffer << "(unknown)" 1549 str << buffer << "(unknown)"
1974 << (recv_reliable ? " reliable" : "") 1550 << (recv_reliable ? " reliable" : "")
1975 << " resent " 1551 << " resent "
@@ -1987,23 +1563,22 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
1987 // But we don't want to acknowledge UseCircuitCode until the circuit is 1563 // But we don't want to acknowledge UseCircuitCode until the circuit is
1988 // available, which is why the acknowledgement test is done above. JC 1564 // available, which is why the acknowledgement test is done above. JC
1989 1565
1990 valid_packet = decodeTemplate( buffer, mReceiveSize, &mCurrentRMessageTemplate ); 1566 valid_packet = mTemplateMessageReader->validateMessage(buffer,
1991 if( valid_packet ) 1567 receive_size,
1992 { 1568 host);
1993 mCurrentRMessageTemplate->mReceiveCount++;
1994 lldebugst(LLERR_MESSAGE) << "MessageRecvd:" << mCurrentRMessageTemplate->mName << " from " << host << llendl;
1995 }
1996 1569
1997 // UseCircuitCode is allowed in even from an invalid circuit, so that 1570 // UseCircuitCode is allowed in even from an invalid circuit, so that
1998 // we can toss circuits around. 1571 // we can toss circuits around.
1999 if (valid_packet && !cdp && (mCurrentRMessageTemplate->mName != _PREHASH_UseCircuitCode) ) 1572 if(valid_packet && !cdp &&
1573 (mTemplateMessageReader->getMessageName() != _PREHASH_UseCircuitCode))
2000 { 1574 {
2001 logMsgFromInvalidCircuit( host, recv_reliable ); 1575 logMsgFromInvalidCircuit( host, recv_reliable );
2002 clearReceiveState(); 1576 clearReceiveState();
2003 valid_packet = FALSE; 1577 valid_packet = FALSE;
2004 } 1578 }
2005 1579
2006 if (valid_packet && cdp && !cdp->getTrusted() && (mCurrentRMessageTemplate->getTrust() == MT_TRUST) ) 1580 if(valid_packet && cdp && !cdp->getTrusted() &&
1581 mTemplateMessageReader->isTrusted())
2007 { 1582 {
2008 logTrustedMsgFromUntrustedCircuit( host ); 1583 logTrustedMsgFromUntrustedCircuit( host );
2009 clearReceiveState(); 1584 clearReceiveState();
@@ -2013,11 +1588,11 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2013 } 1588 }
2014 1589
2015 if (valid_packet 1590 if (valid_packet
2016 && mCurrentRMessageTemplate->isBanned(cdp && cdp->getTrusted())) 1591 && mTemplateMessageReader->isBanned(cdp && cdp->getTrusted()))
2017 { 1592 {
2018 llwarns << "LLMessageSystem::checkMessages " 1593 llwarns << "LLMessageSystem::checkMessages "
2019 << "received banned message " 1594 << "received banned message "
2020 << mCurrentRMessageTemplate->mName 1595 << mTemplateMessageReader->getMessageName()
2021 << " from " 1596 << " from "
2022 << ((cdp && cdp->getTrusted()) ? "trusted " : "untrusted ") 1597 << ((cdp && cdp->getTrusted()) ? "trusted " : "untrusted ")
2023 << host << llendl; 1598 << host << llendl;
@@ -2029,7 +1604,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2029 { 1604 {
2030 logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) ); 1605 logValidMsg(cdp, host, recv_reliable, recv_resent, (BOOL)(acks>0) );
2031 1606
2032 valid_packet = decodeData( buffer, host ); 1607 valid_packet = mTemplateMessageReader->readMessage(buffer, host);
2033 } 1608 }
2034 1609
2035 // It's possible that the circuit went away, because ANY message can disable the circuit 1610 // It's possible that the circuit went away, because ANY message can disable the circuit
@@ -2042,7 +1617,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2042 if( 1 ) 1617 if( 1 )
2043 { 1618 {
2044 static char* object_update = gMessageStringTable.getString("ObjectUpdate"); 1619 static char* object_update = gMessageStringTable.getString("ObjectUpdate");
2045 if(object_update == mCurrentRMessageTemplate->mName ) 1620 if(object_update == mTemplateMessageReader->getMessageName() )
2046 { 1621 {
2047 llinfos << "ObjectUpdate:" << llendl; 1622 llinfos << "ObjectUpdate:" << llendl;
2048 U32 i; 1623 U32 i;
@@ -2053,8 +1628,8 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2053 } 1628 }
2054 llinfos << "" << llendl; 1629 llinfos << "" << llendl;
2055 1630
2056 llinfos << " Zero Unencoded: " << mReceiveSize << llendl; 1631 llinfos << " Zero Unencoded: " << receive_size << llendl;
2057 for( i = 0; i<mReceiveSize; i++ ) 1632 for( i = 0; i<receive_size; i++ )
2058 { 1633 {
2059 llinfos << " " << i << ": " << (U32) buffer[i] << llendl; 1634 llinfos << " " << i << ": " << (U32) buffer[i] << llendl;
2060 } 1635 }
@@ -2143,7 +1718,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2143 if (mbProtected && (!cdp)) 1718 if (mbProtected && (!cdp))
2144 { 1719 {
2145 llwarns << "Packet " 1720 llwarns << "Packet "
2146 << (mCurrentRMessageTemplate ? mCurrentRMessageTemplate->mName : "") 1721 << mTemplateMessageReader->getMessageName()
2147 << " from invalid circuit " << host << llendl; 1722 << " from invalid circuit " << host << llendl;
2148 mOffCircuitPackets++; 1723 mOffCircuitPackets++;
2149 } 1724 }
@@ -2156,7 +1731,7 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count )
2156 // Code for dumping the complete contents of a message 1731 // Code for dumping the complete contents of a message
2157 // delete [] zero_unexpanded_buffer; 1732 // delete [] zero_unexpanded_buffer;
2158 } 1733 }
2159 } while (!valid_packet && mReceiveSize > 0); 1734 } while (!valid_packet && receive_size > 0);
2160 1735
2161 F64 mt_sec = getMessageTimeSeconds(); 1736 F64 mt_sec = getMessageTimeSeconds();
2162 // Check to see if we need to print debug info 1737 // Check to see if we need to print debug info
@@ -2257,600 +1832,56 @@ void LLMessageSystem::processAcks()
2257 } 1832 }
2258} 1833}
2259 1834
2260
2261void LLMessageSystem::newMessageFast(const char *name)
2262{
2263 mbSBuilt = FALSE;
2264 mbSClear = FALSE;
2265
2266 mCurrentSendTotal = 0;
2267 mSendReliable = FALSE;
2268
2269 char *namep = (char *)name;
2270
2271 if (mMessageTemplates.count(namep) > 0)
2272 {
2273 mCurrentSMessageTemplate = mMessageTemplates[namep];
2274 if (mCurrentSMessageData)
2275 {
2276 delete mCurrentSMessageData;
2277 }
2278 mCurrentSMessageData = new LLMsgData(namep);
2279 mCurrentSMessageName = namep;
2280 mCurrentSDataBlock = NULL;
2281 mCurrentSBlockName = NULL;
2282
2283 // add at one of each block
2284 LLMessageTemplate* msg_template = mMessageTemplates[namep];
2285 for (LLMessageTemplate::message_block_map_t::iterator iter = msg_template->mMemberBlocks.begin();
2286 iter != msg_template->mMemberBlocks.end(); iter++)
2287 {
2288 LLMessageBlock* ci = iter->second;
2289 LLMsgBlkData *tblockp;
2290 tblockp = new LLMsgBlkData(ci->mName, 0);
2291 mCurrentSMessageData->addBlock(tblockp);
2292 }
2293 }
2294 else
2295 {
2296 llerrs << "newMessage - Message " << name << " not registered" << llendl;
2297 }
2298}
2299
2300void LLMessageSystem::copyMessageRtoS() 1835void LLMessageSystem::copyMessageRtoS()
2301{ 1836{
2302 if (!mCurrentRMessageTemplate) 1837 // NOTE: babbage: switch builder to match reader to avoid
1838 // converting message format
1839 if(mMessageReader == mTemplateMessageReader)
2303 { 1840 {
2304 return; 1841 mMessageBuilder = mTemplateMessageBuilder;
2305 } 1842 }
2306 newMessageFast(mCurrentRMessageTemplate->mName); 1843 else
2307
2308 // copy the blocks
2309 // counting variables used to encode multiple block info
2310 S32 block_count = 0;
2311 char *block_name = NULL;
2312
2313 // loop through msg blocks to loop through variables, totalling up size data and filling the new (send) message
2314 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.begin();
2315 LLMsgData::msg_blk_data_map_t::iterator end = mCurrentRMessageData->mMemberBlocks.end();
2316 for(; iter != end; ++iter)
2317 { 1844 {
2318 LLMsgBlkData* mbci = iter->second; 1845 mMessageBuilder = mLLSDMessageBuilder;
2319 if(!mbci) continue;
2320
2321 // do we need to encode a block code?
2322 if (block_count == 0)
2323 {
2324 block_count = mbci->mBlockNumber;
2325 block_name = (char *)mbci->mName;
2326 }
2327
2328 // counting down mutliple blocks
2329 block_count--;
2330
2331 nextBlockFast(block_name);
2332
2333 // now loop through the variables
2334 LLMsgBlkData::msg_var_data_map_t::iterator dit = mbci->mMemberVarData.begin();
2335 LLMsgBlkData::msg_var_data_map_t::iterator dend = mbci->mMemberVarData.end();
2336
2337 for(; dit != dend; ++dit)
2338 {
2339 LLMsgVarData& mvci = *dit;
2340 addDataFast(mvci.getName(), mvci.getData(), mvci.getType(), mvci.getSize());
2341 }
2342 } 1846 }
1847 mSendReliable = FALSE;
1848 mMessageBuilder->newMessage(mMessageReader->getMessageName());
1849 mMessageReader->copyToBuilder(*mMessageBuilder);
2343} 1850}
2344 1851
2345void LLMessageSystem::clearMessage() 1852void LLMessageSystem::clearMessage()
2346{ 1853{
2347 mbSBuilt = FALSE;
2348 mbSClear = TRUE;
2349
2350 mCurrentSendTotal = 0;
2351 mSendReliable = FALSE; 1854 mSendReliable = FALSE;
2352 1855 mMessageBuilder->clearMessage();
2353 mCurrentSMessageTemplate = NULL;
2354
2355 delete mCurrentSMessageData;
2356 mCurrentSMessageData = NULL;
2357
2358 mCurrentSMessageName = NULL;
2359 mCurrentSDataBlock = NULL;
2360 mCurrentSBlockName = NULL;
2361} 1856}
2362 1857
2363
2364// set block to add data to within current message 1858// set block to add data to within current message
2365void LLMessageSystem::nextBlockFast(const char *blockname) 1859void LLMessageSystem::nextBlockFast(const char *blockname)
2366{ 1860{
2367 char *bnamep = (char *)blockname; 1861 mMessageBuilder->nextBlock(blockname);
2368
2369 if (!mCurrentSMessageTemplate)
2370 {
2371 llerrs << "newMessage not called prior to setBlock" << llendl;
2372 return;
2373 }
2374
2375 // now, does this block exist?
2376 LLMessageTemplate::message_block_map_t::iterator temp_iter = mCurrentSMessageTemplate->mMemberBlocks.find(bnamep);
2377 if (temp_iter == mCurrentSMessageTemplate->mMemberBlocks.end())
2378 {
2379 llerrs << "LLMessageSystem::nextBlockFast " << bnamep
2380 << " not a block in " << mCurrentSMessageTemplate->mName << llendl;
2381 return;
2382 }
2383
2384 LLMessageBlock* template_data = temp_iter->second;
2385
2386 // ok, have we already set this block?
2387 LLMsgBlkData* block_data = mCurrentSMessageData->mMemberBlocks[bnamep];
2388 if (block_data->mBlockNumber == 0)
2389 {
2390 // nope! set this as the current block
2391 block_data->mBlockNumber = 1;
2392 mCurrentSDataBlock = block_data;
2393 mCurrentSBlockName = bnamep;
2394
2395 // add placeholders for each of the variables
2396 for (LLMessageBlock::message_variable_map_t::iterator iter = template_data->mMemberVariables.begin();
2397 iter != template_data->mMemberVariables.end(); iter++)
2398 {
2399 LLMessageVariable& ci = *(iter->second);
2400 mCurrentSDataBlock->addVariable(ci.getName(), ci.getType());
2401 }
2402 return;
2403 }
2404 else
2405 {
2406 // already have this block. . .
2407 // are we supposed to have a new one?
2408
2409 // if the block is type MBT_SINGLE this is bad!
2410 if (template_data->mType == MBT_SINGLE)
2411 {
2412 llerrs << "LLMessageSystem::nextBlockFast called multiple times"
2413 << " for " << bnamep << " but is type MBT_SINGLE" << llendl;
2414 return;
2415 }
2416
2417
2418 // if the block is type MBT_MULTIPLE then we need a known number, make sure that we're not exceeding it
2419 if ( (template_data->mType == MBT_MULTIPLE)
2420 &&(mCurrentSDataBlock->mBlockNumber == template_data->mNumber))
2421 {
2422 llerrs << "LLMessageSystem::nextBlockFast called "
2423 << mCurrentSDataBlock->mBlockNumber << " times for " << bnamep
2424 << " exceeding " << template_data->mNumber
2425 << " specified in type MBT_MULTIPLE." << llendl;
2426 return;
2427 }
2428
2429 // ok, we can make a new one
2430 // modify the name to avoid name collision by adding number to end
2431 S32 count = block_data->mBlockNumber;
2432
2433 // incrememt base name's count
2434 block_data->mBlockNumber++;
2435
2436 if (block_data->mBlockNumber > MAX_BLOCKS)
2437 {
2438 llerrs << "Trying to pack too many blocks into MBT_VARIABLE type (limited to " << MAX_BLOCKS << ")" << llendl;
2439 }
2440
2441 // create new name
2442 // Nota Bene: if things are working correctly, mCurrentMessageData->mMemberBlocks[blockname]->mBlockNumber == mCurrentDataBlock->mBlockNumber + 1
2443
2444 char *nbnamep = bnamep + count;
2445
2446 mCurrentSDataBlock = new LLMsgBlkData(bnamep, count);
2447 mCurrentSDataBlock->mName = nbnamep;
2448 mCurrentSMessageData->mMemberBlocks[nbnamep] = mCurrentSDataBlock;
2449
2450 // add placeholders for each of the variables
2451 for (LLMessageBlock::message_variable_map_t::iterator
2452 iter = template_data->mMemberVariables.begin(),
2453 end = template_data->mMemberVariables.end();
2454 iter != end; iter++)
2455 {
2456 LLMessageVariable& ci = *(iter->second);
2457 mCurrentSDataBlock->addVariable(ci.getName(), ci.getType());
2458 }
2459 return;
2460 }
2461}
2462
2463// add data to variable in current block
2464void LLMessageSystem::addDataFast(const char *varname, const void *data, EMsgVariableType type, S32 size)
2465{
2466 char *vnamep = (char *)varname;
2467
2468 // do we have a current message?
2469 if (!mCurrentSMessageTemplate)
2470 {
2471 llerrs << "newMessage not called prior to addData" << llendl;
2472 return;
2473 }
2474
2475 // do we have a current block?
2476 if (!mCurrentSDataBlock)
2477 {
2478 llerrs << "setBlock not called prior to addData" << llendl;
2479 return;
2480 }
2481
2482 // kewl, add the data if it exists
2483 LLMessageVariable* var_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName]->mMemberVariables[vnamep];
2484 if (!var_data || !var_data->getName())
2485 {
2486 llerrs << vnamep << " not a variable in block " << mCurrentSBlockName << " of " << mCurrentSMessageTemplate->mName << llendl;
2487 return;
2488 }
2489
2490 // ok, it seems ok. . . are we the correct size?
2491 if (var_data->getType() == MVT_VARIABLE)
2492 {
2493 // Variable 1 can only store 255 bytes, make sure our data is smaller
2494 if ((var_data->getSize() == 1) &&
2495 (size > 255))
2496 {
2497 llwarns << "Field " << varname << " is a Variable 1 but program "
2498 << "attempted to stuff more than 255 bytes in "
2499 << "(" << size << "). Clamping size and truncating data." << llendl;
2500 size = 255;
2501 char *truncate = (char *)data;
2502 truncate[255] = 0;
2503 }
2504
2505 // no correct size for MVT_VARIABLE, instead we need to tell how many bytes the size will be encoded as
2506 mCurrentSDataBlock->addData(vnamep, data, size, type, var_data->getSize());
2507 mCurrentSendTotal += size;
2508 }
2509 else
2510 {
2511 if (size != var_data->getSize())
2512 {
2513 llerrs << varname << " is type MVT_FIXED but request size " << size << " doesn't match template size "
2514 << var_data->getSize() << llendl;
2515 return;
2516 }
2517 // alright, smash it in
2518 mCurrentSDataBlock->addData(vnamep, data, size, type);
2519 mCurrentSendTotal += size;
2520 }
2521}
2522
2523// add data to variable in current block - fails if variable isn't MVT_FIXED
2524void LLMessageSystem::addDataFast(const char *varname, const void *data, EMsgVariableType type)
2525{
2526 char *vnamep = (char *)varname;
2527
2528 // do we have a current message?
2529 if (!mCurrentSMessageTemplate)
2530 {
2531 llerrs << "newMessage not called prior to addData" << llendl;
2532 return;
2533 }
2534
2535 // do we have a current block?
2536 if (!mCurrentSDataBlock)
2537 {
2538 llerrs << "setBlock not called prior to addData" << llendl;
2539 return;
2540 }
2541
2542 // kewl, add the data if it exists
2543 LLMessageVariable* var_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName]->mMemberVariables[vnamep];
2544 if (!var_data->getName())
2545 {
2546 llerrs << vnamep << " not a variable in block " << mCurrentSBlockName << " of " << mCurrentSMessageTemplate->mName << llendl;
2547 return;
2548 }
2549
2550 // ok, it seems ok. . . are we MVT_VARIABLE?
2551 if (var_data->getType() == MVT_VARIABLE)
2552 {
2553 // nope
2554 llerrs << vnamep << " is type MVT_VARIABLE. Call using addData(name, data, size)" << llendl;
2555 return;
2556 }
2557 else
2558 {
2559 mCurrentSDataBlock->addData(vnamep, data, var_data->getSize(), type);
2560 mCurrentSendTotal += var_data->getSize();
2561 }
2562} 1862}
2563 1863
2564BOOL LLMessageSystem::isSendFull(const char* blockname) 1864BOOL LLMessageSystem::isSendFull(const char* blockname)
2565{ 1865{
2566 if(!blockname) 1866 char* stringTableName = NULL;
1867 if(NULL != blockname)
2567 { 1868 {
2568 return (mCurrentSendTotal > MTUBYTES); 1869 stringTableName = gMessageStringTable.getString(blockname);
2569 } 1870 }
2570 return isSendFullFast(gMessageStringTable.getString(blockname)); 1871 return isSendFullFast(stringTableName);
2571} 1872}
2572 1873
2573BOOL LLMessageSystem::isSendFullFast(const char* blockname) 1874BOOL LLMessageSystem::isSendFullFast(const char* blockname)
2574{ 1875{
2575 if(mCurrentSendTotal > MTUBYTES) 1876 return mMessageBuilder->isMessageFull(blockname);
2576 {
2577 return TRUE;
2578 }
2579 if(!blockname)
2580 {
2581 return FALSE;
2582 }
2583 char* bnamep = (char*)blockname;
2584 S32 max;
2585
2586 LLMessageBlock* template_data = mCurrentSMessageTemplate->mMemberBlocks[bnamep];
2587
2588 switch(template_data->mType)
2589 {
2590 case MBT_SINGLE:
2591 max = 1;
2592 break;
2593 case MBT_MULTIPLE:
2594 max = template_data->mNumber;
2595 break;
2596 case MBT_VARIABLE:
2597 default:
2598 max = MAX_BLOCKS;
2599 break;
2600 }
2601 if(mCurrentSMessageData->mMemberBlocks[bnamep]->mBlockNumber >= max)
2602 {
2603 return TRUE;
2604 }
2605 return FALSE;
2606} 1877}
2607 1878
2608 1879
2609// blow away the last block of a message, return FALSE if that leaves no blocks or there wasn't a block to remove 1880// blow away the last block of a message, return FALSE if that leaves no blocks or there wasn't a block to remove
2610BOOL LLMessageSystem::removeLastBlock() 1881// TODO: Babbage: Remove this horror.
1882BOOL LLMessageSystem::removeLastBlock()
2611{ 1883{
2612 if (mCurrentSBlockName) 1884 return mMessageBuilder->removeLastBlock();
2613 {
2614 if ( (mCurrentSMessageData)
2615 &&(mCurrentSMessageTemplate))
2616 {
2617 if (mCurrentSMessageData->mMemberBlocks[mCurrentSBlockName]->mBlockNumber >= 1)
2618 {
2619 // At least one block for the current block name.
2620
2621 // Store the current block name for future reference.
2622 char *block_name = mCurrentSBlockName;
2623
2624 // Decrement the sent total by the size of the
2625 // data in the message block that we're currently building.
2626
2627 LLMessageBlock* template_data = mCurrentSMessageTemplate->mMemberBlocks[mCurrentSBlockName];
2628
2629 for (LLMessageBlock::message_variable_map_t::iterator iter = template_data->mMemberVariables.begin();
2630 iter != template_data->mMemberVariables.end(); iter++)
2631 {
2632 LLMessageVariable& ci = *(iter->second);
2633 mCurrentSendTotal -= ci.getSize();
2634 }
2635
2636
2637 // Now we want to find the block that we're blowing away.
2638
2639 // Get the number of blocks.
2640 LLMsgBlkData* block_data = mCurrentSMessageData->mMemberBlocks[block_name];
2641 S32 num_blocks = block_data->mBlockNumber;
2642
2643 // Use the same (suspect?) algorithm that's used to generate
2644 // the names in the nextBlock method to find it.
2645 char *block_getting_whacked = block_name + num_blocks - 1;
2646 LLMsgBlkData* whacked_data = mCurrentSMessageData->mMemberBlocks[block_getting_whacked];
2647 delete whacked_data;
2648 mCurrentSMessageData->mMemberBlocks.erase(block_getting_whacked);
2649
2650 if (num_blocks <= 1)
2651 {
2652 // we just blew away the last one, so return FALSE
2653 return FALSE;
2654 }
2655 else
2656 {
2657 // Decrement the counter.
2658 block_data->mBlockNumber--;
2659 return TRUE;
2660 }
2661 }
2662 }
2663 }
2664 return FALSE;
2665}
2666
2667// make sure that all the desired data is in place and then copy the data into mSendBuffer
2668void LLMessageSystem::buildMessage()
2669{
2670 // basic algorithm is to loop through the various pieces, building
2671 // size and offset info if we encounter a -1 for mSize at any
2672 // point that variable wasn't given data
2673
2674 // do we have a current message?
2675 if (!mCurrentSMessageTemplate)
2676 {
2677 llerrs << "newMessage not called prior to buildMessage" << llendl;
2678 return;
2679 }
2680
2681 // zero out some useful values
2682
2683 // leave room for circuit counter
2684 mSendSize = LL_PACKET_ID_SIZE;
2685
2686 // encode message number and adjust total_offset
2687 if (mCurrentSMessageTemplate->mFrequency == MFT_HIGH)
2688 {
2689// old, endian-dependant way
2690// memcpy(&mSendBuffer[mSendSize], &mCurrentMessageTemplate->mMessageNumber, sizeof(U8));
2691
2692// new, independant way
2693 mSendBuffer[mSendSize] = (U8)mCurrentSMessageTemplate->mMessageNumber;
2694 mSendSize += sizeof(U8);
2695 }
2696 else if (mCurrentSMessageTemplate->mFrequency == MFT_MEDIUM)
2697 {
2698 U8 temp = 255;
2699 memcpy(&mSendBuffer[mSendSize], &temp, sizeof(U8)); /*Flawfinder: ignore*/
2700 mSendSize += sizeof(U8);
2701
2702 // mask off unsightly bits
2703 temp = mCurrentSMessageTemplate->mMessageNumber & 255;
2704 memcpy(&mSendBuffer[mSendSize], &temp, sizeof(U8)); /*Flawfinder: ignore*/
2705 mSendSize += sizeof(U8);
2706 }
2707 else if (mCurrentSMessageTemplate->mFrequency == MFT_LOW)
2708 {
2709 U8 temp = 255;
2710 U16 message_num;
2711 memcpy(&mSendBuffer[mSendSize], &temp, sizeof(U8)); /*Flawfinder: ignore*/
2712 mSendSize += sizeof(U8);
2713 memcpy(&mSendBuffer[mSendSize], &temp, sizeof(U8)); /*Flawfinder: ignore*/
2714 mSendSize += sizeof(U8);
2715
2716 // mask off unsightly bits
2717 message_num = mCurrentSMessageTemplate->mMessageNumber & 0xFFFF;
2718
2719 // convert to network byte order
2720 message_num = htons(message_num);
2721 memcpy(&mSendBuffer[mSendSize], &message_num, sizeof(U16)); /*Flawfinder: ignore*/
2722 mSendSize += sizeof(U16);
2723 }
2724 else
2725 {
2726 llerrs << "unexpected message frequency in buildMessage" << llendl;
2727 return;
2728 }
2729
2730 // counting variables used to encode multiple block info
2731 S32 block_count = 0;
2732 U8 temp_block_number;
2733
2734 // loop through msg blocks to loop through variables, totalling up size data and copying into mSendBuffer
2735 for (LLMsgData::msg_blk_data_map_t::iterator
2736 iter = mCurrentSMessageData->mMemberBlocks.begin(),
2737 end = mCurrentSMessageData->mMemberBlocks.end();
2738 iter != end; iter++)
2739 {
2740 LLMsgBlkData* mbci = iter->second;
2741 // do we need to encode a block code?
2742 if (block_count == 0)
2743 {
2744 block_count = mbci->mBlockNumber;
2745
2746 LLMessageBlock* template_data = mCurrentSMessageTemplate->mMemberBlocks[mbci->mName];
2747
2748 // ok, if this is the first block of a repeating pack, set block_count and, if it's type MBT_VARIABLE encode a byte for how many there are
2749 if (template_data->mType == MBT_VARIABLE)
2750 {
2751 // remember that mBlockNumber is a S32
2752 temp_block_number = (U8)mbci->mBlockNumber;
2753 if ((S32)(mSendSize + sizeof(U8)) < MAX_BUFFER_SIZE)
2754 {
2755 memcpy(&mSendBuffer[mSendSize], &temp_block_number, sizeof(U8)); /* Flawfinder: ignore */
2756 mSendSize += sizeof(U8);
2757 }
2758 else
2759 {
2760 // Just reporting error is likely not enough. Need
2761 // to check how to abort or error out gracefully
2762 // from this function. XXXTBD
2763 llerrs << "buildMessage failed. Message excedding"
2764 " sendBuffersize." << llendl;
2765 }
2766 }
2767 else if (template_data->mType == MBT_MULTIPLE)
2768 {
2769 if (block_count != template_data->mNumber)
2770 {
2771 // nope! need to fill it in all the way!
2772 llerrs << "Block " << mbci->mName
2773 << " is type MBT_MULTIPLE but only has data for "
2774 << block_count << " out of its "
2775 << template_data->mNumber << " blocks" << llendl;
2776 }
2777 }
2778 }
2779
2780 // counting down multiple blocks
2781 block_count--;
2782
2783 // now loop through the variables
2784 for (LLMsgBlkData::msg_var_data_map_t::iterator iter = mbci->mMemberVarData.begin();
2785 iter != mbci->mMemberVarData.end(); iter++)
2786 {
2787 LLMsgVarData& mvci = *iter;
2788 if (mvci.getSize() == -1)
2789 {
2790 // oops, this variable wasn't ever set!
2791 llerrs << "The variable " << mvci.getName() << " in block "
2792 << mbci->mName << " of message "
2793 << mCurrentSMessageData->mName
2794 << " wasn't set prior to buildMessage call" << llendl;
2795 }
2796 else
2797 {
2798 S32 data_size = mvci.getDataSize();
2799 if(data_size > 0)
2800 {
2801 // The type is MVT_VARIABLE, which means that we
2802 // need to encode a size argument. Otherwise,
2803 // there is no need.
2804 S32 size = mvci.getSize();
2805 U8 sizeb;
2806 U16 sizeh;
2807 switch(data_size)
2808 {
2809 case 1:
2810 sizeb = size;
2811 htonmemcpy(&mSendBuffer[mSendSize], &sizeb, MVT_U8, 1);
2812 break;
2813 case 2:
2814 sizeh = size;
2815 htonmemcpy(&mSendBuffer[mSendSize], &sizeh, MVT_U16, 2);
2816 break;
2817 case 4:
2818 htonmemcpy(&mSendBuffer[mSendSize], &size, MVT_S32, 4);
2819 break;
2820 default:
2821 llerrs << "Attempting to build variable field with unknown size of " << size << llendl;
2822 break;
2823 }
2824 mSendSize += mvci.getDataSize();
2825 }
2826
2827 // if there is any data to pack, pack it
2828 if((mvci.getData() != NULL) && mvci.getSize())
2829 {
2830 if(mSendSize + mvci.getSize() < (S32)sizeof(mSendBuffer))
2831 {
2832 memcpy( /* Flawfinder: ignore */
2833 &mSendBuffer[mSendSize],
2834 mvci.getData(),
2835 mvci.getSize());
2836 mSendSize += mvci.getSize();
2837 }
2838 else
2839 {
2840 // Just reporting error is likely not
2841 // enough. Need to check how to abort or error
2842 // out gracefully from this function. XXXTBD
2843 llerrs << "LLMessageSystem::buildMessage failed. "
2844 << "Attempted to pack "
2845 << mSendSize + mvci.getSize()
2846 << " bytes into a buffer with size "
2847 << mSendBuffer << "." << llendl
2848 }
2849 }
2850 }
2851 }
2852 }
2853 mbSBuilt = TRUE;
2854} 1885}
2855 1886
2856S32 LLMessageSystem::sendReliable(const LLHost &host) 1887S32 LLMessageSystem::sendReliable(const LLHost &host)
@@ -2874,7 +1905,9 @@ S32 LLMessageSystem::sendSemiReliable(const LLHost &host, void (*callback)(void
2874 timeout = LL_SEMIRELIABLE_TIMEOUT_FACTOR * LL_AVERAGED_PING_MAX; 1905 timeout = LL_SEMIRELIABLE_TIMEOUT_FACTOR * LL_AVERAGED_PING_MAX;
2875 } 1906 }
2876 1907
2877 return sendReliable(host, 0, FALSE, timeout, callback, callback_data); 1908 const S32 retries = 0;
1909 const BOOL ping_based_timeout = FALSE;
1910 return sendReliable(host, retries, ping_based_timeout, timeout, callback, callback_data);
2878} 1911}
2879 1912
2880// send the message via a UDP packet 1913// send the message via a UDP packet
@@ -2900,7 +1933,8 @@ S32 LLMessageSystem::sendReliable( const LLHost &host,
2900 1933
2901 mSendReliable = TRUE; 1934 mSendReliable = TRUE;
2902 mReliablePacketParams.set(host, retries, ping_based_timeout, timeout, 1935 mReliablePacketParams.set(host, retries, ping_based_timeout, timeout,
2903 callback, callback_data, mCurrentSMessageName); 1936 callback, callback_data,
1937 const_cast<char*>(mMessageBuilder->getMessageName()));
2904 return sendMessage(host); 1938 return sendMessage(host);
2905} 1939}
2906 1940
@@ -2938,11 +1972,13 @@ S32 LLMessageSystem::flushSemiReliable(const LLHost &host, void (*callback)(void
2938 } 1972 }
2939 1973
2940 S32 send_bytes = 0; 1974 S32 send_bytes = 0;
2941 if (mCurrentSendTotal) 1975 if (mMessageBuilder->getMessageSize())
2942 { 1976 {
2943 mSendReliable = TRUE; 1977 mSendReliable = TRUE;
2944 // No need for ping-based retry as not going to retry 1978 // No need for ping-based retry as not going to retry
2945 mReliablePacketParams.set(host, 0, FALSE, timeout, callback, callback_data, mCurrentSMessageName); 1979 mReliablePacketParams.set(host, 0, FALSE, timeout, callback,
1980 callback_data,
1981 const_cast<char*>(mMessageBuilder->getMessageName()));
2946 send_bytes = sendMessage(host); 1982 send_bytes = sendMessage(host);
2947 clearMessage(); 1983 clearMessage();
2948 } 1984 }
@@ -2956,7 +1992,7 @@ S32 LLMessageSystem::flushSemiReliable(const LLHost &host, void (*callback)(void
2956S32 LLMessageSystem::flushReliable(const LLHost &host) 1992S32 LLMessageSystem::flushReliable(const LLHost &host)
2957{ 1993{
2958 S32 send_bytes = 0; 1994 S32 send_bytes = 0;
2959 if (mCurrentSendTotal) 1995 if (mMessageBuilder->getMessageSize())
2960 { 1996 {
2961 send_bytes = sendReliable(host); 1997 send_bytes = sendReliable(host);
2962 } 1998 }
@@ -2969,13 +2005,12 @@ S32 LLMessageSystem::flushReliable(const LLHost &host)
2969// so should should not use llinfos. 2005// so should should not use llinfos.
2970S32 LLMessageSystem::sendMessage(const LLHost &host) 2006S32 LLMessageSystem::sendMessage(const LLHost &host)
2971{ 2007{
2972 if (!mbSBuilt) 2008 if (! mMessageBuilder->isBuilt())
2973 { 2009 {
2974 buildMessage(); 2010 mSendSize = mMessageBuilder->buildMessage(mSendBuffer,
2011 MAX_BUFFER_SIZE);
2975 } 2012 }
2976 2013
2977 mCurrentSendTotal = 0;
2978
2979 if (!(host.isOk())) // if port and ip are zero, don't bother trying to send the message 2014 if (!(host.isOk())) // if port and ip are zero, don't bother trying to send the message
2980 { 2015 {
2981 return 0; 2016 return 0;
@@ -2992,10 +2027,10 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
2992 if(mVerboseLog) 2027 if(mVerboseLog)
2993 { 2028 {
2994 llinfos << "MSG: -> " << host << "\tUNKNOWN CIRCUIT:\t" 2029 llinfos << "MSG: -> " << host << "\tUNKNOWN CIRCUIT:\t"
2995 << mCurrentSMessageName << llendl; 2030 << mMessageBuilder->getMessageName() << llendl;
2996 } 2031 }
2997 llwarns << "sendMessage - Trying to send " 2032 llwarns << "sendMessage - Trying to send "
2998 << mCurrentSMessageName << " on unknown circuit " 2033 << mMessageBuilder->getMessageName() << " on unknown circuit "
2999 << host << llendl; 2034 << host << llendl;
3000 return 0; 2035 return 0;
3001 } 2036 }
@@ -3014,15 +2049,41 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
3014 if(mVerboseLog) 2049 if(mVerboseLog)
3015 { 2050 {
3016 llinfos << "MSG: -> " << host << "\tDEAD CIRCUIT\t\t" 2051 llinfos << "MSG: -> " << host << "\tDEAD CIRCUIT\t\t"
3017 << mCurrentSMessageName << llendl; 2052 << mMessageBuilder->getMessageName() << llendl;
3018 } 2053 }
3019 llwarns << "sendMessage - Trying to send message " 2054 llwarns << "sendMessage - Trying to send message "
3020 << mCurrentSMessageName << " to dead circuit " 2055 << mMessageBuilder->getMessageName() << " to dead circuit "
3021 << host << llendl; 2056 << host << llendl;
3022 return 0; 2057 return 0;
3023 } 2058 }
3024 } 2059 }
3025 2060
2061 // NOTE: babbage: LLSD message -> HTTP, template message -> UDP
2062 if(mMessageBuilder == mLLSDMessageBuilder)
2063 {
2064 LLSD message = mLLSDMessageBuilder->getMessage();
2065
2066 const LLHTTPSender& sender = LLHTTPSender::getSender(host);
2067 LLHTTPClient::ResponderPtr responder = NULL;
2068 if(mSendReliable)
2069 {
2070 responder =
2071 new LLFnPtrResponder(mReliablePacketParams.mCallback,
2072 mReliablePacketParams.mCallbackData);
2073 }
2074 else
2075 {
2076 llwarns << "LLMessageSystem::sendMessage: Sending unreliable " << mMessageBuilder->getMessageName() << " message via HTTP" << llendl;
2077 responder = new LLFnPtrResponder(NULL, NULL);
2078 }
2079 sender.send(host, mLLSDMessageBuilder->getMessageName(),
2080 message, responder);
2081
2082 mSendReliable = FALSE;
2083 mReliablePacketParams.clear();
2084 return 1;
2085 }
2086
3026 memset(mSendBuffer,0,LL_PACKET_ID_SIZE); // zero out the packet ID field 2087 memset(mSendBuffer,0,LL_PACKET_ID_SIZE); // zero out the packet ID field
3027 2088
3028 // add the send id to the front of the message 2089 // add the send id to the front of the message
@@ -3033,20 +2094,17 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
3033 2094
3034 // Compress the message, which will usually reduce its size. 2095 // Compress the message, which will usually reduce its size.
3035 U8 * buf_ptr = (U8 *)mSendBuffer; 2096 U8 * buf_ptr = (U8 *)mSendBuffer;
3036 S32 buffer_length = mSendSize; 2097 U32 buffer_length = mSendSize;
3037 if(ME_ZEROCODED == mCurrentSMessageTemplate->getEncoding()) 2098 mMessageBuilder->compressMessage(buf_ptr, buffer_length);
3038 {
3039 zeroCode(&buf_ptr, &buffer_length);
3040 }
3041 2099
3042 if (buffer_length > 1500) 2100 if (buffer_length > 1500)
3043 { 2101 {
3044 if((mCurrentSMessageName != _PREHASH_ChildAgentUpdate) 2102 if((mMessageBuilder->getMessageName() != _PREHASH_ChildAgentUpdate)
3045 && (mCurrentSMessageName != _PREHASH_SendXferPacket)) 2103 && (mMessageBuilder->getMessageName() != _PREHASH_SendXferPacket))
3046 { 2104 {
3047 llwarns << "sendMessage - Trying to send " 2105 llwarns << "sendMessage - Trying to send "
3048 << ((buffer_length > 4000) ? "EXTRA " : "") 2106 << ((buffer_length > 4000) ? "EXTRA " : "")
3049 << "BIG message " << mCurrentSMessageName << " - " 2107 << "BIG message " << mMessageBuilder->getMessageName() << " - "
3050 << buffer_length << llendl; 2108 << buffer_length << llendl;
3051 } 2109 }
3052 } 2110 }
@@ -3071,7 +2129,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
3071 BOOL is_ack_appended = FALSE; 2129 BOOL is_ack_appended = FALSE;
3072 std::vector<TPACKETID> acks; 2130 std::vector<TPACKETID> acks;
3073 if((space_left > 0) && (ack_count > 0) && 2131 if((space_left > 0) && (ack_count > 0) &&
3074 (mCurrentSMessageName != _PREHASH_PacketAck)) 2132 (mMessageBuilder->getMessageName() != _PREHASH_PacketAck))
3075 { 2133 {
3076 buf_ptr[0] |= LL_ACK_FLAG; 2134 buf_ptr[0] |= LL_ACK_FLAG;
3077 S32 append_ack_count = llmin(space_left, ack_count); 2135 S32 append_ack_count = llmin(space_left, ack_count);
@@ -3142,7 +2200,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
3142 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 2200 char buffer[MAX_STRING]; /* Flawfinder: ignore */
3143 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID()); /* Flawfinder: ignore */ 2201 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mSendSize, buffer_length, cdp->getPacketOutID()); /* Flawfinder: ignore */
3144 str << buffer 2202 str << buffer
3145 << mCurrentSMessageTemplate->mName 2203 << mMessageBuilder->getMessageName()
3146 << (mSendReliable ? " reliable " : ""); 2204 << (mSendReliable ? " reliable " : "");
3147 if(is_ack_appended) 2205 if(is_ack_appended)
3148 { 2206 {
@@ -3153,89 +2211,19 @@ S32 LLMessageSystem::sendMessage(const LLHost &host)
3153 llinfos << str.str() << llendl; 2211 llinfos << str.str() << llendl;
3154 } 2212 }
3155 2213
3156 lldebugst(LLERR_MESSAGE) << "MessageSent at: " << (S32)totalTime() 2214 /*lldebugst(LLERR_MESSAGE) << "MessageSent at: " << (S32)totalTime()
3157 << ", " << mCurrentSMessageTemplate->mName 2215 << "," << mMessageBuilder->getMessageName()
3158 << " to " << host 2216 << " to " << host
3159 << llendl; 2217 << llendl;*/
3160
3161 // ok, clean up temp data
3162 delete mCurrentSMessageData;
3163 mCurrentSMessageData = NULL;
3164 2218
3165 mPacketsOut++; 2219 mPacketsOut++;
3166 mBytesOut += buffer_length; 2220 mBytesOut += buffer_length;
3167 2221
2222 mSendReliable = FALSE;
2223 mReliablePacketParams.clear();
3168 return buffer_length; 2224 return buffer_length;
3169} 2225}
3170 2226
3171
3172// Returns template for the message contained in buffer
3173BOOL LLMessageSystem::decodeTemplate(
3174 const U8* buffer, S32 buffer_size, // inputs
3175 LLMessageTemplate** msg_template ) // outputs
3176{
3177 const U8* header = buffer + LL_PACKET_ID_SIZE;
3178
3179 // is there a message ready to go?
3180 if (buffer_size <= 0)
3181 {
3182 llwarns << "No message waiting for decode!" << llendl;
3183 return(FALSE);
3184 }
3185
3186 U32 num = 0;
3187
3188 if (header[0] != 255)
3189 {
3190 // high frequency message
3191 num = header[0];
3192 }
3193 else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 1)) && (header[1] != 255))
3194 {
3195 // medium frequency message
3196 num = (255 << 8) | header[1];
3197 }
3198 else if ((buffer_size >= ((S32) LL_MINIMUM_VALID_PACKET_SIZE + 3)) && (header[1] == 255))
3199 {
3200 // low frequency message
3201 U16 message_id_U16 = 0;
3202 // I think this check busts the message system.
3203 // it appears that if there is a NULL in the message #, it won't copy it....
3204 // what was the goal?
3205 //if(header[2])
3206 memcpy(&message_id_U16, &header[2], 2); /* Flawfinder: ignore */
3207
3208 // dependant on endian-ness:
3209 // U32 temp = (255 << 24) | (255 << 16) | header[2];
3210
3211 // independant of endian-ness:
3212 message_id_U16 = ntohs(message_id_U16);
3213 num = 0xFFFF0000 | message_id_U16;
3214 }
3215 else // bogus packet received (too short)
3216 {
3217 llwarns << "Packet with unusable length received (too short): "
3218 << buffer_size << llendl;
3219 return(FALSE);
3220 }
3221
3222 LLMessageTemplate* temp = get_ptr_in_map(mMessageNumbers,num);
3223 if (temp)
3224 {
3225 *msg_template = temp;
3226 }
3227 else
3228 {
3229 llwarns << "Message #" << std::hex << num << std::dec
3230 << " received but not registered!" << llendl;
3231 callExceptionFunc(MX_UNREGISTERED_MESSAGE);
3232 return(FALSE);
3233 }
3234
3235 return(TRUE);
3236}
3237
3238
3239void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_reliable ) 2227void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_reliable )
3240{ 2228{
3241 if(mVerboseLog) 2229 if(mVerboseLog)
@@ -3243,9 +2231,9 @@ void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_re
3243 std::ostringstream str; 2231 std::ostringstream str;
3244 str << "MSG: <- " << host; 2232 str << "MSG: <- " << host;
3245 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 2233 char buffer[MAX_STRING]; /* Flawfinder: ignore */
3246 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mReceiveSize, (mIncomingCompressedSize ? mIncomingCompressedSize: mReceiveSize), mCurrentRecvPacketID); /* Flawfinder: ignore */ 2234 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize: mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */
3247 str << buffer 2235 str << buffer
3248 << mCurrentRMessageTemplate->mName 2236 << mMessageReader->getMessageName()
3249 << (recv_reliable ? " reliable" : "") 2237 << (recv_reliable ? " reliable" : "")
3250 << " REJECTED"; 2238 << " REJECTED";
3251 llinfos << str.str() << llendl; 2239 llinfos << str.str() << llendl;
@@ -3260,8 +2248,9 @@ void LLMessageSystem::logMsgFromInvalidCircuit( const LLHost& host, BOOL recv_re
3260 } 2248 }
3261 else 2249 else
3262 { 2250 {
3263 mMessageCountList[mNumMessageCounts].mMessageNum = mCurrentRMessageTemplate->mMessageNumber; 2251 // TODO: babbage: work out if we need these
3264 mMessageCountList[mNumMessageCounts].mMessageBytes = mReceiveSize; 2252 // mMessageCountList[mNumMessageCounts].mMessageNum = mCurrentRMessageTemplate->mMessageNumber;
2253 mMessageCountList[mNumMessageCounts].mMessageBytes = mMessageReader->getMessageSize();
3265 mMessageCountList[mNumMessageCounts].mInvalid = TRUE; 2254 mMessageCountList[mNumMessageCounts].mInvalid = TRUE;
3266 mNumMessageCounts++; 2255 mNumMessageCounts++;
3267 } 2256 }
@@ -3271,11 +2260,11 @@ void LLMessageSystem::logTrustedMsgFromUntrustedCircuit( const LLHost& host )
3271{ 2260{
3272 // RequestTrustedCircuit is how we establish trust, so don't spam 2261 // RequestTrustedCircuit is how we establish trust, so don't spam
3273 // if it's received on a trusted circuit. JC 2262 // if it's received on a trusted circuit. JC
3274 if (strcmp(mCurrentRMessageTemplate->mName, "RequestTrustedCircuit")) 2263 if (strcmp(mMessageReader->getMessageName(), "RequestTrustedCircuit"))
3275 { 2264 {
3276 llwarns << "Received trusted message on untrusted circuit. " 2265 llwarns << "Received trusted message on untrusted circuit. "
3277 << "Will reply with deny. " 2266 << "Will reply with deny. "
3278 << "Message: " << mCurrentRMessageTemplate->mName 2267 << "Message: " << mMessageReader->getMessageName()
3279 << " Host: " << host << llendl; 2268 << " Host: " << host << llendl;
3280 } 2269 }
3281 2270
@@ -3287,10 +2276,11 @@ void LLMessageSystem::logTrustedMsgFromUntrustedCircuit( const LLHost& host )
3287 } 2276 }
3288 else 2277 else
3289 { 2278 {
3290 mMessageCountList[mNumMessageCounts].mMessageNum 2279 // TODO: babbage: work out if we need these
3291 = mCurrentRMessageTemplate->mMessageNumber; 2280 //mMessageCountList[mNumMessageCounts].mMessageNum
2281 // = mCurrentRMessageTemplate->mMessageNumber;
3292 mMessageCountList[mNumMessageCounts].mMessageBytes 2282 mMessageCountList[mNumMessageCounts].mMessageBytes
3293 = mReceiveSize; 2283 = mMessageReader->getMessageSize();
3294 mMessageCountList[mNumMessageCounts].mInvalid = TRUE; 2284 mMessageCountList[mNumMessageCounts].mInvalid = TRUE;
3295 mNumMessageCounts++; 2285 mNumMessageCounts++;
3296 } 2286 }
@@ -3304,8 +2294,9 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r
3304 } 2294 }
3305 else 2295 else
3306 { 2296 {
3307 mMessageCountList[mNumMessageCounts].mMessageNum = mCurrentRMessageTemplate->mMessageNumber; 2297 // TODO: babbage: work out if we need these
3308 mMessageCountList[mNumMessageCounts].mMessageBytes = mReceiveSize; 2298 //mMessageCountList[mNumMessageCounts].mMessageNum = mCurrentRMessageTemplate->mMessageNumber;
2299 mMessageCountList[mNumMessageCounts].mMessageBytes = mMessageReader->getMessageSize();
3309 mMessageCountList[mNumMessageCounts].mInvalid = FALSE; 2300 mMessageCountList[mNumMessageCounts].mInvalid = FALSE;
3310 mNumMessageCounts++; 2301 mNumMessageCounts++;
3311 } 2302 }
@@ -3322,9 +2313,9 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r
3322 std::ostringstream str; 2313 std::ostringstream str;
3323 str << "MSG: <- " << host; 2314 str << "MSG: <- " << host;
3324 char buffer[MAX_STRING]; /* Flawfinder: ignore */ 2315 char buffer[MAX_STRING]; /* Flawfinder: ignore */
3325 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mReceiveSize, (mIncomingCompressedSize ? mIncomingCompressedSize : mReceiveSize), mCurrentRecvPacketID); /* Flawfinder: ignore */ 2316 snprintf(buffer, MAX_STRING, "\t%6d\t%6d\t%6d ", mMessageReader->getMessageSize(), (mIncomingCompressedSize ? mIncomingCompressedSize : mMessageReader->getMessageSize()), mCurrentRecvPacketID); /* Flawfinder: ignore */
3326 str << buffer 2317 str << buffer
3327 << mCurrentRMessageTemplate->mName 2318 << mMessageReader->getMessageName()
3328 << (recv_reliable ? " reliable" : "") 2319 << (recv_reliable ? " reliable" : "")
3329 << (recv_resent ? " resent" : "") 2320 << (recv_resent ? " resent" : "")
3330 << (recv_acks ? " acks" : ""); 2321 << (recv_acks ? " acks" : "");
@@ -3332,435 +2323,19 @@ void LLMessageSystem::logValidMsg(LLCircuitData *cdp, const LLHost& host, BOOL r
3332 } 2323 }
3333} 2324}
3334 2325
3335
3336void LLMessageSystem::logRanOffEndOfPacket( const LLHost& host )
3337{
3338 // we've run off the end of the packet!
3339 llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName
3340 << " with id " << mCurrentRecvPacketID << " from " << host
3341 << llendl;
3342 if(mVerboseLog)
3343 {
3344 llinfos << "MSG: -> " << host << "\tREAD PAST END:\t"
3345 << mCurrentRecvPacketID << " "
3346 << mCurrentSMessageTemplate->mName << llendl;
3347 }
3348 callExceptionFunc(MX_RAN_OFF_END_OF_PACKET);
3349}
3350
3351
3352// decode a given message
3353BOOL LLMessageSystem::decodeData(const U8* buffer, const LLHost& sender )
3354{
3355 llassert( mReceiveSize >= 0 );
3356 llassert( mCurrentRMessageTemplate);
3357 llassert( !mCurrentRMessageData );
3358 delete mCurrentRMessageData; // just to make sure
3359
3360 S32 decode_pos = LL_PACKET_ID_SIZE + (S32)(mCurrentRMessageTemplate->mFrequency);
3361
3362 // create base working data set
3363 mCurrentRMessageData = new LLMsgData(mCurrentRMessageTemplate->mName);
3364
3365 // loop through the template building the data structure as we go
3366 for (LLMessageTemplate::message_block_map_t::iterator iter = mCurrentRMessageTemplate->mMemberBlocks.begin();
3367 iter != mCurrentRMessageTemplate->mMemberBlocks.end(); iter++)
3368 {
3369 LLMessageBlock* mbci = iter->second;
3370 U8 repeat_number;
3371 S32 i;
3372
3373 // how many of this block?
3374
3375 if (mbci->mType == MBT_SINGLE)
3376 {
3377 // just one
3378 repeat_number = 1;
3379 }
3380 else if (mbci->mType == MBT_MULTIPLE)
3381 {
3382 // a known number
3383 repeat_number = mbci->mNumber;
3384 }
3385 else if (mbci->mType == MBT_VARIABLE)
3386 {
3387 // need to read the number from the message
3388 // repeat number is a single byte
3389 if (decode_pos >= mReceiveSize)
3390 {
3391 logRanOffEndOfPacket( sender );
3392 return FALSE;
3393 }
3394 repeat_number = buffer[decode_pos];
3395 decode_pos++;
3396 }
3397 else
3398 {
3399 llerrs << "Unknown block type" << llendl;
3400 return FALSE;
3401 }
3402
3403 LLMsgBlkData* cur_data_block = NULL;
3404
3405 // now loop through the block
3406 for (i = 0; i < repeat_number; i++)
3407 {
3408 if (i)
3409 {
3410 // build new name to prevent collisions
3411 // TODO: This should really change to a vector
3412 cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
3413 cur_data_block->mName = mbci->mName + i;
3414 }
3415 else
3416 {
3417 cur_data_block = new LLMsgBlkData(mbci->mName, repeat_number);
3418 }
3419
3420 // add the block to the message
3421 mCurrentRMessageData->addBlock(cur_data_block);
3422
3423 // now read the variables
3424 for (LLMessageBlock::message_variable_map_t::iterator iter = mbci->mMemberVariables.begin();
3425 iter != mbci->mMemberVariables.end(); iter++)
3426 {
3427 LLMessageVariable& mvci = *(iter->second);
3428 // ok, build out the variables
3429 // add variable block
3430 cur_data_block->addVariable(mvci.getName(), mvci.getType());
3431
3432 // what type of variable?
3433 if (mvci.getType() == MVT_VARIABLE)
3434 {
3435 // variable, get the number of bytes to read from the template
3436 S32 data_size = mvci.getSize();
3437 U8 tsizeb = 0;
3438 U16 tsizeh = 0;
3439 U32 tsize = 0;
3440
3441 if ((decode_pos + data_size) > mReceiveSize)
3442 {
3443 logRanOffEndOfPacket( sender );
3444 return FALSE;
3445 }
3446 switch(data_size)
3447 {
3448 case 1:
3449 htonmemcpy(&tsizeb, &buffer[decode_pos], MVT_U8, 1);
3450 tsize = tsizeb;
3451 break;
3452 case 2:
3453 htonmemcpy(&tsizeh, &buffer[decode_pos], MVT_U16, 2);
3454 tsize = tsizeh;
3455 break;
3456 case 4:
3457 htonmemcpy(&tsizeb, &buffer[decode_pos], MVT_U32, 4);
3458 break;
3459 default:
3460 llerrs << "Attempting to read variable field with unknown size of " << data_size << llendl;
3461 break;
3462
3463 }
3464 decode_pos += data_size;
3465
3466 if ((decode_pos + (S32)tsize) > mReceiveSize)
3467 {
3468 logRanOffEndOfPacket( sender );
3469 return FALSE;
3470 }
3471 cur_data_block->addData(mvci.getName(), &buffer[decode_pos], tsize, mvci.getType());
3472 decode_pos += tsize;
3473 }
3474 else
3475 {
3476 // fixed!
3477 // so, copy data pointer and set data size to fixed size
3478
3479 if ((decode_pos + mvci.getSize()) > mReceiveSize)
3480 {
3481 logRanOffEndOfPacket( sender );
3482 return FALSE;
3483 }
3484
3485 cur_data_block->addData(mvci.getName(), &buffer[decode_pos], mvci.getSize(), mvci.getType());
3486 decode_pos += mvci.getSize();
3487 }
3488 }
3489 }
3490 }
3491
3492 if (mCurrentRMessageData->mMemberBlocks.empty()
3493 && !mCurrentRMessageTemplate->mMemberBlocks.empty())
3494 {
3495 lldebugs << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << llendl;
3496 return FALSE;
3497 }
3498
3499 {
3500 static LLTimer decode_timer;
3501
3502 if( mTimeDecodes )
3503 {
3504 decode_timer.reset();
3505 }
3506
3507 // if( mCurrentRMessageTemplate->mName == _PREHASH_AgentToNewRegion )
3508 // {
3509 // VTResume(); // VTune
3510 // }
3511
3512 {
3513 LLFastTimer t(LLFastTimer::FTM_PROCESS_MESSAGES);
3514 if( !mCurrentRMessageTemplate->callHandlerFunc(this) )
3515 {
3516 llwarns << "Message from " << sender << " with no handler function received: " << mCurrentRMessageTemplate->mName << llendl;
3517 }
3518 }
3519
3520 // if( mCurrentRMessageTemplate->mName == _PREHASH_AgentToNewRegion )
3521 // {
3522 // VTPause(); // VTune
3523 // }
3524
3525 if( mTimeDecodes )
3526 {
3527 F32 decode_time = decode_timer.getElapsedTimeF32();
3528 mCurrentRMessageTemplate->mDecodeTimeThisFrame += decode_time;
3529
3530 mCurrentRMessageTemplate->mTotalDecoded++;
3531 mCurrentRMessageTemplate->mTotalDecodeTime += decode_time;
3532
3533 if( mCurrentRMessageTemplate->mMaxDecodeTimePerMsg < decode_time )
3534 {
3535 mCurrentRMessageTemplate->mMaxDecodeTimePerMsg = decode_time;
3536 }
3537
3538
3539 if( decode_time > mTimeDecodesSpamThreshold )
3540 {
3541 lldebugs << "--------- Message " << mCurrentRMessageTemplate->mName << " decode took " << decode_time << " seconds. (" <<
3542 mCurrentRMessageTemplate->mMaxDecodeTimePerMsg << " max, " <<
3543 (mCurrentRMessageTemplate->mTotalDecodeTime / mCurrentRMessageTemplate->mTotalDecoded) << " avg)" << llendl;
3544 }
3545 }
3546 }
3547 return TRUE;
3548}
3549
3550void LLMessageSystem::getDataFast(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum, S32 max_size)
3551{
3552 // is there a message ready to go?
3553 if (mReceiveSize == -1)
3554 {
3555 llerrs << "No message waiting for decode 2!" << llendl;
3556 return;
3557 }
3558
3559 if (!mCurrentRMessageData)
3560 {
3561 llerrs << "Invalid mCurrentMessageData in getData!" << llendl;
3562 return;
3563 }
3564
3565 char *bnamep = (char *)blockname + blocknum; // this works because it's just a hash. The bnamep is never derefference
3566 char *vnamep = (char *)varname;
3567
3568 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
3569
3570 if (iter == mCurrentRMessageData->mMemberBlocks.end())
3571 {
3572 llerrs << "Block " << blockname << " #" << blocknum
3573 << " not in message " << mCurrentRMessageData->mName << llendl;
3574 return;
3575 }
3576
3577 LLMsgBlkData *msg_block_data = iter->second;
3578 LLMsgVarData& vardata = msg_block_data->mMemberVarData[vnamep];
3579
3580 if (!vardata.getName())
3581 {
3582 llerrs << "Variable "<< vnamep << " not in message "
3583 << mCurrentRMessageData->mName<< " block " << bnamep << llendl;
3584 return;
3585 }
3586
3587 if (size && size != vardata.getSize())
3588 {
3589 llerrs << "Msg " << mCurrentRMessageData->mName
3590 << " variable " << vnamep
3591 << " is size " << vardata.getSize()
3592 << " but copying into buffer of size " << size
3593 << llendl;
3594 return;
3595 }
3596
3597
3598 const S32 vardata_size = vardata.getSize();
3599 if( max_size >= vardata_size )
3600 {
3601 switch( vardata_size )
3602 {
3603 case 1:
3604 *((U8*)datap) = *((U8*)vardata.getData());
3605 break;
3606 case 2:
3607 *((U16*)datap) = *((U16*)vardata.getData());
3608 break;
3609 case 4:
3610 *((U32*)datap) = *((U32*)vardata.getData());
3611 break;
3612 case 8:
3613 ((U32*)datap)[0] = ((U32*)vardata.getData())[0];
3614 ((U32*)datap)[1] = ((U32*)vardata.getData())[1];
3615 break;
3616 default:
3617 memcpy(datap, vardata.getData(), vardata_size); /* Flawfinder: ignore */
3618 break;
3619 }
3620 }
3621 else
3622 {
3623 llwarns << "Msg " << mCurrentRMessageData->mName
3624 << " variable " << vnamep
3625 << " is size " << vardata.getSize()
3626 << " but truncated to max size of " << max_size
3627 << llendl;
3628
3629 memcpy(datap, vardata.getData(), max_size); /* Flawfinder: ignore */
3630 }
3631}
3632
3633S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname)
3634{
3635 // is there a message ready to go?
3636 if (mReceiveSize == -1)
3637 {
3638 llerrs << "No message waiting for decode 3!" << llendl;
3639 return -1;
3640 }
3641
3642 if (!mCurrentRMessageData)
3643 {
3644 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
3645 return -1;
3646 }
3647
3648 char *bnamep = (char *)blockname;
3649
3650 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
3651
3652 if (iter == mCurrentRMessageData->mMemberBlocks.end())
3653 {
3654// sprintf(errmsg, "Block %s not in message %s", bnamep, mCurrentRMessageData->mName);
3655// llerrs << errmsg << llendl;
3656// return -1;
3657 return 0;
3658 }
3659
3660 return (iter->second)->mBlockNumber;
3661}
3662
3663S32 LLMessageSystem::getSizeFast(const char *blockname, const char *varname)
3664{
3665 // is there a message ready to go?
3666 if (mReceiveSize == -1)
3667 {
3668 llerrs << "No message waiting for decode 4!" << llendl;
3669 return -1;
3670 }
3671
3672 if (!mCurrentRMessageData)
3673 {
3674 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
3675 return -1;
3676 }
3677
3678 char *bnamep = (char *)blockname;
3679
3680 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
3681
3682 if (iter == mCurrentRMessageData->mMemberBlocks.end())
3683 {
3684 llerrs << "Block " << bnamep << " not in message "
3685 << mCurrentRMessageData->mName << llendl;
3686 return -1;
3687 }
3688
3689 char *vnamep = (char *)varname;
3690
3691 LLMsgBlkData* msg_data = iter->second;
3692 LLMsgVarData& vardata = msg_data->mMemberVarData[vnamep];
3693
3694 if (!vardata.getName())
3695 {
3696 llerrs << "Variable " << varname << " not in message "
3697 << mCurrentRMessageData->mName << " block " << bnamep << llendl;
3698 return -1;
3699 }
3700
3701 if (mCurrentRMessageTemplate->mMemberBlocks[bnamep]->mType != MBT_SINGLE)
3702 {
3703 llerrs << "Block " << bnamep << " isn't type MBT_SINGLE,"
3704 " use getSize with blocknum argument!" << llendl;
3705 return -1;
3706 }
3707
3708 return vardata.getSize();
3709}
3710
3711
3712S32 LLMessageSystem::getSizeFast(const char *blockname, S32 blocknum, const char *varname)
3713{
3714 // is there a message ready to go?
3715 if (mReceiveSize == -1)
3716 {
3717 llerrs << "No message waiting for decode 5!" << llendl;
3718 return -1;
3719 }
3720
3721 if (!mCurrentRMessageData)
3722 {
3723 llerrs << "Invalid mCurrentRMessageData in getData!" << llendl;
3724 return -1;
3725 }
3726
3727 char *bnamep = (char *)blockname + blocknum;
3728 char *vnamep = (char *)varname;
3729
3730 LLMsgData::msg_blk_data_map_t::iterator iter = mCurrentRMessageData->mMemberBlocks.find(bnamep);
3731
3732 if (iter == mCurrentRMessageData->mMemberBlocks.end())
3733 {
3734 llerrs << "Block " << bnamep << " not in message "
3735 << mCurrentRMessageData->mName << llendl;
3736 return -1;
3737 }
3738
3739 LLMsgBlkData* msg_data = iter->second;
3740 LLMsgVarData& vardata = msg_data->mMemberVarData[vnamep];
3741
3742 if (!vardata.getName())
3743 {
3744 llerrs << "Variable " << vnamep << " not in message "
3745 << mCurrentRMessageData->mName << " block " << bnamep << llendl;
3746 return -1;
3747 }
3748
3749 return vardata.getSize();
3750}
3751
3752
3753void LLMessageSystem::sanityCheck() 2326void LLMessageSystem::sanityCheck()
3754{ 2327{
3755 if (!mCurrentRMessageData) 2328// TODO: babbage: reinstate
3756 {
3757 llerrs << "mCurrentRMessageData is NULL" << llendl;
3758 }
3759 2329
3760 if (!mCurrentRMessageTemplate) 2330// if (!mCurrentRMessageData)
3761 { 2331// {
3762 llerrs << "mCurrentRMessageTemplate is NULL" << llendl; 2332// llerrs << "mCurrentRMessageData is NULL" << llendl;
3763 } 2333// }
2334
2335// if (!mCurrentRMessageTemplate)
2336// {
2337// llerrs << "mCurrentRMessageTemplate is NULL" << llendl;
2338// }
3764 2339
3765// if (!mCurrentRTemplateBlock) 2340// if (!mCurrentRTemplateBlock)
3766// { 2341// {
@@ -3772,25 +2347,25 @@ void LLMessageSystem::sanityCheck()
3772// llerrs << "mCurrentRDataBlock is NULL" << llendl; 2347// llerrs << "mCurrentRDataBlock is NULL" << llendl;
3773// } 2348// }
3774 2349
3775 if (!mCurrentSMessageData) 2350// if (!mCurrentSMessageData)
3776 { 2351// {
3777 llerrs << "mCurrentSMessageData is NULL" << llendl; 2352// llerrs << "mCurrentSMessageData is NULL" << llendl;
3778 } 2353// }
3779 2354
3780 if (!mCurrentSMessageTemplate) 2355// if (!mCurrentSMessageTemplate)
3781 { 2356// {
3782 llerrs << "mCurrentSMessageTemplate is NULL" << llendl; 2357// llerrs << "mCurrentSMessageTemplate is NULL" << llendl;
3783 } 2358// }
3784 2359
3785// if (!mCurrentSTemplateBlock) 2360// if (!mCurrentSTemplateBlock)
3786// { 2361// {
3787// llerrs << "mCurrentSTemplateBlock is NULL" << llendl; 2362// llerrs << "mCurrentSTemplateBlock is NULL" << llendl;
3788// } 2363// }
3789 2364
3790 if (!mCurrentSDataBlock) 2365// if (!mCurrentSDataBlock)
3791 { 2366// {
3792 llerrs << "mCurrentSDataBlock is NULL" << llendl; 2367// llerrs << "mCurrentSDataBlock is NULL" << llendl;
3793 } 2368// }
3794} 2369}
3795 2370
3796void LLMessageSystem::showCircuitInfo() 2371void LLMessageSystem::showCircuitInfo()
@@ -4176,7 +2751,8 @@ bool LLMessageSystem::addCircuitCode(U32 code, const LLUUID& session_id)
4176//} 2751//}
4177 2752
4178// static 2753// static
4179void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg, void**) 2754void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg,
2755 void** user)
4180{ 2756{
4181 U32 circuit_code_in; 2757 U32 circuit_code_in;
4182 msg->getU32Fast(_PREHASH_CircuitCode, _PREHASH_Code, circuit_code_in); 2758 msg->getU32Fast(_PREHASH_CircuitCode, _PREHASH_Code, circuit_code_in);
@@ -4296,6 +2872,13 @@ void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg, void**)
4296 llinfos << "Circuit code " << circuit_code_in << " from " 2872 llinfos << "Circuit code " << circuit_code_in << " from "
4297 << msg->getSender() << " for agent " << id << " in session " 2873 << msg->getSender() << " for agent " << id << " in session "
4298 << session_id << llendl; 2874 << session_id << llendl;
2875
2876 const LLUseCircuitCodeResponder* responder =
2877 (const LLUseCircuitCodeResponder*) user;
2878 if(responder)
2879 {
2880 responder->complete(msg->getSender(), id);
2881 }
4299 } 2882 }
4300 else 2883 else
4301 { 2884 {
@@ -4303,7 +2886,50 @@ void LLMessageSystem::processUseCircuitCode(LLMessageSystem* msg, void**)
4303 } 2886 }
4304} 2887}
4305 2888
2889static LLHTTPNode& messageRootNode()
2890{
2891 static LLHTTPNode root_node;
2892 static bool initialized = false;
2893 if (!initialized) {
2894 initialized = true;
2895 LLHTTPRegistrar::buildAllServices(root_node);
2896 }
2897
2898 return root_node;
2899}
4306 2900
2901//static
2902void LLMessageSystem::dispatch(const std::string& msg_name,
2903 const LLSD& message)
2904{
2905 LLPointer<LLSimpleResponse> responsep = LLSimpleResponse::create();
2906 dispatch(msg_name, message, responsep);
2907}
2908
2909//static
2910void LLMessageSystem::dispatch(const std::string& msg_name,
2911 const LLSD& message,
2912 LLHTTPNode::ResponsePtr responsep)
2913{
2914 if (msg_name.empty())
2915 {
2916 llwarns << "LLMessageService::dispatch called with no message name"
2917 << llendl;
2918 return;
2919 }
2920
2921 std::string path = "/message/" + msg_name;
2922 LLSD context;
2923 const LLHTTPNode* handler = messageRootNode().traverse(path, context);
2924 if (!handler)
2925 {
2926 llwarns << "LLMessageService::dispatch > no handler for "
2927 << path << llendl;
2928 return;
2929 }
2930
2931 handler->post(responsep, context, message);
2932}
4307 2933
4308static void check_for_unrecognized_messages( 2934static void check_for_unrecognized_messages(
4309 const char* type, 2935 const char* type,
@@ -4535,76 +3161,6 @@ void process_deny_trusted_circuit(LLMessageSystem *msg, void **)
4535 msg->sendCreateTrustedCircuit(msg->getSender(), local_id, remote_id); 3161 msg->sendCreateTrustedCircuit(msg->getSender(), local_id, remote_id);
4536} 3162}
4537 3163
4538#define LL_ENCRYPT_BUF_LENGTH 16384
4539
4540void encrypt_template(const char *src_name, const char *dest_name)
4541{
4542 // encrypt and decrypt are symmetric
4543 decrypt_template(src_name, dest_name);
4544}
4545
4546BOOL decrypt_template(const char *src_name, const char *dest_name)
4547{
4548 S32 buf_length = LL_ENCRYPT_BUF_LENGTH;
4549 char buf[LL_ENCRYPT_BUF_LENGTH]; /* Flawfinder: ignore */
4550
4551 FILE* infp = NULL;
4552 FILE* outfp = NULL;
4553 BOOL success = FALSE;
4554 char* bufp = NULL;
4555 U32 key = 0;
4556 S32 more_data = 0;
4557
4558 if(src_name==NULL)
4559 {
4560 llwarns << "Input src_name is NULL!!" << llendl;
4561 goto exit;
4562 }
4563
4564 infp = LLFile::fopen(src_name,"rb"); /* Flawfinder: ignore */
4565 if (!infp)
4566 {
4567 llwarns << "could not open " << src_name << " for reading" << llendl;
4568 goto exit;
4569 }
4570
4571 if(dest_name==NULL)
4572 {
4573 llwarns << "Output dest_name is NULL!!" << llendl;
4574 goto exit;
4575 }
4576
4577 outfp = LLFile::fopen(dest_name,"w+b"); /* Flawfinder: ignore */
4578 if (!outfp)
4579 {
4580 llwarns << "could not open " << src_name << " for writing" << llendl;
4581 goto exit;
4582 }
4583
4584 while ((buf_length = (S32)fread(buf,1,LL_ENCRYPT_BUF_LENGTH,infp)))
4585 {
4586 // unscrozzle bits here
4587 bufp = buf;
4588 more_data = buf_length;
4589 while (more_data--)
4590 {
4591 *bufp = *bufp ^ ((key * 43) % 256);
4592 key++;
4593 bufp++;
4594 }
4595
4596 if(buf_length != (S32)fwrite(buf,1,buf_length,outfp))
4597 {
4598 goto exit;
4599 }
4600 }
4601 success = TRUE;
4602
4603 exit:
4604 if(infp) fclose(infp);
4605 if(outfp) fclose(outfp);
4606 return success;
4607}
4608 3164
4609void dump_prehash_files() 3165void dump_prehash_files()
4610{ 3166{
@@ -4688,7 +3244,8 @@ BOOL start_messaging_system(
4688 S32 version_minor, 3244 S32 version_minor,
4689 S32 version_patch, 3245 S32 version_patch,
4690 BOOL b_dump_prehash_file, 3246 BOOL b_dump_prehash_file,
4691 const std::string& secret) 3247 const std::string& secret,
3248 const LLUseCircuitCodeResponder* responder)
4692{ 3249{
4693 gMessageSystem = new LLMessageSystem( 3250 gMessageSystem = new LLMessageSystem(
4694 template_name.c_str(), 3251 template_name.c_str(),
@@ -4737,7 +3294,7 @@ BOOL start_messaging_system(
4737 //gMessageSystem->setHandlerFuncFast(_PREHASH_AssignCircuitCode, LLMessageSystem::processAssignCircuitCode); 3294 //gMessageSystem->setHandlerFuncFast(_PREHASH_AssignCircuitCode, LLMessageSystem::processAssignCircuitCode);
4738 gMessageSystem->setHandlerFuncFast(_PREHASH_AddCircuitCode, LLMessageSystem::processAddCircuitCode); 3295 gMessageSystem->setHandlerFuncFast(_PREHASH_AddCircuitCode, LLMessageSystem::processAddCircuitCode);
4739 //gMessageSystem->setHandlerFuncFast(_PREHASH_AckAddCircuitCode, ack_add_circuit_code, NULL); 3296 //gMessageSystem->setHandlerFuncFast(_PREHASH_AckAddCircuitCode, ack_add_circuit_code, NULL);
4740 gMessageSystem->setHandlerFuncFast(_PREHASH_UseCircuitCode, LLMessageSystem::processUseCircuitCode); 3297 gMessageSystem->setHandlerFuncFast(_PREHASH_UseCircuitCode, LLMessageSystem::processUseCircuitCode, (void**)responder);
4741 gMessageSystem->setHandlerFuncFast(_PREHASH_PacketAck, process_packet_ack, NULL); 3298 gMessageSystem->setHandlerFuncFast(_PREHASH_PacketAck, process_packet_ack, NULL);
4742 gMessageSystem->setHandlerFuncFast(_PREHASH_TemplateChecksumRequest, process_template_checksum_request, NULL); 3299 gMessageSystem->setHandlerFuncFast(_PREHASH_TemplateChecksumRequest, process_template_checksum_request, NULL);
4743 gMessageSystem->setHandlerFuncFast(_PREHASH_SecuredTemplateChecksumRequest, process_secured_template_checksum_request, NULL); 3300 gMessageSystem->setHandlerFuncFast(_PREHASH_SecuredTemplateChecksumRequest, process_secured_template_checksum_request, NULL);
@@ -4790,75 +3347,75 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
4790 char tmp_str[MAX_STRING]; /* Flawfinder: ignore */ 3347 char tmp_str[MAX_STRING]; /* Flawfinder: ignore */
4791 F32 run_time = mMessageSystemTimer.getElapsedTimeF32(); 3348 F32 run_time = mMessageSystemTimer.getElapsedTimeF32();
4792 str << "START MESSAGE LOG SUMMARY" << std::endl; 3349 str << "START MESSAGE LOG SUMMARY" << std::endl;
4793 snprintf(buffer, MAX_STRING, "Run time: %12.3f seconds", run_time); /* Flawfinder: ignore */ 3350 snprintf(buffer, MAX_STRING, "Run time: %12.3f seconds", run_time); /* Flawfinder: ignore */
4794 3351
4795 // Incoming 3352 // Incoming
4796 str << buffer << std::endl << "Incoming:" << std::endl; 3353 str << buffer << std::endl << "Incoming:" << std::endl;
4797 U64_to_str(mTotalBytesIn, tmp_str, sizeof(tmp_str)); 3354 U64_to_str(mTotalBytesIn, tmp_str, sizeof(tmp_str));
4798 snprintf(buffer, MAX_STRING, "Total bytes received: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesIn * 0.008f) / run_time); /* Flawfinder: ignore */ 3355 snprintf(buffer, MAX_STRING, "Total bytes received: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesIn * 0.008f) / run_time); /* Flawfinder: ignore */
4799 str << buffer << std::endl; 3356 str << buffer << std::endl;
4800 U64_to_str(mPacketsIn, tmp_str, sizeof(tmp_str)); 3357 U64_to_str(mPacketsIn, tmp_str, sizeof(tmp_str));
4801 snprintf(buffer, MAX_STRING, "Total packets received: %20s (%5.2f packets per second)", tmp_str, ((F32) mPacketsIn / run_time)); /* Flawfinder: ignore */ 3358 snprintf(buffer, MAX_STRING, "Total packets received: %20s (%5.2f packets per second)", tmp_str, ((F32) mPacketsIn / run_time)); /* Flawfinder: ignore */
4802 str << buffer << std::endl; 3359 str << buffer << std::endl;
4803 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn); /* Flawfinder: ignore */ 3360 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesIn / (F32)mPacketsIn); /* Flawfinder: ignore */
4804 str << buffer << std::endl; 3361 str << buffer << std::endl;
4805 U64_to_str(mReliablePacketsIn, tmp_str, sizeof(tmp_str)); 3362 U64_to_str(mReliablePacketsIn, tmp_str, sizeof(tmp_str));
4806 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ 3363 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */
4807 str << buffer << std::endl; 3364 str << buffer << std::endl;
4808 U64_to_str(mCompressedPacketsIn, tmp_str, sizeof(tmp_str)); 3365 U64_to_str(mCompressedPacketsIn, tmp_str, sizeof(tmp_str));
4809 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */ 3366 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsIn)/((F32) mPacketsIn + 1)); /* Flawfinder: ignore */
4810 str << buffer << std::endl; 3367 str << buffer << std::endl;
4811 S64 savings = mUncompressedBytesIn - mCompressedBytesIn; 3368 S64 savings = mUncompressedBytesIn - mCompressedBytesIn;
4812 U64_to_str(savings, tmp_str, sizeof(tmp_str)); 3369 U64_to_str(savings, tmp_str, sizeof(tmp_str));
4813 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ 3370 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */
4814 str << buffer << std::endl; 3371 str << buffer << std::endl;
4815 U64_to_str(savings/(mCompressedPacketsIn +1), tmp_str, sizeof(tmp_str)); 3372 U64_to_str(savings/(mCompressedPacketsIn +1), tmp_str, sizeof(tmp_str));
4816 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1)); /* Flawfinder: ignore */ 3373 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesIn)/((F32) mCompressedBytesIn+1)); /* Flawfinder: ignore */
4817 str << buffer << std::endl; 3374 str << buffer << std::endl;
4818 U64_to_str(savings/(mPacketsIn+1), tmp_str, sizeof(tmp_str)); 3375 U64_to_str(savings/(mPacketsIn+1), tmp_str, sizeof(tmp_str));
4819 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f)); /* Flawfinder: ignore */ 3376 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesIn + (F32) savings)/((F32) mTotalBytesIn + 1.f)); /* Flawfinder: ignore */
4820 3377
4821 // Outgoing 3378 // Outgoing
4822 str << buffer << std::endl << std::endl << "Outgoing:" << std::endl; 3379 str << buffer << std::endl << std::endl << "Outgoing:" << std::endl;
4823 U64_to_str(mTotalBytesOut, tmp_str, sizeof(tmp_str)); 3380 U64_to_str(mTotalBytesOut, tmp_str, sizeof(tmp_str));
4824 snprintf(buffer, MAX_STRING, "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesOut * 0.008f) / run_time ); /* Flawfinder: ignore */ 3381 snprintf(buffer, MAX_STRING, "Total bytes sent: %20s (%5.2f kbits per second)", tmp_str, ((F32)mTotalBytesOut * 0.008f) / run_time ); /* Flawfinder: ignore */
4825 str << buffer << std::endl; 3382 str << buffer << std::endl;
4826 U64_to_str(mPacketsOut, tmp_str, sizeof(tmp_str)); 3383 U64_to_str(mPacketsOut, tmp_str, sizeof(tmp_str));
4827 snprintf(buffer, MAX_STRING, "Total packets sent: %20s (%5.2f packets per second)", tmp_str, ((F32)mPacketsOut / run_time)); /* Flawfinder: ignore */ 3384 snprintf(buffer, MAX_STRING, "Total packets sent: %20s (%5.2f packets per second)", tmp_str, ((F32)mPacketsOut / run_time)); /* Flawfinder: ignore */
4828 str << buffer << std::endl; 3385 str << buffer << std::endl;
4829 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut); /* Flawfinder: ignore */ 3386 snprintf(buffer, MAX_STRING, "Average packet size: %20.0f bytes", (F32)mTotalBytesOut / (F32)mPacketsOut); /* Flawfinder: ignore */
4830 str << buffer << std::endl; 3387 str << buffer << std::endl;
4831 U64_to_str(mReliablePacketsOut, tmp_str, sizeof(tmp_str)); 3388 U64_to_str(mReliablePacketsOut, tmp_str, sizeof(tmp_str));
4832 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ 3389 snprintf(buffer, MAX_STRING, "Total reliable packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mReliablePacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */
4833 str << buffer << std::endl; 3390 str << buffer << std::endl;
4834 U64_to_str(mCompressedPacketsOut, tmp_str, sizeof(tmp_str)); 3391 U64_to_str(mCompressedPacketsOut, tmp_str, sizeof(tmp_str));
4835 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */ 3392 snprintf(buffer, MAX_STRING, "Total compressed packets: %20s (%5.2f%%)", tmp_str, 100.f * ((F32) mCompressedPacketsOut)/((F32) mPacketsOut + 1)); /* Flawfinder: ignore */
4836 str << buffer << std::endl; 3393 str << buffer << std::endl;
4837 savings = mUncompressedBytesOut - mCompressedBytesOut; 3394 savings = mUncompressedBytesOut - mCompressedBytesOut;
4838 U64_to_str(savings, tmp_str, sizeof(tmp_str)); 3395 U64_to_str(savings, tmp_str, sizeof(tmp_str));
4839 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */ 3396 snprintf(buffer, MAX_STRING, "Total compression savings: %20s bytes", tmp_str); /* Flawfinder: ignore */
4840 str << buffer << std::endl; 3397 str << buffer << std::endl;
4841 U64_to_str(savings/(mCompressedPacketsOut +1), tmp_str, sizeof(tmp_str)); 3398 U64_to_str(savings/(mCompressedPacketsOut +1), tmp_str, sizeof(tmp_str));
4842 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1)); /* Flawfinder: ignore */ 3399 snprintf(buffer, MAX_STRING, "Avg comp packet savings: %20s (%5.2f : 1)", tmp_str, ((F32) mUncompressedBytesOut)/((F32) mCompressedBytesOut+1)); /* Flawfinder: ignore */
4843 str << buffer << std::endl; 3400 str << buffer << std::endl;
4844 U64_to_str(savings/(mPacketsOut+1), tmp_str, sizeof(tmp_str)); 3401 U64_to_str(savings/(mPacketsOut+1), tmp_str, sizeof(tmp_str));
4845 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f)); /* Flawfinder: ignore */ 3402 snprintf(buffer, MAX_STRING, "Avg overall comp savings: %20s (%5.2f : 1)", tmp_str, ((F32) mTotalBytesOut + (F32) savings)/((F32) mTotalBytesOut + 1.f)); /* Flawfinder: ignore */
4846 str << buffer << std::endl << std::endl; 3403 str << buffer << std::endl << std::endl;
4847 snprintf(buffer, MAX_STRING, "SendPacket failures: %20d", mSendPacketFailureCount); /* Flawfinder: ignore */ 3404 snprintf(buffer, MAX_STRING, "SendPacket failures: %20d", mSendPacketFailureCount); /* Flawfinder: ignore */
4848 str << buffer << std::endl; 3405 str << buffer << std::endl;
4849 snprintf(buffer, MAX_STRING, "Dropped packets: %20d", mDroppedPackets); /* Flawfinder: ignore */ 3406 snprintf(buffer, MAX_STRING, "Dropped packets: %20d", mDroppedPackets); /* Flawfinder: ignore */
4850 str << buffer << std::endl; 3407 str << buffer << std::endl;
4851 snprintf(buffer, MAX_STRING, "Resent packets: %20d", mResentPackets); /* Flawfinder: ignore */ 3408 snprintf(buffer, MAX_STRING, "Resent packets: %20d", mResentPackets); /* Flawfinder: ignore */
4852 str << buffer << std::endl; 3409 str << buffer << std::endl;
4853 snprintf(buffer, MAX_STRING, "Failed reliable resends: %20d", mFailedResendPackets); /* Flawfinder: ignore */ 3410 snprintf(buffer, MAX_STRING, "Failed reliable resends: %20d", mFailedResendPackets); /* Flawfinder: ignore */
4854 str << buffer << std::endl; 3411 str << buffer << std::endl;
4855 snprintf(buffer, MAX_STRING, "Off-circuit rejected packets: %17d", mOffCircuitPackets); /* Flawfinder: ignore */ 3412 snprintf(buffer, MAX_STRING, "Off-circuit rejected packets: %17d", mOffCircuitPackets); /* Flawfinder: ignore */
4856 str << buffer << std::endl; 3413 str << buffer << std::endl;
4857 snprintf(buffer, MAX_STRING, "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets); /* Flawfinder: ignore */ 3414 snprintf(buffer, MAX_STRING, "On-circuit invalid packets: %17d", mInvalidOnCircuitPackets); /* Flawfinder: ignore */
4858 str << buffer << std::endl << std::endl; 3415 str << buffer << std::endl << std::endl;
4859 3416
4860 str << "Decoding: " << std::endl; 3417 str << "Decoding: " << std::endl;
4861 snprintf(buffer, MAX_STRING, "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg"); /* Flawfinder: ignore */ 3418 snprintf(buffer, MAX_STRING, "%35s%10s%10s%10s%10s", "Message", "Count", "Time", "Max", "Avg"); /* Flawfinder: ignore */
4862 str << buffer << std:: endl; 3419 str << buffer << std:: endl;
4863 F32 avg; 3420 F32 avg;
4864 for (message_template_name_map_t::iterator iter = mMessageTemplates.begin(), 3421 for (message_template_name_map_t::iterator iter = mMessageTemplates.begin(),
@@ -4869,7 +3426,7 @@ void LLMessageSystem::summarizeLogs(std::ostream& str)
4869 if(mt->mTotalDecoded > 0) 3426 if(mt->mTotalDecoded > 0)
4870 { 3427 {
4871 avg = mt->mTotalDecodeTime / (F32)mt->mTotalDecoded; 3428 avg = mt->mTotalDecodeTime / (F32)mt->mTotalDecoded;
4872 snprintf(buffer, MAX_STRING, "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg); /* Flawfinder: ignore */ 3429 snprintf(buffer, MAX_STRING, "%35s%10u%10f%10f%10f", mt->mName, mt->mTotalDecoded, mt->mTotalDecodeTime, mt->mMaxDecodeTimePerMsg, avg); /* Flawfinder: ignore */
4873 str << buffer << std::endl; 3430 str << buffer << std::endl;
4874 } 3431 }
4875 } 3432 }
@@ -4957,13 +3514,13 @@ void LLMessageSystem::dumpReceiveCounts()
4957 3514
4958BOOL LLMessageSystem::isClear() const 3515BOOL LLMessageSystem::isClear() const
4959{ 3516{
4960 return mbSClear; 3517 return mMessageBuilder->isClear();
4961} 3518}
4962 3519
4963 3520
4964S32 LLMessageSystem::flush(const LLHost &host) 3521S32 LLMessageSystem::flush(const LLHost &host)
4965{ 3522{
4966 if (mCurrentSendTotal) 3523 if (mMessageBuilder->getMessageSize())
4967 { 3524 {
4968 S32 sentbytes = sendMessage(host); 3525 S32 sentbytes = sendMessage(host);
4969 clearMessage(); 3526 clearMessage();
@@ -4980,91 +3537,22 @@ U32 LLMessageSystem::getListenPort( void ) const
4980 return mPort; 3537 return mPort;
4981} 3538}
4982 3539
4983 3540// TODO: babbage: remove this horror!
4984S32 LLMessageSystem::zeroCode(U8 **data, S32 *data_size) 3541S32 LLMessageSystem::zeroCodeAdjustCurrentSendTotal()
4985{ 3542{
4986 S32 count = *data_size; 3543 if(mMessageBuilder == mLLSDMessageBuilder)
4987
4988 S32 net_gain = 0;
4989 U8 num_zeroes = 0;
4990
4991 U8 *inptr = (U8 *)*data;
4992 U8 *outptr = (U8 *)mEncodedSendBuffer;
4993
4994// skip the packet id field
4995
4996 for (U32 i=0;i<LL_PACKET_ID_SIZE;i++)
4997 {
4998 count--;
4999 *outptr++ = *inptr++;
5000 }
5001
5002// build encoded packet, keeping track of net size gain
5003
5004// sequential zero bytes are encoded as 0 [U8 count]
5005// with 0 0 [count] representing wrap (>256 zeroes)
5006
5007 while (count--)
5008 { 3544 {
5009 if (!(*inptr)) // in a zero count 3545 // babbage: don't compress LLSD messages, so delta is 0
5010 { 3546 return 0;
5011 if (num_zeroes)
5012 {
5013 if (++num_zeroes > 254)
5014 {
5015 *outptr++ = num_zeroes;
5016 num_zeroes = 0;
5017 }
5018 net_gain--; // subseqent zeroes save one
5019 }
5020 else
5021 {
5022 *outptr++ = 0;
5023 net_gain++; // starting a zero count adds one
5024 num_zeroes = 1;
5025 }
5026 inptr++;
5027 }
5028 else
5029 {
5030 if (num_zeroes)
5031 {
5032 *outptr++ = num_zeroes;
5033 num_zeroes = 0;
5034 }
5035 *outptr++ = *inptr++;
5036 }
5037 }
5038
5039 if (num_zeroes)
5040 {
5041 *outptr++ = num_zeroes;
5042 }
5043
5044 if (net_gain < 0)
5045 {
5046 mCompressedPacketsOut++;
5047 mUncompressedBytesOut += *data_size;
5048
5049 *data = mEncodedSendBuffer;
5050 *data_size += net_gain;
5051 mEncodedSendBuffer[0] |= LL_ZERO_CODE_FLAG; // set the head bit to indicate zero coding
5052
5053 mCompressedBytesOut += *data_size;
5054
5055 } 3547 }
5056 mTotalBytesOut += *data_size; 3548
5057 3549 if (! mMessageBuilder->isBuilt())
5058 return(net_gain);
5059}
5060
5061S32 LLMessageSystem::zeroCodeAdjustCurrentSendTotal()
5062{
5063 if (!mbSBuilt)
5064 { 3550 {
5065 buildMessage(); 3551 mSendSize = mMessageBuilder->buildMessage(mSendBuffer,
3552 MAX_BUFFER_SIZE);
5066 } 3553 }
5067 mbSBuilt = FALSE; 3554 // TODO: babbage: remove this horror
3555 mMessageBuilder->setBuilt(FALSE);
5068 3556
5069 S32 count = mSendSize; 3557 S32 count = mSendSize;
5070 3558
@@ -5244,7 +3732,6 @@ void LLMessageSystem::setHandlerFuncFast(const char *name, void (*handler_func)(
5244 } 3732 }
5245} 3733}
5246 3734
5247
5248bool LLMessageSystem::callHandler(const char *name, 3735bool LLMessageSystem::callHandler(const char *name,
5249 bool trustedSource, LLMessageSystem* msg) 3736 bool trustedSource, LLMessageSystem* msg)
5250{ 3737{
@@ -5297,6 +3784,12 @@ BOOL LLMessageSystem::callExceptionFunc(EMessageException exception)
5297 return FALSE; 3784 return FALSE;
5298} 3785}
5299 3786
3787void LLMessageSystem::setTimingFunc(msg_timing_callback func, void* data)
3788{
3789 mTimingCallback = func;
3790 mTimingCallbackData = data;
3791}
3792
5300BOOL LLMessageSystem::isCircuitCodeKnown(U32 code) const 3793BOOL LLMessageSystem::isCircuitCodeKnown(U32 code) const
5301{ 3794{
5302 if(mCircuitCodes.find(code) == mCircuitCodes.end()) 3795 if(mCircuitCodes.find(code) == mCircuitCodes.end())
@@ -5306,27 +3799,14 @@ BOOL LLMessageSystem::isCircuitCodeKnown(U32 code) const
5306 3799
5307BOOL LLMessageSystem::isMessageFast(const char *msg) 3800BOOL LLMessageSystem::isMessageFast(const char *msg)
5308{ 3801{
5309 if (mCurrentRMessageTemplate) 3802 return(msg == mMessageReader->getMessageName());
5310 {
5311 return(msg == mCurrentRMessageTemplate->mName);
5312 }
5313 else
5314 {
5315 return FALSE;
5316 }
5317} 3803}
5318 3804
5319 3805
5320char* LLMessageSystem::getMessageName() 3806char* LLMessageSystem::getMessageName()
5321{ 3807{
5322 if (mCurrentRMessageTemplate) 3808 const char* name = mMessageReader->getMessageName();
5323 { 3809 return name[0] == '\0'? NULL : const_cast<char*>(name);
5324 return mCurrentRMessageTemplate->mName;
5325 }
5326 else
5327 {
5328 return NULL;
5329 }
5330} 3810}
5331 3811
5332const LLUUID& LLMessageSystem::getSenderID() const 3812const LLUUID& LLMessageSystem::getSenderID() const
@@ -5350,211 +3830,6 @@ const LLUUID& LLMessageSystem::getSenderSessionID() const
5350 return LLUUID::null; 3830 return LLUUID::null;
5351} 3831}
5352 3832
5353void LLMessageSystem::addVector3Fast(const char *varname, const LLVector3& vec)
5354{
5355 addDataFast(varname, vec.mV, MVT_LLVector3, sizeof(vec.mV));
5356}
5357
5358void LLMessageSystem::addVector3(const char *varname, const LLVector3& vec)
5359{
5360 addDataFast(gMessageStringTable.getString(varname), vec.mV, MVT_LLVector3, sizeof(vec.mV));
5361}
5362
5363void LLMessageSystem::addVector4Fast(const char *varname, const LLVector4& vec)
5364{
5365 addDataFast(varname, vec.mV, MVT_LLVector4, sizeof(vec.mV));
5366}
5367
5368void LLMessageSystem::addVector4(const char *varname, const LLVector4& vec)
5369{
5370 addDataFast(gMessageStringTable.getString(varname), vec.mV, MVT_LLVector4, sizeof(vec.mV));
5371}
5372
5373
5374void LLMessageSystem::addVector3dFast(const char *varname, const LLVector3d& vec)
5375{
5376 addDataFast(varname, vec.mdV, MVT_LLVector3d, sizeof(vec.mdV));
5377}
5378
5379void LLMessageSystem::addVector3d(const char *varname, const LLVector3d& vec)
5380{
5381 addDataFast(gMessageStringTable.getString(varname), vec.mdV, MVT_LLVector3d, sizeof(vec.mdV));
5382}
5383
5384
5385void LLMessageSystem::addQuatFast(const char *varname, const LLQuaternion& quat)
5386{
5387 addDataFast(varname, quat.packToVector3().mV, MVT_LLQuaternion, sizeof(LLVector3));
5388}
5389
5390void LLMessageSystem::addQuat(const char *varname, const LLQuaternion& quat)
5391{
5392 addDataFast(gMessageStringTable.getString(varname), quat.packToVector3().mV, MVT_LLQuaternion, sizeof(LLVector3));
5393}
5394
5395
5396void LLMessageSystem::addUUIDFast(const char *varname, const LLUUID& uuid)
5397{
5398 addDataFast(varname, uuid.mData, MVT_LLUUID, sizeof(uuid.mData));
5399}
5400
5401void LLMessageSystem::addUUID(const char *varname, const LLUUID& uuid)
5402{
5403 addDataFast(gMessageStringTable.getString(varname), uuid.mData, MVT_LLUUID, sizeof(uuid.mData));
5404}
5405
5406void LLMessageSystem::getF32Fast(const char *block, const char *var, F32 &d, S32 blocknum)
5407{
5408 getDataFast(block, var, &d, sizeof(F32), blocknum);
5409
5410 if( !llfinite( d ) )
5411 {
5412 llwarns << "non-finite in getF32Fast " << block << " " << var << llendl;
5413 d = 0;
5414 }
5415}
5416
5417void LLMessageSystem::getF32(const char *block, const char *var, F32 &d, S32 blocknum)
5418{
5419 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(F32), blocknum);
5420
5421 if( !llfinite( d ) )
5422 {
5423 llwarns << "non-finite in getF32 " << block << " " << var << llendl;
5424 d = 0;
5425 }
5426}
5427
5428void LLMessageSystem::getF64Fast(const char *block, const char *var, F64 &d, S32 blocknum)
5429{
5430 getDataFast(block, var, &d, sizeof(F64), blocknum);
5431
5432 if( !llfinite( d ) )
5433 {
5434 llwarns << "non-finite in getF64Fast " << block << " " << var << llendl;
5435 d = 0;
5436 }
5437}
5438
5439void LLMessageSystem::getF64(const char *block, const char *var, F64 &d, S32 blocknum)
5440{
5441 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(F64), blocknum);
5442
5443 if( !llfinite( d ) )
5444 {
5445 llwarns << "non-finite in getF64 " << block << " " << var << llendl;
5446 d = 0;
5447 }
5448}
5449
5450
5451void LLMessageSystem::getVector3Fast(const char *block, const char *var, LLVector3 &v, S32 blocknum )
5452{
5453 getDataFast(block, var, v.mV, sizeof(v.mV), blocknum);
5454
5455 if( !v.isFinite() )
5456 {
5457 llwarns << "non-finite in getVector3Fast " << block << " " << var << llendl;
5458 v.zeroVec();
5459 }
5460}
5461
5462void LLMessageSystem::getVector3(const char *block, const char *var, LLVector3 &v, S32 blocknum )
5463{
5464 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), v.mV, sizeof(v.mV), blocknum);
5465
5466 if( !v.isFinite() )
5467 {
5468 llwarns << "non-finite in getVector4 " << block << " " << var << llendl;
5469 v.zeroVec();
5470 }
5471}
5472
5473void LLMessageSystem::getVector4Fast(const char *block, const char *var, LLVector4 &v, S32 blocknum )
5474{
5475 getDataFast(block, var, v.mV, sizeof(v.mV), blocknum);
5476
5477 if( !v.isFinite() )
5478 {
5479 llwarns << "non-finite in getVector4Fast " << block << " " << var << llendl;
5480 v.zeroVec();
5481 }
5482}
5483
5484void LLMessageSystem::getVector4(const char *block, const char *var, LLVector4 &v, S32 blocknum )
5485{
5486 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), v.mV, sizeof(v.mV), blocknum);
5487
5488 if( !v.isFinite() )
5489 {
5490 llwarns << "non-finite in getVector3 " << block << " " << var << llendl;
5491 v.zeroVec();
5492 }
5493}
5494
5495void LLMessageSystem::getVector3dFast(const char *block, const char *var, LLVector3d &v, S32 blocknum )
5496{
5497 getDataFast(block, var, v.mdV, sizeof(v.mdV), blocknum);
5498
5499 if( !v.isFinite() )
5500 {
5501 llwarns << "non-finite in getVector3dFast " << block << " " << var << llendl;
5502 v.zeroVec();
5503 }
5504
5505}
5506
5507void LLMessageSystem::getVector3d(const char *block, const char *var, LLVector3d &v, S32 blocknum )
5508{
5509 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), v.mdV, sizeof(v.mdV), blocknum);
5510
5511 if( !v.isFinite() )
5512 {
5513 llwarns << "non-finite in getVector3d " << block << " " << var << llendl;
5514 v.zeroVec();
5515 }
5516}
5517
5518void LLMessageSystem::getQuatFast(const char *block, const char *var, LLQuaternion &q, S32 blocknum )
5519{
5520 LLVector3 vec;
5521 getDataFast(block, var, vec.mV, sizeof(vec.mV), blocknum);
5522 if( vec.isFinite() )
5523 {
5524 q.unpackFromVector3( vec );
5525 }
5526 else
5527 {
5528 llwarns << "non-finite in getQuatFast " << block << " " << var << llendl;
5529 q.loadIdentity();
5530 }
5531}
5532
5533void LLMessageSystem::getQuat(const char *block, const char *var, LLQuaternion &q, S32 blocknum )
5534{
5535 LLVector3 vec;
5536 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), vec.mV, sizeof(vec.mV), blocknum);
5537 if( vec.isFinite() )
5538 {
5539 q.unpackFromVector3( vec );
5540 }
5541 else
5542 {
5543 llwarns << "non-finite in getQuat " << block << " " << var << llendl;
5544 q.loadIdentity();
5545 }
5546}
5547
5548void LLMessageSystem::getUUIDFast(const char *block, const char *var, LLUUID &u, S32 blocknum )
5549{
5550 getDataFast(block, var, u.mData, sizeof(u.mData), blocknum);
5551}
5552
5553void LLMessageSystem::getUUID(const char *block, const char *var, LLUUID &u, S32 blocknum )
5554{
5555 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), u.mData, sizeof(u.mData), blocknum);
5556}
5557
5558bool LLMessageSystem::generateDigestForNumberAndUUIDs( 3833bool LLMessageSystem::generateDigestForNumberAndUUIDs(
5559 char* digest, 3834 char* digest,
5560 const U32 number, 3835 const U32 number,
@@ -5584,7 +3859,7 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(
5584 3859
5585 d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ 3860 d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */
5586 3861
5587 snprintf(tbuf, sizeof(tbuf),"%i", number); /* Flawfinder: ignore */ 3862 snprintf(tbuf, sizeof(tbuf),"%i", number); /* Flawfinder: ignore */
5588 d.update((unsigned char *) tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */ 3863 d.update((unsigned char *) tbuf, (U32)strlen(tbuf)); /* Flawfinder: ignore */
5589 3864
5590 d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ 3865 d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */
@@ -5843,7 +4118,7 @@ void LLMessageSystem::dumpPacketToLog()
5843 S32 cur_line = 0; 4118 S32 cur_line = 0;
5844 for (i = 0; i < mTrueReceiveSize; i++) 4119 for (i = 0; i < mTrueReceiveSize; i++)
5845 { 4120 {
5846 snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer),"%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */ 4121 snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer),"%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */
5847 cur_line_pos++; 4122 cur_line_pos++;
5848 if (cur_line_pos >= 16) 4123 if (cur_line_pos >= 16)
5849 { 4124 {
@@ -5859,6 +4134,121 @@ void LLMessageSystem::dumpPacketToLog()
5859} 4134}
5860 4135
5861//static 4136//static
4137BOOL LLMessageSystem::isTemplateConfirmed()
4138{
4139 return gMessageSystem->mTemplateConfirmed;
4140}
4141
4142//static
4143BOOL LLMessageSystem::doesTemplateMatch()
4144{
4145 if (!isTemplateConfirmed())
4146 {
4147 return FALSE;
4148 }
4149 return gMessageSystem->mTemplateMatches;
4150}
4151
4152//static
4153void LLMessageSystem::sendMessageTemplateChecksum(const LLHost &currentHost)
4154{
4155 gMessageSystem->mTemplateConfirmed = FALSE;
4156 gMessageSystem->mTemplateMatches = FALSE;
4157 gMessageSystem->newMessageFast(_PREHASH_TemplateChecksumRequest);
4158 // Don't use ping-based retry
4159 gMessageSystem->sendReliable(currentHost, 40, FALSE, 3, NULL, NULL);
4160}
4161
4162//static
4163void LLMessageSystem::processMessageTemplateChecksumReply(LLMessageSystem *msg,
4164 void** user_data)
4165{
4166 U32 remote_template_checksum = 0;
4167 msg->getU32Fast(_PREHASH_DataBlock, _PREHASH_Checksum, remote_template_checksum);
4168 msg->mTemplateConfirmed = TRUE;
4169 if ((remote_template_checksum) != msg->mMessageFileChecksum)
4170 {
4171 llwarns << "out of sync message template!" << llendl;
4172
4173 msg->mTemplateMatches = FALSE;
4174 msg->newMessageFast(_PREHASH_CloseCircuit);
4175 msg->sendMessage(msg->getSender());
4176 return;
4177 }
4178
4179 msg->mTemplateMatches = TRUE;
4180 llinfos << "According to " << msg->getSender()
4181 << " the message template is current!"
4182 << llendl;
4183}
4184
4185//static
4186void LLMessageSystem::sendSecureMessageTemplateChecksum(const LLHost& host)
4187{
4188 // generate an token for use during template checksum requests to
4189 // prevent DOS attacks from injected bad template checksum replies.
4190 LLUUID *template_tokenp = new LLUUID;
4191 template_tokenp->generate();
4192 lldebugs << "random token: " << *template_tokenp << llendl;
4193
4194 // register the handler for the reply while saving off template_token
4195 gMessageSystem->setHandlerFuncFast(_PREHASH_TemplateChecksumReply,
4196 LLMessageSystem::processSecureTemplateChecksumReply,
4197 (void**)template_tokenp);
4198
4199 // send checksum request
4200 gMessageSystem->mTemplateConfirmed = FALSE;
4201 gMessageSystem->newMessageFast(_PREHASH_SecuredTemplateChecksumRequest);
4202 gMessageSystem->nextBlockFast(_PREHASH_TokenBlock);
4203 gMessageSystem->addUUIDFast(_PREHASH_Token, *template_tokenp);
4204 gMessageSystem->sendReliable(host);
4205}
4206
4207//static
4208void LLMessageSystem::processSecureTemplateChecksumReply(LLMessageSystem *msg,
4209 void** user_data)
4210{
4211 // copy the token out into the stack and delete allocated memory
4212 LLUUID template_token = *((LLUUID*)user_data);
4213 delete user_data;
4214
4215 LLUUID received_token;
4216 msg->getUUID("TokenBlock", "Token", received_token);
4217
4218 if(received_token != template_token)
4219 {
4220 llwarns << "Incorrect token in template checksum reply: "
4221 << received_token << llendl;
4222 //return do_normal_idle;
4223 return;
4224 }
4225
4226 U32 remote_template_checksum = 0;
4227 U8 major_version = 0;
4228 U8 minor_version = 0;
4229 U8 patch_version = 0;
4230 U8 server_version = 0;
4231 U32 flags = 0x0;
4232 msg->getU32("DataBlock", "Checksum", remote_template_checksum);
4233 msg->getU8 ("DataBlock", "MajorVersion", major_version);
4234 msg->getU8 ("DataBlock", "MinorVersion", minor_version);
4235 msg->getU8 ("DataBlock", "PatchVersion", patch_version);
4236 msg->getU8 ("DataBlock", "ServerVersion", server_version);
4237 msg->getU32("DataBlock", "Flags", flags);
4238
4239 msg->mTemplateConfirmed = TRUE;
4240 if (remote_template_checksum != gMessageSystem->mMessageFileChecksum)
4241 {
4242 llinfos << "Message template out of sync" << llendl;
4243 msg->mTemplateMatches = FALSE;
4244 }
4245 else
4246 {
4247 msg->mTemplateMatches = TRUE;
4248 }
4249}
4250
4251//static
5862U64 LLMessageSystem::getMessageTimeUsecs(const BOOL update) 4252U64 LLMessageSystem::getMessageTimeUsecs(const BOOL update)
5863{ 4253{
5864 if (gMessageSystem) 4254 if (gMessageSystem)
@@ -5903,3 +4293,558 @@ std::string get_shared_secret()
5903 return g_shared_secret; 4293 return g_shared_secret;
5904} 4294}
5905 4295
4296typedef std::map<const char*, LLMessageBuilder*> BuilderMap;
4297
4298static void setBuilder(BuilderMap& map, const char* name, LLMessageBuilder* builder)
4299{
4300 map[gMessageStringTable.getString(name)] = builder;
4301}
4302
4303void LLMessageSystem::newMessageFast(const char *name)
4304{
4305 if(LLMessageConfig::isMessageBuiltTemplate(name))
4306 {
4307 mMessageBuilder = mTemplateMessageBuilder;
4308 }
4309 else
4310 {
4311 mMessageBuilder = mLLSDMessageBuilder;
4312 }
4313 mSendReliable = FALSE;
4314 mMessageBuilder->newMessage(name);
4315}
4316
4317void LLMessageSystem::newMessage(const char *name)
4318{
4319 newMessageFast(gMessageStringTable.getString(name));
4320}
4321
4322void LLMessageSystem::addBinaryDataFast(const char *varname, const void *data, S32 size)
4323{
4324 mMessageBuilder->addBinaryData(varname, data, size);
4325}
4326
4327void LLMessageSystem::addBinaryData(const char *varname, const void *data, S32 size)
4328{
4329 mMessageBuilder->addBinaryData(gMessageStringTable.getString(varname),data, size);
4330}
4331
4332void LLMessageSystem::addS8Fast(const char *varname, S8 v)
4333{
4334 mMessageBuilder->addS8(varname, v);
4335}
4336
4337void LLMessageSystem::addS8(const char *varname, S8 v)
4338{
4339 mMessageBuilder->addS8(gMessageStringTable.getString(varname), v);
4340}
4341
4342void LLMessageSystem::addU8Fast(const char *varname, U8 v)
4343{
4344 mMessageBuilder->addU8(varname, v);
4345}
4346
4347void LLMessageSystem::addU8(const char *varname, U8 v)
4348{
4349 mMessageBuilder->addU8(gMessageStringTable.getString(varname), v);
4350}
4351
4352void LLMessageSystem::addS16Fast(const char *varname, S16 v)
4353{
4354 mMessageBuilder->addS16(varname, v);
4355}
4356
4357void LLMessageSystem::addS16(const char *varname, S16 v)
4358{
4359 mMessageBuilder->addS16(gMessageStringTable.getString(varname), v);
4360}
4361
4362void LLMessageSystem::addU16Fast(const char *varname, U16 v)
4363{
4364 mMessageBuilder->addU16(varname, v);
4365}
4366
4367void LLMessageSystem::addU16(const char *varname, U16 v)
4368{
4369 mMessageBuilder->addU16(gMessageStringTable.getString(varname), v);
4370}
4371
4372void LLMessageSystem::addF32Fast(const char *varname, F32 v)
4373{
4374 mMessageBuilder->addF32(varname, v);
4375}
4376
4377void LLMessageSystem::addF32(const char *varname, F32 v)
4378{
4379 mMessageBuilder->addF32(gMessageStringTable.getString(varname), v);
4380}
4381
4382void LLMessageSystem::addS32Fast(const char *varname, S32 v)
4383{
4384 mMessageBuilder->addS32(varname, v);
4385}
4386
4387void LLMessageSystem::addS32(const char *varname, S32 v)
4388{
4389 mMessageBuilder->addS32(gMessageStringTable.getString(varname), v);
4390}
4391
4392void LLMessageSystem::addU32Fast(const char *varname, U32 v)
4393{
4394 mMessageBuilder->addU32(varname, v);
4395}
4396
4397void LLMessageSystem::addU32(const char *varname, U32 v)
4398{
4399 mMessageBuilder->addU32(gMessageStringTable.getString(varname), v);
4400}
4401
4402void LLMessageSystem::addU64Fast(const char *varname, U64 v)
4403{
4404 mMessageBuilder->addU64(varname, v);
4405}
4406
4407void LLMessageSystem::addU64(const char *varname, U64 v)
4408{
4409 mMessageBuilder->addU64(gMessageStringTable.getString(varname), v);
4410}
4411
4412void LLMessageSystem::addF64Fast(const char *varname, F64 v)
4413{
4414 mMessageBuilder->addF64(varname, v);
4415}
4416
4417void LLMessageSystem::addF64(const char *varname, F64 v)
4418{
4419 mMessageBuilder->addF64(gMessageStringTable.getString(varname), v);
4420}
4421
4422void LLMessageSystem::addIPAddrFast(const char *varname, U32 v)
4423{
4424 mMessageBuilder->addIPAddr(varname, v);
4425}
4426
4427void LLMessageSystem::addIPAddr(const char *varname, U32 v)
4428{
4429 mMessageBuilder->addIPAddr(gMessageStringTable.getString(varname), v);
4430}
4431
4432void LLMessageSystem::addIPPortFast(const char *varname, U16 v)
4433{
4434 mMessageBuilder->addIPPort(varname, v);
4435}
4436
4437void LLMessageSystem::addIPPort(const char *varname, U16 v)
4438{
4439 mMessageBuilder->addIPPort(gMessageStringTable.getString(varname), v);
4440}
4441
4442void LLMessageSystem::addBOOLFast(const char* varname, BOOL v)
4443{
4444 mMessageBuilder->addBOOL(varname, v);
4445}
4446
4447void LLMessageSystem::addBOOL(const char* varname, BOOL v)
4448{
4449 mMessageBuilder->addBOOL(gMessageStringTable.getString(varname), v);
4450}
4451
4452void LLMessageSystem::addStringFast(const char* varname, const char* v)
4453{
4454 mMessageBuilder->addString(varname, v);
4455}
4456
4457void LLMessageSystem::addString(const char* varname, const char* v)
4458{
4459 mMessageBuilder->addString(gMessageStringTable.getString(varname), v);
4460}
4461
4462void LLMessageSystem::addStringFast(const char* varname, const std::string& v)
4463{
4464 mMessageBuilder->addString(varname, v);
4465}
4466
4467void LLMessageSystem::addString(const char* varname, const std::string& v)
4468{
4469 mMessageBuilder->addString(gMessageStringTable.getString(varname), v);
4470}
4471
4472void LLMessageSystem::addVector3Fast(const char *varname, const LLVector3& v)
4473{
4474 mMessageBuilder->addVector3(varname, v);
4475}
4476
4477void LLMessageSystem::addVector3(const char *varname, const LLVector3& v)
4478{
4479 mMessageBuilder->addVector3(gMessageStringTable.getString(varname), v);
4480}
4481
4482void LLMessageSystem::addVector4Fast(const char *varname, const LLVector4& v)
4483{
4484 mMessageBuilder->addVector4(varname, v);
4485}
4486
4487void LLMessageSystem::addVector4(const char *varname, const LLVector4& v)
4488{
4489 mMessageBuilder->addVector4(gMessageStringTable.getString(varname), v);
4490}
4491
4492void LLMessageSystem::addVector3dFast(const char *varname, const LLVector3d& v)
4493{
4494 mMessageBuilder->addVector3d(varname, v);
4495}
4496
4497void LLMessageSystem::addVector3d(const char *varname, const LLVector3d& v)
4498{
4499 mMessageBuilder->addVector3d(gMessageStringTable.getString(varname), v);
4500}
4501
4502void LLMessageSystem::addQuatFast(const char *varname, const LLQuaternion& v)
4503{
4504 mMessageBuilder->addQuat(varname, v);
4505}
4506
4507void LLMessageSystem::addQuat(const char *varname, const LLQuaternion& v)
4508{
4509 mMessageBuilder->addQuat(gMessageStringTable.getString(varname), v);
4510}
4511
4512
4513void LLMessageSystem::addUUIDFast(const char *varname, const LLUUID& v)
4514{
4515 mMessageBuilder->addUUID(varname, v);
4516}
4517
4518void LLMessageSystem::addUUID(const char *varname, const LLUUID& v)
4519{
4520 mMessageBuilder->addUUID(gMessageStringTable.getString(varname), v);
4521}
4522
4523S32 LLMessageSystem::getCurrentSendTotal() const
4524{
4525 return mMessageBuilder->getMessageSize();
4526}
4527
4528void LLMessageSystem::getS8Fast(const char *block, const char *var, S8 &u,
4529 S32 blocknum)
4530{
4531 mMessageReader->getS8(block, var, u, blocknum);
4532}
4533
4534void LLMessageSystem::getS8(const char *block, const char *var, S8 &u,
4535 S32 blocknum)
4536{
4537 getS8Fast(gMessageStringTable.getString(block),
4538 gMessageStringTable.getString(var), u, blocknum);
4539}
4540
4541void LLMessageSystem::getU8Fast(const char *block, const char *var, U8 &u,
4542 S32 blocknum)
4543{
4544 mMessageReader->getU8(block, var, u, blocknum);
4545}
4546
4547void LLMessageSystem::getU8(const char *block, const char *var, U8 &u,
4548 S32 blocknum)
4549{
4550 getU8Fast(gMessageStringTable.getString(block),
4551 gMessageStringTable.getString(var), u, blocknum);
4552}
4553
4554void LLMessageSystem::getBOOLFast(const char *block, const char *var, BOOL &b,
4555 S32 blocknum)
4556{
4557 mMessageReader->getBOOL(block, var, b, blocknum);
4558}
4559
4560void LLMessageSystem::getBOOL(const char *block, const char *var, BOOL &b,
4561 S32 blocknum)
4562{
4563 getBOOLFast(gMessageStringTable.getString(block),
4564 gMessageStringTable.getString(var), b, blocknum);
4565}
4566
4567void LLMessageSystem::getS16Fast(const char *block, const char *var, S16 &d,
4568 S32 blocknum)
4569{
4570 mMessageReader->getS16(block, var, d, blocknum);
4571}
4572
4573void LLMessageSystem::getS16(const char *block, const char *var, S16 &d,
4574 S32 blocknum)
4575{
4576 getS16Fast(gMessageStringTable.getString(block),
4577 gMessageStringTable.getString(var), d, blocknum);
4578}
4579
4580void LLMessageSystem::getU16Fast(const char *block, const char *var, U16 &d,
4581 S32 blocknum)
4582{
4583 mMessageReader->getU16(block, var, d, blocknum);
4584}
4585
4586void LLMessageSystem::getU16(const char *block, const char *var, U16 &d,
4587 S32 blocknum)
4588{
4589 getU16Fast(gMessageStringTable.getString(block),
4590 gMessageStringTable.getString(var), d, blocknum);
4591}
4592
4593void LLMessageSystem::getS32Fast(const char *block, const char *var, S32 &d,
4594 S32 blocknum)
4595{
4596 mMessageReader->getS32(block, var, d, blocknum);
4597}
4598
4599void LLMessageSystem::getS32(const char *block, const char *var, S32 &d,
4600 S32 blocknum)
4601{
4602 getS32Fast(gMessageStringTable.getString(block),
4603 gMessageStringTable.getString(var), d, blocknum);
4604}
4605
4606void LLMessageSystem::getU32Fast(const char *block, const char *var, U32 &d,
4607 S32 blocknum)
4608{
4609 mMessageReader->getU32(block, var, d, blocknum);
4610}
4611
4612void LLMessageSystem::getU32(const char *block, const char *var, U32 &d,
4613 S32 blocknum)
4614{
4615 getU32Fast(gMessageStringTable.getString(block),
4616 gMessageStringTable.getString(var), d, blocknum);
4617}
4618
4619void LLMessageSystem::getU64Fast(const char *block, const char *var, U64 &d,
4620 S32 blocknum)
4621{
4622 mMessageReader->getU64(block, var, d, blocknum);
4623}
4624
4625void LLMessageSystem::getU64(const char *block, const char *var, U64 &d,
4626 S32 blocknum)
4627{
4628
4629 getU64Fast(gMessageStringTable.getString(block),
4630 gMessageStringTable.getString(var), d, blocknum);
4631}
4632
4633void LLMessageSystem::getBinaryDataFast(const char *blockname,
4634 const char *varname,
4635 void *datap, S32 size,
4636 S32 blocknum, S32 max_size)
4637{
4638 mMessageReader->getBinaryData(blockname, varname, datap, size, blocknum,
4639 max_size);
4640}
4641
4642void LLMessageSystem::getBinaryData(const char *blockname,
4643 const char *varname,
4644 void *datap, S32 size,
4645 S32 blocknum, S32 max_size)
4646{
4647 getBinaryDataFast(gMessageStringTable.getString(blockname),
4648 gMessageStringTable.getString(varname),
4649 datap, size, blocknum, max_size);
4650}
4651
4652void LLMessageSystem::getF32Fast(const char *block, const char *var, F32 &d,
4653 S32 blocknum)
4654{
4655 mMessageReader->getF32(block, var, d, blocknum);
4656}
4657
4658void LLMessageSystem::getF32(const char *block, const char *var, F32 &d,
4659 S32 blocknum)
4660{
4661 getF32Fast(gMessageStringTable.getString(block),
4662 gMessageStringTable.getString(var), d, blocknum);
4663}
4664
4665void LLMessageSystem::getF64Fast(const char *block, const char *var, F64 &d,
4666 S32 blocknum)
4667{
4668 mMessageReader->getF64(block, var, d, blocknum);
4669}
4670
4671void LLMessageSystem::getF64(const char *block, const char *var, F64 &d,
4672 S32 blocknum)
4673{
4674 getF64Fast(gMessageStringTable.getString(block),
4675 gMessageStringTable.getString(var), d, blocknum);
4676}
4677
4678
4679void LLMessageSystem::getVector3Fast(const char *block, const char *var,
4680 LLVector3 &v, S32 blocknum )
4681{
4682 mMessageReader->getVector3(block, var, v, blocknum);
4683}
4684
4685void LLMessageSystem::getVector3(const char *block, const char *var,
4686 LLVector3 &v, S32 blocknum )
4687{
4688 getVector3Fast(gMessageStringTable.getString(block),
4689 gMessageStringTable.getString(var), v, blocknum);
4690}
4691
4692void LLMessageSystem::getVector4Fast(const char *block, const char *var,
4693 LLVector4 &v, S32 blocknum )
4694{
4695 mMessageReader->getVector4(block, var, v, blocknum);
4696}
4697
4698void LLMessageSystem::getVector4(const char *block, const char *var,
4699 LLVector4 &v, S32 blocknum )
4700{
4701 getVector4Fast(gMessageStringTable.getString(block),
4702 gMessageStringTable.getString(var), v, blocknum);
4703}
4704
4705void LLMessageSystem::getVector3dFast(const char *block, const char *var,
4706 LLVector3d &v, S32 blocknum )
4707{
4708 mMessageReader->getVector3d(block, var, v, blocknum);
4709}
4710
4711void LLMessageSystem::getVector3d(const char *block, const char *var,
4712 LLVector3d &v, S32 blocknum )
4713{
4714 getVector3dFast(gMessageStringTable.getString(block),
4715 gMessageStringTable.getString(var), v, blocknum);
4716}
4717
4718void LLMessageSystem::getQuatFast(const char *block, const char *var,
4719 LLQuaternion &q, S32 blocknum )
4720{
4721 mMessageReader->getQuat(block, var, q, blocknum);
4722}
4723
4724void LLMessageSystem::getQuat(const char *block, const char *var,
4725 LLQuaternion &q, S32 blocknum)
4726{
4727 getQuatFast(gMessageStringTable.getString(block),
4728 gMessageStringTable.getString(var), q, blocknum);
4729}
4730
4731void LLMessageSystem::getUUIDFast(const char *block, const char *var,
4732 LLUUID &u, S32 blocknum )
4733{
4734 mMessageReader->getUUID(block, var, u, blocknum);
4735}
4736
4737void LLMessageSystem::getUUID(const char *block, const char *var, LLUUID &u,
4738 S32 blocknum )
4739{
4740 getUUIDFast(gMessageStringTable.getString(block),
4741 gMessageStringTable.getString(var), u, blocknum);
4742}
4743
4744void LLMessageSystem::getIPAddrFast(const char *block, const char *var,
4745 U32 &u, S32 blocknum)
4746{
4747 mMessageReader->getIPAddr(block, var, u, blocknum);
4748}
4749
4750void LLMessageSystem::getIPAddr(const char *block, const char *var, U32 &u,
4751 S32 blocknum)
4752{
4753 getIPAddrFast(gMessageStringTable.getString(block),
4754 gMessageStringTable.getString(var), u, blocknum);
4755}
4756
4757void LLMessageSystem::getIPPortFast(const char *block, const char *var,
4758 U16 &u, S32 blocknum)
4759{
4760 mMessageReader->getIPPort(block, var, u, blocknum);
4761}
4762
4763void LLMessageSystem::getIPPort(const char *block, const char *var, U16 &u,
4764 S32 blocknum)
4765{
4766 getIPPortFast(gMessageStringTable.getString(block),
4767 gMessageStringTable.getString(var), u,
4768 blocknum);
4769}
4770
4771
4772void LLMessageSystem::getStringFast(const char *block, const char *var,
4773 S32 buffer_size, char *s, S32 blocknum)
4774{
4775 mMessageReader->getString(block, var, buffer_size, s, blocknum);
4776}
4777
4778void LLMessageSystem::getString(const char *block, const char *var,
4779 S32 buffer_size, char *s, S32 blocknum )
4780{
4781 getStringFast(gMessageStringTable.getString(block),
4782 gMessageStringTable.getString(var), buffer_size, s,
4783 blocknum);
4784}
4785
4786S32 LLMessageSystem::getNumberOfBlocksFast(const char *blockname)
4787{
4788 return mMessageReader->getNumberOfBlocks(blockname);
4789}
4790
4791S32 LLMessageSystem::getNumberOfBlocks(const char *blockname)
4792{
4793 return getNumberOfBlocksFast(gMessageStringTable.getString(blockname));
4794}
4795
4796S32 LLMessageSystem::getSizeFast(const char *blockname, const char *varname)
4797{
4798 return mMessageReader->getSize(blockname, varname);
4799}
4800
4801S32 LLMessageSystem::getSize(const char *blockname, const char *varname)
4802{
4803 return getSizeFast(gMessageStringTable.getString(blockname),
4804 gMessageStringTable.getString(varname));
4805}
4806
4807// size in bytes of variable length data
4808S32 LLMessageSystem::getSizeFast(const char *blockname, S32 blocknum,
4809 const char *varname)
4810{
4811 return mMessageReader->getSize(blockname, blocknum, varname);
4812}
4813
4814S32 LLMessageSystem::getSize(const char *blockname, S32 blocknum,
4815 const char *varname)
4816{
4817 return getSizeFast(gMessageStringTable.getString(blockname), blocknum,
4818 gMessageStringTable.getString(varname));
4819}
4820
4821S32 LLMessageSystem::getReceiveSize() const
4822{
4823 return mMessageReader->getMessageSize();
4824}
4825
4826//static
4827void LLMessageSystem::setTimeDecodes( BOOL b )
4828{
4829 LLMessageReader::setTimeDecodes(b);
4830}
4831
4832//static
4833void LLMessageSystem::setTimeDecodesSpamThreshold( F32 seconds )
4834{
4835 LLMessageReader::setTimeDecodesSpamThreshold(seconds);
4836}
4837
4838// HACK! babbage: return true if message rxed via either UDP or HTTP
4839// TODO: babbage: move gServicePump in to LLMessageSystem?
4840bool LLMessageSystem::checkAllMessages(S64 frame_count, LLPumpIO* http_pump)
4841{
4842 if(checkMessages(frame_count))
4843 {
4844 return true;
4845 }
4846 U32 packetsIn = mPacketsIn;
4847 http_pump->pump();
4848 http_pump->callback();
4849 return (mPacketsIn - packetsIn) > 0;
4850}
diff --git a/linden/indra/llmessage/message.h b/linden/indra/llmessage/message.h
index 5cc3ec1..0a55485 100644
--- a/linden/indra/llmessage/message.h
+++ b/linden/indra/llmessage/message.h
@@ -1,9 +1,10 @@
1/** 1/**
2 * @file message.h 2 * @FILE message.h
3 * @brief LLMessageSystem class header file 3 * @brief LLMessageSystem class header file
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -45,16 +46,15 @@
45#include "llerror.h" 46#include "llerror.h"
46#include "net.h" 47#include "net.h"
47#include "string_table.h" 48#include "string_table.h"
48#include "llptrskipmap.h"
49#include "llcircuit.h" 49#include "llcircuit.h"
50#include "lltimer.h" 50#include "lltimer.h"
51#include "llpacketring.h" 51#include "llpacketring.h"
52#include "llhost.h" 52#include "llhost.h"
53#include "llhttpnode.h"
53#include "llpacketack.h" 54#include "llpacketack.h"
54#include "doublelinkedlist.h"
55#include "message_prehash.h" 55#include "message_prehash.h"
56#include "llstl.h" 56#include "llstl.h"
57#include "lldarray.h" 57#include "llmsgvariabletype.h"
58 58
59const U32 MESSAGE_MAX_STRINGS_LENGTH = 64; 59const U32 MESSAGE_MAX_STRINGS_LENGTH = 64;
60const U32 MESSAGE_NUMBER_OF_HASH_BUCKETS = 8192; 60const U32 MESSAGE_NUMBER_OF_HASH_BUCKETS = 8192;
@@ -153,39 +153,10 @@ class LLQuaternion;
153class LLSD; 153class LLSD;
154class LLUUID; 154class LLUUID;
155class LLMessageSystem; 155class LLMessageSystem;
156class LLPumpIO;
156 157
157// message data pieces are used to collect the data called for by the message template 158// message data pieces are used to collect the data called for by the message template
158 159
159// iterator typedefs precede each class as needed
160typedef enum e_message_variable_type
161{
162 MVT_NULL,
163 MVT_FIXED,
164 MVT_VARIABLE,
165 MVT_U8,
166 MVT_U16,
167 MVT_U32,
168 MVT_U64,
169 MVT_S8,
170 MVT_S16,
171 MVT_S32,
172 MVT_S64,
173 MVT_F32,
174 MVT_F64,
175 MVT_LLVector3,
176 MVT_LLVector3d,
177 MVT_LLVector4,
178 MVT_LLQuaternion,
179 MVT_LLUUID,
180 MVT_BOOL,
181 MVT_IP_ADDR,
182 MVT_IP_PORT,
183 MVT_U16Vec3,
184 MVT_U16Quat,
185 MVT_S16Array,
186 MVT_EOL
187} EMsgVariableType;
188
189// message system exceptional condition handlers. 160// message system exceptional condition handlers.
190enum EMessageException 161enum EMessageException
191{ 162{
@@ -197,25 +168,34 @@ enum EMessageException
197typedef void (*msg_exception_callback)(LLMessageSystem*,void*,EMessageException); 168typedef void (*msg_exception_callback)(LLMessageSystem*,void*,EMessageException);
198 169
199 170
200
201class LLMsgData; 171class LLMsgData;
202class LLMsgBlkData; 172class LLMsgBlkData;
203class LLMessageTemplate; 173class LLMessageTemplate;
204 174
205class LLMessagePollInfo; 175class LLMessagePollInfo;
176class LLMessageBuilder;
177class LLTemplateMessageBuilder;
178class LLSDMessageBuilder;
179class LLMessageReader;
180class LLTemplateMessageReader;
181class LLSDMessageReader;
206 182
207class LLMessageSystem 183class LLUseCircuitCodeResponder
208{ 184{
209 LOG_CLASS(LLMessageSystem); 185 LOG_CLASS(LLMessageSystem);
210 186
211public: 187public:
188 virtual ~LLUseCircuitCodeResponder();
189 virtual void complete(const LLHost& host, const LLUUID& agent) const = 0;
190};
191
192class LLMessageSystem
193{
194 private:
212 U8 mSendBuffer[MAX_BUFFER_SIZE]; 195 U8 mSendBuffer[MAX_BUFFER_SIZE];
213 // Encoded send buffer needs to be slightly larger since the zero
214 // coding can potentially increase the size of the send data.
215 U8 mEncodedSendBuffer[2 * MAX_BUFFER_SIZE];
216 S32 mSendSize; 196 S32 mSendSize;
217 S32 mCurrentSendTotal;
218 197
198 public:
219 LLPacketRing mPacketRing; 199 LLPacketRing mPacketRing;
220 LLReliablePacketParams mReliablePacketParams; 200 LLReliablePacketParams mReliablePacketParams;
221 201
@@ -294,12 +274,7 @@ public:
294 LLMessageSystem(const char *filename, U32 port, S32 version_major, 274 LLMessageSystem(const char *filename, U32 port, S32 version_major,
295 S32 version_minor, S32 version_patch); 275 S32 version_minor, S32 version_patch);
296 276
297public: 277 ~LLMessageSystem();
298 // Subclass use.
299 LLMessageSystem();
300
301public:
302 virtual ~LLMessageSystem();
303 278
304 BOOL isOK() const { return !mbError; } 279 BOOL isOK() const { return !mbError; }
305 S32 getErrorCode() const { return mErrorCode; } 280 S32 getErrorCode() const { return mErrorCode; }
@@ -317,15 +292,26 @@ public:
317 setHandlerFuncFast(gMessageStringTable.getString(name), handler_func, user_data); 292 setHandlerFuncFast(gMessageStringTable.getString(name), handler_func, user_data);
318 } 293 }
319 294
320 bool callHandler(const char *name, bool trustedSource,
321 LLMessageSystem* msg);
322
323 // Set a callback function for a message system exception. 295 // Set a callback function for a message system exception.
324 void setExceptionFunc(EMessageException exception, msg_exception_callback func, void* data = NULL); 296 void setExceptionFunc(EMessageException exception, msg_exception_callback func, void* data = NULL);
325 // Call the specified exception func, and return TRUE if a 297 // Call the specified exception func, and return TRUE if a
326 // function was found and called. Otherwise return FALSE. 298 // function was found and called. Otherwise return FALSE.
327 BOOL callExceptionFunc(EMessageException exception); 299 BOOL callExceptionFunc(EMessageException exception);
328 300
301 // Set a function that will be called once per packet processed with the
302 // hashed message name and the time spent in the processing handler function
303 // measured in seconds. JC
304 typedef void (*msg_timing_callback)(const char* hashed_name, F32 time, void* data);
305 void setTimingFunc(msg_timing_callback func, void* data = NULL);
306 msg_timing_callback getTimingCallback()
307 {
308 return mTimingCallback;
309 }
310 void* getTimingCallbackData()
311 {
312 return mTimingCallbackData;
313 }
314
329 // This method returns true if the code is in the circuit codes map. 315 // This method returns true if the code is in the circuit codes map.
330 BOOL isCircuitCodeKnown(U32 code) const; 316 BOOL isCircuitCodeKnown(U32 code) const;
331 317
@@ -364,42 +350,21 @@ public:
364 void setMySessionID(const LLUUID& session_id) { mSessionID = session_id; } 350 void setMySessionID(const LLUUID& session_id) { mSessionID = session_id; }
365 const LLUUID& getMySessionID() { return mSessionID; } 351 const LLUUID& getMySessionID() { return mSessionID; }
366 352
367 virtual void newMessageFast(const char *name); 353 void newMessageFast(const char *name);
368 void newMessage(const char *name) 354 void newMessage(const char *name);
369 {
370 newMessageFast(gMessageStringTable.getString(name));
371 }
372 355
373 void copyMessageRtoS(); 356 void copyMessageRtoS();
374 void clearMessage(); 357 void clearMessage();
375 358
376 virtual void nextBlockFast(const char *blockname); 359 void nextBlockFast(const char *blockname);
377 void nextBlock(const char *blockname) 360 void nextBlock(const char *blockname)
378 { 361 {
379 nextBlockFast(gMessageStringTable.getString(blockname)); 362 nextBlockFast(gMessageStringTable.getString(blockname));
380 } 363 }
381private:
382 void addDataFast(const char *varname, const void *data, EMsgVariableType type, S32 size); // Use only for types not in system already
383 void addData(const char *varname, const void *data, EMsgVariableType type, S32 size)
384 {
385 addDataFast(gMessageStringTable.getString(varname), data, type, size);
386 }
387 364
388
389 void addDataFast(const char *varname, const void *data, EMsgVariableType type); // DEPRECATED - not typed, doesn't check storage space
390 void addData(const char *varname, const void *data, EMsgVariableType type)
391 {
392 addDataFast(gMessageStringTable.getString(varname), data, type);
393 }
394public: 365public:
395 void addBinaryDataFast(const char *varname, const void *data, S32 size) 366 void addBinaryDataFast(const char *varname, const void *data, S32 size);
396 { 367 void addBinaryData(const char *varname, const void *data, S32 size);
397 addDataFast(varname, data, MVT_FIXED, size);
398 }
399 void addBinaryData(const char *varname, const void *data, S32 size)
400 {
401 addDataFast(gMessageStringTable.getString(varname), data, MVT_FIXED, size);
402 }
403 368
404 void addBOOLFast( const char* varname, BOOL b); // typed, checks storage space 369 void addBOOLFast( const char* varname, BOOL b); // typed, checks storage space
405 void addBOOL( const char* varname, BOOL b); // typed, checks storage space 370 void addBOOL( const char* varname, BOOL b); // typed, checks storage space
@@ -415,7 +380,7 @@ public:
415 void addF32( const char *varname, F32 f); // typed, checks storage space 380 void addF32( const char *varname, F32 f); // typed, checks storage space
416 void addS32Fast( const char *varname, S32 s); // typed, checks storage space 381 void addS32Fast( const char *varname, S32 s); // typed, checks storage space
417 void addS32( const char *varname, S32 s); // typed, checks storage space 382 void addS32( const char *varname, S32 s); // typed, checks storage space
418 virtual void addU32Fast( const char *varname, U32 u); // typed, checks storage space 383 void addU32Fast( const char *varname, U32 u); // typed, checks storage space
419 void addU32( const char *varname, U32 u); // typed, checks storage space 384 void addU32( const char *varname, U32 u); // typed, checks storage space
420 void addU64Fast( const char *varname, U64 lu); // typed, checks storage space 385 void addU64Fast( const char *varname, U64 lu); // typed, checks storage space
421 void addU64( const char *varname, U64 lu); // typed, checks storage space 386 void addU64( const char *varname, U64 lu); // typed, checks storage space
@@ -429,7 +394,7 @@ public:
429 void addVector3d( const char *varname, const LLVector3d& vec); // typed, checks storage space 394 void addVector3d( const char *varname, const LLVector3d& vec); // typed, checks storage space
430 void addQuatFast( const char *varname, const LLQuaternion& quat); // typed, checks storage space 395 void addQuatFast( const char *varname, const LLQuaternion& quat); // typed, checks storage space
431 void addQuat( const char *varname, const LLQuaternion& quat); // typed, checks storage space 396 void addQuat( const char *varname, const LLQuaternion& quat); // typed, checks storage space
432 virtual void addUUIDFast( const char *varname, const LLUUID& uuid); // typed, checks storage space 397 void addUUIDFast( const char *varname, const LLUUID& uuid); // typed, checks storage space
433 void addUUID( const char *varname, const LLUUID& uuid); // typed, checks storage space 398 void addUUID( const char *varname, const LLUUID& uuid); // typed, checks storage space
434 void addIPAddrFast( const char *varname, const U32 ip); // typed, checks storage space 399 void addIPAddrFast( const char *varname, const U32 ip); // typed, checks storage space
435 void addIPAddr( const char *varname, const U32 ip); // typed, checks storage space 400 void addIPAddr( const char *varname, const U32 ip); // typed, checks storage space
@@ -440,8 +405,8 @@ public:
440 void addStringFast( const char* varname, const std::string& s); // typed, checks storage space 405 void addStringFast( const char* varname, const std::string& s); // typed, checks storage space
441 void addString( const char* varname, const std::string& s); // typed, checks storage space 406 void addString( const char* varname, const std::string& s); // typed, checks storage space
442 407
408 S32 getCurrentSendTotal() const;
443 TPACKETID getCurrentRecvPacketID() { return mCurrentRecvPacketID; } 409 TPACKETID getCurrentRecvPacketID() { return mCurrentRecvPacketID; }
444 S32 getCurrentSendTotal() const { return mCurrentSendTotal; }
445 410
446 // This method checks for current send total and returns true if 411 // This method checks for current send total and returns true if
447 // you need to go to the next block type or need to start a new 412 // you need to go to the next block type or need to start a new
@@ -450,16 +415,16 @@ public:
450 BOOL isSendFull(const char* blockname = NULL); 415 BOOL isSendFull(const char* blockname = NULL);
451 BOOL isSendFullFast(const char* blockname = NULL); 416 BOOL isSendFullFast(const char* blockname = NULL);
452 417
453 BOOL removeLastBlock(); 418 BOOL removeLastBlock();
454 419
455 void buildMessage(); 420 //void buildMessage();
456 421
457 S32 zeroCode(U8 **data, S32 *data_size); 422 S32 zeroCode(U8 **data, S32 *data_size);
458 S32 zeroCodeExpand(U8 **data, S32 *data_size); 423 S32 zeroCodeExpand(U8 **data, S32 *data_size);
459 S32 zeroCodeAdjustCurrentSendTotal(); 424 S32 zeroCodeAdjustCurrentSendTotal();
460 425
461 // Uses ping-based retry 426 // Uses ping-based retry
462 virtual S32 sendReliable(const LLHost &host); 427 S32 sendReliable(const LLHost &host);
463 428
464 // Uses ping-based retry 429 // Uses ping-based retry
465 S32 sendReliable(const U32 circuit) { return sendReliable(findHost(circuit)); } 430 S32 sendReliable(const U32 circuit) { return sendReliable(findHost(circuit)); }
@@ -488,28 +453,10 @@ public:
488 S32 sendMessage(const LLHost &host); 453 S32 sendMessage(const LLHost &host);
489 S32 sendMessage(const U32 circuit); 454 S32 sendMessage(const U32 circuit);
490 455
491 BOOL decodeData(const U8 *buffer, const LLHost &host); 456 // BOOL decodeData(const U8 *buffer, const LLHost &host);
492
493 // TODO: Consolide these functions
494 // TODO: Make these private, force use of typed functions.
495 // If size is not 0, an error is generated if size doesn't exactly match the size of the data.
496 // At all times, the number if bytes written to *datap is <= max_size.
497private:
498 void getDataFast(const char *blockname, const char *varname, void *datap, S32 size = 0, S32 blocknum = 0, S32 max_size = S32_MAX);
499 void getData(const char *blockname, const char *varname, void *datap, S32 size = 0, S32 blocknum = 0, S32 max_size = S32_MAX)
500 {
501 getDataFast(gMessageStringTable.getString(blockname), gMessageStringTable.getString(varname), datap, size, blocknum, max_size);
502 }
503public:
504 void getBinaryDataFast(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX)
505 {
506 getDataFast(blockname, varname, datap, size, blocknum, max_size);
507 }
508 void getBinaryData(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX)
509 {
510 getDataFast(gMessageStringTable.getString(blockname), gMessageStringTable.getString(varname), datap, size, blocknum, max_size);
511 }
512 457
458 void getBinaryDataFast(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX);
459 void getBinaryData(const char *blockname, const char *varname, void *datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX);
513 void getBOOLFast( const char *block, const char *var, BOOL &data, S32 blocknum = 0); 460 void getBOOLFast( const char *block, const char *var, BOOL &data, S32 blocknum = 0);
514 void getBOOL( const char *block, const char *var, BOOL &data, S32 blocknum = 0); 461 void getBOOL( const char *block, const char *var, BOOL &data, S32 blocknum = 0);
515 void getS8Fast( const char *block, const char *var, S8 &data, S32 blocknum = 0); 462 void getS8Fast( const char *block, const char *var, S8 &data, S32 blocknum = 0);
@@ -524,9 +471,9 @@ public:
524 void getS32( const char *block, const char *var, S32 &data, S32 blocknum = 0); 471 void getS32( const char *block, const char *var, S32 &data, S32 blocknum = 0);
525 void getF32Fast( const char *block, const char *var, F32 &data, S32 blocknum = 0); 472 void getF32Fast( const char *block, const char *var, F32 &data, S32 blocknum = 0);
526 void getF32( const char *block, const char *var, F32 &data, S32 blocknum = 0); 473 void getF32( const char *block, const char *var, F32 &data, S32 blocknum = 0);
527 virtual void getU32Fast( const char *block, const char *var, U32 &data, S32 blocknum = 0); 474 void getU32Fast( const char *block, const char *var, U32 &data, S32 blocknum = 0);
528 void getU32( const char *block, const char *var, U32 &data, S32 blocknum = 0); 475 void getU32( const char *block, const char *var, U32 &data, S32 blocknum = 0);
529 virtual void getU64Fast( const char *block, const char *var, U64 &data, S32 blocknum = 0); 476 void getU64Fast( const char *block, const char *var, U64 &data, S32 blocknum = 0);
530 void getU64( const char *block, const char *var, U64 &data, S32 blocknum = 0); 477 void getU64( const char *block, const char *var, U64 &data, S32 blocknum = 0);
531 void getF64Fast( const char *block, const char *var, F64 &data, S32 blocknum = 0); 478 void getF64Fast( const char *block, const char *var, F64 &data, S32 blocknum = 0);
532 void getF64( const char *block, const char *var, F64 &data, S32 blocknum = 0); 479 void getF64( const char *block, const char *var, F64 &data, S32 blocknum = 0);
@@ -538,13 +485,13 @@ public:
538 void getVector3d(const char *block, const char *var, LLVector3d &vec, S32 blocknum = 0); 485 void getVector3d(const char *block, const char *var, LLVector3d &vec, S32 blocknum = 0);
539 void getQuatFast( const char *block, const char *var, LLQuaternion &q, S32 blocknum = 0); 486 void getQuatFast( const char *block, const char *var, LLQuaternion &q, S32 blocknum = 0);
540 void getQuat( const char *block, const char *var, LLQuaternion &q, S32 blocknum = 0); 487 void getQuat( const char *block, const char *var, LLQuaternion &q, S32 blocknum = 0);
541 virtual void getUUIDFast( const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0); 488 void getUUIDFast( const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0);
542 void getUUID( const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0); 489 void getUUID( const char *block, const char *var, LLUUID &uuid, S32 blocknum = 0);
543 virtual void getIPAddrFast( const char *block, const char *var, U32 &ip, S32 blocknum = 0); 490 void getIPAddrFast( const char *block, const char *var, U32 &ip, S32 blocknum = 0);
544 void getIPAddr( const char *block, const char *var, U32 &ip, S32 blocknum = 0); 491 void getIPAddr( const char *block, const char *var, U32 &ip, S32 blocknum = 0);
545 virtual void getIPPortFast( const char *block, const char *var, U16 &port, S32 blocknum = 0); 492 void getIPPortFast( const char *block, const char *var, U16 &port, S32 blocknum = 0);
546 void getIPPort( const char *block, const char *var, U16 &port, S32 blocknum = 0); 493 void getIPPort( const char *block, const char *var, U16 &port, S32 blocknum = 0);
547 virtual void getStringFast( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); 494 void getStringFast( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0);
548 void getString( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0); 495 void getString( const char *block, const char *var, S32 buffer_size, char *buffer, S32 blocknum = 0);
549 496
550 497
@@ -566,7 +513,7 @@ public:
566 void showCircuitInfo(); 513 void showCircuitInfo();
567 LLString getCircuitInfoString(); 514 LLString getCircuitInfoString();
568 515
569 virtual U32 getOurCircuitCode(); 516 U32 getOurCircuitCode();
570 517
571 void enableCircuit(const LLHost &host, BOOL trusted); 518 void enableCircuit(const LLHost &host, BOOL trusted);
572 void disableCircuit(const LLHost &host); 519 void disableCircuit(const LLHost &host);
@@ -612,20 +559,12 @@ public:
612 void sanityCheck(); 559 void sanityCheck();
613 560
614 S32 getNumberOfBlocksFast(const char *blockname); 561 S32 getNumberOfBlocksFast(const char *blockname);
615 S32 getNumberOfBlocks(const char *blockname) 562 S32 getNumberOfBlocks(const char *blockname);
616 {
617 return getNumberOfBlocksFast(gMessageStringTable.getString(blockname));
618 }
619 S32 getSizeFast(const char *blockname, const char *varname); 563 S32 getSizeFast(const char *blockname, const char *varname);
620 S32 getSize(const char *blockname, const char *varname) 564 S32 getSize(const char *blockname, const char *varname);
621 { 565 S32 getSizeFast(const char *blockname, S32 blocknum,
622 return getSizeFast(gMessageStringTable.getString(blockname), gMessageStringTable.getString(varname)); 566 const char *varname); // size in bytes of data
623 } 567 S32 getSize(const char *blockname, S32 blocknum, const char *varname);
624 S32 getSizeFast(const char *blockname, S32 blocknum, const char *varname); // size in bytes of variable length data
625 S32 getSize(const char *blockname, S32 blocknum, const char *varname)
626 {
627 return getSizeFast(gMessageStringTable.getString(blockname), blocknum, gMessageStringTable.getString(varname));
628 }
629 568
630 void resetReceiveCounts(); // resets receive counts for all message types to 0 569 void resetReceiveCounts(); // resets receive counts for all message types to 0
631 void dumpReceiveCounts(); // dumps receive count for each message type to llinfos 570 void dumpReceiveCounts(); // dumps receive count for each message type to llinfos
@@ -640,14 +579,14 @@ public:
640 void stopLogging(); // flush and close file 579 void stopLogging(); // flush and close file
641 void summarizeLogs(std::ostream& str); // log statistics 580 void summarizeLogs(std::ostream& str); // log statistics
642 581
643 S32 getReceiveSize() const { return mReceiveSize; } 582 S32 getReceiveSize() const;
644 S32 getReceiveCompressedSize() const { return mIncomingCompressedSize; } 583 S32 getReceiveCompressedSize() const { return mIncomingCompressedSize; }
645 S32 getReceiveBytes() const; 584 S32 getReceiveBytes() const;
646 585
647 S32 getUnackedListSize() const { return mUnackedListSize; } 586 S32 getUnackedListSize() const { return mUnackedListSize; }
648 587
649 const char* getCurrentSMessageName() const { return mCurrentSMessageName; } 588 //const char* getCurrentSMessageName() const { return mCurrentSMessageName; }
650 const char* getCurrentSBlockName() const { return mCurrentSBlockName; } 589 //const char* getCurrentSBlockName() const { return mCurrentSBlockName; }
651 590
652 // friends 591 // friends
653 friend std::ostream& operator<<(std::ostream& s, LLMessageSystem &msg); 592 friend std::ostream& operator<<(std::ostream& s, LLMessageSystem &msg);
@@ -656,25 +595,41 @@ public:
656 void setMaxMessageCounts(const S32 num); // Max number of messages before dumping (neg to disable) 595 void setMaxMessageCounts(const S32 num); // Max number of messages before dumping (neg to disable)
657 596
658 // statics 597 // statics
659public: 598 static BOOL isTemplateConfirmed();
599 static BOOL doesTemplateMatch();
600 static void sendMessageTemplateChecksum(const LLHost&);
601 static void processMessageTemplateChecksumReply(LLMessageSystem *msg,
602 void** user_data);
603 static void sendSecureMessageTemplateChecksum(const LLHost&);
604 static void processSecureTemplateChecksumReply(LLMessageSystem *msg,
605 void** user_data);
660 static U64 getMessageTimeUsecs(const BOOL update = FALSE); // Get the current message system time in microseconds 606 static U64 getMessageTimeUsecs(const BOOL update = FALSE); // Get the current message system time in microseconds
661 static F64 getMessageTimeSeconds(const BOOL update = FALSE); // Get the current message system time in seconds 607 static F64 getMessageTimeSeconds(const BOOL update = FALSE); // Get the current message system time in seconds
662 608
663 static void setTimeDecodes( BOOL b ) 609 static void setTimeDecodes(BOOL b);
664 { LLMessageSystem::mTimeDecodes = b; } 610 static void setTimeDecodesSpamThreshold(F32 seconds);
665
666 static void setTimeDecodesSpamThreshold( F32 seconds )
667 { LLMessageSystem::mTimeDecodesSpamThreshold = seconds; }
668 611
669 // message handlers internal to the message systesm 612 // message handlers internal to the message systesm
670 //static void processAssignCircuitCode(LLMessageSystem* msg, void**); 613 //static void processAssignCircuitCode(LLMessageSystem* msg, void**);
671 static void processAddCircuitCode(LLMessageSystem* msg, void**); 614 static void processAddCircuitCode(LLMessageSystem* msg, void**);
672 static void processUseCircuitCode(LLMessageSystem* msg, void**); 615 static void processUseCircuitCode(LLMessageSystem* msg, void**);
673 616
617 // dispatch llsd message to http node tree
618 static void dispatch(const std::string& msg_name,
619 const LLSD& message);
620 static void dispatch(const std::string& msg_name,
621 const LLSD& message,
622 LLHTTPNode::ResponsePtr responsep);
623
674 void setMessageBans(const LLSD& trusted, const LLSD& untrusted); 624 void setMessageBans(const LLSD& trusted, const LLSD& untrusted);
625
626 // Check UDP messages and pump http_pump to receive HTTP messages.
627 bool checkAllMessages(S64 frame_count, LLPumpIO* http_pump);
675 628
676private: 629private:
677 // data used in those internal handlers 630 // data used in those internal handlers
631 BOOL mTemplateConfirmed;
632 BOOL mTemplateMatches;
678 633
679 // The mCircuitCodes is a map from circuit codes to session 634 // The mCircuitCodes is a map from circuit codes to session
680 // ids. This allows us to verify sessions on connect. 635 // ids. This allows us to verify sessions on connect.
@@ -685,7 +640,6 @@ private:
685 // that no one gives them a bad circuit code. 640 // that no one gives them a bad circuit code.
686 LLUUID mSessionID; 641 LLUUID mSessionID;
687 642
688private:
689 void addTemplate(LLMessageTemplate *templatep); 643 void addTemplate(LLMessageTemplate *templatep);
690 void clearReceiveState(); 644 void clearReceiveState();
691 BOOL decodeTemplate( const U8* buffer, S32 buffer_size, LLMessageTemplate** msg_template ); 645 BOOL decodeTemplate( const U8* buffer, S32 buffer_size, LLMessageTemplate** msg_template );
@@ -695,7 +649,6 @@ private:
695 void logValidMsg(LLCircuitData *cdp, const LLHost& sender, BOOL recv_reliable, BOOL recv_resent, BOOL recv_acks ); 649 void logValidMsg(LLCircuitData *cdp, const LLHost& sender, BOOL recv_reliable, BOOL recv_resent, BOOL recv_acks );
696 void logRanOffEndOfPacket( const LLHost& sender ); 650 void logRanOffEndOfPacket( const LLHost& sender );
697 651
698private:
699 class LLMessageCountInfo 652 class LLMessageCountInfo
700 { 653 {
701 public: 654 public:
@@ -711,26 +664,10 @@ private:
711 S32 mTrueReceiveSize; 664 S32 mTrueReceiveSize;
712 665
713 // Must be valid during decode 666 // Must be valid during decode
714 S32 mReceiveSize; 667
715 TPACKETID mCurrentRecvPacketID; // packet ID of current receive packet (for reporting)
716 LLMessageTemplate *mCurrentRMessageTemplate;
717 LLMsgData *mCurrentRMessageData;
718 S32 mIncomingCompressedSize; // original size of compressed msg (0 if uncomp.)
719 LLHost mLastSender;
720
721 // send message storage
722 LLMsgData *mCurrentSMessageData;
723 LLMessageTemplate *mCurrentSMessageTemplate;
724 LLMsgBlkData *mCurrentSDataBlock;
725 char *mCurrentSMessageName;
726 char *mCurrentSBlockName;
727
728 BOOL mbError; 668 BOOL mbError;
729 S32 mErrorCode; 669 S32 mErrorCode;
730 670
731 BOOL mbSBuilt; // is send message built?
732 BOOL mbSClear; // is the send message clear?
733
734 F64 mResendDumpTime; // The last time we dumped resends 671 F64 mResendDumpTime; // The last time we dumped resends
735 672
736 LLMessageCountInfo mMessageCountList[MAX_MESSAGE_COUNT_NUM]; 673 LLMessageCountInfo mMessageCountList[MAX_MESSAGE_COUNT_NUM];
@@ -753,16 +690,31 @@ private:
753 static F32 mTimeDecodesSpamThreshold; // If mTimeDecodes is on, all this many seconds for each msg decode before spamming 690 static F32 mTimeDecodesSpamThreshold; // If mTimeDecodes is on, all this many seconds for each msg decode before spamming
754 static BOOL mTimeDecodes; // Measure time for all message decodes if TRUE; 691 static BOOL mTimeDecodes; // Measure time for all message decodes if TRUE;
755 692
693 msg_timing_callback mTimingCallback;
694 void* mTimingCallbackData;
695
756 void init(); // ctor shared initialisation. 696 void init(); // ctor shared initialisation.
697
698 LLHost mLastSender;
699 S32 mIncomingCompressedSize; // original size of compressed msg (0 if uncomp.)
700 TPACKETID mCurrentRecvPacketID; // packet ID of current receive packet (for reporting)
701
702 LLMessageBuilder* mMessageBuilder;
703 LLTemplateMessageBuilder* mTemplateMessageBuilder;
704 LLSDMessageBuilder* mLLSDMessageBuilder;
705 LLMessageReader* mMessageReader;
706 LLTemplateMessageReader* mTemplateMessageReader;
707 LLSDMessageReader* mLLSDMessageReader;
708
709 friend class LLMessageHandlerBridge;
710
711 bool callHandler(const char *name, bool trustedSource,
712 LLMessageSystem* msg);
757}; 713};
758 714
759 715
760// external hook into messaging system 716// external hook into messaging system
761extern LLMessageSystem *gMessageSystem; 717extern LLMessageSystem *gMessageSystem;
762//extern const char* MESSAGE_LOG_FILENAME;
763
764void encrypt_template(const char *src_name, const char *dest_name);
765BOOL decrypt_template(const char *src_name, const char *dest_name);
766 718
767// Must specific overall system version, which is used to determine 719// Must specific overall system version, which is used to determine
768// if a patch is available in the message template checksum verification. 720// if a patch is available in the message template checksum verification.
@@ -774,7 +726,8 @@ BOOL start_messaging_system(
774 S32 version_minor, 726 S32 version_minor,
775 S32 version_patch, 727 S32 version_patch,
776 BOOL b_dump_prehash_file, 728 BOOL b_dump_prehash_file,
777 const std::string& secret); 729 const std::string& secret,
730 const LLUseCircuitCodeResponder* responder = NULL);
778 731
779void end_messaging_system(); 732void end_messaging_system();
780 733
@@ -950,12 +903,9 @@ inline void *ntohmemcpy(void *s, const void *ct, EMsgVariableType type, size_t n
950} 903}
951 904
952 905
953inline const LLHost& LLMessageSystem::getSender() const 906inline const LLHost& LLMessageSystem::getSender() const {return mLastSender;}
954{
955 return mLastSender;
956}
957 907
958inline U32 LLMessageSystem::getSenderIP() const 908inline U32 LLMessageSystem::getSenderIP() const
959{ 909{
960 return mLastSender.getAddress(); 910 return mLastSender.getAddress();
961} 911}
@@ -965,308 +915,13 @@ inline U32 LLMessageSystem::getSenderPort() const
965 return mLastSender.getPort(); 915 return mLastSender.getPort();
966} 916}
967 917
968inline void LLMessageSystem::addS8Fast(const char *varname, S8 s)
969{
970 addDataFast(varname, &s, MVT_S8, sizeof(s));
971}
972
973inline void LLMessageSystem::addS8(const char *varname, S8 s)
974{
975 addDataFast(gMessageStringTable.getString(varname), &s, MVT_S8, sizeof(s));
976}
977
978inline void LLMessageSystem::addU8Fast(const char *varname, U8 u)
979{
980 addDataFast(varname, &u, MVT_U8, sizeof(u));
981}
982
983inline void LLMessageSystem::addU8(const char *varname, U8 u)
984{
985 addDataFast(gMessageStringTable.getString(varname), &u, MVT_U8, sizeof(u));
986}
987
988inline void LLMessageSystem::addS16Fast(const char *varname, S16 i)
989{
990 addDataFast(varname, &i, MVT_S16, sizeof(i));
991}
992
993inline void LLMessageSystem::addS16(const char *varname, S16 i)
994{
995 addDataFast(gMessageStringTable.getString(varname), &i, MVT_S16, sizeof(i));
996}
997
998inline void LLMessageSystem::addU16Fast(const char *varname, U16 i)
999{
1000 addDataFast(varname, &i, MVT_U16, sizeof(i));
1001}
1002
1003inline void LLMessageSystem::addU16(const char *varname, U16 i)
1004{
1005 addDataFast(gMessageStringTable.getString(varname), &i, MVT_U16, sizeof(i));
1006}
1007
1008inline void LLMessageSystem::addF32Fast(const char *varname, F32 f)
1009{
1010 addDataFast(varname, &f, MVT_F32, sizeof(f));
1011}
1012
1013inline void LLMessageSystem::addF32(const char *varname, F32 f)
1014{
1015 addDataFast(gMessageStringTable.getString(varname), &f, MVT_F32, sizeof(f));
1016}
1017
1018inline void LLMessageSystem::addS32Fast(const char *varname, S32 s)
1019{
1020 addDataFast(varname, &s, MVT_S32, sizeof(s));
1021}
1022
1023inline void LLMessageSystem::addS32(const char *varname, S32 s)
1024{
1025 addDataFast(gMessageStringTable.getString(varname), &s, MVT_S32, sizeof(s));
1026}
1027
1028inline void LLMessageSystem::addU32Fast(const char *varname, U32 u)
1029{
1030 addDataFast(varname, &u, MVT_U32, sizeof(u));
1031}
1032
1033inline void LLMessageSystem::addU32(const char *varname, U32 u)
1034{
1035 addDataFast(gMessageStringTable.getString(varname), &u, MVT_U32, sizeof(u));
1036}
1037
1038inline void LLMessageSystem::addU64Fast(const char *varname, U64 lu)
1039{
1040 addDataFast(varname, &lu, MVT_U64, sizeof(lu));
1041}
1042
1043inline void LLMessageSystem::addU64(const char *varname, U64 lu)
1044{
1045 addDataFast(gMessageStringTable.getString(varname), &lu, MVT_U64, sizeof(lu));
1046}
1047
1048inline void LLMessageSystem::addF64Fast(const char *varname, F64 d)
1049{
1050 addDataFast(varname, &d, MVT_F64, sizeof(d));
1051}
1052
1053inline void LLMessageSystem::addF64(const char *varname, F64 d)
1054{
1055 addDataFast(gMessageStringTable.getString(varname), &d, MVT_F64, sizeof(d));
1056}
1057
1058inline void LLMessageSystem::addIPAddrFast(const char *varname, U32 u)
1059{
1060 addDataFast(varname, &u, MVT_IP_ADDR, sizeof(u));
1061}
1062
1063inline void LLMessageSystem::addIPAddr(const char *varname, U32 u)
1064{
1065 addDataFast(gMessageStringTable.getString(varname), &u, MVT_IP_ADDR, sizeof(u));
1066}
1067
1068inline void LLMessageSystem::addIPPortFast(const char *varname, U16 u)
1069{
1070 u = htons(u);
1071 addDataFast(varname, &u, MVT_IP_PORT, sizeof(u));
1072}
1073
1074inline void LLMessageSystem::addIPPort(const char *varname, U16 u)
1075{
1076 u = htons(u);
1077 addDataFast(gMessageStringTable.getString(varname), &u, MVT_IP_PORT, sizeof(u));
1078}
1079
1080inline void LLMessageSystem::addBOOLFast(const char* varname, BOOL b)
1081{
1082 // Can't just cast a BOOL (actually a U32) to a U8.
1083 // In some cases the low order bits will be zero.
1084 U8 temp = (b != 0);
1085 addDataFast(varname, &temp, MVT_BOOL, sizeof(temp));
1086}
1087
1088inline void LLMessageSystem::addBOOL(const char* varname, BOOL b)
1089{
1090 // Can't just cast a BOOL (actually a U32) to a U8.
1091 // In some cases the low order bits will be zero.
1092 U8 temp = (b != 0);
1093 addDataFast(gMessageStringTable.getString(varname), &temp, MVT_BOOL, sizeof(temp));
1094}
1095
1096inline void LLMessageSystem::addStringFast(const char* varname, const char* s)
1097{
1098 if (s)
1099 addDataFast( varname, (void *)s, MVT_VARIABLE, (S32)strlen(s) + 1); /* Flawfinder: ignore */
1100 else
1101 addDataFast( varname, NULL, MVT_VARIABLE, 0);
1102}
1103
1104inline void LLMessageSystem::addString(const char* varname, const char* s)
1105{
1106 if (s)
1107 addDataFast( gMessageStringTable.getString(varname), (void *)s, MVT_VARIABLE, (S32)strlen(s) + 1); /* Flawfinder: ignore */
1108 else
1109 addDataFast( gMessageStringTable.getString(varname), NULL, MVT_VARIABLE, 0);
1110}
1111
1112inline void LLMessageSystem::addStringFast(const char* varname, const std::string& s)
1113{
1114 if (s.size())
1115 addDataFast( varname, (void *)s.c_str(), MVT_VARIABLE, (S32)(s.size()) + 1);
1116 else
1117 addDataFast( varname, NULL, MVT_VARIABLE, 0);
1118}
1119
1120inline void LLMessageSystem::addString(const char* varname, const std::string& s)
1121{
1122 if (s.size())
1123 addDataFast( gMessageStringTable.getString(varname), (void *)s.c_str(), MVT_VARIABLE, (S32)(s.size()) + 1);
1124 else
1125 addDataFast( gMessageStringTable.getString(varname), NULL, MVT_VARIABLE, 0);
1126}
1127
1128
1129//-----------------------------------------------------------------------------
1130// Retrieval aliases
1131//-----------------------------------------------------------------------------
1132inline void LLMessageSystem::getS8Fast(const char *block, const char *var, S8 &u, S32 blocknum)
1133{
1134 getDataFast(block, var, &u, sizeof(S8), blocknum);
1135}
1136
1137inline void LLMessageSystem::getS8(const char *block, const char *var, S8 &u, S32 blocknum)
1138{
1139 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &u, sizeof(S8), blocknum);
1140}
1141
1142inline void LLMessageSystem::getU8Fast(const char *block, const char *var, U8 &u, S32 blocknum)
1143{
1144 getDataFast(block, var, &u, sizeof(U8), blocknum);
1145}
1146
1147inline void LLMessageSystem::getU8(const char *block, const char *var, U8 &u, S32 blocknum)
1148{
1149 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &u, sizeof(U8), blocknum);
1150}
1151
1152inline void LLMessageSystem::getBOOLFast(const char *block, const char *var, BOOL &b, S32 blocknum )
1153{
1154 U8 value;
1155 getDataFast(block, var, &value, sizeof(U8), blocknum);
1156 b = (BOOL) value;
1157}
1158
1159inline void LLMessageSystem::getBOOL(const char *block, const char *var, BOOL &b, S32 blocknum )
1160{
1161 U8 value;
1162 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &value, sizeof(U8), blocknum);
1163 b = (BOOL) value;
1164}
1165
1166inline void LLMessageSystem::getS16Fast(const char *block, const char *var, S16 &d, S32 blocknum)
1167{
1168 getDataFast(block, var, &d, sizeof(S16), blocknum);
1169}
1170
1171inline void LLMessageSystem::getS16(const char *block, const char *var, S16 &d, S32 blocknum)
1172{
1173 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(S16), blocknum);
1174}
1175
1176inline void LLMessageSystem::getU16Fast(const char *block, const char *var, U16 &d, S32 blocknum)
1177{
1178 getDataFast(block, var, &d, sizeof(U16), blocknum);
1179}
1180
1181inline void LLMessageSystem::getU16(const char *block, const char *var, U16 &d, S32 blocknum)
1182{
1183 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(U16), blocknum);
1184}
1185
1186inline void LLMessageSystem::getS32Fast(const char *block, const char *var, S32 &d, S32 blocknum)
1187{
1188 getDataFast(block, var, &d, sizeof(S32), blocknum);
1189}
1190
1191inline void LLMessageSystem::getS32(const char *block, const char *var, S32 &d, S32 blocknum)
1192{
1193 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(S32), blocknum);
1194}
1195
1196inline void LLMessageSystem::getU32Fast(const char *block, const char *var, U32 &d, S32 blocknum)
1197{
1198 getDataFast(block, var, &d, sizeof(U32), blocknum);
1199}
1200
1201inline void LLMessageSystem::getU32(const char *block, const char *var, U32 &d, S32 blocknum)
1202{
1203 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(U32), blocknum);
1204}
1205
1206inline void LLMessageSystem::getU64Fast(const char *block, const char *var, U64 &d, S32 blocknum)
1207{
1208 getDataFast(block, var, &d, sizeof(U64), blocknum);
1209}
1210
1211inline void LLMessageSystem::getU64(const char *block, const char *var, U64 &d, S32 blocknum)
1212{
1213 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &d, sizeof(U64), blocknum);
1214}
1215
1216
1217inline void LLMessageSystem::getIPAddrFast(const char *block, const char *var, U32 &u, S32 blocknum)
1218{
1219 getDataFast(block, var, &u, sizeof(U32), blocknum);
1220}
1221
1222inline void LLMessageSystem::getIPAddr(const char *block, const char *var, U32 &u, S32 blocknum)
1223{
1224 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &u, sizeof(U32), blocknum);
1225}
1226
1227inline void LLMessageSystem::getIPPortFast(const char *block, const char *var, U16 &u, S32 blocknum)
1228{
1229 getDataFast(block, var, &u, sizeof(U16), blocknum);
1230 u = ntohs(u);
1231}
1232
1233inline void LLMessageSystem::getIPPort(const char *block, const char *var, U16 &u, S32 blocknum)
1234{
1235 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), &u, sizeof(U16), blocknum);
1236 u = ntohs(u);
1237}
1238
1239
1240inline void LLMessageSystem::getStringFast(const char *block, const char *var, S32 buffer_size, char *s, S32 blocknum )
1241{
1242 s[0] = '\0';
1243 getDataFast(block, var, s, 0, blocknum, buffer_size);
1244 s[buffer_size - 1] = '\0';
1245}
1246
1247inline void LLMessageSystem::getString(const char *block, const char *var, S32 buffer_size, char *s, S32 blocknum )
1248{
1249 s[0] = '\0';
1250 getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), s, 0, blocknum, buffer_size);
1251 s[buffer_size - 1] = '\0';
1252}
1253
1254//----------------------------------------------------------------------------- 918//-----------------------------------------------------------------------------
1255// Transmission aliases 919// Transmission aliases
1256//----------------------------------------------------------------------------- 920//-----------------------------------------------------------------------------
1257//inline S32 LLMessageSystem::sendMessage(U32 ip, U32 port, BOOL zero_code)
1258//{
1259// return sendMessage(LLHost(ip, port), zero_code);
1260//}
1261
1262//inline S32 LLMessageSystem::sendMessage(const char *ip_str, U32 port, BOOL zero_code)
1263//{
1264// return sendMessage(LLHost(ip_str, port), zero_code);
1265//}
1266 921
1267inline S32 LLMessageSystem::sendMessage(const U32 circuit)//, BOOL zero_code) 922inline S32 LLMessageSystem::sendMessage(const U32 circuit)
1268{ 923{
1269 return sendMessage(findHost(circuit));//, zero_code); 924 return sendMessage(findHost(circuit));
1270} 925}
1271 926
1272#endif 927#endif
diff --git a/linden/indra/llmessage/message_prehash.cpp b/linden/indra/llmessage/message_prehash.cpp
index ef01c82..39b3737 100644
--- a/linden/indra/llmessage/message_prehash.cpp
+++ b/linden/indra/llmessage/message_prehash.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -39,7 +40,6 @@ char * _PREHASH_X;
39char * _PREHASH_Y; 40char * _PREHASH_Y;
40char * _PREHASH_Z; 41char * _PREHASH_Z;
41char * _PREHASH_AddFlags; 42char * _PREHASH_AddFlags;
42char * _PREHASH_ReservedNewbie;
43char * _PREHASH_FailureInfo; 43char * _PREHASH_FailureInfo;
44char * _PREHASH_MapData; 44char * _PREHASH_MapData;
45char * _PREHASH_AddItem; 45char * _PREHASH_AddItem;
@@ -108,7 +108,6 @@ char * _PREHASH_RelatedRights;
108char * _PREHASH_RedirectGridX; 108char * _PREHASH_RedirectGridX;
109char * _PREHASH_RedirectGridY; 109char * _PREHASH_RedirectGridY;
110char * _PREHASH_TransferID; 110char * _PREHASH_TransferID;
111char * _PREHASH_Transacted;
112char * _PREHASH_TexturesChanged; 111char * _PREHASH_TexturesChanged;
113char * _PREHASH_UserLookAt; 112char * _PREHASH_UserLookAt;
114char * _PREHASH_TestBlock1; 113char * _PREHASH_TestBlock1;
@@ -135,7 +134,6 @@ char * _PREHASH_SetSimStatusInDatabase;
135char * _PREHASH_SetSimPresenceInDatabase; 134char * _PREHASH_SetSimPresenceInDatabase;
136char * _PREHASH_CameraProperty; 135char * _PREHASH_CameraProperty;
137char * _PREHASH_BrushSize; 136char * _PREHASH_BrushSize;
138char * _PREHASH_StartExpungeProcess;
139char * _PREHASH_SimulatorSetMap; 137char * _PREHASH_SimulatorSetMap;
140char * _PREHASH_RegionPresenceRequestByRegionID; 138char * _PREHASH_RegionPresenceRequestByRegionID;
141char * _PREHASH_ParcelObjectOwnersReply; 139char * _PREHASH_ParcelObjectOwnersReply;
@@ -229,8 +227,8 @@ char * _PREHASH_SimName;
229char * _PREHASH_UserReport; 227char * _PREHASH_UserReport;
230char * _PREHASH_DownloadPriority; 228char * _PREHASH_DownloadPriority;
231char * _PREHASH_ToAgentId; 229char * _PREHASH_ToAgentId;
232char * _PREHASH_Mag;
233char * _PREHASH_DirPopularQuery; 230char * _PREHASH_DirPopularQuery;
231char * _PREHASH_Mag;
234char * _PREHASH_ParcelPropertiesRequestByID; 232char * _PREHASH_ParcelPropertiesRequestByID;
235char * _PREHASH_ObjectLink; 233char * _PREHASH_ObjectLink;
236char * _PREHASH_RpcScriptReplyInbound; 234char * _PREHASH_RpcScriptReplyInbound;
@@ -439,7 +437,6 @@ char * _PREHASH_TerminateFriendship;
439char * _PREHASH_TaskData; 437char * _PREHASH_TaskData;
440char * _PREHASH_SimWideMaxPrims; 438char * _PREHASH_SimWideMaxPrims;
441char * _PREHASH_TotalPrims; 439char * _PREHASH_TotalPrims;
442char * _PREHASH_SourceFilename;
443char * _PREHASH_ProfileBegin; 440char * _PREHASH_ProfileBegin;
444char * _PREHASH_MoneyDetailsRequest; 441char * _PREHASH_MoneyDetailsRequest;
445char * _PREHASH_Request; 442char * _PREHASH_Request;
@@ -486,7 +483,6 @@ char * _PREHASH_ParamInUse;
486char * _PREHASH_GodKickUser; 483char * _PREHASH_GodKickUser;
487char * _PREHASH_PickName; 484char * _PREHASH_PickName;
488char * _PREHASH_TaskName; 485char * _PREHASH_TaskName;
489char * _PREHASH_ParcelGodReserveForNewbie;
490char * _PREHASH_SubType; 486char * _PREHASH_SubType;
491char * _PREHASH_ObjectCount; 487char * _PREHASH_ObjectCount;
492char * _PREHASH_RegionPresenceRequestByHandle; 488char * _PREHASH_RegionPresenceRequestByHandle;
@@ -505,10 +501,13 @@ char * _PREHASH_UpdateParcel;
505char * _PREHASH_ClearAgentSessions; 501char * _PREHASH_ClearAgentSessions;
506char * _PREHASH_SetAlwaysRun; 502char * _PREHASH_SetAlwaysRun;
507char * _PREHASH_NVPair; 503char * _PREHASH_NVPair;
504char * _PREHASH_SearchType;
508char * _PREHASH_ObjectSpinStart; 505char * _PREHASH_ObjectSpinStart;
509char * _PREHASH_UseEstateSun; 506char * _PREHASH_UseEstateSun;
510char * _PREHASH_LogoutBlock; 507char * _PREHASH_LogoutBlock;
508char * _PREHASH_RelayLogControl;
511char * _PREHASH_RegionID; 509char * _PREHASH_RegionID;
510char * _PREHASH_AbuseRegionID;
512char * _PREHASH_Creator; 511char * _PREHASH_Creator;
513char * _PREHASH_ProposalText; 512char * _PREHASH_ProposalText;
514char * _PREHASH_DirEventsReply; 513char * _PREHASH_DirEventsReply;
@@ -553,7 +552,6 @@ char * _PREHASH_MaxY;
553char * _PREHASH_TextureAnim; 552char * _PREHASH_TextureAnim;
554char * _PREHASH_ReturnIDs; 553char * _PREHASH_ReturnIDs;
555char * _PREHASH_Date; 554char * _PREHASH_Date;
556char * _PREHASH_GestureUpdate;
557char * _PREHASH_AgentWearablesUpdate; 555char * _PREHASH_AgentWearablesUpdate;
558char * _PREHASH_AgentDataUpdate; 556char * _PREHASH_AgentDataUpdate;
559char * _PREHASH_Hash; 557char * _PREHASH_Hash;
@@ -575,7 +573,6 @@ char * _PREHASH_HistoryItemData;
575char * _PREHASH_AgentCachedTexture; 573char * _PREHASH_AgentCachedTexture;
576char * _PREHASH_Subject; 574char * _PREHASH_Subject;
577char * _PREHASH_East; 575char * _PREHASH_East;
578char * _PREHASH_GodExpungeUser;
579char * _PREHASH_QueryReplies; 576char * _PREHASH_QueryReplies;
580char * _PREHASH_ObjectCategory; 577char * _PREHASH_ObjectCategory;
581char * _PREHASH_Time; 578char * _PREHASH_Time;
@@ -802,6 +799,7 @@ char * _PREHASH_UnsubscribeLoad;
802char * _PREHASH_Packet; 799char * _PREHASH_Packet;
803char * _PREHASH_UndoLand; 800char * _PREHASH_UndoLand;
804char * _PREHASH_SimAccess; 801char * _PREHASH_SimAccess;
802char * _PREHASH_AbuserID;
805char * _PREHASH_MembershipFee; 803char * _PREHASH_MembershipFee;
806char * _PREHASH_InviteGroupResponse; 804char * _PREHASH_InviteGroupResponse;
807char * _PREHASH_CreateInventoryFolder; 805char * _PREHASH_CreateInventoryFolder;
@@ -939,6 +937,7 @@ char * _PREHASH_ImageNotInDatabase;
939char * _PREHASH_StartDate; 937char * _PREHASH_StartDate;
940char * _PREHASH_AnimID; 938char * _PREHASH_AnimID;
941char * _PREHASH_Serial; 939char * _PREHASH_Serial;
940char * _PREHASH_AbuseRegionName;
942char * _PREHASH_ControlPort; 941char * _PREHASH_ControlPort;
943char * _PREHASH_ModifyLand; 942char * _PREHASH_ModifyLand;
944char * _PREHASH_Digest; 943char * _PREHASH_Digest;
@@ -1003,11 +1002,11 @@ char * _PREHASH_EventFlags;
1003char * _PREHASH_TallyVotes; 1002char * _PREHASH_TallyVotes;
1004char * _PREHASH_Result; 1003char * _PREHASH_Result;
1005char * _PREHASH_LookAt; 1004char * _PREHASH_LookAt;
1005char * _PREHASH_SearchOrder;
1006char * _PREHASH_PayButton; 1006char * _PREHASH_PayButton;
1007char * _PREHASH_SelfCount; 1007char * _PREHASH_SelfCount;
1008char * _PREHASH_PacketCount; 1008char * _PREHASH_PacketCount;
1009char * _PREHASH_ParcelBuyPass; 1009char * _PREHASH_ParcelBuyPass;
1010char * _PREHASH_Identified;
1011char * _PREHASH_OldItemID; 1010char * _PREHASH_OldItemID;
1012char * _PREHASH_RegionPort; 1011char * _PREHASH_RegionPort;
1013char * _PREHASH_PriceEnergyUnit; 1012char * _PREHASH_PriceEnergyUnit;
@@ -1043,7 +1042,6 @@ char * _PREHASH_EconomyDataRequest;
1043char * _PREHASH_TeleportLureRequest; 1042char * _PREHASH_TeleportLureRequest;
1044char * _PREHASH_FolderID; 1043char * _PREHASH_FolderID;
1045char * _PREHASH_RegionHandleRequest; 1044char * _PREHASH_RegionHandleRequest;
1046char * _PREHASH_GestureRequest;
1047char * _PREHASH_ScriptDataRequest; 1045char * _PREHASH_ScriptDataRequest;
1048char * _PREHASH_GroupRoleDataRequest; 1046char * _PREHASH_GroupRoleDataRequest;
1049char * _PREHASH_GroupTitlesRequest; 1047char * _PREHASH_GroupTitlesRequest;
@@ -1187,11 +1185,9 @@ char * _PREHASH_Ratio;
1187char * _PREHASH_JoinGroupReply; 1185char * _PREHASH_JoinGroupReply;
1188char * _PREHASH_LiveHelpGroupReply; 1186char * _PREHASH_LiveHelpGroupReply;
1189char * _PREHASH_Score; 1187char * _PREHASH_Score;
1190char * _PREHASH_ExpungeData;
1191char * _PREHASH_Image; 1188char * _PREHASH_Image;
1192char * _PREHASH_ObjectClickAction; 1189char * _PREHASH_ObjectClickAction;
1193char * _PREHASH_Delta; 1190char * _PREHASH_Delta;
1194char * _PREHASH_InitiateUpload;
1195char * _PREHASH_Parameter; 1191char * _PREHASH_Parameter;
1196char * _PREHASH_Flags; 1192char * _PREHASH_Flags;
1197char * _PREHASH_Plane; 1193char * _PREHASH_Plane;
@@ -1227,7 +1223,6 @@ char * _PREHASH_Disconnect;
1227char * _PREHASH_SimPosition; 1223char * _PREHASH_SimPosition;
1228char * _PREHASH_SimWideTotalPrims; 1224char * _PREHASH_SimWideTotalPrims;
1229char * _PREHASH_Index; 1225char * _PREHASH_Index;
1230char * _PREHASH_BaseFilename;
1231char * _PREHASH_SimFilename; 1226char * _PREHASH_SimFilename;
1232char * _PREHASH_LastOwnerID; 1227char * _PREHASH_LastOwnerID;
1233char * _PREHASH_GroupNoticeRequest; 1228char * _PREHASH_GroupNoticeRequest;
@@ -1312,6 +1307,7 @@ char * _PREHASH_AssetBlock;
1312char * _PREHASH_AcceptNotices; 1307char * _PREHASH_AcceptNotices;
1313char * _PREHASH_SetGroupAcceptNotices; 1308char * _PREHASH_SetGroupAcceptNotices;
1314char * _PREHASH_CloseCircuit; 1309char * _PREHASH_CloseCircuit;
1310char * _PREHASH_LogControl;
1315char * _PREHASH_TeleportFinish; 1311char * _PREHASH_TeleportFinish;
1316char * _PREHASH_PathRevolutions; 1312char * _PREHASH_PathRevolutions;
1317char * _PREHASH_ClassifiedInfoReply; 1313char * _PREHASH_ClassifiedInfoReply;
@@ -1491,7 +1487,6 @@ char * _PREHASH_DirLandReply;
1491char * _PREHASH_SpaceLocationTeleportReply; 1487char * _PREHASH_SpaceLocationTeleportReply;
1492char * _PREHASH_MuteType; 1488char * _PREHASH_MuteType;
1493char * _PREHASH_IMViaEMail; 1489char * _PREHASH_IMViaEMail;
1494char * _PREHASH_StartExpungeProcessAck;
1495char * _PREHASH_RentPrice; 1490char * _PREHASH_RentPrice;
1496char * _PREHASH_GenericMessage; 1491char * _PREHASH_GenericMessage;
1497char * _PREHASH_ChildAgentAlive; 1492char * _PREHASH_ChildAgentAlive;
@@ -1511,7 +1506,6 @@ void init_prehash_data()
1511 _PREHASH_Y = gMessageStringTable.getString("Y"); 1506 _PREHASH_Y = gMessageStringTable.getString("Y");
1512 _PREHASH_Z = gMessageStringTable.getString("Z"); 1507 _PREHASH_Z = gMessageStringTable.getString("Z");
1513 _PREHASH_AddFlags = gMessageStringTable.getString("AddFlags"); 1508 _PREHASH_AddFlags = gMessageStringTable.getString("AddFlags");
1514 _PREHASH_ReservedNewbie = gMessageStringTable.getString("ReservedNewbie");
1515 _PREHASH_FailureInfo = gMessageStringTable.getString("FailureInfo"); 1509 _PREHASH_FailureInfo = gMessageStringTable.getString("FailureInfo");
1516 _PREHASH_MapData = gMessageStringTable.getString("MapData"); 1510 _PREHASH_MapData = gMessageStringTable.getString("MapData");
1517 _PREHASH_AddItem = gMessageStringTable.getString("AddItem"); 1511 _PREHASH_AddItem = gMessageStringTable.getString("AddItem");
@@ -1580,7 +1574,6 @@ void init_prehash_data()
1580 _PREHASH_RedirectGridX = gMessageStringTable.getString("RedirectGridX"); 1574 _PREHASH_RedirectGridX = gMessageStringTable.getString("RedirectGridX");
1581 _PREHASH_RedirectGridY = gMessageStringTable.getString("RedirectGridY"); 1575 _PREHASH_RedirectGridY = gMessageStringTable.getString("RedirectGridY");
1582 _PREHASH_TransferID = gMessageStringTable.getString("TransferID"); 1576 _PREHASH_TransferID = gMessageStringTable.getString("TransferID");
1583 _PREHASH_Transacted = gMessageStringTable.getString("Transacted");
1584 _PREHASH_TexturesChanged = gMessageStringTable.getString("TexturesChanged"); 1577 _PREHASH_TexturesChanged = gMessageStringTable.getString("TexturesChanged");
1585 _PREHASH_UserLookAt = gMessageStringTable.getString("UserLookAt"); 1578 _PREHASH_UserLookAt = gMessageStringTable.getString("UserLookAt");
1586 _PREHASH_TestBlock1 = gMessageStringTable.getString("TestBlock1"); 1579 _PREHASH_TestBlock1 = gMessageStringTable.getString("TestBlock1");
@@ -1607,7 +1600,6 @@ void init_prehash_data()
1607 _PREHASH_SetSimPresenceInDatabase = gMessageStringTable.getString("SetSimPresenceInDatabase"); 1600 _PREHASH_SetSimPresenceInDatabase = gMessageStringTable.getString("SetSimPresenceInDatabase");
1608 _PREHASH_CameraProperty = gMessageStringTable.getString("CameraProperty"); 1601 _PREHASH_CameraProperty = gMessageStringTable.getString("CameraProperty");
1609 _PREHASH_BrushSize = gMessageStringTable.getString("BrushSize"); 1602 _PREHASH_BrushSize = gMessageStringTable.getString("BrushSize");
1610 _PREHASH_StartExpungeProcess = gMessageStringTable.getString("StartExpungeProcess");
1611 _PREHASH_SimulatorSetMap = gMessageStringTable.getString("SimulatorSetMap"); 1603 _PREHASH_SimulatorSetMap = gMessageStringTable.getString("SimulatorSetMap");
1612 _PREHASH_RegionPresenceRequestByRegionID = gMessageStringTable.getString("RegionPresenceRequestByRegionID"); 1604 _PREHASH_RegionPresenceRequestByRegionID = gMessageStringTable.getString("RegionPresenceRequestByRegionID");
1613 _PREHASH_ParcelObjectOwnersReply = gMessageStringTable.getString("ParcelObjectOwnersReply"); 1605 _PREHASH_ParcelObjectOwnersReply = gMessageStringTable.getString("ParcelObjectOwnersReply");
@@ -1701,8 +1693,8 @@ void init_prehash_data()
1701 _PREHASH_UserReport = gMessageStringTable.getString("UserReport"); 1693 _PREHASH_UserReport = gMessageStringTable.getString("UserReport");
1702 _PREHASH_DownloadPriority = gMessageStringTable.getString("DownloadPriority"); 1694 _PREHASH_DownloadPriority = gMessageStringTable.getString("DownloadPriority");
1703 _PREHASH_ToAgentId = gMessageStringTable.getString("ToAgentId"); 1695 _PREHASH_ToAgentId = gMessageStringTable.getString("ToAgentId");
1704 _PREHASH_Mag = gMessageStringTable.getString("Mag");
1705 _PREHASH_DirPopularQuery = gMessageStringTable.getString("DirPopularQuery"); 1696 _PREHASH_DirPopularQuery = gMessageStringTable.getString("DirPopularQuery");
1697 _PREHASH_Mag = gMessageStringTable.getString("Mag");
1706 _PREHASH_ParcelPropertiesRequestByID = gMessageStringTable.getString("ParcelPropertiesRequestByID"); 1698 _PREHASH_ParcelPropertiesRequestByID = gMessageStringTable.getString("ParcelPropertiesRequestByID");
1707 _PREHASH_ObjectLink = gMessageStringTable.getString("ObjectLink"); 1699 _PREHASH_ObjectLink = gMessageStringTable.getString("ObjectLink");
1708 _PREHASH_RpcScriptReplyInbound = gMessageStringTable.getString("RpcScriptReplyInbound"); 1700 _PREHASH_RpcScriptReplyInbound = gMessageStringTable.getString("RpcScriptReplyInbound");
@@ -1911,7 +1903,6 @@ void init_prehash_data()
1911 _PREHASH_TaskData = gMessageStringTable.getString("TaskData"); 1903 _PREHASH_TaskData = gMessageStringTable.getString("TaskData");
1912 _PREHASH_SimWideMaxPrims = gMessageStringTable.getString("SimWideMaxPrims"); 1904 _PREHASH_SimWideMaxPrims = gMessageStringTable.getString("SimWideMaxPrims");
1913 _PREHASH_TotalPrims = gMessageStringTable.getString("TotalPrims"); 1905 _PREHASH_TotalPrims = gMessageStringTable.getString("TotalPrims");
1914 _PREHASH_SourceFilename = gMessageStringTable.getString("SourceFilename");
1915 _PREHASH_ProfileBegin = gMessageStringTable.getString("ProfileBegin"); 1906 _PREHASH_ProfileBegin = gMessageStringTable.getString("ProfileBegin");
1916 _PREHASH_MoneyDetailsRequest = gMessageStringTable.getString("MoneyDetailsRequest"); 1907 _PREHASH_MoneyDetailsRequest = gMessageStringTable.getString("MoneyDetailsRequest");
1917 _PREHASH_Request = gMessageStringTable.getString("Request"); 1908 _PREHASH_Request = gMessageStringTable.getString("Request");
@@ -1958,7 +1949,6 @@ void init_prehash_data()
1958 _PREHASH_GodKickUser = gMessageStringTable.getString("GodKickUser"); 1949 _PREHASH_GodKickUser = gMessageStringTable.getString("GodKickUser");
1959 _PREHASH_PickName = gMessageStringTable.getString("PickName"); 1950 _PREHASH_PickName = gMessageStringTable.getString("PickName");
1960 _PREHASH_TaskName = gMessageStringTable.getString("TaskName"); 1951 _PREHASH_TaskName = gMessageStringTable.getString("TaskName");
1961 _PREHASH_ParcelGodReserveForNewbie = gMessageStringTable.getString("ParcelGodReserveForNewbie");
1962 _PREHASH_SubType = gMessageStringTable.getString("SubType"); 1952 _PREHASH_SubType = gMessageStringTable.getString("SubType");
1963 _PREHASH_ObjectCount = gMessageStringTable.getString("ObjectCount"); 1953 _PREHASH_ObjectCount = gMessageStringTable.getString("ObjectCount");
1964 _PREHASH_RegionPresenceRequestByHandle = gMessageStringTable.getString("RegionPresenceRequestByHandle"); 1954 _PREHASH_RegionPresenceRequestByHandle = gMessageStringTable.getString("RegionPresenceRequestByHandle");
@@ -1977,10 +1967,13 @@ void init_prehash_data()
1977 _PREHASH_ClearAgentSessions = gMessageStringTable.getString("ClearAgentSessions"); 1967 _PREHASH_ClearAgentSessions = gMessageStringTable.getString("ClearAgentSessions");
1978 _PREHASH_SetAlwaysRun = gMessageStringTable.getString("SetAlwaysRun"); 1968 _PREHASH_SetAlwaysRun = gMessageStringTable.getString("SetAlwaysRun");
1979 _PREHASH_NVPair = gMessageStringTable.getString("NVPair"); 1969 _PREHASH_NVPair = gMessageStringTable.getString("NVPair");
1970 _PREHASH_SearchType = gMessageStringTable.getString("SearchType");
1980 _PREHASH_ObjectSpinStart = gMessageStringTable.getString("ObjectSpinStart"); 1971 _PREHASH_ObjectSpinStart = gMessageStringTable.getString("ObjectSpinStart");
1981 _PREHASH_UseEstateSun = gMessageStringTable.getString("UseEstateSun"); 1972 _PREHASH_UseEstateSun = gMessageStringTable.getString("UseEstateSun");
1982 _PREHASH_LogoutBlock = gMessageStringTable.getString("LogoutBlock"); 1973 _PREHASH_LogoutBlock = gMessageStringTable.getString("LogoutBlock");
1974 _PREHASH_RelayLogControl = gMessageStringTable.getString("RelayLogControl");
1983 _PREHASH_RegionID = gMessageStringTable.getString("RegionID"); 1975 _PREHASH_RegionID = gMessageStringTable.getString("RegionID");
1976 _PREHASH_AbuseRegionID = gMessageStringTable.getString("AbuseRegionID");
1984 _PREHASH_Creator = gMessageStringTable.getString("Creator"); 1977 _PREHASH_Creator = gMessageStringTable.getString("Creator");
1985 _PREHASH_ProposalText = gMessageStringTable.getString("ProposalText"); 1978 _PREHASH_ProposalText = gMessageStringTable.getString("ProposalText");
1986 _PREHASH_DirEventsReply = gMessageStringTable.getString("DirEventsReply"); 1979 _PREHASH_DirEventsReply = gMessageStringTable.getString("DirEventsReply");
@@ -2025,7 +2018,6 @@ void init_prehash_data()
2025 _PREHASH_TextureAnim = gMessageStringTable.getString("TextureAnim"); 2018 _PREHASH_TextureAnim = gMessageStringTable.getString("TextureAnim");
2026 _PREHASH_ReturnIDs = gMessageStringTable.getString("ReturnIDs"); 2019 _PREHASH_ReturnIDs = gMessageStringTable.getString("ReturnIDs");
2027 _PREHASH_Date = gMessageStringTable.getString("Date"); 2020 _PREHASH_Date = gMessageStringTable.getString("Date");
2028 _PREHASH_GestureUpdate = gMessageStringTable.getString("GestureUpdate");
2029 _PREHASH_AgentWearablesUpdate = gMessageStringTable.getString("AgentWearablesUpdate"); 2021 _PREHASH_AgentWearablesUpdate = gMessageStringTable.getString("AgentWearablesUpdate");
2030 _PREHASH_AgentDataUpdate = gMessageStringTable.getString("AgentDataUpdate"); 2022 _PREHASH_AgentDataUpdate = gMessageStringTable.getString("AgentDataUpdate");
2031 _PREHASH_Hash = gMessageStringTable.getString("Hash"); 2023 _PREHASH_Hash = gMessageStringTable.getString("Hash");
@@ -2047,7 +2039,6 @@ void init_prehash_data()
2047 _PREHASH_AgentCachedTexture = gMessageStringTable.getString("AgentCachedTexture"); 2039 _PREHASH_AgentCachedTexture = gMessageStringTable.getString("AgentCachedTexture");
2048 _PREHASH_Subject = gMessageStringTable.getString("Subject"); 2040 _PREHASH_Subject = gMessageStringTable.getString("Subject");
2049 _PREHASH_East = gMessageStringTable.getString("East"); 2041 _PREHASH_East = gMessageStringTable.getString("East");
2050 _PREHASH_GodExpungeUser = gMessageStringTable.getString("GodExpungeUser");
2051 _PREHASH_QueryReplies = gMessageStringTable.getString("QueryReplies"); 2042 _PREHASH_QueryReplies = gMessageStringTable.getString("QueryReplies");
2052 _PREHASH_ObjectCategory = gMessageStringTable.getString("ObjectCategory"); 2043 _PREHASH_ObjectCategory = gMessageStringTable.getString("ObjectCategory");
2053 _PREHASH_Time = gMessageStringTable.getString("Time"); 2044 _PREHASH_Time = gMessageStringTable.getString("Time");
@@ -2274,6 +2265,7 @@ void init_prehash_data()
2274 _PREHASH_Packet = gMessageStringTable.getString("Packet"); 2265 _PREHASH_Packet = gMessageStringTable.getString("Packet");
2275 _PREHASH_UndoLand = gMessageStringTable.getString("UndoLand"); 2266 _PREHASH_UndoLand = gMessageStringTable.getString("UndoLand");
2276 _PREHASH_SimAccess = gMessageStringTable.getString("SimAccess"); 2267 _PREHASH_SimAccess = gMessageStringTable.getString("SimAccess");
2268 _PREHASH_AbuserID = gMessageStringTable.getString("AbuserID");
2277 _PREHASH_MembershipFee = gMessageStringTable.getString("MembershipFee"); 2269 _PREHASH_MembershipFee = gMessageStringTable.getString("MembershipFee");
2278 _PREHASH_InviteGroupResponse = gMessageStringTable.getString("InviteGroupResponse"); 2270 _PREHASH_InviteGroupResponse = gMessageStringTable.getString("InviteGroupResponse");
2279 _PREHASH_CreateInventoryFolder = gMessageStringTable.getString("CreateInventoryFolder"); 2271 _PREHASH_CreateInventoryFolder = gMessageStringTable.getString("CreateInventoryFolder");
@@ -2411,6 +2403,7 @@ void init_prehash_data()
2411 _PREHASH_StartDate = gMessageStringTable.getString("StartDate"); 2403 _PREHASH_StartDate = gMessageStringTable.getString("StartDate");
2412 _PREHASH_AnimID = gMessageStringTable.getString("AnimID"); 2404 _PREHASH_AnimID = gMessageStringTable.getString("AnimID");
2413 _PREHASH_Serial = gMessageStringTable.getString("Serial"); 2405 _PREHASH_Serial = gMessageStringTable.getString("Serial");
2406 _PREHASH_AbuseRegionName = gMessageStringTable.getString("AbuseRegionName");
2414 _PREHASH_ControlPort = gMessageStringTable.getString("ControlPort"); 2407 _PREHASH_ControlPort = gMessageStringTable.getString("ControlPort");
2415 _PREHASH_ModifyLand = gMessageStringTable.getString("ModifyLand"); 2408 _PREHASH_ModifyLand = gMessageStringTable.getString("ModifyLand");
2416 _PREHASH_Digest = gMessageStringTable.getString("Digest"); 2409 _PREHASH_Digest = gMessageStringTable.getString("Digest");
@@ -2475,11 +2468,11 @@ void init_prehash_data()
2475 _PREHASH_TallyVotes = gMessageStringTable.getString("TallyVotes"); 2468 _PREHASH_TallyVotes = gMessageStringTable.getString("TallyVotes");
2476 _PREHASH_Result = gMessageStringTable.getString("Result"); 2469 _PREHASH_Result = gMessageStringTable.getString("Result");
2477 _PREHASH_LookAt = gMessageStringTable.getString("LookAt"); 2470 _PREHASH_LookAt = gMessageStringTable.getString("LookAt");
2471 _PREHASH_SearchOrder = gMessageStringTable.getString("SearchOrder");
2478 _PREHASH_PayButton = gMessageStringTable.getString("PayButton"); 2472 _PREHASH_PayButton = gMessageStringTable.getString("PayButton");
2479 _PREHASH_SelfCount = gMessageStringTable.getString("SelfCount"); 2473 _PREHASH_SelfCount = gMessageStringTable.getString("SelfCount");
2480 _PREHASH_PacketCount = gMessageStringTable.getString("PacketCount"); 2474 _PREHASH_PacketCount = gMessageStringTable.getString("PacketCount");
2481 _PREHASH_ParcelBuyPass = gMessageStringTable.getString("ParcelBuyPass"); 2475 _PREHASH_ParcelBuyPass = gMessageStringTable.getString("ParcelBuyPass");
2482 _PREHASH_Identified = gMessageStringTable.getString("Identified");
2483 _PREHASH_OldItemID = gMessageStringTable.getString("OldItemID"); 2476 _PREHASH_OldItemID = gMessageStringTable.getString("OldItemID");
2484 _PREHASH_RegionPort = gMessageStringTable.getString("RegionPort"); 2477 _PREHASH_RegionPort = gMessageStringTable.getString("RegionPort");
2485 _PREHASH_PriceEnergyUnit = gMessageStringTable.getString("PriceEnergyUnit"); 2478 _PREHASH_PriceEnergyUnit = gMessageStringTable.getString("PriceEnergyUnit");
@@ -2515,7 +2508,6 @@ void init_prehash_data()
2515 _PREHASH_TeleportLureRequest = gMessageStringTable.getString("TeleportLureRequest"); 2508 _PREHASH_TeleportLureRequest = gMessageStringTable.getString("TeleportLureRequest");
2516 _PREHASH_FolderID = gMessageStringTable.getString("FolderID"); 2509 _PREHASH_FolderID = gMessageStringTable.getString("FolderID");
2517 _PREHASH_RegionHandleRequest = gMessageStringTable.getString("RegionHandleRequest"); 2510 _PREHASH_RegionHandleRequest = gMessageStringTable.getString("RegionHandleRequest");
2518 _PREHASH_GestureRequest = gMessageStringTable.getString("GestureRequest");
2519 _PREHASH_ScriptDataRequest = gMessageStringTable.getString("ScriptDataRequest"); 2511 _PREHASH_ScriptDataRequest = gMessageStringTable.getString("ScriptDataRequest");
2520 _PREHASH_GroupRoleDataRequest = gMessageStringTable.getString("GroupRoleDataRequest"); 2512 _PREHASH_GroupRoleDataRequest = gMessageStringTable.getString("GroupRoleDataRequest");
2521 _PREHASH_GroupTitlesRequest = gMessageStringTable.getString("GroupTitlesRequest"); 2513 _PREHASH_GroupTitlesRequest = gMessageStringTable.getString("GroupTitlesRequest");
@@ -2659,11 +2651,9 @@ void init_prehash_data()
2659 _PREHASH_JoinGroupReply = gMessageStringTable.getString("JoinGroupReply"); 2651 _PREHASH_JoinGroupReply = gMessageStringTable.getString("JoinGroupReply");
2660 _PREHASH_LiveHelpGroupReply = gMessageStringTable.getString("LiveHelpGroupReply"); 2652 _PREHASH_LiveHelpGroupReply = gMessageStringTable.getString("LiveHelpGroupReply");
2661 _PREHASH_Score = gMessageStringTable.getString("Score"); 2653 _PREHASH_Score = gMessageStringTable.getString("Score");
2662 _PREHASH_ExpungeData = gMessageStringTable.getString("ExpungeData");
2663 _PREHASH_Image = gMessageStringTable.getString("Image"); 2654 _PREHASH_Image = gMessageStringTable.getString("Image");
2664 _PREHASH_ObjectClickAction = gMessageStringTable.getString("ObjectClickAction"); 2655 _PREHASH_ObjectClickAction = gMessageStringTable.getString("ObjectClickAction");
2665 _PREHASH_Delta = gMessageStringTable.getString("Delta"); 2656 _PREHASH_Delta = gMessageStringTable.getString("Delta");
2666 _PREHASH_InitiateUpload = gMessageStringTable.getString("InitiateUpload");
2667 _PREHASH_Parameter = gMessageStringTable.getString("Parameter"); 2657 _PREHASH_Parameter = gMessageStringTable.getString("Parameter");
2668 _PREHASH_Flags = gMessageStringTable.getString("Flags"); 2658 _PREHASH_Flags = gMessageStringTable.getString("Flags");
2669 _PREHASH_Plane = gMessageStringTable.getString("Plane"); 2659 _PREHASH_Plane = gMessageStringTable.getString("Plane");
@@ -2699,7 +2689,6 @@ void init_prehash_data()
2699 _PREHASH_SimPosition = gMessageStringTable.getString("SimPosition"); 2689 _PREHASH_SimPosition = gMessageStringTable.getString("SimPosition");
2700 _PREHASH_SimWideTotalPrims = gMessageStringTable.getString("SimWideTotalPrims"); 2690 _PREHASH_SimWideTotalPrims = gMessageStringTable.getString("SimWideTotalPrims");
2701 _PREHASH_Index = gMessageStringTable.getString("Index"); 2691 _PREHASH_Index = gMessageStringTable.getString("Index");
2702 _PREHASH_BaseFilename = gMessageStringTable.getString("BaseFilename");
2703 _PREHASH_SimFilename = gMessageStringTable.getString("SimFilename"); 2692 _PREHASH_SimFilename = gMessageStringTable.getString("SimFilename");
2704 _PREHASH_LastOwnerID = gMessageStringTable.getString("LastOwnerID"); 2693 _PREHASH_LastOwnerID = gMessageStringTable.getString("LastOwnerID");
2705 _PREHASH_GroupNoticeRequest = gMessageStringTable.getString("GroupNoticeRequest"); 2694 _PREHASH_GroupNoticeRequest = gMessageStringTable.getString("GroupNoticeRequest");
@@ -2784,6 +2773,7 @@ void init_prehash_data()
2784 _PREHASH_AcceptNotices = gMessageStringTable.getString("AcceptNotices"); 2773 _PREHASH_AcceptNotices = gMessageStringTable.getString("AcceptNotices");
2785 _PREHASH_SetGroupAcceptNotices = gMessageStringTable.getString("SetGroupAcceptNotices"); 2774 _PREHASH_SetGroupAcceptNotices = gMessageStringTable.getString("SetGroupAcceptNotices");
2786 _PREHASH_CloseCircuit = gMessageStringTable.getString("CloseCircuit"); 2775 _PREHASH_CloseCircuit = gMessageStringTable.getString("CloseCircuit");
2776 _PREHASH_LogControl = gMessageStringTable.getString("LogControl");
2787 _PREHASH_TeleportFinish = gMessageStringTable.getString("TeleportFinish"); 2777 _PREHASH_TeleportFinish = gMessageStringTable.getString("TeleportFinish");
2788 _PREHASH_PathRevolutions = gMessageStringTable.getString("PathRevolutions"); 2778 _PREHASH_PathRevolutions = gMessageStringTable.getString("PathRevolutions");
2789 _PREHASH_ClassifiedInfoReply = gMessageStringTable.getString("ClassifiedInfoReply"); 2779 _PREHASH_ClassifiedInfoReply = gMessageStringTable.getString("ClassifiedInfoReply");
@@ -2963,7 +2953,6 @@ void init_prehash_data()
2963 _PREHASH_SpaceLocationTeleportReply = gMessageStringTable.getString("SpaceLocationTeleportReply"); 2953 _PREHASH_SpaceLocationTeleportReply = gMessageStringTable.getString("SpaceLocationTeleportReply");
2964 _PREHASH_MuteType = gMessageStringTable.getString("MuteType"); 2954 _PREHASH_MuteType = gMessageStringTable.getString("MuteType");
2965 _PREHASH_IMViaEMail = gMessageStringTable.getString("IMViaEMail"); 2955 _PREHASH_IMViaEMail = gMessageStringTable.getString("IMViaEMail");
2966 _PREHASH_StartExpungeProcessAck = gMessageStringTable.getString("StartExpungeProcessAck");
2967 _PREHASH_RentPrice = gMessageStringTable.getString("RentPrice"); 2956 _PREHASH_RentPrice = gMessageStringTable.getString("RentPrice");
2968 _PREHASH_GenericMessage = gMessageStringTable.getString("GenericMessage"); 2957 _PREHASH_GenericMessage = gMessageStringTable.getString("GenericMessage");
2969 _PREHASH_ChildAgentAlive = gMessageStringTable.getString("ChildAgentAlive"); 2958 _PREHASH_ChildAgentAlive = gMessageStringTable.getString("ChildAgentAlive");
diff --git a/linden/indra/llmessage/message_prehash.h b/linden/indra/llmessage/message_prehash.h
index 9cb4884..84c769e 100644
--- a/linden/indra/llmessage/message_prehash.h
+++ b/linden/indra/llmessage/message_prehash.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc. 5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -39,7 +40,6 @@ extern char * _PREHASH_X;
39extern char * _PREHASH_Y; 40extern char * _PREHASH_Y;
40extern char * _PREHASH_Z; 41extern char * _PREHASH_Z;
41extern char * _PREHASH_AddFlags; 42extern char * _PREHASH_AddFlags;
42extern char * _PREHASH_ReservedNewbie;
43extern char * _PREHASH_FailureInfo; 43extern char * _PREHASH_FailureInfo;
44extern char * _PREHASH_MapData; 44extern char * _PREHASH_MapData;
45extern char * _PREHASH_AddItem; 45extern char * _PREHASH_AddItem;
@@ -108,7 +108,6 @@ extern char * _PREHASH_RelatedRights;
108extern char * _PREHASH_RedirectGridX; 108extern char * _PREHASH_RedirectGridX;
109extern char * _PREHASH_RedirectGridY; 109extern char * _PREHASH_RedirectGridY;
110extern char * _PREHASH_TransferID; 110extern char * _PREHASH_TransferID;
111extern char * _PREHASH_Transacted;
112extern char * _PREHASH_TexturesChanged; 111extern char * _PREHASH_TexturesChanged;
113extern char * _PREHASH_UserLookAt; 112extern char * _PREHASH_UserLookAt;
114extern char * _PREHASH_TestBlock1; 113extern char * _PREHASH_TestBlock1;
@@ -135,7 +134,6 @@ extern char * _PREHASH_SetSimStatusInDatabase;
135extern char * _PREHASH_SetSimPresenceInDatabase; 134extern char * _PREHASH_SetSimPresenceInDatabase;
136extern char * _PREHASH_CameraProperty; 135extern char * _PREHASH_CameraProperty;
137extern char * _PREHASH_BrushSize; 136extern char * _PREHASH_BrushSize;
138extern char * _PREHASH_StartExpungeProcess;
139extern char * _PREHASH_SimulatorSetMap; 137extern char * _PREHASH_SimulatorSetMap;
140extern char * _PREHASH_RegionPresenceRequestByRegionID; 138extern char * _PREHASH_RegionPresenceRequestByRegionID;
141extern char * _PREHASH_ParcelObjectOwnersReply; 139extern char * _PREHASH_ParcelObjectOwnersReply;
@@ -229,8 +227,8 @@ extern char * _PREHASH_SimName;
229extern char * _PREHASH_UserReport; 227extern char * _PREHASH_UserReport;
230extern char * _PREHASH_DownloadPriority; 228extern char * _PREHASH_DownloadPriority;
231extern char * _PREHASH_ToAgentId; 229extern char * _PREHASH_ToAgentId;
232extern char * _PREHASH_Mag;
233extern char * _PREHASH_DirPopularQuery; 230extern char * _PREHASH_DirPopularQuery;
231extern char * _PREHASH_Mag;
234extern char * _PREHASH_ParcelPropertiesRequestByID; 232extern char * _PREHASH_ParcelPropertiesRequestByID;
235extern char * _PREHASH_ObjectLink; 233extern char * _PREHASH_ObjectLink;
236extern char * _PREHASH_RpcScriptReplyInbound; 234extern char * _PREHASH_RpcScriptReplyInbound;
@@ -439,7 +437,6 @@ extern char * _PREHASH_TerminateFriendship;
439extern char * _PREHASH_TaskData; 437extern char * _PREHASH_TaskData;
440extern char * _PREHASH_SimWideMaxPrims; 438extern char * _PREHASH_SimWideMaxPrims;
441extern char * _PREHASH_TotalPrims; 439extern char * _PREHASH_TotalPrims;
442extern char * _PREHASH_SourceFilename;
443extern char * _PREHASH_ProfileBegin; 440extern char * _PREHASH_ProfileBegin;
444extern char * _PREHASH_MoneyDetailsRequest; 441extern char * _PREHASH_MoneyDetailsRequest;
445extern char * _PREHASH_Request; 442extern char * _PREHASH_Request;
@@ -486,7 +483,6 @@ extern char * _PREHASH_ParamInUse;
486extern char * _PREHASH_GodKickUser; 483extern char * _PREHASH_GodKickUser;
487extern char * _PREHASH_PickName; 484extern char * _PREHASH_PickName;
488extern char * _PREHASH_TaskName; 485extern char * _PREHASH_TaskName;
489extern char * _PREHASH_ParcelGodReserveForNewbie;
490extern char * _PREHASH_SubType; 486extern char * _PREHASH_SubType;
491extern char * _PREHASH_ObjectCount; 487extern char * _PREHASH_ObjectCount;
492extern char * _PREHASH_RegionPresenceRequestByHandle; 488extern char * _PREHASH_RegionPresenceRequestByHandle;
@@ -505,10 +501,13 @@ extern char * _PREHASH_UpdateParcel;
505extern char * _PREHASH_ClearAgentSessions; 501extern char * _PREHASH_ClearAgentSessions;
506extern char * _PREHASH_SetAlwaysRun; 502extern char * _PREHASH_SetAlwaysRun;
507extern char * _PREHASH_NVPair; 503extern char * _PREHASH_NVPair;
504extern char * _PREHASH_SearchType;
508extern char * _PREHASH_ObjectSpinStart; 505extern char * _PREHASH_ObjectSpinStart;
509extern char * _PREHASH_UseEstateSun; 506extern char * _PREHASH_UseEstateSun;
510extern char * _PREHASH_LogoutBlock; 507extern char * _PREHASH_LogoutBlock;
508extern char * _PREHASH_RelayLogControl;
511extern char * _PREHASH_RegionID; 509extern char * _PREHASH_RegionID;
510extern char * _PREHASH_AbuseRegionID;
512extern char * _PREHASH_Creator; 511extern char * _PREHASH_Creator;
513extern char * _PREHASH_ProposalText; 512extern char * _PREHASH_ProposalText;
514extern char * _PREHASH_DirEventsReply; 513extern char * _PREHASH_DirEventsReply;
@@ -553,7 +552,6 @@ extern char * _PREHASH_MaxY;
553extern char * _PREHASH_TextureAnim; 552extern char * _PREHASH_TextureAnim;
554extern char * _PREHASH_ReturnIDs; 553extern char * _PREHASH_ReturnIDs;
555extern char * _PREHASH_Date; 554extern char * _PREHASH_Date;
556extern char * _PREHASH_GestureUpdate;
557extern char * _PREHASH_AgentWearablesUpdate; 555extern char * _PREHASH_AgentWearablesUpdate;
558extern char * _PREHASH_AgentDataUpdate; 556extern char * _PREHASH_AgentDataUpdate;
559extern char * _PREHASH_Hash; 557extern char * _PREHASH_Hash;
@@ -575,7 +573,6 @@ extern char * _PREHASH_HistoryItemData;
575extern char * _PREHASH_AgentCachedTexture; 573extern char * _PREHASH_AgentCachedTexture;
576extern char * _PREHASH_Subject; 574extern char * _PREHASH_Subject;
577extern char * _PREHASH_East; 575extern char * _PREHASH_East;
578extern char * _PREHASH_GodExpungeUser;
579extern char * _PREHASH_QueryReplies; 576extern char * _PREHASH_QueryReplies;
580extern char * _PREHASH_ObjectCategory; 577extern char * _PREHASH_ObjectCategory;
581extern char * _PREHASH_Time; 578extern char * _PREHASH_Time;
@@ -802,6 +799,7 @@ extern char * _PREHASH_UnsubscribeLoad;
802extern char * _PREHASH_Packet; 799extern char * _PREHASH_Packet;
803extern char * _PREHASH_UndoLand; 800extern char * _PREHASH_UndoLand;
804extern char * _PREHASH_SimAccess; 801extern char * _PREHASH_SimAccess;
802extern char * _PREHASH_AbuserID;
805extern char * _PREHASH_MembershipFee; 803extern char * _PREHASH_MembershipFee;
806extern char * _PREHASH_InviteGroupResponse; 804extern char * _PREHASH_InviteGroupResponse;
807extern char * _PREHASH_CreateInventoryFolder; 805extern char * _PREHASH_CreateInventoryFolder;
@@ -939,6 +937,7 @@ extern char * _PREHASH_ImageNotInDatabase;
939extern char * _PREHASH_StartDate; 937extern char * _PREHASH_StartDate;
940extern char * _PREHASH_AnimID; 938extern char * _PREHASH_AnimID;
941extern char * _PREHASH_Serial; 939extern char * _PREHASH_Serial;
940extern char * _PREHASH_AbuseRegionName;
942extern char * _PREHASH_ControlPort; 941extern char * _PREHASH_ControlPort;
943extern char * _PREHASH_ModifyLand; 942extern char * _PREHASH_ModifyLand;
944extern char * _PREHASH_Digest; 943extern char * _PREHASH_Digest;
@@ -1003,11 +1002,11 @@ extern char * _PREHASH_EventFlags;
1003extern char * _PREHASH_TallyVotes; 1002extern char * _PREHASH_TallyVotes;
1004extern char * _PREHASH_Result; 1003extern char * _PREHASH_Result;
1005extern char * _PREHASH_LookAt; 1004extern char * _PREHASH_LookAt;
1005extern char * _PREHASH_SearchOrder;
1006extern char * _PREHASH_PayButton; 1006extern char * _PREHASH_PayButton;
1007extern char * _PREHASH_SelfCount; 1007extern char * _PREHASH_SelfCount;
1008extern char * _PREHASH_PacketCount; 1008extern char * _PREHASH_PacketCount;
1009extern char * _PREHASH_ParcelBuyPass; 1009extern char * _PREHASH_ParcelBuyPass;
1010extern char * _PREHASH_Identified;
1011extern char * _PREHASH_OldItemID; 1010extern char * _PREHASH_OldItemID;
1012extern char * _PREHASH_RegionPort; 1011extern char * _PREHASH_RegionPort;
1013extern char * _PREHASH_PriceEnergyUnit; 1012extern char * _PREHASH_PriceEnergyUnit;
@@ -1043,7 +1042,6 @@ extern char * _PREHASH_EconomyDataRequest;
1043extern char * _PREHASH_TeleportLureRequest; 1042extern char * _PREHASH_TeleportLureRequest;
1044extern char * _PREHASH_FolderID; 1043extern char * _PREHASH_FolderID;
1045extern char * _PREHASH_RegionHandleRequest; 1044extern char * _PREHASH_RegionHandleRequest;
1046extern char * _PREHASH_GestureRequest;
1047extern char * _PREHASH_ScriptDataRequest; 1045extern char * _PREHASH_ScriptDataRequest;
1048extern char * _PREHASH_GroupRoleDataRequest; 1046extern char * _PREHASH_GroupRoleDataRequest;
1049extern char * _PREHASH_GroupTitlesRequest; 1047extern char * _PREHASH_GroupTitlesRequest;
@@ -1187,11 +1185,9 @@ extern char * _PREHASH_Ratio;
1187extern char * _PREHASH_JoinGroupReply; 1185extern char * _PREHASH_JoinGroupReply;
1188extern char * _PREHASH_LiveHelpGroupReply; 1186extern char * _PREHASH_LiveHelpGroupReply;
1189extern char * _PREHASH_Score; 1187extern char * _PREHASH_Score;
1190extern char * _PREHASH_ExpungeData;
1191extern char * _PREHASH_Image; 1188extern char * _PREHASH_Image;
1192extern char * _PREHASH_ObjectClickAction; 1189extern char * _PREHASH_ObjectClickAction;
1193extern char * _PREHASH_Delta; 1190extern char * _PREHASH_Delta;
1194extern char * _PREHASH_InitiateUpload;
1195extern char * _PREHASH_Parameter; 1191extern char * _PREHASH_Parameter;
1196extern char * _PREHASH_Flags; 1192extern char * _PREHASH_Flags;
1197extern char * _PREHASH_Plane; 1193extern char * _PREHASH_Plane;
@@ -1227,7 +1223,6 @@ extern char * _PREHASH_Disconnect;
1227extern char * _PREHASH_SimPosition; 1223extern char * _PREHASH_SimPosition;
1228extern char * _PREHASH_SimWideTotalPrims; 1224extern char * _PREHASH_SimWideTotalPrims;
1229extern char * _PREHASH_Index; 1225extern char * _PREHASH_Index;
1230extern char * _PREHASH_BaseFilename;
1231extern char * _PREHASH_SimFilename; 1226extern char * _PREHASH_SimFilename;
1232extern char * _PREHASH_LastOwnerID; 1227extern char * _PREHASH_LastOwnerID;
1233extern char * _PREHASH_GroupNoticeRequest; 1228extern char * _PREHASH_GroupNoticeRequest;
@@ -1312,6 +1307,7 @@ extern char * _PREHASH_AssetBlock;
1312extern char * _PREHASH_AcceptNotices; 1307extern char * _PREHASH_AcceptNotices;
1313extern char * _PREHASH_SetGroupAcceptNotices; 1308extern char * _PREHASH_SetGroupAcceptNotices;
1314extern char * _PREHASH_CloseCircuit; 1309extern char * _PREHASH_CloseCircuit;
1310extern char * _PREHASH_LogControl;
1315extern char * _PREHASH_TeleportFinish; 1311extern char * _PREHASH_TeleportFinish;
1316extern char * _PREHASH_PathRevolutions; 1312extern char * _PREHASH_PathRevolutions;
1317extern char * _PREHASH_ClassifiedInfoReply; 1313extern char * _PREHASH_ClassifiedInfoReply;
@@ -1491,7 +1487,6 @@ extern char * _PREHASH_DirLandReply;
1491extern char * _PREHASH_SpaceLocationTeleportReply; 1487extern char * _PREHASH_SpaceLocationTeleportReply;
1492extern char * _PREHASH_MuteType; 1488extern char * _PREHASH_MuteType;
1493extern char * _PREHASH_IMViaEMail; 1489extern char * _PREHASH_IMViaEMail;
1494extern char * _PREHASH_StartExpungeProcessAck;
1495extern char * _PREHASH_RentPrice; 1490extern char * _PREHASH_RentPrice;
1496extern char * _PREHASH_GenericMessage; 1491extern char * _PREHASH_GenericMessage;
1497extern char * _PREHASH_ChildAgentAlive; 1492extern char * _PREHASH_ChildAgentAlive;
diff --git a/linden/indra/llmessage/message_string_table.cpp b/linden/indra/llmessage/message_string_table.cpp
index 7fea048..2ae269b 100644
--- a/linden/indra/llmessage/message_string_table.cpp
+++ b/linden/indra/llmessage/message_string_table.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/net.cpp b/linden/indra/llmessage/net.cpp
index de19ef8..c61f4a2 100644
--- a/linden/indra/llmessage/net.cpp
+++ b/linden/indra/llmessage/net.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
@@ -241,6 +242,12 @@ S32 start_net(S32& socket_out, int& nPort)
241 return 4; 242 return 4;
242 } 243 }
243 } 244 }
245
246 sockaddr_in socket_address;
247 S32 socket_address_size = sizeof(socket_address);
248 getsockname(hSocket, (SOCKADDR*) &socket_address, &socket_address_size);
249 attempt_port = ntohs(socket_address.sin_port);
250
244 llinfos << "connected on port " << attempt_port << llendl; 251 llinfos << "connected on port " << attempt_port << llendl;
245 nPort = attempt_port; 252 nPort = attempt_port;
246 253
diff --git a/linden/indra/llmessage/net.h b/linden/indra/llmessage/net.h
index d406006..b2f931f 100644
--- a/linden/indra/llmessage/net.h
+++ b/linden/indra/llmessage/net.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/network.cpp b/linden/indra/llmessage/network.cpp
index 46e9893..03aad63 100644
--- a/linden/indra/llmessage/network.cpp
+++ b/linden/indra/llmessage/network.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/network.h b/linden/indra/llmessage/network.h
index 8a20e32..6c6577b 100644
--- a/linden/indra/llmessage/network.h
+++ b/linden/indra/llmessage/network.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/partsyspacket.cpp b/linden/indra/llmessage/partsyspacket.cpp
index d6ba11e..4750faa 100644
--- a/linden/indra/llmessage/partsyspacket.cpp
+++ b/linden/indra/llmessage/partsyspacket.cpp
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2000-2007, Linden Research, Inc. 6 * Copyright (c) 2000-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/partsyspacket.h b/linden/indra/llmessage/partsyspacket.h
index 8e10e56..5dbc41c 100644
--- a/linden/indra/llmessage/partsyspacket.h
+++ b/linden/indra/llmessage/partsyspacket.h
@@ -5,6 +5,7 @@
5 * 5 *
6 * Copyright (c) 2000-2007, Linden Research, Inc. 6 * Copyright (c) 2000-2007, Linden Research, Inc.
7 * 7 *
8 * Second Life Viewer Source Code
8 * The source code in this file ("Source Code") is provided by Linden Lab 9 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0 10 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement 11 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/patch_code.cpp b/linden/indra/llmessage/patch_code.cpp
index 3eb2be6..c996899 100644
--- a/linden/indra/llmessage/patch_code.cpp
+++ b/linden/indra/llmessage/patch_code.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/patch_code.h b/linden/indra/llmessage/patch_code.h
index 28b1839..ba3dea4 100644
--- a/linden/indra/llmessage/patch_code.h
+++ b/linden/indra/llmessage/patch_code.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/patch_dct.cpp b/linden/indra/llmessage/patch_dct.cpp
index b404c75..0e8aa25 100644
--- a/linden/indra/llmessage/patch_dct.cpp
+++ b/linden/indra/llmessage/patch_dct.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/patch_dct.h b/linden/indra/llmessage/patch_dct.h
index 5d98921..b69249e 100644
--- a/linden/indra/llmessage/patch_dct.h
+++ b/linden/indra/llmessage/patch_dct.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/patch_idct.cpp b/linden/indra/llmessage/patch_idct.cpp
index a20641f..680003a 100644
--- a/linden/indra/llmessage/patch_idct.cpp
+++ b/linden/indra/llmessage/patch_idct.cpp
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2000-2007, Linden Research, Inc. 5 * Copyright (c) 2000-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement
diff --git a/linden/indra/llmessage/sound_ids.h b/linden/indra/llmessage/sound_ids.h
index 11452c0..2652778 100644
--- a/linden/indra/llmessage/sound_ids.h
+++ b/linden/indra/llmessage/sound_ids.h
@@ -4,6 +4,7 @@
4 * 4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc. 5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 * 6 *
7 * Second Life Viewer Source Code
7 * The source code in this file ("Source Code") is provided by Linden Lab 8 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0 9 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement 10 * ("GPL"), unless you have obtained a separate licensing agreement