PageRenderTime 42ms CodeModel.GetById 23ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #include "linden_common.h"
  29. #include "llpacketack.h"
  30. #if !LL_WINDOWS
  31. #include <netinet/in.h>
  32. #else
  33. #include "winsock2.h"
  34. #endif
  35. #include "message.h"
  36. LLReliablePacket::LLReliablePacket(
  37. S32 socket,
  38. U8* buf_ptr,
  39. S32 buf_len,
  40. LLReliablePacketParams* params) :
  41. mBuffer(NULL),
  42. mBufferLength(0)
  43. {
  44. if (params)
  45. {
  46. mHost = params->mHost;
  47. mRetries = params->mRetries;
  48. mPingBasedRetry = params->mPingBasedRetry;
  49. mTimeout = params->mTimeout;
  50. mCallback = params->mCallback;
  51. mCallbackData = params->mCallbackData;
  52. mMessageName = params->mMessageName;
  53. }
  54. else
  55. {
  56. mRetries = 0;
  57. mPingBasedRetry = TRUE;
  58. mTimeout = 0.f;
  59. mCallback = NULL;
  60. mCallbackData = NULL;
  61. mMessageName = NULL;
  62. }
  63. mExpirationTime = (F64)((S64)totalTime())/1000000.0 + mTimeout;
  64. mPacketID = ntohl(*((U32*)(&buf_ptr[PHL_PACKET_ID])));
  65. mSocket = socket;
  66. if (mRetries)
  67. {
  68. mBuffer = new U8[buf_len];
  69. if (mBuffer != NULL)
  70. {
  71. memcpy(mBuffer,buf_ptr,buf_len); /*Flawfinder: ignore*/
  72. mBufferLength = buf_len;
  73. }
  74. }
  75. }