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.

258 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. nbp.h
  5. Abstract:
  6. This module contains NBP specific declarations.
  7. Author:
  8. Jameel Hyder (jameelh@microsoft.com)
  9. Nikhil Kamkolkar (nikhilk@microsoft.com)
  10. Revision History:
  11. 25 Feb 1993 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _NBP_
  15. // Each "OpenSocket" structure has a "RegsiteredName" field which is the list
  16. // of Network Visible Entities (NVE) available on that socket. Each NVE is
  17. // made up of three fields: object, type, zone For example:
  18. // "Sidhu:MailBox:Bandley3". We don't have to store the zone in the NVE
  19. // structure because each entity must be registered in the zone that the node
  20. // resides in.
  21. // NBP entity multiple character wildcard.
  22. #define NBP_WILD_CHARACTER 0xC5
  23. // The largest "on the wire" NBP tuple
  24. #define MAX_NBP_TUPLELENGTH (2 + 1 + 1 + 1 + \
  25. 3 * (MAX_ENTITY_LENGTH + 1))
  26. #define MIN_NBP_TUPLELENGTH (2 + 1 + 1 + 1 + 3 * (1 + 1))
  27. // Structure of NBP Header
  28. typedef struct _NbpHeader {
  29. BYTE _CmdAndTupleCnt;
  30. BYTE _NbpId;
  31. } NBPHDR, *PNBPHDR;
  32. // An internal representation of an NBP tuple. This structure is never
  33. // actually put out on the wire so it can be in a convienient form to work
  34. // with. See "Inside AppleTalk" for further information.
  35. typedef struct
  36. {
  37. ATALK_ADDR tpl_Address;
  38. SHORT tpl_Enumerator;
  39. BYTE tpl_ObjectLen;
  40. BYTE tpl_Object[MAX_ENTITY_LENGTH];
  41. BYTE tpl_TypeLen;
  42. BYTE tpl_Type [MAX_ENTITY_LENGTH];
  43. BYTE tpl_ZoneLen;
  44. BYTE tpl_Zone [MAX_ENTITY_LENGTH];
  45. } NBPTUPLE, *PNBPTUPLE;
  46. // A registered name hangs off a open socket
  47. #define RDN_SIGNATURE *(PULONG)"NBPR"
  48. #if DBG
  49. #define VALID_REGDNAME(pRegdName) (((pRegdName) != NULL) && \
  50. ((pRegdName)->rdn_Signature == RDN_SIGNATURE))
  51. #else
  52. #define VALID_REGDNAME(pRegdName) ((pRegdName) != NULL)
  53. #endif
  54. typedef struct _REGD_NAME
  55. {
  56. #if DBG
  57. ULONG rdn_Signature;
  58. #endif
  59. struct _REGD_NAME * rdn_Next;
  60. NBPTUPLE rdn_Tuple;
  61. } REGD_NAME, *PREGD_NAME;
  62. #define FOR_REGISTER 1
  63. #define FOR_CONFIRM 2
  64. #define FOR_LOOKUP 3
  65. #define PDN_FREE_REGDNAME 0x0001
  66. #define PDN_CLOSING 0x8000
  67. // When we're doing NBP registers, lookups, or confirms we need to have a
  68. // concept of "pending" NVE's.
  69. #define PDN_SIGNATURE *(PULONG)"NBPP"
  70. #if DBG
  71. #define VALID_PENDNAME(pPendName) (((pPendName) != NULL) && \
  72. ((pPendName)->pdn_Signature == PDN_SIGNATURE))
  73. #else
  74. #define VALID_PENDNAME(pPendName) ((pPendName) != NULL)
  75. #endif
  76. typedef struct _PEND_NAME
  77. {
  78. #if DBG
  79. ULONG pdn_Signature;
  80. #endif
  81. struct _PEND_NAME * pdn_Next; // Next in the chain
  82. PREGD_NAME pdn_pRegdName; // This is moved to the open socket, if
  83. // FOR_REGISTER and successful
  84. PDDP_ADDROBJ pdn_pDdpAddr; // Socket that is registering,
  85. // confiming or looking-up.
  86. ATALK_ADDR pdn_ConfirmAddr; // The expected internet address
  87. // that we're trying to confirm.
  88. TIMERLIST pdn_Timer; // Broadcast timer
  89. LONG pdn_RefCount; // Reference count
  90. USHORT pdn_NbpId; // So we can sort out answers!
  91. USHORT pdn_Flags; // PDN_xxx values
  92. USHORT pdn_MaxTuples; // For lookup, what is the max # of
  93. // tuples our client is expecting?
  94. USHORT pdn_TotalTuples; // For lookup, how many tuples have we stored so far?
  95. BYTE pdn_Reason; // Confirm,Lookup or Register
  96. BYTE pdn_RemainingBroadcasts;// How many more till we assume we're finished?
  97. USHORT pdn_DatagramLength; // Actual length of the datagram
  98. USHORT pdn_MdlLength; // Length of user Mdl
  99. PAMDL pdn_pAMdl; // Start of caller's "buffer" used to recieve tuples.
  100. PACTREQ pdn_pActReq; // Passed on to the completion routine.
  101. ATALK_ERROR pdn_Status; // Final status
  102. ATALK_SPIN_LOCK pdn_Lock; // Lock for this pending name
  103. CHAR pdn_Datagram[sizeof(NBPHDR) + MAX_NBP_TUPLELENGTH];
  104. // The DDP datagram that we use to broadcast
  105. // the request.
  106. } PEND_NAME, *PPEND_NAME;
  107. // Default values for NBP timers
  108. #define NBP_BROADCAST_INTERVAL 10 // In 100ms units
  109. #define NBP_NUM_BROADCASTS 10
  110. // The three NBP command types
  111. #define NBP_BROADCAST_REQUEST 1
  112. #define NBP_LOOKUP 2
  113. #define NBP_LOOKUP_REPLY 3
  114. #define NBP_FORWARD_REQUEST 4
  115. extern
  116. VOID
  117. AtalkNbpPacketIn(
  118. IN PPORT_DESCRIPTOR pPortDesc,
  119. IN PDDP_ADDROBJ pDdpAddr,
  120. IN PBYTE pPkt,
  121. IN USHORT PktLen,
  122. IN PATALK_ADDR pSrcAddr,
  123. IN PATALK_ADDR pDstAddr,
  124. IN ATALK_ERROR ErrorCode,
  125. IN BYTE DdpType,
  126. IN PVOID pHandlerCtx,
  127. IN BOOLEAN OptimizePath,
  128. IN PVOID OptimizeCtx
  129. );
  130. extern
  131. ATALK_ERROR
  132. AtalkNbpAction(
  133. IN PDDP_ADDROBJ pDdpAddr,
  134. IN BYTE Reason,
  135. IN PNBPTUPLE pNbpTuple,
  136. OUT PAMDL pAMdl OPTIONAL, // FOR_LOOKUP
  137. IN USHORT MaxTuples OPTIONAL, // FOR_LOOKUP
  138. IN PACTREQ pActReq
  139. );
  140. extern
  141. VOID
  142. AtalkNbpCloseSocket(
  143. IN PDDP_ADDROBJ pDdpAddr
  144. );
  145. extern
  146. ATALK_ERROR
  147. AtalkNbpRemove(
  148. IN PDDP_ADDROBJ pDdpAddr,
  149. IN PNBPTUPLE pNbpTuple,
  150. IN PACTREQ pActReq
  151. );
  152. LOCAL LONG FASTCALL
  153. atalkNbpTimer(
  154. IN PTIMERLIST pTimer,
  155. IN BOOLEAN TimerShuttingDown
  156. );
  157. LOCAL VOID
  158. atalkNbpLookupNames(
  159. IN PPORT_DESCRIPTOR pPortDesc,
  160. IN PDDP_ADDROBJ pDdpAddr,
  161. IN PNBPTUPLE pNbpTuple,
  162. IN SHORT NbpId
  163. );
  164. LOCAL BOOLEAN
  165. atalkNbpMatchWild(
  166. IN PBYTE WildString,
  167. IN BYTE WildStringLen,
  168. IN PBYTE String,
  169. IN BYTE StringLen
  170. );
  171. LOCAL SHORT
  172. atalkNbpEncodeTuple(
  173. IN PNBPTUPLE pNbpTuple,
  174. IN PBYTE pZone OPTIONAL,
  175. IN BYTE ZoneLen OPTIONAL,
  176. IN BYTE Socket OPTIONAL,
  177. OUT PBYTE pBuffer
  178. );
  179. LOCAL SHORT
  180. atalkNbpDecodeTuple(
  181. IN PBYTE pBuffer,
  182. IN USHORT PktLen,
  183. OUT PNBPTUPLE pNbpTuple
  184. );
  185. LOCAL VOID
  186. atalkNbpLinkPendingNameInList(
  187. IN PDDP_ADDROBJ pDdpAddr,
  188. IN OUT PPEND_NAME pPendName
  189. );
  190. LOCAL BOOLEAN
  191. atalkNbpSendRequest(
  192. IN PPEND_NAME pPendName
  193. );
  194. LOCAL VOID
  195. atalkNbpSendLookupDatagram(
  196. IN PPORT_DESCRIPTOR pPortDesc,
  197. IN PDDP_ADDROBJ pDdpAddr,
  198. IN SHORT NbpId,
  199. IN PNBPTUPLE pNbpTuple
  200. );
  201. LOCAL VOID
  202. atalkNbpSendForwardRequest(
  203. IN PDDP_ADDROBJ pDdpAddr,
  204. IN struct _RoutingTableEntry * pRte,
  205. IN SHORT NbpId,
  206. IN PNBPTUPLE pNbpTuple
  207. );
  208. VOID
  209. atalkNbpDerefPendName(
  210. IN PPEND_NAME pPendName
  211. );
  212. VOID FASTCALL
  213. atalkNbpSendComplete(
  214. IN NDIS_STATUS Status,
  215. IN PSEND_COMPL_INFO pSendInfo
  216. );
  217. #endif // _NBP_
  218.