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.

201 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. routing\ip\rtrmgr\rtrdisc.h
  5. Abstract:
  6. Header file for router discover related stuff
  7. Revision History:
  8. Amritansh Raghav 20th Mar 1996 Created
  9. --*/
  10. #ifndef __RTRDISC_H__
  11. #define __RTRDISC_H__
  12. typedef struct _ICB ICB, *PICB;
  13. typedef struct _TIMER_QUEUE_ITEM
  14. {
  15. LIST_ENTRY leTimerLink;
  16. LARGE_INTEGER liFiringTime;
  17. }TIMER_QUEUE_ITEM, *PTIMER_QUEUE_ITEM;
  18. typedef struct _ROUTER_DISC_CB
  19. {
  20. WORD wMaxAdvtInterval;
  21. WORD wAdvtLifetime;
  22. BOOL bAdvertise;
  23. BOOL bActive;
  24. LONG lPrefLevel;
  25. DWORD dwNumAdvtsSent;
  26. DWORD dwNumSolicitationsSeen;
  27. TIMER_QUEUE_ITEM tqiTimer;
  28. BOOL bReplyPending;
  29. LARGE_INTEGER liMaxMinDiff;
  30. LARGE_INTEGER liMinAdvtIntervalInSysUnits;
  31. SOCKET *pRtrDiscSockets;
  32. }ROUTER_DISC_CB, *PROUTER_DISC_CB;
  33. //
  34. // Blocking mode socket with IP Multicast capability
  35. //
  36. #define RTR_DISC_SOCKET_FLAGS (WSA_FLAG_MULTIPOINT_C_LEAF|WSA_FLAG_MULTIPOINT_D_LEAF)
  37. #define ALL_ROUTERS_MULTICAST_GROUP ((DWORD)0x020000E0) //inet_addr("224.0.0.2")
  38. #define ALL_SYSTEMS_MULTICAST_GROUP ((DWORD)0x010000E0) //inet_addr("224.0.0.1")
  39. //#define ALL_SYSTEMS_MULTICAST_GROUP ((DWORD)0xFFFFFFFF) //inet_addr("224.0.0.1")
  40. #define ICMP_ROUTER_DISCOVERY_TYPE ((BYTE) 0x9)
  41. #define ICMP_ROUTER_DISCOVERY_CODE ((BYTE) 0x0)
  42. #define ICMP_ROUTER_DISCOVERY_ADDR_SIZE ((BYTE) 0x2)
  43. #include <packon.h>
  44. typedef struct _ICMP_ROUTER_SOL_MSG
  45. {
  46. BYTE byType;
  47. BYTE byCode;
  48. WORD wXSum;
  49. DWORD dwReserved;
  50. }ICMP_ROUTER_SOL_MSG, *PICMP_ROUTER_SOL_MSG;
  51. typedef struct _ICMP_ADVT
  52. {
  53. DWORD dwRtrIpAddr;
  54. LONG lPrefLevel;
  55. }ICMP_ADVT, *PICMP_ADVT;
  56. typedef struct _ICMP_ROUTER_ADVT_MSG
  57. {
  58. BYTE byType;
  59. BYTE byCode;
  60. WORD wXSum;
  61. BYTE byNumAddrs;
  62. BYTE byAddrEntrySize;
  63. WORD wLifeTime;
  64. ICMP_ADVT iaAdvt[1];
  65. }ICMP_ROUTER_ADVT_MSG, *PICMP_ROUTER_ADVT_MSG;
  66. #define SIZEOF_RTRDISC_ADVT(X) \
  67. (FIELD_OFFSET(ICMP_ROUTER_ADVT_MSG, iaAdvt[0]) + \
  68. ((X) * sizeof(ICMP_ADVT)))
  69. typedef struct _IP_HEADER
  70. {
  71. BYTE byVerLen; // Version and length.
  72. BYTE byTos; // Type of service.
  73. WORD wLength; // Total length of datagram.
  74. WORD wId; // Identification.
  75. WORD wFlagOff; // Flags and fragment offset.
  76. BYTE byTtl; // Time to live.
  77. BYTE byProtocol; // Protocol.
  78. WORD wXSum; // Header checksum.
  79. DWORD dwSrc; // Source address.
  80. DWORD dwDest; // Destination address.
  81. }IP_HEADER, *PIP_HEADER;
  82. //
  83. // Max size of the IP Header in DWORDs
  84. //
  85. #include <packoff.h>
  86. #define MAX_LEN_HDR 15
  87. //
  88. // Take the largest ICMP packet that can be received to avoid getting
  89. // too many buffer size errors
  90. //
  91. #define ICMP_RCV_BUFFER_LEN ((2*MAX_LEN_HDR) + 2 +2)
  92. //
  93. // Function prototypes
  94. //
  95. VOID
  96. SetRouterDiscoveryInfo(
  97. IN PICB picb,
  98. IN PRTR_INFO_BLOCK_HEADER pInfoHdr
  99. );
  100. VOID
  101. InitializeRouterDiscoveryInfo(
  102. IN PICB picb,
  103. IN PRTR_INFO_BLOCK_HEADER pInfoHdr
  104. );
  105. DWORD
  106. GetInterfaceRouterDiscoveryInfo(
  107. PICB picb,
  108. PRTR_TOC_ENTRY pToc,
  109. PBYTE dataptr,
  110. PRTR_INFO_BLOCK_HEADER pInfoHdr,
  111. PDWORD pdwSize
  112. );
  113. DWORD
  114. ActivateRouterDiscovery(
  115. IN PICB picb
  116. );
  117. BOOL
  118. SetFiringTimeForAdvt(
  119. IN PICB picb
  120. );
  121. DWORD
  122. CreateSockets(
  123. IN PICB picb
  124. );
  125. DWORD
  126. UpdateAdvertisement(
  127. IN PICB picb
  128. );
  129. VOID
  130. HandleRtrDiscTimer(
  131. VOID
  132. );
  133. VOID
  134. HandleSolicitations(
  135. VOID
  136. );
  137. VOID
  138. AdvertiseInterface(
  139. IN PICB picb
  140. );
  141. WORD
  142. Compute16BitXSum(
  143. IN PVOID pvData,
  144. IN DWORD dwNumBytes
  145. );
  146. DWORD
  147. DeActivateRouterDiscovery(
  148. IN PICB picb
  149. );
  150. VOID
  151. SetFiringTimeForReply(
  152. IN PICB picb
  153. );
  154. #endif