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.

92 lines
2.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1995 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. ipaddres.h
  7. Ip address control
  8. FILE HISTORY:
  9. */
  10. #ifndef _IPADDRES_H
  11. #define _IPADDRES_H
  12. //
  13. // IP Address Conversion Macros
  14. //
  15. /*
  16. #ifndef MAKEIPADDRESS
  17. #define MAKEIPADDRESS(b1,b2,b3,b4) ((LONG)(((DWORD)(b1)<<24)+((DWORD)(b2)<<16)+((DWORD)(b3)<<8)+((DWORD)(b4))))
  18. #define GETIP_FIRST(x) ((x>>24) & 0xff)
  19. #define GETIP_SECOND(x) ((x>>16) & 0xff)
  20. #define GETIP_THIRD(x) ((x>> 8) & 0xff)
  21. #define GETIP_FOURTH(x) ((x) & 0xff)
  22. #endif // MAKEIPADDRESS*/
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CIpAddress class
  25. class CIpAddress : public CObjectPlus
  26. {
  27. public:
  28. // Constructors
  29. CIpAddress()
  30. {
  31. m_lIpAddress = 0L;
  32. m_fInitOk = FALSE;
  33. }
  34. CIpAddress (LONG l)
  35. {
  36. m_lIpAddress = l;
  37. m_fInitOk = TRUE;
  38. }
  39. CIpAddress (BYTE b1, BYTE b2, BYTE b3, BYTE b4)
  40. {
  41. m_lIpAddress = (LONG) MAKEIPADDRESS(b1,b2,b3,b4);
  42. m_fInitOk = TRUE;
  43. }
  44. CIpAddress(const CIpAddress& ia)
  45. {
  46. m_lIpAddress = ia.m_lIpAddress;
  47. m_fInitOk = ia.m_fInitOk;
  48. }
  49. CIpAddress (const CString & str);
  50. //
  51. // Assignment operators
  52. //
  53. const CIpAddress & operator =(const LONG l);
  54. const CIpAddress & operator =(const CString & str);
  55. const CIpAddress & operator =(const CIpAddress& ia)
  56. {
  57. m_lIpAddress = ia.m_lIpAddress;
  58. m_fInitOk = ia.m_fInitOk;
  59. return *this;
  60. }
  61. //
  62. // Conversion operators
  63. //
  64. operator const LONG() const
  65. {
  66. return m_lIpAddress;
  67. }
  68. operator const CString&() const;
  69. public:
  70. BOOL IsValid() const
  71. {
  72. return m_fInitOk;
  73. }
  74. private:
  75. LONG m_lIpAddress;
  76. BOOL m_fInitOk;
  77. };
  78. #endif _IPADDRES_H