PageRenderTime 32ms CodeModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #include "linden_common.h"
  27. #include "llpacketbuffer.h"
  28. #include "net.h"
  29. #include "timing.h"
  30. #include "llhost.h"
  31. ///////////////////////////////////////////////////////////
  32. LLPacketBuffer::LLPacketBuffer(const LLHost &host, const char *datap, const S32 size) : mHost(host)
  33. {
  34. mSize = 0;
  35. mData[0] = '!';
  36. if (size > NET_BUFFER_SIZE)
  37. {
  38. llerrs << "Sending packet > " << NET_BUFFER_SIZE << " of size " << size << llendl;
  39. }
  40. else
  41. {
  42. if (datap != NULL)
  43. {
  44. memcpy(mData, datap, size);
  45. mSize = size;
  46. }
  47. }
  48. }
  49. LLPacketBuffer::LLPacketBuffer (S32 hSocket)
  50. {
  51. init(hSocket);
  52. }
  53. ///////////////////////////////////////////////////////////
  54. LLPacketBuffer::~LLPacketBuffer ()
  55. {
  56. }
  57. ///////////////////////////////////////////////////////////
  58. void LLPacketBuffer::init (S32 hSocket)
  59. {
  60. mSize = receive_packet(hSocket, mData);
  61. mHost = ::get_sender();
  62. mReceivingIF = ::get_receiving_interface();
  63. }