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.

104 lines
2.0 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996.
  5. //
  6. // File: mach.hxx
  7. //
  8. // Contents:
  9. // Net helper functions.
  10. //
  11. // History:
  12. //--------------------------------------------------------------------------
  13. #ifndef __MACH_HXX__
  14. #define __MACH_HXX__
  15. #include <rpc.h>
  16. #ifndef _CHICAGO_
  17. #include <netevent.h>
  18. #endif
  19. #include <winsock.h>
  20. const UINT IPMaximumPrettyName = 256; // DNS limit
  21. const UINT IPMaximumRawName = 16; // xxx.xxx.xxx.xxx
  22. typedef struct
  23. {
  24. UINT Count;
  25. WCHAR **NetworkAddresses;
  26. } NetworkAddressVector;
  27. //
  28. // This class is basically just a ref-counted wrapper around
  29. // the NetworkAddressVector struct above.
  30. //
  31. class CIPAddrs
  32. {
  33. public:
  34. CIPAddrs();
  35. ~CIPAddrs();
  36. void IncRefCount();
  37. void DecRefCount();
  38. // These members are read-only by users:
  39. NetworkAddressVector* _pIPAddresses;
  40. private:
  41. LONG _lRefs;
  42. };
  43. class CMachineName
  44. {
  45. public:
  46. CMachineName();
  47. DWORD Initialize();
  48. inline
  49. WCHAR *
  50. Name()
  51. {
  52. ASSERT(_bInitialized);
  53. return _wszMachineName;
  54. }
  55. BOOL Compare( IN WCHAR * pwszName );
  56. void IPAddrsChanged() { ASSERT(_bInitialized); _bIPAddrsChanged = TRUE; };
  57. CIPAddrs *GetIPAddrs();
  58. private:
  59. void
  60. SetName();
  61. void
  62. SetDNSName();
  63. void
  64. SetHostAliases(HOSTENT*);
  65. NetworkAddressVector*
  66. COMMON_IP_BuildAddressVector();
  67. SOCKET _socket;
  68. BYTE* _pAddrQueryBuf;
  69. DWORD _dwAddrQueryBufSize;
  70. CIPAddrs* _pIPAddresses;
  71. BOOL _bIPAddrsChanged;
  72. DWORD _dwcResets; // counts how many times we've queried for new IP addresses
  73. BOOL _bInitialized; // True after we've successfully initialized
  74. WCHAR * _pwszDNSName;
  75. WCHAR ** _pAliases;
  76. WCHAR _wszMachineName[MAX_COMPUTERNAME_LENGTH+1];
  77. CRITICAL_SECTION _csMachineNameLock;
  78. };
  79. extern CMachineName * gpMachineName;
  80. #endif \\__MACH_HXX__