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
4.2 KiB

  1. /*++
  2. Copyright (c) 1992-1996 Microsoft Corporation
  3. Module Name:
  4. arp.h
  5. Abstract:
  6. This file contains the definitions and data declarations for the atmarp server.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com) July 1996
  9. Environment:
  10. Kernel mode
  11. Revision History:
  12. --*/
  13. //
  14. // Definition for an IP address
  15. //
  16. typedef ULONG IPADDR; // An IP address
  17. //
  18. // OpCodes - Define these in network byte order
  19. //
  20. #define ATMARP_Request 0x0100
  21. #define ATMARP_Reply 0x0200
  22. #define InATMARP_Request 0x0800
  23. #define InATMARP_Reply 0x0900
  24. #define ATMARP_Nak 0x0A00
  25. #define ATM_HWTYPE 0x1300 // ATM Forum assigned - in network byte order
  26. #define IP_PROTOCOL_TYPE 0x0008 // In network byte order
  27. #define IP_ADDR_LEN sizeof(IPADDR)
  28. //
  29. // the offset into the 20 byte ATM address where the ESI starts
  30. //
  31. #define ESI_START_OFFSET 13
  32. //
  33. // Structure of a Q2931 ARP header.
  34. //
  35. //
  36. // Encoding of the TL, ATM Number and ATM Sub-address encoding
  37. //
  38. typedef UCHAR ATM_ADDR_TL;
  39. #define TL_LEN(_x_) ((_x_) & 0x3F) // Low 6 bits
  40. // range is from 0-ATM_ADDRESS_LENGTH
  41. #define TL_TYPE(_x_) (((_x_) & 0x40) >> 6) // Bit # 7, 0 - ATM Forum NSAP, 1 - E164
  42. #define TL_RESERVED(_x_) (((_x_) & 0x80) >> 7) // Bit # 8 - Must be 0
  43. #define TL(_type_, _len_) (((UCHAR)(_type_) << 6) + (UCHAR)(_len_))
  44. #define ADDR_TYPE_NSAP 0
  45. #define ADDR_TYPE_E164 1
  46. #if (ADDR_TYPE_NSAP != ATM_NSAP)
  47. #error "Atm address type mismatch"
  48. #endif
  49. #if (ADDR_TYPE_E164 != ATM_E164)
  50. #error "Atm address type mismatch"
  51. #endif
  52. //
  53. // the structure for the LLC/SNAP encapsulation header on the IP packets for Q2931
  54. //
  55. typedef struct
  56. {
  57. UCHAR LLC[3];
  58. UCHAR OUI[3];
  59. USHORT EtherType;
  60. } LLC_SNAP_HDR, *PLLC_SNAP_HDR;
  61. //
  62. // On the wire format for Atm ARP request
  63. //
  64. typedef struct _ARPS_HEADER
  65. {
  66. LLC_SNAP_HDR LlcSnapHdr; // LLC SNAP Header
  67. USHORT HwType; // Hardware address space.
  68. USHORT Protocol; // Protocol address space.
  69. ATM_ADDR_TL SrcAddressTL; // Src ATM number type & length
  70. ATM_ADDR_TL SrcSubAddrTL; // Src ATM subaddr type & length
  71. USHORT Opcode; // Opcode.
  72. UCHAR SrcProtoAddrLen; // Src protocol addr length
  73. ATM_ADDR_TL DstAddressTL; // Dest ATM number type & length
  74. ATM_ADDR_TL DstSubAddrTL; // Dest ATM subaddr type & length
  75. UCHAR DstProtoAddrLen; // Dest protocol addr length
  76. //
  77. // This is followed by variable length fields and is dictated by the value of fields above.
  78. //
  79. } ARPS_HEADER, *PARPS_HEADER;
  80. //
  81. // The following structure is used ONLY to allocate space for the packet.
  82. // It represents the maximum space needed for an arp request/reply.
  83. //
  84. typedef struct
  85. {
  86. UCHAR SrcHwAddr[ATM_ADDRESS_LENGTH]; // Source HW address.
  87. UCHAR SrcHwSubAddr[ATM_ADDRESS_LENGTH];// Source HW sub-address.
  88. IPADDR SrcProtoAddr; // Source protocol address.
  89. UCHAR DstHwAddr[ATM_ADDRESS_LENGTH]; // Destination HW address.
  90. UCHAR DstHwSubAddr[ATM_ADDRESS_LENGTH];// Destination HW sub-address.
  91. IPADDR DstProtoAddr; // Destination protocol address.
  92. } ARPS_VAR_HDR, *PARPS_VAR_HDR;
  93. //
  94. // Get a short (16-bits) from on-the-wire format (big-endian)
  95. // to a short in the host format (either big or little endian)
  96. //
  97. #define GETSHORT2SHORT(_D_, _S_) \
  98. *(PUSHORT)(_D_) = ((*((PUCHAR)(_S_)+0) << 8) + (*((PUCHAR)(_S_)+1)))
  99. //
  100. // Copy a short (16-bits) from the host format (either big or little endian)
  101. // to a short in the on-the-wire format (big-endian)
  102. //
  103. #define PUTSHORT2SHORT(_D_, _S_) \
  104. *((PUCHAR)(_D_)+0) = (UCHAR)((USHORT)(_S_) >> 8), \
  105. *((PUCHAR)(_D_)+1) = (UCHAR)(_S_)
  106. //
  107. // Get a ULONG from on-the-wire format to a ULONG in the host format
  108. //
  109. #define GETULONG2ULONG(DstPtr, SrcPtr) \
  110. *(PULONG)(DstPtr) = ((*((PUCHAR)(SrcPtr)+0) << 24) + \
  111. (*((PUCHAR)(SrcPtr)+1) << 16) + \
  112. (*((PUCHAR)(SrcPtr)+2) << 8) + \
  113. (*((PUCHAR)(SrcPtr)+3) ))
  114. //
  115. // Put a ULONG from the host format to a ULONG to on-the-wire format
  116. //
  117. #define PUTULONG2ULONG(DstPtr, Src) \
  118. *((PUCHAR)(DstPtr)+0) = (UCHAR) ((ULONG)(Src) >> 24), \
  119. *((PUCHAR)(DstPtr)+1) = (UCHAR) ((ULONG)(Src) >> 16), \
  120. *((PUCHAR)(DstPtr)+2) = (UCHAR) ((ULONG)(Src) >> 8), \
  121. *((PUCHAR)(DstPtr)+3) = (UCHAR) (Src)
  122.