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.

75 lines
1.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation
  6. //
  7. // File: queue.h
  8. //
  9. //--------------------------------------------------------------------------
  10. #if !defined( _QUEUE_H_ )
  11. #define _QUEUE_H_
  12. #define SMALL_STRING 64
  13. #include <tchar.h>
  14. #include <cmnhdr.h>
  15. #include <windows.h>
  16. #include <winsock2.h>
  17. #include <TlntUtils.h>
  18. #include <Telnetd.h>
  19. class CQueue;
  20. typedef char IP_ADDR;
  21. typedef struct Q_LIST_ENTRY {
  22. struct Q_LIST_ENTRY *pQPrev;
  23. struct Q_LIST_ENTRY *pQNext;
  24. IP_ADDR chIPAddr[SMALL_STRING];
  25. DWORD dwPid;
  26. HANDLE hWritePipe;
  27. } Q_LIST_ENTRY, *PQ_LIST_ENTRY;
  28. class CQueue
  29. {
  30. PQ_LIST_ENTRY m_pHead;
  31. PQ_LIST_ENTRY m_pTail;
  32. CRITICAL_SECTION m_csQModification;
  33. public:
  34. DWORD m_dwNumOfUnauthenticatedConnections;
  35. DWORD m_dwMaxUnauthenticatedConnections;
  36. DWORD m_dwMaxIPLimit;
  37. // constructor
  38. CQueue();
  39. // destructor
  40. ~CQueue();
  41. bool IsQFull();
  42. // Allocates memory for an entry and adds it in the queue.
  43. bool Push(DWORD dwPid, HANDLE *phWritePipe, IP_ADDR *pchIPAddr);
  44. // Frees a head entry in the queue.
  45. bool Pop(HANDLE *phWritePipe);
  46. // Frees a particular entry in the queue.
  47. bool FreeEntry(DWORD dwPid);
  48. //See if allowed to add to the queue.
  49. bool OkToProceedWithThisClient(IP_ADDR *pchIPAddr);
  50. //Check whether the client was added to our queue or not
  51. bool WasTheClientAdded(DWORD dwPid, IP_ADDR *pchIPAddr, HANDLE *phWritePipe, bool *pbSendMessage);
  52. //See if per IP limit is reached
  53. bool IsIPLimitReached(IP_ADDR *pchIPAddr);
  54. };
  55. #endif