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.

149 lines
3.5 KiB

  1. //============================================================================
  2. // Copyright (C) Microsoft Corporation, 1996 - 1999
  3. //
  4. // File: ipcontrol.h
  5. //
  6. // History:
  7. // ??/??/?? Tony Romano Created.
  8. // 05/16/96 Abolade Gbadegesin Revised.
  9. //============================================================================
  10. #ifndef __IPCTRL_H
  11. #define __IPCTRL_H
  12. #if _MSC_VER >= 1000
  13. #pragma once
  14. #endif // _MSC_VER >= 1000
  15. //----------------------------------------------------------------------------
  16. // Class: IPControl
  17. //
  18. // Controls an IP-address edit-control.
  19. //----------------------------------------------------------------------------
  20. class IPControl {
  21. public:
  22. IPControl( );
  23. ~IPControl( );
  24. BOOL
  25. Create(
  26. HWND hParent,
  27. UINT nID );
  28. operator
  29. HWND( ) { ASSERT(m_hIPaddr); return m_hIPaddr; }
  30. BOOL
  31. IsBlank( );
  32. VOID
  33. SetFocusField(
  34. DWORD dwField );
  35. VOID
  36. SetFieldRange(
  37. DWORD dwField,
  38. DWORD dwMin,
  39. DWORD dwMax );
  40. VOID
  41. ClearAddress( );
  42. VOID
  43. SetAddress(
  44. DWORD ardwAddress[4] );
  45. VOID
  46. SetAddress(
  47. DWORD a1,
  48. DWORD a2,
  49. DWORD a3,
  50. DWORD a4 );
  51. VOID
  52. SetAddress(
  53. LPCTSTR lpszString );
  54. INT
  55. GetAddress(
  56. DWORD ardwAddress[4] );
  57. INT
  58. GetAddress(
  59. DWORD* a1,
  60. DWORD* a2,
  61. DWORD* a3,
  62. DWORD* a4 );
  63. INT
  64. GetAddress(
  65. CString& address );
  66. LRESULT
  67. SendMessage(
  68. UINT uMsg,
  69. WPARAM wParam,
  70. LPARAM lParam );
  71. protected:
  72. HWND m_hIPaddr;
  73. };
  74. //----------------------------------------------------------------------------
  75. // Macro: MAKEADDR
  76. //
  77. // Given an a, b, c, and d, constructs a network-order DWORD corresponding
  78. // to the IP-address a.b.c.d
  79. //----------------------------------------------------------------------------
  80. #define MAKEADDR(a, b, c, d) \
  81. (((a) & 0xff) | (((b) & 0xff) << 8) | (((c) & 0xff) << 16) | (((d) & 0xff) << 24))
  82. //----------------------------------------------------------------------------
  83. // Macros: INET_NTOA
  84. // INET_ADDR
  85. //
  86. // Generic-text macros for IP-address conversion.
  87. //----------------------------------------------------------------------------
  88. /*
  89. #ifndef UNICODE
  90. #define INET_NTOA(a) inet_ntoa(*(struct in_addr *)&(a))
  91. #define INET_ADDR inet_addr
  92. #else
  93. #define INET_NTOA(a) inet_ntoaw(*(struct in_addr *)&(a))
  94. #define INET_ADDR inet_addrw
  95. #endif
  96. */
  97. //----------------------------------------------------------------------------
  98. // Macro: INET_CMP
  99. //
  100. // Comparison macro for IP addresses.
  101. //
  102. // This macro compares two IP addresses in network order by
  103. // masking off each pair of octets and doing a subtraction;
  104. // the result of the final subtraction is stored in the third argument
  105. //----------------------------------------------------------------------------
  106. inline int INET_CMP(DWORD a, DWORD b)
  107. {
  108. DWORD t;
  109. return ((t = ((a & 0x000000ff) - (b & 0x000000ff))) ? t :
  110. ((t = ((a & 0x0000ff00) - (b & 0x0000ff00))) ? t :
  111. ((t = ((a & 0x00ff0000) - (b & 0x00ff0000))) ? t :
  112. ((t = (((a>>8) & 0x00ff0000) - ((b>>8) & 0x00ff0000)))))));
  113. }
  114. #endif