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.

795 lines
18 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. isnnb.h
  5. Abstract:
  6. This module contains definitions specific to the
  7. Netbios module of the ISN transport.
  8. Author:
  9. Adam Barr (adamba) 2-September-1993
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #define NB_MAXIMUM_MAC 40
  15. #define NB_SOCKET 0x5504
  16. #if defined(_PNP_POWER)
  17. #define NB_NETBIOS_NAME_SIZE 16
  18. #define LOCK_ACQUIRED TRUE
  19. #define LOCK_NOT_ACQUIRED FALSE
  20. #endif _PNP_POWER
  21. //
  22. // Defined granularity of find name timeouts in milliseconds --
  23. // we make this the same as the spec'ed RIP gap to avoid
  24. // flooding routers.
  25. //
  26. #define FIND_NAME_GRANULARITY 55
  27. //
  28. // Defines the number of milliseconds between expirations of the
  29. // short and long timers.
  30. //
  31. #define MILLISECONDS 10000 // number of NT time units in one
  32. #define SHORT_TIMER_DELTA 100
  33. #define LONG_TIMER_DELTA 2000
  34. //
  35. // Convert a ushort netware order <-> machine order
  36. //
  37. #define REORDER_USHORT(_Ushort) ((((_Ushort) & 0xff00) >> 8) | (((_Ushort) & 0x00ff) << 8))
  38. //
  39. // Convert a ulong netware order <-> machine order
  40. //
  41. #define REORDER_ULONG(_Ulong) \
  42. ((((_Ulong) & 0xff000000) >> 24) | \
  43. (((_Ulong) & 0x00ff0000) >> 8) | \
  44. (((_Ulong) & 0x0000ff00) << 8) | \
  45. (((_Ulong) & 0x000000ff) << 24))
  46. #include <packon.h>
  47. #ifdef _PNP_POWER_
  48. //
  49. // This is the packaging for the data we send to TDI in TdiRegisterNetAddress
  50. //
  51. typedef struct _NBIPX_PNP_CONTEXT_
  52. {
  53. TDI_PNP_CONTEXT TDIContext;
  54. PVOID ContextData;
  55. } NBIPX_PNP_CONTEXT, *PNBIPX_PNP_CONTEXT;
  56. #endif // _PNP_POWER_
  57. //
  58. // Definition of the Netbios header for name frames.
  59. //
  60. typedef struct _NB_NAME_FRAME {
  61. union {
  62. struct {
  63. UCHAR ConnectionControlFlag;
  64. UCHAR DataStreamType;
  65. };
  66. UCHAR RoutingInfo[32];
  67. };
  68. UCHAR NameTypeFlag;
  69. UCHAR DataStreamType2;
  70. UCHAR Name[16];
  71. } NB_NAME_FRAME, *PNB_NAME_FRAME;
  72. //
  73. // Definition of the Netbios header for directed datagrams.
  74. //
  75. typedef struct _NB_DATAGRAM {
  76. UCHAR ConnectionControlFlag;
  77. UCHAR DataStreamType;
  78. UCHAR SourceName[16];
  79. UCHAR DestinationName[16];
  80. } NB_DATAGRAM, *PNB_DATAGRAM;
  81. //
  82. // Definition of the Netbios header for a status query.
  83. //
  84. typedef struct _NB_STATUS_QUERY {
  85. UCHAR ConnectionControlFlag;
  86. UCHAR DataStreamType;
  87. UCHAR Padding[14];
  88. } NB_STATUS_QUERY, *PNB_STATUS_QUERY;
  89. //
  90. // Definition of the Netbios header for a status response
  91. // (this does not include the status buffer itself).
  92. //
  93. typedef struct _NB_STATUS_RESPONSE {
  94. UCHAR ConnectionControlFlag;
  95. UCHAR DataStreamType;
  96. } NB_STATUS_RESPONSE, *PNB_STATUS_RESPONSE;
  97. //
  98. // Definition of the general Netbios connectionless header.
  99. //
  100. typedef struct _NB_CONNECTIONLESS {
  101. IPX_HEADER IpxHeader;
  102. union {
  103. NB_NAME_FRAME NameFrame;
  104. NB_DATAGRAM Datagram;
  105. NB_STATUS_QUERY StatusQuery;
  106. NB_STATUS_RESPONSE StatusResponse;
  107. };
  108. } NB_CONNECTIONLESS, *PNB_CONNECTIONLESS;
  109. //
  110. // Definition of the Netbios session frame.
  111. //
  112. typedef struct _NB_SESSION {
  113. UCHAR ConnectionControlFlag;
  114. UCHAR DataStreamType;
  115. USHORT SourceConnectionId;
  116. USHORT DestConnectionId;
  117. USHORT SendSequence;
  118. USHORT TotalDataLength;
  119. USHORT Offset;
  120. USHORT DataLength;
  121. USHORT ReceiveSequence;
  122. union {
  123. USHORT BytesReceived;
  124. USHORT ReceiveSequenceMax;
  125. };
  126. } NB_SESSION, *PNB_SESSION;
  127. //
  128. // Definition of the extra fields in a Netbios
  129. // session frame for session init and session init
  130. // ack.
  131. //
  132. typedef struct _NB_SESSION_INIT {
  133. UCHAR SourceName[16];
  134. UCHAR DestinationName[16];
  135. USHORT MaximumDataSize;
  136. USHORT MaximumPacketTime;
  137. USHORT StartTripTime;
  138. } NB_SESSION_INIT, *PNB_SESSION_INIT;
  139. //
  140. // Definition of the general Netbios connection-oriented header.
  141. //
  142. typedef struct _NB_CONNECTION {
  143. IPX_HEADER IpxHeader;
  144. NB_SESSION Session;
  145. } NB_CONNECTION, *PNB_CONNECTION;
  146. //
  147. // Definition of a Netbios packet.
  148. //
  149. typedef union _NB_FRAME {
  150. NB_CONNECTIONLESS Connectionless;
  151. NB_CONNECTION Connection;
  152. } NB_FRAME, *PNB_FRAME;
  153. #include <packoff.h>
  154. //
  155. // Definitions for the DataStreamType field, with the
  156. // format used shown in the comment afterward.
  157. //
  158. #define NB_CMD_FIND_NAME 0x01 // NAME_FRAME
  159. #define NB_CMD_NAME_RECOGNIZED 0x02 // NAME_FRAME
  160. #define NB_CMD_ADD_NAME 0x03 // NAME_FRAME
  161. #define NB_CMD_NAME_IN_USE 0x04 // NAME_FRAME
  162. #define NB_CMD_DELETE_NAME 0x05 // NAME_FRAME
  163. #define NB_CMD_SESSION_DATA 0x06 // SESSION
  164. #define NB_CMD_SESSION_END 0x07 // SESSION
  165. #define NB_CMD_SESSION_END_ACK 0x08 // SESSION
  166. #define NB_CMD_STATUS_QUERY 0x09 // STATUS_QUERY
  167. #define NB_CMD_STATUS_RESPONSE 0x0a // STATUS_RESPONSE
  168. #define NB_CMD_DATAGRAM 0x0b // DATAGRAM
  169. #define NB_CMD_BROADCAST_DATAGRAM 0x0c // BROADCAST_DATAGRAM
  170. #ifdef RSRC_TIMEOUT_DBG
  171. #define NB_CMD_DEATH_PACKET 0x99 //
  172. #endif // RSRC_TIMEOUT_DBG
  173. //
  174. // Bit values in the NameTypeFlag of NB_NAME_FRAME frames.
  175. //
  176. #define NB_NAME_UNIQUE 0x00
  177. #define NB_NAME_GROUP 0x80
  178. #define NB_NAME_USED 0x40
  179. #define NB_NAME_REGISTERED 0x04
  180. #define NB_NAME_DUPLICATED 0x02
  181. #define NB_NAME_DEREGISTERED 0x01
  182. //
  183. // Bit values in the ConnectionControlFlag.
  184. //
  185. #define NB_CONTROL_SYSTEM 0x80
  186. #define NB_CONTROL_SEND_ACK 0x40
  187. #define NB_CONTROL_ATTENTION 0x20
  188. #define NB_CONTROL_EOM 0x10
  189. #define NB_CONTROL_RESEND 0x08
  190. #define NB_CONTROL_NEW_NB 0x01
  191. #define NB_DEVICE_SIGNATURE 0x1401
  192. #if defined(_PNP_POWER)
  193. #define NB_ADAPTER_ADDRESS_SIGNATURE 0x1403
  194. #endif _PNP_POWER
  195. #define NB_ADDRESS_SIGNATURE 0x1404
  196. #define NB_ADDRESSFILE_SIGNATURE 0x1405
  197. #define NB_CONNECTION_SIGNATURE 0x1406
  198. //
  199. // Useful in various places.
  200. //
  201. #if defined(_PNP_POWER)
  202. extern IPX_LOCAL_TARGET BroadcastTarget;
  203. #endif _PNP_POWER
  204. extern UCHAR BroadcastAddress[6];
  205. extern UCHAR NetbiosBroadcastName[16];
  206. //
  207. // Contains the default handler for each of the TDI event types
  208. // that are supported.
  209. //
  210. extern PVOID TdiDefaultHandlers[6];
  211. //
  212. // Define a structure that can track lock acquire/release.
  213. //
  214. typedef struct _NB_LOCK {
  215. CTELock Lock;
  216. #if DBG
  217. ULONG LockAcquired;
  218. UCHAR LastAcquireFile[8];
  219. ULONG LastAcquireLine;
  220. UCHAR LastReleaseFile[8];
  221. ULONG LastReleaseLine;
  222. #endif
  223. } NB_LOCK, *PNB_LOCK;
  224. #if DBG
  225. extern ULONG NbiDebug;
  226. extern ULONG NbiDebug2;
  227. extern ULONG NbiMemoryDebug;
  228. #define NB_MEMORY_LOG_SIZE 128
  229. #define MAX_ARGLEN 80
  230. #define TEMP_BUF_LEN 150
  231. extern UCHAR NbiDebugMemory[NB_MEMORY_LOG_SIZE][MAX_ARGLEN];
  232. extern PUCHAR NbiDebugMemoryLoc;
  233. extern PUCHAR NbiDebugMemoryEnd;
  234. VOID
  235. NbiDebugMemoryLog(
  236. IN PUCHAR FormatString,
  237. ...
  238. );
  239. #define NB_DEBUG(_Flag, _Print) { \
  240. if (NbiDebug & (NB_DEBUG_ ## _Flag)) { \
  241. DbgPrint ("NBI: "); \
  242. DbgPrint _Print; \
  243. } \
  244. if (NbiMemoryDebug & (NB_DEBUG_ ## _Flag)) { \
  245. NbiDebugMemoryLog _Print; \
  246. } \
  247. }
  248. #define NB_DEBUG2(_Flag, _Print) { \
  249. if (NbiDebug2 & (NB_DEBUG_ ## _Flag)) { \
  250. DbgPrint ("NBI: "); \
  251. DbgPrint _Print; \
  252. } \
  253. if (NbiMemoryDebug & (NB_DEBUG_ ## _Flag)) { \
  254. NbiDebugMemoryLog _Print; \
  255. } \
  256. }
  257. #else
  258. #define NB_DEBUG(_Flag, _Print)
  259. #define NB_DEBUG2(_Flag, _Print)
  260. #endif
  261. //
  262. // These definitions are for abstracting IRPs from the
  263. // transport for portability.
  264. //
  265. #if ISN_NT
  266. typedef IRP REQUEST, *PREQUEST;
  267. typedef struct _REQUEST_LIST_HEAD {
  268. PREQUEST Head; // list is empty if this is NULL
  269. PREQUEST Tail; // undefined if the list is empty.
  270. } REQUEST_LIST_HEAD, *PREQUEST_LIST_HEAD;
  271. //
  272. // PREQUEST
  273. // NbiAllocateRequest(
  274. // IN PDEVICE Device,
  275. // IN PIRP Irp
  276. // );
  277. //
  278. // Allocates a request for the system-specific request structure.
  279. //
  280. #define NbiAllocateRequest(_Device,_Irp) \
  281. (_Irp)
  282. //
  283. // BOOLEAN
  284. // IF_NOT_ALLOCATED(
  285. // IN PREQUEST Request
  286. // );
  287. //
  288. // Checks if a request was not successfully allocated.
  289. //
  290. #define IF_NOT_ALLOCATED(_Request) \
  291. if (0)
  292. //
  293. // VOID
  294. // NbiFreeRequest(
  295. // IN PDEVICE Device,
  296. // IN PREQUEST Request
  297. // );
  298. //
  299. // Frees a previously allocated request.
  300. //
  301. #define NbiFreeRequest(_Device,_Request) \
  302. ;
  303. //
  304. // VOID
  305. // MARK_REQUEST_PENDING(
  306. // IN PREQUEST Request
  307. // );
  308. //
  309. // Marks that a request will pend.
  310. //
  311. #define MARK_REQUEST_PENDING(_Request) \
  312. IoMarkIrpPending(_Request)
  313. //
  314. // VOID
  315. // UNMARK_REQUEST_PENDING(
  316. // IN PREQUEST Request
  317. // );
  318. //
  319. // Marks that a request will not pend.
  320. //
  321. #define UNMARK_REQUEST_PENDING(_Request) \
  322. (((IoGetCurrentIrpStackLocation(_Request))->Control) &= ~SL_PENDING_RETURNED)
  323. //
  324. // UCHAR
  325. // REQUEST_MAJOR_FUNCTION
  326. // IN PREQUEST Request
  327. // );
  328. //
  329. // Returns the major function code of a request.
  330. //
  331. #define REQUEST_MAJOR_FUNCTION(_Request) \
  332. ((IoGetCurrentIrpStackLocation(_Request))->MajorFunction)
  333. //
  334. // UCHAR
  335. // REQUEST_MINOR_FUNCTION
  336. // IN PREQUEST Request
  337. // );
  338. //
  339. // Returns the minor function code of a request.
  340. //
  341. #define REQUEST_MINOR_FUNCTION(_Request) \
  342. ((IoGetCurrentIrpStackLocation(_Request))->MinorFunction)
  343. //
  344. // PNDIS_BUFFER
  345. // REQUEST_NDIS_BUFFER
  346. // IN PREQUEST Request
  347. // );
  348. //
  349. // Returns the NDIS buffer chain associated with a request.
  350. //
  351. #define REQUEST_NDIS_BUFFER(_Request) \
  352. ((PNDIS_BUFFER)((_Request)->MdlAddress))
  353. //
  354. // PVOID
  355. // REQUEST_OPEN_CONTEXT(
  356. // IN PREQUEST Request
  357. // );
  358. //
  359. // Gets the context associated with an opened address/connection/control channel.
  360. //
  361. #define REQUEST_OPEN_CONTEXT(_Request) \
  362. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext)
  363. //
  364. // PVOID
  365. // REQUEST_OPEN_TYPE(
  366. // IN PREQUEST Request
  367. // );
  368. //
  369. // Gets the type associated with an opened address/connection/control channel.
  370. //
  371. #define REQUEST_OPEN_TYPE(_Request) \
  372. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext2)
  373. //
  374. // PFILE_FULL_EA_INFORMATION
  375. // OPEN_REQUEST_EA_INFORMATION(
  376. // IN PREQUEST Request
  377. // );
  378. //
  379. // Returns the EA information associated with an open/close request.
  380. //
  381. #define OPEN_REQUEST_EA_INFORMATION(_Request) \
  382. ((PFILE_FULL_EA_INFORMATION)((_Request)->AssociatedIrp.SystemBuffer))
  383. //
  384. // PTDI_REQUEST_KERNEL
  385. // REQUEST_PARAMETERS(
  386. // IN PREQUEST Request
  387. // );
  388. //
  389. // Obtains a pointer to the parameters of a request.
  390. //
  391. #define REQUEST_PARAMETERS(_Request) \
  392. (&((IoGetCurrentIrpStackLocation(_Request))->Parameters))
  393. //
  394. // PLIST_ENTRY
  395. // REQUEST_LINKAGE(
  396. // IN PREQUEST Request
  397. // );
  398. //
  399. // Returns a pointer to a linkage field in the request.
  400. //
  401. #define REQUEST_LINKAGE(_Request) \
  402. (&((_Request)->Tail.Overlay.ListEntry))
  403. //
  404. // PREQUEST
  405. // REQUEST_SINGLE_LINKAGE(
  406. // IN PREQUEST Request
  407. // );
  408. //
  409. // Used to access a single list linkage field in the request.
  410. //
  411. #define REQUEST_SINGLE_LINKAGE(_Request) \
  412. (*((PREQUEST *)&((_Request)->Tail.Overlay.ListEntry.Flink)))
  413. //
  414. // ULONG
  415. // REQUEST_REFCOUNT(
  416. // IN PREQUEST Request
  417. // );
  418. //
  419. // Used to access a field in the request which can be used for
  420. // the reference count, as long as it is on a REQUEST_LIST.
  421. //
  422. #define REQUEST_REFCOUNT(_Request) \
  423. (*((PULONG)&((_Request)->Tail.Overlay.ListEntry.Blink)))
  424. //
  425. // VOID
  426. // REQUEST_LIST_INSERT_TAIL(
  427. // IN PREQUEST_LIST_HEAD Head,
  428. // IN PREQUEST Entry
  429. // );
  430. //
  431. // Inserts a request into a single list linkage queue.
  432. //
  433. #define REQUEST_LIST_INSERT_TAIL(_Head,_Entry) { \
  434. if ((_Head)->Head == NULL) { \
  435. (_Head)->Head = (_Entry); \
  436. (_Head)->Tail = (_Entry); \
  437. } else { \
  438. REQUEST_SINGLE_LINKAGE((_Head)->Tail) = (_Entry); \
  439. (_Head)->Tail = (_Entry); \
  440. } \
  441. }
  442. //
  443. // PREQUEST
  444. // LIST_ENTRY_TO_REQUEST(
  445. // IN PLIST_ENTRY ListEntry
  446. // );
  447. //
  448. // Returns a request given a linkage field in it.
  449. //
  450. #define LIST_ENTRY_TO_REQUEST(_ListEntry) \
  451. ((PREQUEST)(CONTAINING_RECORD(_ListEntry, REQUEST, Tail.Overlay.ListEntry)))
  452. //
  453. // NTSTATUS
  454. // REQUEST_STATUS(
  455. // IN PREQUEST Request
  456. // );
  457. //
  458. // Used to access the status field of a request.
  459. //
  460. #define REQUEST_STATUS(_Request) \
  461. (_Request)->IoStatus.Status
  462. //
  463. // NTSTATUS
  464. // REQUEST_STATUSPTR(
  465. // IN PREQUEST Request
  466. // );
  467. //
  468. // Used to access the status field of a request.
  469. //
  470. #define REQUEST_STATUSPTR(_Request) \
  471. (_Request)->IoStatus.Pointer
  472. //
  473. // ULONG
  474. // REQUEST_INFORMATION(
  475. // IN PREQUEST Request)
  476. // );
  477. //
  478. // Used to access the information field of a request.
  479. //
  480. #define REQUEST_INFORMATION(_Request) \
  481. (_Request)->IoStatus.Information
  482. //
  483. // VOID
  484. // NbiCompleteRequest(
  485. // IN PREQUEST Request
  486. // );
  487. //
  488. // Completes a request whose status and information fields have
  489. // been filled in.
  490. //
  491. #define NbiCompleteRequest(_Request) \
  492. IoCompleteRequest (_Request, IO_NETWORK_INCREMENT)
  493. #else
  494. //
  495. // These routines must be defined for portability to a VxD.
  496. //
  497. #endif
  498. //
  499. // some utility macros.
  500. // Minimum of two
  501. //
  502. #define NB_MIN( _a , _b ) ( ( (_a) < (_b) ) ? (_a) : (_b) )
  503. //
  504. // Swap the _s1 and _s2 of Type _T
  505. //
  506. #define NB_SWAP(_s1, _s2, _T) { \
  507. _T _temp; \
  508. _temp = (_s1); \
  509. (_s1) = (_s2); \
  510. (_s2) = _temp; \
  511. }
  512. #define NB_SWAP_IRQL( _s1, _s2 ) NB_SWAP( _s1, _s2, CTELockHandle )
  513. //
  514. // Define our own spinlock routines.
  515. //
  516. #if DBG
  517. #define NB_GET_LOCK(_Lock, _LockHandle) { \
  518. CTEGetLock(&(_Lock)->Lock, _LockHandle); \
  519. (_Lock)->LockAcquired = TRUE; \
  520. strncpy((_Lock)->LastAcquireFile, strrchr(__FILE__,'\\')+1, 7); \
  521. (_Lock)->LastAcquireLine = __LINE__; \
  522. }
  523. #define NB_FREE_LOCK(_Lock, _LockHandle) { \
  524. (_Lock)->LockAcquired = FALSE; \
  525. strncpy((_Lock)->LastReleaseFile, strrchr(__FILE__,'\\')+1, 7); \
  526. (_Lock)->LastReleaseLine = __LINE__; \
  527. CTEFreeLock(&(_Lock)->Lock, _LockHandle); \
  528. }
  529. #define NB_GET_LOCK_DPC(_Lock) { \
  530. ExAcquireSpinLockAtDpcLevel(&(_Lock)->Lock); \
  531. (_Lock)->LockAcquired = TRUE; \
  532. strncpy((_Lock)->LastAcquireFile, strrchr(__FILE__,'\\')+1, 7); \
  533. (_Lock)->LastAcquireLine = __LINE__; \
  534. }
  535. #define NB_FREE_LOCK_DPC(_Lock) { \
  536. (_Lock)->LockAcquired = FALSE; \
  537. strncpy((_Lock)->LastReleaseFile, strrchr(__FILE__,'\\')+1, 7); \
  538. (_Lock)->LastReleaseLine = __LINE__; \
  539. ExReleaseSpinLockFromDpcLevel(&(_Lock)->Lock); \
  540. }
  541. #else
  542. #define NB_GET_LOCK(_Lock, _LockHandle) CTEGetLock(&(_Lock)->Lock, _LockHandle)
  543. #define NB_FREE_LOCK(_Lock, _LockHandle) CTEFreeLock(&(_Lock)->Lock, _LockHandle)
  544. #define NB_GET_LOCK_DPC(_Lock) ExAcquireSpinLockAtDpcLevel(&(_Lock)->Lock)
  545. #define NB_FREE_LOCK_DPC(_Lock) ExReleaseSpinLockFromDpcLevel(&(_Lock)->Lock)
  546. #endif
  547. #define NB_GET_CANCEL_LOCK( _LockHandle ) IoAcquireCancelSpinLock( _LockHandle )
  548. #define NB_FREE_CANCEL_LOCK( _LockHandle ) IoReleaseCancelSpinLock( _LockHandle )
  549. //
  550. // Routines to optimize for a uni-processor environment.
  551. //
  552. #define NB_INCREMENT(_Long, _Lock) InterlockedIncrement(_Long)
  553. #define NB_DECREMENT(_Long, _Lock) InterlockedDecrement(_Long)
  554. #define NB_ADD_ULONG(_Pulong, _Ulong, _Lock) ExInterlockedAddUlong(_Pulong, _Ulong, &(_Lock)->Lock)
  555. #define NB_DEFINE_SYNC_CONTEXT(_SyncContext)
  556. #define NB_BEGIN_SYNC(_SyncContext)
  557. #define NB_END_SYNC(_SyncContext)
  558. #define NB_DEFINE_LOCK_HANDLE(_LockHandle) CTELockHandle _LockHandle;
  559. //
  560. // Make these be NB_XXX_LOCK_DPC calls -- then the definitions
  561. // of the NB_SYNC_XXX_LOCK calls can be changed to not need _LockHandle
  562. // and many of the functions won't need that as a parameter.
  563. //
  564. #define NB_SYNC_GET_LOCK(_Lock, _LockHandle) NB_GET_LOCK(_Lock, _LockHandle)
  565. #define NB_SYNC_FREE_LOCK(_Lock, _LockHandle) NB_FREE_LOCK(_Lock, _LockHandle)
  566. #define NB_REMOVE_HEAD_LIST(_Queue, _Lock) ExInterlockedRemoveHeadList(_Queue, &(_Lock)->Lock)
  567. #define NB_LIST_WAS_EMPTY(_Queue, _OldHead) ((_OldHead) == NULL)
  568. #define NB_INSERT_HEAD_LIST(_Queue, _Entry, _Lock) ExInterlockedInsertHeadList(_Queue, _Entry, &(_Lock)->Lock)
  569. #define NB_INSERT_TAIL_LIST(_Queue, _Entry, _Lock) ExInterlockedInsertTailList(_Queue, _Entry, &(_Lock)->Lock)
  570. #define NB_POP_ENTRY_LIST(_Queue, _Lock) ExInterlockedPopEntryList(_Queue, &(_Lock)->Lock)
  571. #define NB_PUSH_ENTRY_LIST(_Queue, _Entry, _Lock) ExInterlockedPushEntryList(_Queue, _Entry, &(_Lock)->Lock)
  572. #define NB_LOCK_HANDLE_PARAM(_LockHandle) , IN CTELockHandle _LockHandle
  573. #define NB_LOCK_HANDLE_ARG(_LockHandle) , (_LockHandle)
  574. #define NB_SYNC_SWAP_IRQL( _s1, _s2 ) NB_SWAP( _s1, _s2, CTELockHandle )
  575. //
  576. // This macro adds a ULONG to a LARGE_INTEGER (should be
  577. // called with a spinlock held).
  578. //
  579. #define ADD_TO_LARGE_INTEGER(_LargeInteger,_Ulong) \
  580. ExInterlockedAddLargeStatistic((_LargeInteger),(ULONG)(_Ulong))
  581. #define NB_DEBUG_DEVICE 0x00000001
  582. #define NB_DEBUG_ADDRESS 0x00000004
  583. #define NB_DEBUG_SEND 0x00000008
  584. #define NB_DEBUG_RECEIVE 0x00000020
  585. #define NB_DEBUG_CONFIG 0x00000040
  586. #define NB_DEBUG_PACKET 0x00000080
  587. #define NB_DEBUG_BIND 0x00000200
  588. #define NB_DEBUG_ADDRESS_FRAME 0x00000400
  589. #define NB_DEBUG_CONNECTION 0x00000800
  590. #define NB_DEBUG_QUERY 0x00001000
  591. #define NB_DEBUG_DRIVER 0x00002000
  592. #define NB_DEBUG_CACHE 0x00004000
  593. #define NB_DEBUG_DATAGRAM 0x00008000
  594. #define NB_DEBUG_TIMER 0x00010000
  595. #define NB_DEBUG_SEND_WINDOW 0x00020000
  596. //
  597. // NB_GET_NBHDR_BUFF - gets the nb header in the packet. It is always the
  598. // second buffer.
  599. //
  600. #define NB_GET_NBHDR_BUFF(Packet) (NDIS_BUFFER_LINKAGE((Packet)->Private.Head))