Leaked source code of windows server 2003
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.

120 lines
2.6 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. void Request::setPacket(const RadiusPacket& packet)
  40. {
  41. RadiusAttribute* attr = FindAttribute(packet, RADIUS_USER_NAME);
  42. if (attr != 0)
  43. {
  44. userName.assign(attr->value, attr->length);
  45. }
  46. }
  47. bool Request::onReceive(BYTE code) throw ()
  48. {
  49. // Compute the round-trip time.
  50. timeStamp = GetSystemTime64() - timeStamp;
  51. // Cancel the request timeout timer.
  52. cancelTimer();
  53. // Update server state.
  54. return dst->onReceive(code);
  55. }
  56. void Request::AddRef() throw ()
  57. {
  58. ++refCount;
  59. }
  60. void Request::Release() throw ()
  61. {
  62. if (--refCount == 0) { delete this; }
  63. }
  64. void Request::onExpiry() throw ()
  65. {
  66. RadiusProxyEngine::onRequestTimeout(this);
  67. }
  68. const void* Request::getKey() const throw ()
  69. {
  70. return &id;
  71. }
  72. bool Request::matches(const void* key) const throw ()
  73. {
  74. return id == *(PLONG)key;
  75. }
  76. ULONG WINAPI Request::hash(const void* key) throw ()
  77. {
  78. return *(PLONG)key;
  79. }
  80. void ServerBinding::AddRef() throw ()
  81. {
  82. ++refCount;
  83. }
  84. void ServerBinding::Release() throw ()
  85. {
  86. if (--refCount == 0) { delete this; }
  87. }
  88. const void* ServerBinding::getKey() const throw ()
  89. {
  90. return &state;
  91. }
  92. bool ServerBinding::matches(const void* key) const throw ()
  93. {
  94. const RadiusRawOctets* p = (const RadiusRawOctets*)key;
  95. return state.length() == p->len && !memcmp(state, p->value, p->len);
  96. }
  97. ULONG WINAPI ServerBinding::hash(const void* key) throw ()
  98. {
  99. const RadiusRawOctets* p = (const RadiusRawOctets*)key;
  100. return IASHashBytes(p->value, p->len);
  101. }