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.

416 lines
9.0 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. zip.h
  5. Abstract:
  6. This module contains information for the Zone Information Protocol.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 19 Jun 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _ZIP_
  15. #define _ZIP_
  16. #define MAX_ZONE_LENGTH 32
  17. #define MAX_ZONES_PER_NET 255 // AppleTalk phase 2
  18. // ZIP specific data:
  19. #define ZIP_QUERY 1
  20. #define ZIP_REPLY 2
  21. #define ZIP_TAKEDOWN 3
  22. #define ZIP_BRINGUP 4
  23. #define ZIP_GET_NETINFO 5
  24. #define ZIP_NETINFO_REPLY 6
  25. #define ZIP_NOTIFY 7
  26. #define ZIP_EXT_REPLY 8
  27. #define ZIP_ONEZONEQUERY_DDPSIZE 4
  28. #define ZIP_GETZONELIST_DDPSIZE 8
  29. // For GetZoneList and GetMyZone we're handling simple ATP packets:
  30. #define ATP_ZIP_CMD_OFF (ATP_USER_BYTES_OFF + 0)
  31. #define ATP_ZIP_LAST_FLAG_OFF (ATP_USER_BYTES_OFF + 0)
  32. #define ATP_ZIP_START_INDEX_OFF (ATP_USER_BYTES_OFF + 2)
  33. #define ATP_ZIP_ZONE_CNT_OFF (ATP_USER_BYTES_OFF + 2)
  34. #define ATP_ZIP_FIRST_ZONE_OFF (ATP_USER_BYTES_OFF + 4)
  35. // Offsets into the datagram
  36. #define ZIP_CMD_OFF 0
  37. #define ZIP_NW_CNT_OFF 1
  38. #define ZIP_FLAGS_OFF 1
  39. #define ZIP_FIRST_NET_OFF 2 // Zip Query/Reply
  40. #define ZIP_FIRST_ZONELEN_OFF 4
  41. #define ZIP_LAST_NET_OFF 4 // Zip Query/Reply
  42. #define ZIP_FIRST_ZONENAME_OFF 5
  43. #define ZIP_REQ_ZONELEN_OFF 6 // Zip Query/Reply
  44. #define ZIP_REQ_ZONENAME_OFF 7 // Zip Query/Reply
  45. #define ZIP_CABLE_RANGE_START_OFF 2 // Phase II Values
  46. #define ZIP_CABLE_RANGE_END_OFF 4
  47. #define ZIP_ZONELEN_OFF 6
  48. #define ZIP_OLD_ZONELEN_OFF 6
  49. #define ZIP_ZONENAME_OFF 7
  50. #define ZIP_OLD_ZONENAME_OFF 7
  51. // The three ZIP ATP commands:
  52. #define ZIP_GET_MY_ZONE 7
  53. #define ZIP_GET_ZONE_LIST 8
  54. #define ZIP_GET_LOCAL_ZONES 9
  55. // The ZIP NetInfoReply and Notify flags.
  56. #define ZIP_ZONE_INVALID_FLAG 0x80
  57. #define ZIP_USE_BROADCAST_FLAG 0x40
  58. #define ZIP_ONLYONE_ZONE_FLAG 0x20
  59. // When we're starting up (on extended networks) we send out a few NetGetInfo's
  60. // to try to find out our zone name. This seems to be what phase II Macintosh
  61. // nodes do (timing wise):
  62. #define ZIP_GET_NETINFO_WAIT 500 // In Ms
  63. #define ZIP_NUM_GETNET_INFOS 3
  64. // When nodes are doing either GetMyZone (non-extended only) or GetZoneList
  65. // (both flavours) the request is sent to A-ROUTER a few times:
  66. #define ZIP_GET_ZONEINFO_TIMER 10 // In 100ms units
  67. #define ZIP_GET_ZONEINFO_RETRIES 3
  68. // The ZIP specific timer values:
  69. #define ZIP_QUERY_TIMER 100 // In 100ms units
  70. // When we're looking for the zone list of a network, when starting the
  71. // router, how many zip queries? how fast?
  72. #define ZIP_QUERY_WAIT 10 // In Ms
  73. #define ZIP_NUM_QUERIES 30
  74. #define ZIP_NUM_RETRIES 10
  75. #define ZONE_NAMES 1
  76. #define ZONE_NUM 2
  77. // Zone structure
  78. typedef struct _ZONE
  79. {
  80. struct _ZONE * zn_Next; // Next zone in the table
  81. struct _ZONE ** zn_Prev; // Next zone in the table
  82. LONG zn_RefCount; // Reference count
  83. BYTE zn_ZoneLen; // Length of the zone name string
  84. BYTE zn_Zone[1]; // Zone string, not null-terminated
  85. } ZONE, *PZONE;
  86. #define ZONES_EQUAL(pZ1, pZ2) AtalkFixedCompareCaseInsensitive( \
  87. (pZ1)->zn_Zone, \
  88. (pZ1)->zn_ZoneLen, \
  89. (pZ2)->zn_Zone, \
  90. (pZ1)->zn_ZoneLen) \
  91. typedef struct _ZONE_LIST
  92. {
  93. struct _ZONE_LIST * zl_Next; // Next zone on the list
  94. PZONE zl_pZone; // The zone itself
  95. } ZONE_LIST, *PZONE_LIST;
  96. #define NUM_ZONES_HASH_BUCKETS 23
  97. extern ATALK_SPIN_LOCK AtalkZoneLock;
  98. extern PZONE * AtalkZonesTable;
  99. extern PZONE AtalkDesiredZone;
  100. extern
  101. ATALK_ERROR
  102. AtalkZipInit(
  103. IN BOOLEAN Init
  104. );
  105. extern
  106. VOID
  107. AtalkZipMulticastAddrForZone(
  108. IN PPORT_DESCRIPTOR pPortDesc,
  109. IN PBYTE pZone,
  110. IN BYTE ZoneLen,
  111. IN PBYTE MulticastAddr
  112. );
  113. extern
  114. BOOLEAN
  115. AtalkZipGetNetworkInfoForNode(
  116. IN PPORT_DESCRIPTOR pPortDesc,
  117. IN PATALK_NODEADDR pNode,
  118. IN BOOLEAN FindDefZone
  119. );
  120. extern
  121. VOID
  122. AtalkZipPacketIn(
  123. IN PPORT_DESCRIPTOR pPortDesc,
  124. IN PDDP_ADDROBJ pDdpAddr,
  125. IN PBYTE pPkt,
  126. IN USHORT PktLen,
  127. IN PATALK_ADDR pSrcAddr,
  128. IN PATALK_ADDR pDstAddr,
  129. IN ATALK_ERROR ErrorCode,
  130. IN BYTE DdpType,
  131. IN PVOID pHandlerCtx,
  132. IN BOOLEAN OptimizePath,
  133. IN PVOID OptimizeCtx
  134. );
  135. extern
  136. VOID
  137. AtalkZipPacketInRouter(
  138. IN PPORT_DESCRIPTOR pPortDesc,
  139. IN PDDP_ADDROBJ pDdpAddr,
  140. IN PBYTE pPkt,
  141. IN USHORT PktLen,
  142. IN PATALK_ADDR pSrcAddr,
  143. IN PATALK_ADDR pDstAddr,
  144. IN ATALK_ERROR ErrorCode,
  145. IN BYTE DdpType,
  146. IN PVOID pHandlerCtx,
  147. IN BOOLEAN OptimizePath,
  148. IN PVOID OptimizeCtx
  149. );
  150. BOOLEAN
  151. AtalkInitZipStartProcessingOnPort(
  152. IN PPORT_DESCRIPTOR pPortDesc,
  153. IN PATALK_NODEADDR RouterNode
  154. );
  155. extern
  156. ATALK_ERROR
  157. AtalkZipGetMyZone(
  158. IN PPORT_DESCRIPTOR pPortDesc,
  159. IN BOOLEAN fDesired,
  160. IN OUT PAMDL pAMdl,
  161. IN INT Size,
  162. IN struct _ActionReq * pActReq
  163. );
  164. extern
  165. ATALK_ERROR
  166. AtalkZipGetZoneList(
  167. IN PPORT_DESCRIPTOR pPortDesc,
  168. IN BOOLEAN fLocalZones,
  169. IN OUT PAMDL pAMdl,
  170. IN INT Size,
  171. IN struct _ActionReq * pActReq
  172. );
  173. extern
  174. PZONE
  175. AtalkZoneReferenceByName(
  176. IN PBYTE ZoneName,
  177. IN BYTE ZoneLen
  178. );
  179. extern
  180. VOID
  181. AtalkZoneReferenceByPtr(
  182. IN PZONE pZone
  183. );
  184. VOID
  185. AtalkZoneDereference(
  186. IN PZONE pZone
  187. );
  188. extern
  189. VOID
  190. AtalkZoneFreeList(
  191. IN PZONE_LIST pZoneList
  192. );
  193. extern
  194. ULONG
  195. AtalkZoneNumOnList(
  196. IN PZONE_LIST ZoneList
  197. );
  198. extern
  199. PZONE_LIST
  200. AtalkZoneAddToList(
  201. IN PZONE_LIST ZoneList,
  202. IN PBYTE Zone,
  203. IN BYTE ZoneLen
  204. );
  205. extern
  206. PZONE_LIST
  207. AtalkZoneCopyList(
  208. IN PZONE_LIST ZoneList
  209. );
  210. extern
  211. BOOLEAN
  212. AtalkZoneNameOnList(
  213. IN PBYTE ZoneName,
  214. IN BYTE ZoneLen,
  215. IN PZONE_LIST pZoneList
  216. );
  217. extern
  218. BOOLEAN
  219. AtalkZoneOnList(
  220. IN PZONE pZone,
  221. IN PZONE_LIST pZoneList
  222. );
  223. extern TIMERLIST atalkZipQTimer;
  224. extern BOOLEAN atalkZipQryTmrRunning;
  225. LOCAL VOID
  226. atalkZipHandleNetInfo(
  227. IN PPORT_DESCRIPTOR pPortDesc,
  228. IN PDDP_ADDROBJ pDdpAddr,
  229. IN PATALK_ADDR pSrcAddr,
  230. IN PATALK_ADDR pDstAddr,
  231. IN PBYTE pPkt,
  232. IN USHORT PktLen
  233. );
  234. LOCAL VOID
  235. atalkZipHandleReply(
  236. IN PDDP_ADDROBJ pDdpAddr,
  237. IN PATALK_ADDR pSrcAddr,
  238. IN PBYTE pPkt,
  239. IN USHORT PktLen
  240. );
  241. LOCAL VOID
  242. atalkZipHandleQuery(
  243. IN PPORT_DESCRIPTOR pPortDesc,
  244. IN PDDP_ADDROBJ pDdpAddr,
  245. IN PATALK_ADDR pSrcAddr,
  246. IN PBYTE pPkt,
  247. IN USHORT PktLen
  248. );
  249. LOCAL VOID
  250. atalkZipHandleAtpRequest(
  251. IN PPORT_DESCRIPTOR pPortDesc,
  252. IN PDDP_ADDROBJ pDdpAddr,
  253. IN PATALK_ADDR pSrcAddr,
  254. IN BYTE CmdType,
  255. IN USHORT TrId,
  256. IN USHORT StartIndex
  257. );
  258. LOCAL LONG FASTCALL
  259. atalkZipQueryTimer(
  260. IN PTIMERLIST pContext,
  261. IN BOOLEAN TimerShuttingDown
  262. );
  263. LOCAL BOOLEAN
  264. atalkZipGetZoneListForPort(
  265. IN PPORT_DESCRIPTOR pPortDesc
  266. );
  267. // Control blocks from processing GetMyZone and GetZoneList calls
  268. #define ZCI_SIGNATURE (*(PULONG)"ZCI")
  269. #if DBG
  270. #define VALID_ZCI(pZci) (((pZci) != NULL) && \
  271. ((pZci)->zci_Signature == ZCI_SIGNATURE))
  272. #else
  273. #define VALID_ZCI(pZci) ((pZci) != NULL)
  274. #endif
  275. typedef struct _ZipCompletionInfo
  276. {
  277. #if DBG
  278. ULONG zci_Signature;
  279. #endif
  280. LONG zci_RefCount;
  281. PPORT_DESCRIPTOR zci_pPortDesc;
  282. PDDP_ADDROBJ zci_pDdpAddr;
  283. DDPAO_HANDLER zci_Handler;
  284. PAMDL zci_pAMdl;
  285. INT zci_BufLen;
  286. PACTREQ zci_pActReq;
  287. ATALK_ADDR zci_Router;
  288. TIMERLIST zci_Timer;
  289. USHORT zci_NextZoneOff;
  290. SHORT zci_ZoneCount;
  291. SHORT zci_ExpirationCount;
  292. SHORT zci_AtpRequestType;
  293. ATALK_ERROR zci_FinalStatus;
  294. BYTE zci_Datagram[ZIP_GETZONELIST_DDPSIZE];
  295. ATALK_SPIN_LOCK zci_Lock;
  296. } ZIPCOMPLETIONINFO, *PZIPCOMPLETIONINFO;
  297. LOCAL VOID
  298. atalkZipGetMyZoneReply(
  299. IN PPORT_DESCRIPTOR pPortDesc,
  300. IN PDDP_ADDROBJ pDdpAddr,
  301. IN PBYTE pPkt,
  302. IN USHORT PktLen,
  303. IN PATALK_ADDR pSrcAddr,
  304. IN PATALK_ADDR pDstAddr,
  305. IN ATALK_ERROR ErrorCode,
  306. IN BYTE DdpType,
  307. IN PZIPCOMPLETIONINFO pZci,
  308. IN BOOLEAN OptimizePath,
  309. IN PVOID OptimizeCtx
  310. );
  311. LOCAL VOID
  312. atalkZipGetZoneListReply(
  313. IN PPORT_DESCRIPTOR pPortDesc,
  314. IN PDDP_ADDROBJ pDdpAddr,
  315. IN PBYTE pPkt,
  316. IN USHORT PktLen,
  317. IN PATALK_ADDR pSrcAddr,
  318. IN PATALK_ADDR pDstAddr,
  319. IN ATALK_ERROR ErrorCode,
  320. IN BYTE DdpType,
  321. IN PZIPCOMPLETIONINFO pZci,
  322. IN BOOLEAN OptimizePath,
  323. IN PVOID OptimizeCtx
  324. );
  325. LOCAL ATALK_ERROR
  326. atalkZipSendPacket(
  327. IN PZIPCOMPLETIONINFO pZci,
  328. IN BOOLEAN TimerEnqueue
  329. );
  330. LOCAL VOID
  331. atalkZipDereferenceZci(
  332. IN PZIPCOMPLETIONINFO pZci
  333. );
  334. LOCAL LONG FASTCALL
  335. atalkZipZoneInfoTimer(
  336. IN PTIMERLIST pTimer,
  337. IN BOOLEAN TimerShuttingDown
  338. );
  339. LOCAL VOID FASTCALL
  340. atalkZipSendComplete(
  341. IN NDIS_STATUS Status,
  342. IN PSEND_COMPL_INFO pSendInfo
  343. );
  344. #endif // _ZIP_
  345.