aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llpacketack.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/llpacketack.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/llpacketack.h')
-rw-r--r--linden/indra/llmessage/llpacketack.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/linden/indra/llmessage/llpacketack.h b/linden/indra/llmessage/llpacketack.h
new file mode 100644
index 0000000..d7d960e
--- /dev/null
+++ b/linden/indra/llmessage/llpacketack.h
@@ -0,0 +1,162 @@
1/**
2 * @file llpacketack.h
3 * @brief Reliable UDP helpers for the message system.
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 LL_LLPACKETACK_H
29#define LL_LLPACKETACK_H
30
31#include <cstring>
32#include <stdio.h>
33
34#include "llerror.h"
35#include "lltimer.h"
36#include "llhost.h"
37
38//class LLPacketAck
39//{
40//public:
41// LLHost mHost;
42// TPACKETID mPacketID;
43//public:
44// LLPacketAck(const LLHost &host, TPACKETID packet_id)
45// {
46// mHost = host;
47// mPacketID = packet_id;
48// };
49// ~LLPacketAck(){};
50//};
51
52class LLReliablePacketParams
53{
54public:
55 LLHost mHost;
56 S32 mRetries;
57 BOOL mPingBasedRetry;
58 F32 mTimeout;
59 void (*mCallback)(void **,S32);
60 void **mCallbackData;
61 char *mMessageName;
62
63public:
64 LLReliablePacketParams()
65 {
66 mRetries = 0;
67 mPingBasedRetry = TRUE;
68 mTimeout = 0.f;
69 mCallback = NULL;
70 mCallbackData = NULL;
71 mMessageName = NULL;
72 };
73
74 ~LLReliablePacketParams() { };
75
76 void set ( const LLHost &host, S32 retries, BOOL ping_based_retry,
77 F32 timeout,
78 void (*callback)(void **,S32), void **callback_data, char *name )
79 {
80 mHost = host;
81 mRetries = retries;
82 mPingBasedRetry = ping_based_retry;
83 mTimeout = timeout;
84 mCallback = callback;
85 mCallbackData = callback_data;
86 mMessageName = name;
87 };
88};
89
90class LLReliablePacket
91{
92public:
93 LLReliablePacket(S32 socket, U8 *buf_ptr, S32 buf_len, LLReliablePacketParams *params) :
94 mBuffer(NULL),
95 mBufferLength(0)
96 {
97 if (params)
98 {
99 mHost = params->mHost;
100 mRetries = params->mRetries;
101 mPingBasedRetry = params->mPingBasedRetry;
102 mTimeout = params->mTimeout;
103 mCallback = params->mCallback;
104 mCallbackData = params->mCallbackData;
105 mMessageName = params->mMessageName;
106 }
107 else
108 {
109 mRetries = 0;
110 mPingBasedRetry = TRUE;
111 mTimeout = 0.f;
112 mCallback = NULL;
113 mCallbackData = NULL;
114 mMessageName = NULL;
115 }
116
117 mExpirationTime = (F64)((S64)totalTime())/1000000.0 + mTimeout;
118 mPacketID = buf_ptr[1] + ((buf_ptr[0] & 0x0f ) * 256);
119 if (sizeof(TPACKETID) == 4)
120 {
121 mPacketID *= 256;
122 mPacketID += buf_ptr[2];
123 mPacketID *= 256;
124 mPacketID += buf_ptr[3];
125 }
126
127 mSocket = socket;
128 if (mRetries)
129 {
130 mBuffer = new U8[buf_len];
131 if (mBuffer != NULL)
132 {
133 memcpy(mBuffer,buf_ptr,buf_len);
134 mBufferLength = buf_len;
135 }
136
137 }
138 };
139 ~LLReliablePacket(){ delete [] mBuffer; };
140
141 friend class LLCircuitData;
142protected:
143 S32 mSocket;
144 LLHost mHost;
145 S32 mRetries;
146 BOOL mPingBasedRetry;
147 F32 mTimeout;
148 void (*mCallback)(void **,S32);
149 void **mCallbackData;
150 char *mMessageName;
151
152 U8 *mBuffer;
153 S32 mBufferLength;
154
155 TPACKETID mPacketID;
156
157 F64 mExpirationTime;
158
159};
160
161#endif
162