PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llpacketbuffer.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 76 lines | 35 code | 13 blank | 28 comment | 3 complexity | 9ee6e8be38da40b8b3e0f2ceeacc0659 MD5 | raw file
 1/** 
 2 * @file llpacketbuffer.cpp
 3 * @brief implementation of LLPacketBuffer class for a packet.
 4 *
 5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
 6 * Second Life Viewer Source Code
 7 * Copyright (C) 2010, Linden Research, Inc.
 8 * 
 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation;
12 * version 2.1 of the License only.
13 * 
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 * Lesser General Public License for more details.
18 * 
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 * 
23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
24 * $/LicenseInfo$
25 */
26
27#include "linden_common.h"
28
29#include "llpacketbuffer.h"
30
31#include "net.h"
32#include "timing.h"
33#include "llhost.h"
34
35///////////////////////////////////////////////////////////
36
37LLPacketBuffer::LLPacketBuffer(const LLHost &host, const char *datap, const S32 size) : mHost(host)
38{
39	mSize = 0;
40	mData[0] = '!';
41
42	if (size > NET_BUFFER_SIZE)
43	{
44		llerrs << "Sending packet > " << NET_BUFFER_SIZE << " of size " << size << llendl;
45	}
46	else
47	{
48		if (datap != NULL)
49		{
50			memcpy(mData, datap, size);
51			mSize = size;
52		}
53	}
54	
55}
56
57LLPacketBuffer::LLPacketBuffer (S32 hSocket)
58{
59	init(hSocket);
60}
61
62///////////////////////////////////////////////////////////
63
64LLPacketBuffer::~LLPacketBuffer ()
65{
66}
67
68///////////////////////////////////////////////////////////
69
70void LLPacketBuffer::init (S32 hSocket)
71{
72	mSize = receive_packet(hSocket, mData);
73	mHost = ::get_sender();
74	mReceivingIF = ::get_receiving_interface();
75}
76