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.

50 lines
1.2 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. private\inc\ipcmp.h
  5. Abstract:
  6. Compare utility functions for IP
  7. Revision History:
  8. Amritansh Raghav 6/16/95 Created
  9. --*/
  10. #ifndef __IPUTILS_H__
  11. #define __IPUTILS_H__
  12. //
  13. // ULONG
  14. // Cmp(DWORD dwFirst, DWORD dwSecond, ULONG lResult)
  15. //
  16. #define Cmp(dwFirst,dwSecond,lResult) ((ULONG)((lResult) = ((dwFirst) - (dwSecond))))
  17. //
  18. // LONG
  19. // PortCmp(WORD wPort1, WORD wPort2, LONG lResult)
  20. //
  21. #define PortCmp(dwPort1, dwPort2,lResult) ((LONG)((lResult) = ((ntohs((WORD)dwPort1)) - (ntohs((WORD)dwPort2)))))
  22. // The addresses are in Network order
  23. //
  24. // LONG
  25. // InetCmp(DWORD IpAddr1, DWORD IpAddr2, LONG lResult)
  26. //
  27. #define InetCmp(dwIpAddr1,dwIpAddr2,res) \
  28. ((LONG)(((res) = (((dwIpAddr1) & 0x000000ff) - ((dwIpAddr2) & 0x000000ff))) ? (res) : \
  29. (((res) = (((dwIpAddr1) & 0x0000ff00) - ((dwIpAddr2) & 0x0000ff00))) ? (res) : \
  30. (((res) = (((dwIpAddr1) & 0x00ff0000) - ((dwIpAddr2) & 0x00ff0000))) ? (res) : \
  31. ((res) = ((((dwIpAddr1) & 0xff000000)>>8) - (((dwIpAddr2) & 0xff000000)>>8)))))))
  32. #endif // __IPUTILS_H__