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.

275 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. node.h
  5. Abstract:
  6. This module contains support for the Appletalk Node structure.
  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 _NODE_
  15. #define _NODE_
  16. #define ANY_ROUTER_NODE 0
  17. #define UNKNOWN_NODE 0
  18. #define MAX_ATALK_NODES 256
  19. #define MIN_USABLE_ATALKNODE 1
  20. #define MAX_USABLE_ATALKNODE 254
  21. #define MAX_EXT_ATALKNODE 253
  22. #define HIGHEST_WORKSTATION_NODE 127
  23. #define LOWEST_SERVER_NODE 128
  24. #define ATALK_BROADCAST_NODE ((BYTE)0xFF)
  25. #define NUM_USER_NODES 2
  26. // NODE STATES
  27. #define AN_OPEN 0x01
  28. #define AN_ROUTER_NODE 0x02
  29. #define AN_ORPHAN_NODE 0x04
  30. #define AN_CLOSING 0x80
  31. // values under which pram nodes are stored
  32. #define ROUTER_NODE_VALUE L"RouterPramNode"
  33. #define USER_NODE1_VALUE L"UserPramNode1"
  34. #define USER_NODE2_VALUE L"UserPramNode2"
  35. // Number of slots in the socket hash table stored per node
  36. #define NODE_DDPAO_HASH_SIZE 8
  37. #define AN_SIGNATURE (*(PULONG)"ANOD")
  38. #if DBG
  39. #define VALID_ATALK_NODE(pNode) (((pNode) != NULL) && \
  40. ((pNode)->an_Signature == AN_SIGNATURE))
  41. #else
  42. #define VALID_ATALK_NODE(pNode) ((pNode) != NULL)
  43. #endif
  44. typedef struct _ATALK_NODE
  45. {
  46. #if DBG
  47. ULONG an_Signature;
  48. #endif
  49. // List for all active nodes on a port
  50. struct _ATALK_NODE * an_Next;
  51. ULONG an_RefCount;
  52. // Backpointer to the port for this node
  53. struct _PORT_DESCRIPTOR *an_Port;
  54. // State of the node
  55. BYTE an_Flags;
  56. // Next dynamic socket number to create on this node.
  57. BYTE an_NextDynSkt;
  58. // Nbp Id & Enumerator to use on the next NbpAction
  59. BYTE an_NextNbpId;
  60. BYTE an_NextNbpEnum;
  61. // Hash List of ddp address objects (accessed by the
  62. // Appletalk socket address) on this node
  63. struct _DDP_ADDROBJ * an_DdpAoHash[NODE_DDPAO_HASH_SIZE];
  64. // Address of this node
  65. ATALK_NODEADDR an_NodeAddr;
  66. // Lock
  67. ATALK_SPIN_LOCK an_Lock;
  68. } ATALK_NODE, *PATALK_NODE;
  69. // Exports
  70. VOID
  71. AtalkNodeRefByAddr(
  72. IN PPORT_DESCRIPTOR pPortDesc,
  73. IN PATALK_NODEADDR pNodeAddr,
  74. OUT PATALK_NODE * pNode,
  75. OUT PATALK_ERROR pErr
  76. );
  77. // VOID
  78. // AtalkNodeRefByPtr(
  79. // IN OUT PATALK_NODE Node,
  80. // OUT PATALK_ERROR pErr
  81. // );
  82. #define AtalkNodeRefByPtr(_pNode, _pErr) \
  83. { \
  84. KIRQL OldIrql; \
  85. \
  86. ASSERT(VALID_ATALK_NODE(_pNode)); \
  87. \
  88. ACQUIRE_SPIN_LOCK(&(_pNode)->an_Lock, &OldIrql);\
  89. AtalkNodeRefByPtrNonInterlock(_pNode, _pErr); \
  90. RELEASE_SPIN_LOCK(&(_pNode)->an_Lock, OldIrql); \
  91. }
  92. // VOID
  93. // AtalkNodeRefByPtrNonInterlock(
  94. // IN OUT PATALK_NODE Node,
  95. // OUT PATALK_ERROR pErr
  96. // );
  97. #define AtalkNodeRefByPtrNonInterlock(_pNode, _pErr) \
  98. { \
  99. ASSERT(VALID_ATALK_NODE(_pNode)); \
  100. \
  101. if (((_pNode)->an_Flags & AN_CLOSING) == 0) \
  102. { \
  103. (_pNode)->an_RefCount++; \
  104. *(_pErr) = ATALK_NO_ERROR; \
  105. } \
  106. else \
  107. { \
  108. *(_pErr) = ATALK_NODE_CLOSING; \
  109. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_WARN, \
  110. ("AtalkNodeRefByPtrNonInterlock: Attempt to ref a closing node %lx (%x.%x)\n",\
  111. _pNode, (_pNode)->an_NodeAddr.atn_Network, (_pNode)->an_NodeAddr.atn_Node));\
  112. } \
  113. }
  114. VOID
  115. AtalkNodeRefNextNc(
  116. IN PATALK_NODE pNode,
  117. IN PATALK_NODE * ppNode,
  118. OUT PATALK_ERROR pErr
  119. );
  120. VOID
  121. AtalkNodeDeref(
  122. IN OUT PATALK_NODE pNode
  123. );
  124. ATALK_ERROR
  125. AtalkInitNodeCreateOnPort(
  126. IN PPORT_DESCRIPTOR pPortDesc,
  127. IN BOOLEAN AllowStartupRange,
  128. IN BOOLEAN RouterNode,
  129. IN PATALK_NODEADDR pNodeAddr
  130. );
  131. ATALK_ERROR
  132. AtalkNodeReleaseOnPort(
  133. IN PPORT_DESCRIPTOR pPortDesc,
  134. IN PATALK_NODE pNode
  135. );
  136. BOOLEAN
  137. AtalkNodeExistsOnPort(
  138. IN PPORT_DESCRIPTOR pPortDesc,
  139. IN PATALK_NODEADDR pNodeAddr
  140. );
  141. ATALK_ERROR
  142. AtalkInitNodeAllocate(
  143. IN PPORT_DESCRIPTOR pPortDesc,
  144. OUT PATALK_NODE * ppNode
  145. );
  146. // MACROS
  147. #if DBG
  148. #define AtalkNodeReferenceByAddr(pPortDesc,NodeAddr,Node, pErr) \
  149. { \
  150. AtalkNodeRefByAddr(pPortDesc,NodeAddr,Node, pErr); \
  151. if (ATALK_SUCCESS(*pErr)) \
  152. { \
  153. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_REFNODE, \
  154. ("AtalkNodeRefByAddr : %s %d PostCount %d\n", \
  155. __FILE__, __LINE__,(*Node)->an_RefCount)); \
  156. } \
  157. }
  158. #define AtalkNodeReferenceByPtr(Node, pErr) \
  159. { \
  160. AtalkNodeRefByPtr(Node, pErr); \
  161. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_REFNODE, \
  162. ("AtalkNodeRefByPtr : %s %d PostCount %d\n", \
  163. __FILE__, __LINE__, Node->an_RefCount)) \
  164. }
  165. #define AtalkNodeReferenceByPtrNonInterlock(Node, pErr) \
  166. { \
  167. AtalkNodeRefByPtrNonInterlock(Node, pErr); \
  168. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_REFNODE, \
  169. ("AtalkNodeRefByPtrNi : %s %d PostCount %d\n", \
  170. __FILE__, __LINE__,Node->an_RefCount)); \
  171. }
  172. #define AtalkNodeReferenceNextNc(pNode, ppNode, pErr) \
  173. { \
  174. AtalkNodeRefNextNc(pNode, ppNode, pErr); \
  175. if (ATALK_SUCCESS(*pErr)) \
  176. { \
  177. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_REFNODE, \
  178. ("AtalkNodeRefByPtrNc : %s %d PostCount %d\n", \
  179. __FILE__, __LINE__, (*ppNode)->an_RefCount)); \
  180. } \
  181. }
  182. #define AtalkNodeDereference(Node) \
  183. { \
  184. DBGPRINT(DBG_COMP_NODE, DBG_LEVEL_REFNODE, \
  185. ("AtalkNodeDerefByPtr : %s %d PreCount %d\n", \
  186. __FILE__, __LINE__,Node->an_RefCount)); \
  187. AtalkNodeDeref(Node); \
  188. }
  189. #else
  190. #define AtalkNodeReferenceByAddr(pPortDesc,NodeAddr,Node, pErr) \
  191. AtalkNodeRefByAddr(pPortDesc,NodeAddr,Node, pErr)
  192. #define AtalkNodeReferenceByPtr(Node, pErr) \
  193. AtalkNodeRefByPtr(Node, pErr)
  194. #define AtalkNodeReferenceByPtrNonInterlock(Node, pErr) \
  195. AtalkNodeRefByPtrNonInterlock(Node, pErr)
  196. #define AtalkNodeReferenceNextNcNonInterlock(pNode, ppNode, pErr)\
  197. AtalkNodeRefNextNcNonInterlock(pNode, ppNode, pErr)
  198. #define AtalkNodeReferenceNextNc(pNode, ppNode, pErr) \
  199. AtalkNodeRefNextNc(pNode, ppNode, pErr);
  200. #define AtalkNodeDereference(Node) AtalkNodeDeref(Node)
  201. #endif
  202. VOID
  203. AtalkInitNodeSavePramAddr(
  204. IN PPORT_DESCRIPTOR pPortDesc,
  205. IN PWSTR RegValue,
  206. IN PATALK_NODEADDR Node
  207. );
  208. VOID
  209. AtalkInitNodeGetPramAddr(
  210. IN PPORT_DESCRIPTOR pPortDesc,
  211. IN PWSTR RegValue,
  212. OUT PATALK_NODEADDR Node
  213. );
  214. VOID
  215. AtalkZapPramValue(
  216. IN PPORT_DESCRIPTOR pPortDesc,
  217. IN PWSTR RegValue
  218. );
  219. #endif // _NODE_
  220.