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.

155 lines
3.6 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. VOID
  29. Create(HWND hwnd)
  30. {
  31. m_hIPaddr = hwnd;
  32. }
  33. operator
  34. HWND( ) { ASSERT(m_hIPaddr); return m_hIPaddr; }
  35. BOOL
  36. IsBlank( );
  37. VOID
  38. SetFocusField(
  39. DWORD dwField );
  40. VOID
  41. SetFieldRange(
  42. DWORD dwField,
  43. DWORD dwMin,
  44. DWORD dwMax );
  45. VOID
  46. ClearAddress( );
  47. VOID
  48. SetAddress(
  49. DWORD ardwAddress[4] );
  50. VOID
  51. SetAddress(
  52. DWORD a1,
  53. DWORD a2,
  54. DWORD a3,
  55. DWORD a4 );
  56. VOID
  57. SetAddress(
  58. LPCTSTR lpszString );
  59. INT
  60. GetAddress(
  61. DWORD ardwAddress[4] );
  62. INT
  63. GetAddress(
  64. DWORD* a1,
  65. DWORD* a2,
  66. DWORD* a3,
  67. DWORD* a4 );
  68. INT
  69. GetAddress(
  70. CString& address );
  71. LRESULT
  72. SendMessage(
  73. UINT uMsg,
  74. WPARAM wParam,
  75. LPARAM lParam );
  76. public:
  77. HWND m_hIPaddr;
  78. };
  79. //----------------------------------------------------------------------------
  80. // Macro: MAKEADDR
  81. //
  82. // Given an a, b, c, and d, constructs a network-order DWORD corresponding
  83. // to the IP-address a.b.c.d
  84. //----------------------------------------------------------------------------
  85. #define MAKEADDR(a, b, c, d) \
  86. (((a) & 0xff) | (((b) & 0xff) << 8) | (((c) & 0xff) << 16) | (((d) & 0xff) << 24))
  87. //----------------------------------------------------------------------------
  88. // Macros: INET_NTOA
  89. // INET_ADDR
  90. //
  91. // Generic-text macros for IP-address conversion.
  92. //----------------------------------------------------------------------------
  93. /*
  94. #ifndef UNICODE
  95. #define INET_NTOA(a) inet_ntoa(*(struct in_addr *)&(a))
  96. #define INET_ADDR inet_addr
  97. #else
  98. #define INET_NTOA(a) inet_ntoaw(*(struct in_addr *)&(a))
  99. #define INET_ADDR inet_addrw
  100. #endif
  101. */
  102. //----------------------------------------------------------------------------
  103. // Macro: INET_CMP
  104. //
  105. // Comparison macro for IP addresses.
  106. //
  107. // This macro compares two IP addresses in network order by
  108. // masking off each pair of octets and doing a subtraction;
  109. // the result of the final subtraction is stored in the third argument
  110. //----------------------------------------------------------------------------
  111. inline int INET_CMP(DWORD a, DWORD b)
  112. {
  113. DWORD t;
  114. return ((t = ((a & 0x000000ff) - (b & 0x000000ff))) ? t :
  115. ((t = ((a & 0x0000ff00) - (b & 0x0000ff00))) ? t :
  116. ((t = ((a & 0x00ff0000) - (b & 0x00ff0000))) ? t :
  117. ((t = (((a>>8) & 0x00ff0000) - ((b>>8) & 0x00ff0000)))))));
  118. }
  119. #endif