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.

261 lines
8.3 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. net\routing\ipx\sap\sapdefs.h
  5. Abstract:
  6. Constants and data structures common to all SAP files
  7. Author:
  8. Vadim Eydelman 05-15-1995
  9. Revision History:
  10. --*/
  11. #ifndef _SAP_SAPDEFS
  12. #define _SAP_SAPDEFS
  13. extern UCHAR IPX_SAP_SOCKET[2]; // Defined in workers.c
  14. #define IPX_SAP_PACKET_TYPE 4
  15. #define IPX_SAP_MAX_ENTRY 7
  16. #define IPX_MAX_HOP_COUNT 16
  17. // Operations in IPX SAP
  18. #define SAP_GENERAL_REQ 1
  19. #define SAP_GENERAL_RESP 2
  20. #define SAP_GET_NEAREST_REQ 3
  21. #define SAP_GET_NEAREST_RESP 4
  22. // Time constants
  23. // IPX specific
  24. #define IPX_SAP_INTERPACKET_GAP 55 // msec
  25. // Registry configurable values (defaults and ranges)
  26. #define SAP_SERVICE_REGISTRY_KEY_STR \
  27. "System\\CurrentControlSet\\Services\\NwSapAgent"
  28. #define SAP_ROUTER_REGISTRY_KEY_STR \
  29. "System\\CurrentControlSet\\Services\\RemoteAccess\\RouterManagers\\IPX\\RoutingProtocols\\IPXSAP"
  30. // Interval for periodic update broadcasts (for standalone service only)
  31. #define SAP_UPDATE_INTERVAL_DEF 1 // min
  32. #define SAP_UPDATE_INTERVAL_MIN 1
  33. #define SAP_UPDATE_INTERVAL_MAX 30
  34. #define SAP_UPDATE_INTERVAL_STR "SendTime"
  35. // Server aging timeout (for standalone service only)
  36. #define SAP_AGING_TIMEOUT_DEF 3 // min
  37. #define SAP_AGING_TIMEOUT_MIN 3
  38. #define SAP_AGING_TIMEOUT_MAX 90
  39. #define SAP_AGING_TIMEOUT_STR "EntryTimeout"
  40. // Update mode on WAN lines
  41. #define SAP_WAN_NO_UPDATE 0
  42. #define SAP_WAN_CHANGES_ONLY 1
  43. #define SAP_WAN_STANDART_UPDATE 2
  44. #define SAP_WAN_UPDATE_MODE_DEF SAP_WAN_NO_UPDATE
  45. #define SAP_WAN_UPDATE_MODE_MIN SAP_WAN_NO_UPDATE
  46. #define SAP_WAN_UPDATE_MODE_MAX SAP_WAN_STANDART_UPDATE
  47. #define SAP_WAN_UPDATE_MODE_STR "WANFilter"
  48. // Interval for periodic update broadcasts on WAN lines (for standalone service only)
  49. #define SAP_WAN_UPDATE_INTERVAL_DEF 1 // min
  50. #define SAP_WAN_UPDATE_INTERVAL_MIN 1
  51. #define SAP_WAN_UPDATE_INTERVAL_MAX 30
  52. #define SAP_WAN_UPDATE_INTERVAL_STR "WANUpdateTime"
  53. // Max number of pending recv work items
  54. #define SAP_MAX_UNPROCESSED_REQUESTS_DEF 100
  55. #define SAP_MAX_UNPROCESSED_REQUESTS_MIN 10
  56. #define SAP_MAX_UNPROCESSED_REQUESTS_MAX 1000
  57. #define SAP_MAX_UNPROCESSED_REQUESTS_STR "MaxRecvBufferLookAhead"
  58. // Whether to respond for internal servers that are not registered with SAP
  59. // through the API calls (for standalone service only)
  60. #define SAP_RESPOND_FOR_INTERNAL_DEF TRUE
  61. #define SAP_RESPOND_FOR_INTERNAL_MIN FALSE
  62. #define SAP_RESPOND_FOR_INTERNAL_MAX TRUE
  63. #define SAP_RESPOND_FOR_INTERNAL_STR "RespondForInternalServers"
  64. // Delay in response to general reguests for specific server type
  65. // if local servers are included in the packet
  66. #define SAP_DELAY_RESPONSE_TO_GENERAL_DEF 0 // msec
  67. #define SAP_DELAY_RESPONSE_TO_GENERAL_MIN 0
  68. #define SAP_DELAY_RESPONSE_TO_GENERAL_MAX 2000
  69. #define SAP_DELAY_RESPONSE_TO_GENERAL_STR "DelayRespondToGeneral"
  70. // Delay in sending change broadcasts if packet is not full
  71. #define SAP_DELAY_CHANGE_BROADCAST_DEF 3 // sec
  72. #define SAP_DELAY_CHANGE_BROADCAST_MIN 0
  73. #define SAP_DELAY_CHANGE_BROADCAST_MAX 30
  74. #define SAP_DELAY_CHANGE_BROADCAST_STR "DelayChangeBroadcast"
  75. // Size of heap reserved for the database
  76. #define SAP_SDB_MAX_HEAP_SIZE_DEF 8 // Meg
  77. #define SAP_SDB_MAX_HEAP_SIZE_MIN 1
  78. #define SAP_SDB_MAX_HEAP_SIZE_MAX 32
  79. #define SAP_SDB_MAX_HEAP_SIZE_STR "NameTableReservedHeapSize"
  80. // Interval with which to update the sorted list
  81. #define SAP_SDB_SORT_LATENCY_DEF 60 // sec
  82. #define SAP_SDB_SORT_LATENCY_MIN 10
  83. #define SAP_SDB_SORT_LATENCY_MAX 600
  84. #define SAP_SDB_SORT_LATENCY_STR "NameTableSortLatency"
  85. // Max number of unsorted servers
  86. #define SAP_SDB_MAX_UNSORTED_DEF 16
  87. #define SAP_SDB_MAX_UNSORTED_MIN 1
  88. #define SAP_SDB_MAX_UNSORTED_MAX 100
  89. #define SAP_SDB_MAX_UNSORTED_STR "MaxUnsortedNames"
  90. // How often to check on pending triggered update
  91. #define SAP_TRIGGERED_UPDATE_CHECK_INTERVAL_DEF 10 // sec
  92. #define SAP_TRIGGERED_UPDATE_CHECK_INTERVAL_MIN 3
  93. #define SAP_TRIGGERED_UPDATE_CHECK_INTERVAL_MAX 60
  94. #define SAP_TRIGGERED_UPDATE_CHECK_INTERVAL_STR "TriggeredUpdateCheckInterval"
  95. // How many requests to send if no response received within check interval
  96. #define SAP_MAX_TRIGGERED_UPDATE_REQUESTS_DEF 3
  97. #define SAP_MAX_TRIGGERED_UPDATE_REQUESTS_MIN 1
  98. #define SAP_MAX_TRIGGERED_UPDATE_REQUESTS_MAX 10
  99. #define SAP_MAX_TRIGGERED_UPDATE_REQUESTS_STR "MaxTriggeredUpdateRequests"
  100. // Time limit for shutdown broadcast
  101. #define SAP_SHUTDOWN_TIMEOUT_DEF 60 // sec
  102. #define SAP_SHUTDOWN_TIMEOUT_MIN 20
  103. #define SAP_SHUTDOWN_TIMEOUT_MAX 180
  104. #define SAP_SHUTDOWN_TIMEOUT_STR "ShutdownBroadcastTimeout"
  105. // Number of additional recv requests to post when binding the interface
  106. // that has listen enabled
  107. #define SAP_REQUESTS_PER_INTF_DEF 4
  108. #define SAP_REQUESTS_PER_INTF_MIN 1
  109. #define SAP_REQUESTS_PER_INTF_MAX 256
  110. #define SAP_REQUESTS_PER_INTF_STR "RequestsPerInterface"
  111. // Minimum number of queued recv requests
  112. #define SAP_MIN_REQUESTS_DEF 16
  113. #define SAP_MIN_REQUESTS_MIN 16
  114. #define SAP_MIN_REQUESTS_MAX 2048
  115. #define SAP_MIN_REQUESTS_STR "MinimumRequests"
  116. // Time to wait before retrying failed operation that should not fail
  117. #define SAP_ERROR_COOL_OFF_TIME (3*1000)
  118. #define BINDLIB_NCP_SAP 0xC0000000
  119. #define BINDLIB_NCP_MAX_SAP 0xCFFFFFFF
  120. #pragma pack(push, 1)
  121. typedef struct _IPX_ADDRESS_BLOCK {
  122. UCHAR Network[4];
  123. UCHAR Node[6];
  124. UCHAR Socket[2];
  125. } IPX_ADDRESS_BLOCK, *PIPX_ADDRESS_BLOCK;
  126. // Packet typedef for server entry
  127. typedef struct _IPX_SERVER_ENTRY_P {
  128. USHORT Type;
  129. UCHAR Name[48];
  130. UCHAR Network[4];
  131. UCHAR Node[6];
  132. UCHAR Socket[2];
  133. USHORT HopCount;
  134. } IPX_SERVER_ENTRY_P, *PIPX_SERVER_ENTRY_P;
  135. typedef struct _SAP_BUFFER {
  136. USHORT Checksum;
  137. USHORT Length;
  138. UCHAR TransportCtl;
  139. UCHAR PacketType;
  140. IPX_ADDRESS_BLOCK Dst;
  141. IPX_ADDRESS_BLOCK Src;
  142. USHORT Operation;
  143. IPX_SERVER_ENTRY_P Entries[IPX_SAP_MAX_ENTRY];
  144. } SAP_BUFFER, *PSAP_BUFFER;
  145. #pragma pack(pop)
  146. // IPX Server Name copy macro
  147. #define IpxNameCpy(dst,src) strncpy(dst,src,48)
  148. // IPX Server Name comparison
  149. #define IpxNameCmp(name1,name2) strncmp(name1,name2,48)
  150. #define IpxNetCpy(dst,src) *((UNALIGNED ULONG *)(dst)) = *((UNALIGNED ULONG *)(src))
  151. #define IpxNetCmp(net1,net2) memcmp(net1,net2,4)
  152. #define IpxNodeCpy(dst,src) memcpy(dst,src,6)
  153. #define IpxNodeCmp(node1,node2) memcmp(node1,node2,6)
  154. #define IpxSockCpy(dst,src) *((UNALIGNED USHORT *)(dst)) = *((UNALIGNED USHORT *)(src))
  155. #define IpxSockCmp(sock1,sock2) memcmp(sock1,sock2,2)
  156. #define IpxAddrCpy(dst,src) { \
  157. IpxNetCpy((dst)->Network,(src)->Network); \
  158. IpxNodeCpy((dst)->Node,(src)->Node); \
  159. IpxSockCpy((dst)->Socket,(src)->Socket); \
  160. }
  161. #define IpxServerCpy(dst,src) { \
  162. (dst)->Type = (src)->Type; \
  163. IpxNameCpy((dst)->Name,(src)->Name); \
  164. IpxNetCpy((dst)->Network,(src)->Network); \
  165. IpxNodeCpy((dst)->Node,(src)->Node); \
  166. IpxSockCpy((dst)->Socket,(src)->Socket); \
  167. (dst)->HopCount = (src)->HopCount; \
  168. }
  169. // Conversions from/to on-the-wire format
  170. #define GETUSHORT(src) ( \
  171. (USHORT)( \
  172. (((UCHAR *)(src))[0]<<8) \
  173. + (((UCHAR *)(src))[1]) \
  174. ) \
  175. )
  176. #define GETULONG(src) ( \
  177. (ULONG)( \
  178. (((UCHAR *)(src))[0]<<24) \
  179. + (((UCHAR *)(src))[1]<<16) \
  180. + (((UCHAR *)(src))[2]<<8) \
  181. + (((UCHAR *)(src))[3]) \
  182. ) \
  183. )
  184. #define PUTUSHORT(src,dst) { \
  185. ((UCHAR *)(dst))[0] = ((UCHAR)((src)>>8)); \
  186. ((UCHAR *)(dst))[1] = ((UCHAR)(src)); \
  187. }
  188. #define PUTULONG(src,dst) { \
  189. ((UCHAR *)(dst))[0] = ((UCHAR)((src)>>24)); \
  190. ((UCHAR *)(dst))[1] = ((UCHAR)((src)>>16)); \
  191. ((UCHAR *)(dst))[2] = ((UCHAR)((src)>>8)); \
  192. ((UCHAR *)(dst))[3] = ((UCHAR)(src)); \
  193. }
  194. // Complement macros in ntrtl.h
  195. #define InitializeListEntry(entry) InitializeListHead(entry)
  196. #define IsListEntry(entry) (!IsListEmpty(entry))
  197. // Time comparison macro that accounts for possible wraparound
  198. // (maximum time difference is MAXULONG/2 msec (21+ days))
  199. #define IsLater(time1,time2) (((time1)-(time2))<MAXULONG/2)
  200. // Fast round to sec macro (it actually rounds to 1024 msec)
  201. #define RoundUpToSec(msecTime) (((msecTime)&0xFFFFFC00)+0x00000400)
  202. // IPX broadcast node number def
  203. extern UCHAR IPX_BCAST_NODE[6];
  204. #endif