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.

132 lines
2.5 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1997 - 1999
  3. Module Name:
  4. ipname.hxx
  5. Abstract:
  6. Header file for IP name resolution routines.
  7. Author:
  8. Gopal Parupudi <GopalP>
  9. Notes:
  10. a. Class IP_ADDRESS_RESOLVER cloned from RPC Runtime Transport sources
  11. (rpc\runtime\trans\winnt\common\trans.hxx).
  12. Revision History:
  13. GopalP 10/13/1997 Start.
  14. --*/
  15. #define MAX_DESTINATION_NAME_LEN 255
  16. //
  17. // Common macros
  18. //
  19. #if DBG
  20. #define DEBUG_MIN(x,y) min((x),(y))
  21. #else
  22. #define DEBUG_MIN(x,y) max((x),(y))
  23. #endif
  24. //
  25. // Forward declarations
  26. //
  27. DWORD
  28. ResolveName(
  29. IN TCHAR *lpszDestination,
  30. OUT LPDWORD lpdwIpAddr
  31. );
  32. #if !defined(SENS_CHICAGO)
  33. //
  34. // IP name resolver
  35. //
  36. const int IP_RETAIL_BUFFER_SIZE = 3*0x38;
  37. const int IP_BUFFER_SIZE = DEBUG_MIN(1, IP_RETAIL_BUFFER_SIZE);
  38. class IP_ADDRESS_RESOLVER
  39. /*++
  40. Class Description:
  41. Manages the WSALookupServiceBegin/Next/End calls in a more
  42. natural way. Used to convert a string network name into
  43. one or more IP addresses.
  44. Members:
  45. _Name - The name being resolved. Set to NULL after the
  46. first call to NextAddress();
  47. _hRnr - NULL or the handle returned by a call to
  48. WSALookupServiceBegin.
  49. _size - The (total) size of the buffer pointed at by _pwsqs.
  50. _fFree - If TRUE, _pwsqs needs to be freed when the object
  51. is destroyed.
  52. _pwsqs - A buffer of _size bytes used to hold the output
  53. from WSALookupSericeNext. Maybe a caller supplied
  54. buffer or allocated internally.
  55. --*/
  56. {
  57. public:
  58. IP_ADDRESS_RESOLVER(
  59. IN TCHAR *Name,
  60. IN DWORD dwSize,
  61. IN PVOID Buffer
  62. )
  63. /*++
  64. Arguments:
  65. Name - The name (dotted ip address or DNS name) to resolve.
  66. dwSize - The size of the Buffer parameter
  67. Buffer - storage used to keep internal state between
  68. calls to NextAddress. Maybe freed after the object
  69. is destoryed.
  70. --*/
  71. {
  72. _Name = Name;
  73. _hRnr = 0;
  74. _size = dwSize;
  75. _fFree = FALSE;
  76. _pwsqs = (PWSAQUERYSET)Buffer;
  77. ASSERT(dwSize == 0 || dwSize >= sizeof(WSAQUERYSET));
  78. }
  79. RPC_STATUS
  80. NextAddress(
  81. OUT LPDWORD lpdwIpAddr
  82. );
  83. ~IP_ADDRESS_RESOLVER();
  84. private:
  85. TCHAR *_Name;
  86. HANDLE _hRnr;
  87. DWORD _index;
  88. DWORD _size;
  89. BOOL _fFree;
  90. PWSAQUERYSET _pwsqs;
  91. };
  92. #endif // SENS_CHICAGO