PageRenderTime 48ms CodeModel.GetById 31ms app.highlight 12ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llpacketack.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 82 lines | 48 code | 7 blank | 27 comment | 4 complexity | 4575657410273279de52476af416f2f1 MD5 | raw file
 1/** 
 2 * @file llpacketack.cpp
 3 * @author Phoenix
 4 * @date 2007-05-09
 5 * @brief Implementation of the LLReliablePacket.
 6 *
 7 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 8 * Second Life Viewer Source Code
 9 * Copyright (C) 2010, Linden Research, Inc.
10 * 
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation;
14 * version 2.1 of the License only.
15 * 
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 * Lesser General Public License for more details.
20 * 
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24 * 
25 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
26 * $/LicenseInfo$
27 */
28
29#include "linden_common.h"
30#include "llpacketack.h"
31
32#if !LL_WINDOWS
33#include <netinet/in.h>
34#else
35#include "winsock2.h"
36#endif
37
38#include "message.h"
39
40LLReliablePacket::LLReliablePacket(
41	S32 socket,
42	U8* buf_ptr,
43	S32 buf_len,
44	LLReliablePacketParams* params) :
45	mBuffer(NULL),
46	mBufferLength(0)
47{
48	if (params)
49	{
50		mHost = params->mHost;
51		mRetries = params->mRetries;
52		mPingBasedRetry = params->mPingBasedRetry;
53		mTimeout = params->mTimeout;
54		mCallback = params->mCallback;
55		mCallbackData = params->mCallbackData;
56		mMessageName = params->mMessageName;
57	}
58	else
59	{
60		mRetries = 0;
61		mPingBasedRetry = TRUE;
62		mTimeout = 0.f;
63		mCallback = NULL;
64		mCallbackData = NULL;
65		mMessageName = NULL;
66	}
67
68	mExpirationTime = (F64)((S64)totalTime())/1000000.0 + mTimeout;
69	mPacketID = ntohl(*((U32*)(&buf_ptr[PHL_PACKET_ID])));
70
71	mSocket = socket;
72	if (mRetries)
73	{
74		mBuffer = new U8[buf_len];
75		if (mBuffer != NULL)
76		{
77			memcpy(mBuffer,buf_ptr,buf_len);	/*Flawfinder: ignore*/
78			mBufferLength = buf_len;
79		}
80			
81	}
82}