Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.2 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // FILE
  6. //
  7. // radproxyp.cpp
  8. //
  9. // SYNOPSIS
  10. //
  11. // Defines classes that are used in the implementation of RadiusProxy, but
  12. // need not be visible to clients.
  13. //
  14. ///////////////////////////////////////////////////////////////////////////////
  15. #include <proxypch.h>
  16. #include <radproxyp.h>
  17. ProxyContext::~ProxyContext() throw ()
  18. {
  19. if (context)
  20. {
  21. // Our ref count dropped to zero, but we still have a context object.
  22. // That means no one is going to take ownership.
  23. RadiusProxyEngine::onRequestAbandoned(context, primary);
  24. }
  25. }
  26. LONG Request::theNextRequestID;
  27. Request::Request(
  28. ProxyContext* context,
  29. RemoteServer* destination,
  30. BYTE packetCode
  31. ) throw ()
  32. : ctxt(context),
  33. dst(destination),
  34. id(InterlockedIncrement(&theNextRequestID)),
  35. code(packetCode)
  36. {
  37. identifier = port().getIdentifier();
  38. }
  39. bool Request::onReceive() throw ()
  40. {
  41. // Compute the round-trip time.
  42. timeStamp = GetSystemTime64() - timeStamp;
  43. // Cancel the request timeout timer.
  44. cancelTimer();
  45. // Update server state.
  46. return dst->onReceive();
  47. }
  48. void Request::AddRef() throw ()
  49. {
  50. ++refCount;
  51. }
  52. void Request::Release() throw ()
  53. {
  54. if (--refCount == 0) { delete this; }
  55. }
  56. void Request::onExpiry() throw ()
  57. {
  58. RadiusProxyEngine::onRequestTimeout(this);
  59. }
  60. const void* Request::getKey() const throw ()
  61. {
  62. return &id;
  63. }
  64. bool Request::matches(const void* key) const throw ()
  65. {
  66. return id == *(PLONG)key;
  67. }
  68. ULONG WINAPI Request::hash(const void* key) throw ()
  69. {
  70. return *(PLONG)key;
  71. }
  72. void Session::AddRef() throw ()
  73. {
  74. ++refCount;
  75. }
  76. void Session::Release() throw ()
  77. {
  78. if (--refCount == 0) { delete this; }
  79. }
  80. const void* Session::getKey() const throw ()
  81. {
  82. return &state;
  83. }
  84. bool Session::matches(const void* key) const throw ()
  85. {
  86. const RadiusRawOctets* p = (const RadiusRawOctets*)key;
  87. return state.length() == p->len && !memcmp(state, p->value, p->len);
  88. }
  89. ULONG WINAPI Session::hash(const void* key) throw ()
  90. {
  91. const RadiusRawOctets* p = (const RadiusRawOctets*)key;
  92. return IASHashBytes(p->value, p->len);
  93. }