Windows NT 4.0 source code leak
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.

1121 lines
34 KiB

4 years ago
  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1993 **/
  4. /**********************************************************************/
  5. /*
  6. vxdprocs.h
  7. This file contains VxD specific types/manifests for the NBT driver
  8. FILE HISTORY:
  9. Johnl 29-Mar-1993 Created
  10. */
  11. #ifndef _VXDPROCS_H_
  12. #define _VXDPROCS_H_
  13. //--------------------------------------------------------------------
  14. //
  15. // Define some ndis stuff here because tdivxd.h needs it however we can't
  16. // include ndis3\inc\ndis.h because it conflicts with ntconfig.h and we
  17. // can't take out ntconfig.h because it has definitions needed by other
  18. // header files...grrrr....
  19. //
  20. #ifdef CHICAGO
  21. #ifndef NDIS_STDCALL
  22. #define NDIS_STDCALL 1
  23. #endif
  24. #include <vmm.h>
  25. #undef PAGE
  26. #define PAGE _PTEXT
  27. #endif
  28. #ifdef NDIS_STDCALL
  29. #define NDIS_API __stdcall
  30. #else
  31. #define NDIS_API
  32. #endif
  33. //
  34. // Ndis Buffer
  35. //
  36. #define BUFFER_POOL_SIGN (UINT)0X4C50424E /* NBPL */
  37. #define BUFFER_SIGN (UINT)0x4655424e /* NBUF */
  38. typedef INT NDIS_SPIN_LOCK, * PNDIS_SPIN_LOCK;
  39. struct _NDIS_BUFFER;
  40. typedef struct _NDIS_BUFFER_POOL {
  41. UINT Signature; //character signature for debug "NBPL"
  42. NDIS_SPIN_LOCK SpinLock; //to serialize access to the buffer pool
  43. struct _NDIS_BUFFER *FreeList; //linked list of free slots in pool
  44. UINT BufferLength; //amount needed for each buffer descriptor
  45. UCHAR Buffer[1]; //actual pool memory
  46. } NDIS_BUFFER_POOL, * PNDIS_BUFFER_POOL;
  47. #ifdef NDIS_STDCALL
  48. typedef struct _NDIS_BUFFER {
  49. struct _NDIS_BUFFER *Next; //pointer to next buffer descriptor in chain
  50. PVOID VirtualAddress; //linear address of this buffer
  51. PNDIS_BUFFER_POOL Pool; //pointer to pool so we can free to correct pool
  52. UINT Length; //length of this buffer
  53. UINT Signature; //character signature for debug "NBUF"
  54. } NDIS_BUFFER, * PNDIS_BUFFER;
  55. #else
  56. typedef struct _NDIS_BUFFER {
  57. UINT Signature; //character signature for debug "NBUF"
  58. struct _NDIS_BUFFER *Next; //pointer to next buffer descriptor in chain
  59. PVOID VirtualAddress; //linear address of this buffer
  60. PNDIS_BUFFER_POOL Pool; //pointer to pool so we can free to correct pool
  61. UINT Length; //length of this buffer
  62. } NDIS_BUFFER, * PNDIS_BUFFER;
  63. #endif
  64. #define NDIS_STATUS_SUCCESS 0 // Used by CTEinitBlockStruc macro
  65. //
  66. // Possible data types
  67. //
  68. typedef enum _NDIS_PARAMETER_TYPE {
  69. NdisParameterInteger,
  70. NdisParameterHexInteger,
  71. NdisParameterString,
  72. NdisParameterMultiString
  73. } NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
  74. typedef struct _STRING {
  75. USHORT Length;
  76. USHORT MaximumLength;
  77. PUCHAR Buffer;
  78. } STRING, *PSTRING;
  79. typedef STRING NDIS_STRING, *PNDIS_STRING;
  80. typedef PVOID NDIS_HANDLE, *PNDIS_HANDLE;
  81. //
  82. // To store configuration information
  83. //
  84. typedef struct _NDIS_CONFIGURATION_PARAMETER {
  85. NDIS_PARAMETER_TYPE ParameterType;
  86. union {
  87. ULONG IntegerData;
  88. NDIS_STRING StringData;
  89. } ParameterData;
  90. } NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
  91. typedef ULONG NDIS_STATUS;
  92. typedef NDIS_STATUS *PNDIS_STATUS;
  93. VOID NDIS_API
  94. NdisOpenProtocolConfiguration(
  95. OUT PNDIS_STATUS Status,
  96. OUT PNDIS_HANDLE ConfigurationHandle,
  97. IN PNDIS_STRING ProtocolName
  98. );
  99. VOID NDIS_API
  100. NdisReadConfiguration(
  101. OUT PNDIS_STATUS Status,
  102. OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue,
  103. IN NDIS_HANDLE ConfigurationHandle,
  104. IN PNDIS_STRING Parameter,
  105. IN NDIS_PARAMETER_TYPE ParameterType
  106. );
  107. VOID NDIS_API
  108. NdisCloseConfiguration(
  109. IN NDIS_HANDLE ConfigurationHandle
  110. );
  111. //--------------------------------------------------------------------
  112. #include <tdivxd.h>
  113. #include <tdistat.h>
  114. //--------------------------------------------------------------------
  115. //
  116. // Initializes a TA_NETBIOS_ADDRESS structure
  117. //
  118. // ptanb - Pointer to the TA_NETBIOS_ADDRESS
  119. // pName - Pointer to the netbios name this address structure represents
  120. //
  121. #define InitNBAddress( ptanb, pName ) \
  122. { \
  123. (ptanb)->TAAddressCount = 1 ; \
  124. (ptanb)->Address[0].AddressLength = sizeof( TDI_ADDRESS_NETBIOS );\
  125. (ptanb)->Address[0].AddressType = TDI_ADDRESS_TYPE_NETBIOS ; \
  126. (ptanb)->Address[0].Address[0].NetbiosNameType = 0 ; \
  127. CTEMemCopy( (ptanb)->Address[0].Address[0].NetbiosName, \
  128. pName, \
  129. NCBNAMSZ ) ; \
  130. }
  131. //
  132. // Initializes a TDI_CONNECTION_INFORMATION structure for Netbios
  133. //
  134. // pConnInfo - Pointer to TDI_CONNECTION_INFORMATION structure
  135. // ptanb - same as for InitNBAddress
  136. // pName - same as for InitNBAddress
  137. //
  138. #define InitNBTDIConnectInfo( pConnInfo, ptanb, pName ) \
  139. { \
  140. InitNBAddress( ((PTA_NETBIOS_ADDRESS)ptanb), (pName) ) ; \
  141. (pConnInfo)->RemoteAddressLength = sizeof( TA_NETBIOS_ADDRESS ) ; \
  142. (pConnInfo)->RemoteAddress = (ptanb) ; \
  143. }
  144. //
  145. // Initializes an NDIS buffer (doesn't allocate memory)
  146. //
  147. // pndisBuff - Pointer to NDIS buffer to initialize
  148. // pvData - Pointer to buffer data
  149. // cbLen - Length of user data (in bytes)
  150. // pndisBuffnext - Next NDIS buffer in chain (or NULL if last)
  151. //
  152. #define InitNDISBuff( pndisBuff, pvData, cbLen, pndisBuffNext ) \
  153. { \
  154. (pndisBuff)->Signature = BUFFER_SIGN ; \
  155. (pndisBuff)->Next = (pndisBuffNext) ; \
  156. (pndisBuff)->Length = (cbLen) ; \
  157. (pndisBuff)->VirtualAddress = (pvData) ; \
  158. (pndisBuff)->Pool = NULL ; \
  159. }
  160. //
  161. // Proper NCB error type
  162. //
  163. typedef uchar NCBERR ;
  164. //
  165. // This is a private NCB command used for adding name number 0 to the
  166. // name table. It is submitted directly by the Nbt driver during
  167. // initialization. Note that if a client tries to submit an NCB with
  168. // this command we'll return illegal command.
  169. //
  170. #define NCBADD_PERMANENT_NAME 0xff
  171. //
  172. // Last valid NCB session or name number
  173. //
  174. #define MAX_NCB_NUMS 254
  175. //
  176. // When a send or receive tick count reaches this value, it's timed out
  177. //
  178. #define NCB_TIMED_OUT 1
  179. //
  180. // A timeout of this value means the NCB will never timeout
  181. //
  182. #define NCB_INFINITE_TIME_OUT 0
  183. //--------------------------------------------------------------------
  184. //
  185. // Receieve session data context, set in VxdReceive.
  186. // Allocated on the heap (too big for ncb_reserve).
  187. //
  188. #define RCVCONT_SIGN 0x1900BEEF
  189. typedef struct _RCV_CONTEXT
  190. {
  191. union
  192. {
  193. LIST_ENTRY ListEntry ; // Used when NCB is put on RcvHead
  194. EventRcvBuffer evrcvbuf ; // Used for doing actual receive
  195. // (after removed from RcvHead)
  196. } ;
  197. UINT Signature ;
  198. tLOWERCONNECTION * pLowerConnId ; // Where data is arriving from
  199. NCB * pNCB ; // Pointer to NCB
  200. NDIS_BUFFER ndisBuff ; // Transport fills this buffer
  201. UCHAR RTO ; // 1/2 second ticks till timeout
  202. USHORT usFlags; // in case different from default
  203. } RCV_CONTEXT, *PRCV_CONTEXT ;
  204. //
  205. // Allocate, initialize and free a receive context structure
  206. //
  207. #define GetRcvContext( ppContext ) \
  208. (STATUS_SUCCESS == NbtGetBuffer( &NbtConfig.RcvContextFreeList, \
  209. (PLIST_ENTRY*)ppContext, \
  210. eNBT_RCV_CONTEXT ))
  211. #define FreeRcvContext( pRcvContext ) \
  212. { \
  213. ASSERT( (pRcvContext)->Signature == RCVCONT_SIGN ) ; \
  214. InsertTailList( &NbtConfig.RcvContextFreeList, \
  215. &(pRcvContext)->ListEntry ) ; \
  216. }
  217. #define InitRcvContext( pRcvCont, pRcvLowerConn, pRcvNCB ) \
  218. { \
  219. pRcvCont->Signature = RCVCONT_SIGN ; \
  220. pRcvCont->pLowerConnId= pRcvLowerConn ; \
  221. pRcvCont->pNCB = pRcvNCB ; \
  222. }
  223. //--------------------------------------------------------------------
  224. //
  225. // Send session data context, set in VxdSend.
  226. // Stored in ncb_reserve
  227. //
  228. typedef struct _SEND_CONTEXT
  229. {
  230. LIST_ENTRY ListEntry ; // Kept on timeout queue
  231. tSESSIONHDR * pHdr ; // Allocated session header
  232. UCHAR STO ; // 1/2 second ticks till timeout
  233. } SEND_CONTEXT, *PSEND_CONTEXT ;
  234. #define GetSessionHdr( ppHdr ) \
  235. (STATUS_SUCCESS == NbtGetBuffer( &NbtConfig.SessionBufferFreeList, \
  236. (PLIST_ENTRY*)ppHdr, \
  237. eNBT_SESSION_HDR ))
  238. #define FreeSessionHdr( pSessionHdr ) \
  239. { \
  240. InsertTailList( &NbtConfig.SessionBufferFreeList, \
  241. (PLIST_ENTRY) pSessionHdr ) ; \
  242. }
  243. //--------------------------------------------------------------------
  244. //
  245. // TDI Send context (used by TdiSend)
  246. //
  247. // When handling the datagram completion routines, we need to set up
  248. // another completion routine. We store the old completion routine
  249. // in this structure
  250. //
  251. typedef union _TDI_SEND_CONTEXT
  252. {
  253. LIST_ENTRY ListEntry ; // Only used when on buffer free list
  254. struct
  255. {
  256. PVOID NewContext ;
  257. NBT_COMPLETION OldRequestNotifyObject ;
  258. PVOID OldContext ;
  259. NDIS_BUFFER ndisHdr ; // Generally NBT message
  260. NDIS_BUFFER ndisData1 ; // Data or SMB
  261. NDIS_BUFFER ndisData2 ; // Data if ndisData1 is an SMB
  262. } ;
  263. } TDI_SEND_CONTEXT, * PTDI_SEND_CONTEXT ;
  264. //
  265. // Allocates a TDI_SEND_CONTEXT
  266. //
  267. #define GetSendContext( ppContext ) \
  268. (STATUS_SUCCESS == NbtGetBuffer( &NbtConfig.SendContextFreeList, \
  269. (PLIST_ENTRY*)ppContext, \
  270. eNBT_SEND_CONTEXT ))
  271. //
  272. // Frees a send context structure and its allocated memory
  273. //
  274. #define FreeSendContext( psendCont ) \
  275. { \
  276. InsertTailList( &NbtConfig.SendContextFreeList, \
  277. &(psendCont)->ListEntry ) ; \
  278. }
  279. //--------------------------------------------------------------------
  280. //
  281. // Lana related stuff
  282. //
  283. #define NBT_MAX_LANAS 8
  284. typedef struct
  285. {
  286. tDEVICECONTEXT * pDeviceContext ; // Adapter for this Lana
  287. } LANA_ENTRY, *PLANA_ENTRY ;
  288. extern LANA_ENTRY LanaTable[NBT_MAX_LANAS] ;
  289. //--------------------------------------------------------------------
  290. //
  291. // Procedures in ncb.c
  292. //
  293. //
  294. NCBERR MapTDIStatus2NCBErr( TDI_STATUS status ) ;
  295. //
  296. // Get the correct adapter for this NCBs Lana
  297. //
  298. tDEVICECONTEXT *
  299. GetDeviceContext(
  300. NCB * pNCB
  301. );
  302. BOOL
  303. NbtWouldLoopback(
  304. ULONG IpAddr
  305. );
  306. extern BOOL fNCBCompleted ; // Wait NCB completed before returning to submitter
  307. extern BOOL fWaitingForNCB ; // We are blocked waiting for a Wait NCB to complete
  308. extern CTEBlockStruc WaitNCBBlock ; // Wait on this until signaled in completion
  309. extern UCHAR LanaBase ;
  310. #define IPINFO_BUFF_SIZE (sizeof(IPInfo) + MAX_IP_NETS * sizeof(NetInfo))
  311. //--------------------------------------------------------------------
  312. //
  313. // externs from fileio.c
  314. //
  315. extern PUCHAR pFileBuff;
  316. extern PUCHAR pFilePath;
  317. //--------------------------------------------------------------------
  318. //
  319. // TDI Dispatch table (exported from vtdi.386)
  320. //
  321. extern TDIDispatchTable * TdiDispatch ;
  322. //
  323. // Wrappers for interfacing to the TDI Dispatch table
  324. //
  325. #define TdiVxdOpenAddress TdiDispatch->TdiOpenAddressEntry
  326. #define TdiVxdCloseAddress TdiDispatch->TdiCloseAddressEntry
  327. #define TdiVxdOpenConnection TdiDispatch->TdiOpenConnectionEntry
  328. #define TdiVxdCloseConnection TdiDispatch->TdiCloseConnectionEntry
  329. #define TdiVxdAssociateAddress TdiDispatch->TdiAssociateAddressEntry
  330. #define TdiVxdDisAssociateAddress TdiDispatch->TdiDisAssociateAddressEntry
  331. #define TdiVxdConnect TdiDispatch->TdiConnectEntry
  332. #define TdiVxdDisconnect TdiDispatch->TdiDisconnectEntry
  333. #define TdiVxdListen TdiDispatch->TdiListenEntry
  334. #define TdiVxdAccept TdiDispatch->TdiAcceptEntry
  335. #define TdiVxdReceive TdiDispatch->TdiReceiveEntry
  336. #define TdiVxdSend TdiDispatch->TdiSendEntry
  337. #define TdiVxdSendDatagram TdiDispatch->TdiSendDatagramEntry
  338. #define TdiVxdReceiveDatagram TdiDispatch->TdiReceiveDatagramEntry
  339. #define TdiVxdSetEventHandler TdiDispatch->TdiSetEventEntry
  340. #define TdiVxdQueryInformationEx TdiDispatch->TdiQueryInformationExEntry
  341. #define TdiVxdSetInformationEx TdiDispatch->TdiSetInformationExEntry
  342. //--------------------------------------------------------------------
  343. //
  344. // NTSTATUS to TDI_STATUS mappings.
  345. //
  346. // Rather then convert from NTSTATUS to TDI_STATUS (then sometimes back to
  347. // NTSTATUS) we'll just use TDI_STATUS codes everywhere (and map to NCBERR
  348. // when returning codes to the Netbios interface).
  349. //
  350. #undef STATUS_SUCCESS
  351. #undef STATUS_INSUFFICIENT_RESOURCES
  352. #undef STATUS_ADDRESS_ALREADY_EXISTS
  353. #undef STATUS_TOO_MANY_ADDRESSES
  354. #undef STATUS_INVALID_ADDRESS
  355. #undef STATUS_BUFFER_OVERFLOW
  356. #undef STATUS_TRANSACTION_INVALID_TYPE
  357. #undef STATUS_TRANSACTION_INVALID_ID
  358. #undef STATUS_EVENT_DONE
  359. #undef STATUS_TRANSACTION_TIMED_OUT
  360. #undef STATUS_EVENT_PENDING
  361. #undef STATUS_PENDING
  362. #undef STATUS_BAD_NETWORK_NAME
  363. #undef STATUS_REQUEST_NOT_ACCEPTED
  364. #undef STATUS_INVALID_CONNECTION
  365. #undef STATUS_DATA_NOT_ACCEPTED
  366. #undef STATUS_MORE_PROCESSING_REQUIRED
  367. #undef STATUS_IO_TIMEOUT
  368. #undef STATUS_TIMEOUT
  369. #undef STATUS_GRACEFUL_DISCONNECT
  370. #undef STATUS_CONNECTION_RESET
  371. #define STATUS_SUCCESS TDI_SUCCESS
  372. //#define STATUS_UNSUCCESSFUL
  373. #define STATUS_MORE_PROCESSING_REQUIRED TDI_MORE_PROCESSING
  374. #define STATUS_BAD_NETWORK_NAME TDI_INVALID_CONNECTION
  375. #define STATUS_DATA_NOT_ACCEPTED TDI_NOT_ACCEPTED
  376. //#define STATUS_REMOTE_NOT_LISTENING
  377. //#define STATUS_DUPLICATE_NAME
  378. //#define STATUS_INVALID_PARAMETER
  379. //#define STATUS_OBJECT_NAME_COLLISION Duplicate Name
  380. //#define STATUS_SHARING_VIOLATION Duplicate Name
  381. #define STATUS_CONNECTION_INVALID TDI_INVALID_CONNECTION
  382. #define STATUS_INVALID_CONNECTION TDI_INVALID_CONNECTION
  383. #define STATUS_INSUFFICIENT_RESOURCES TDI_NO_RESOURCES
  384. #define STATUS_ADDRESS_ALREADY_EXISTS TDI_ADDR_IN_USE
  385. #define STATUS_TOO_MANY_ADDRESSES TDI_NO_FREE_ADDR
  386. #define STATUS_INVALID_ADDRESS TDI_ADDR_INVALID
  387. #define STATUS_BUFFER_OVERFLOW TDI_BUFFER_OVERFLOW
  388. #define STATUS_TRANSACTION_INVALID_TYPE TDI_BAD_EVENT_TYPE
  389. #define STATUS_TRANSACTION_INVALID_ID TDI_BAD_OPTION // ??
  390. #define STATUS_EVENT_DONE TDI_EVENT_DONE
  391. #define STATUS_TRANSACTION_TIMED_OUT TDI_TIMED_OUT
  392. #define STATUS_IO_TIMEOUT TDI_TIMED_OUT
  393. #define STATUS_TIMEOUT TDI_TIMED_OUT
  394. #define STATUS_EVENT_PENDING TDI_PENDING
  395. #define STATUS_PENDING TDI_PENDING
  396. #define STATUS_GRACEFUL_DISCONNECT TDI_GRACEFUL_DISC
  397. #define STATUS_CONNECTION_RESET TDI_CONNECTION_RESET
  398. //
  399. // This is the "Name deregistered but not deleted because of
  400. // active sessions" error code.
  401. //
  402. #define STATUS_NRC_ACTSES 0xCA000001
  403. //
  404. // The NT_SUCCESS macro looks at the high bytes of the errr code which isn't
  405. // appropriate for our mapping to TDI_STATUS error codes
  406. //
  407. #undef NT_SUCCESS
  408. #define NT_SUCCESS(err) ((err==TDI_SUCCESS)||(err==TDI_PENDING))
  409. //--------------------------------------------------------------------
  410. //
  411. // General porting macros
  412. //
  413. //
  414. //--------------------------------------------------------------------
  415. //
  416. // Note that the ExInterlocked* routines (in ntos\ex\i386) do a spinlock
  417. // for MP machines. Since we aren't MP we shouldn't need the spin lock.
  418. // We shouldn't need to disable interrupts either.
  419. //
  420. #define ExInterlockedInsertTailList(list, entry, spinlock ) \
  421. InsertTailList( (list), (entry) )
  422. #define ExInterlockedInsertHeadList(list, entry, spinlock ) \
  423. InsertHeadList( (list), (entry) )
  424. //
  425. // These two definitions must be kept keep a couple of NT macros use
  426. // the ExInterlocked* macros
  427. //
  428. #ifdef InterlockedIncrement
  429. #undef InterlockedIncrement
  430. #endif
  431. #ifdef InterlockedIncrementLong
  432. #undef InterlockedIncrementLong
  433. #endif
  434. #define InterlockedIncrement(n) \
  435. CTEInterlockedIncrementLong( n )
  436. #define InterlockedIncrementLong InterlockedIncrement
  437. #ifdef InterlockedDecrement
  438. #undef InterlockedDecrement
  439. #endif
  440. #ifdef InterlockedDecrementLong
  441. #undef InterlockedDecrementLong
  442. #endif
  443. #define InterlockedDecrement(n) \
  444. CTEInterlockedDecrementLong( n )
  445. #define InterlockedDecrementLong InterlockedDecrement
  446. //--------------------------------------------------------------------
  447. //
  448. // Debug helper macros
  449. //
  450. #undef ASSERT
  451. #undef ASSERTMSG
  452. #ifdef DEBUG
  453. #include <vxddebug.h>
  454. extern DWORD DebugFlags ;
  455. extern char DBOut[4096] ;
  456. extern char szOutput[1024];
  457. extern int iCurPos ;
  458. void NbtDebugOut( char * ) ;
  459. #define DBGFLAG_ALL (0x00000001) // Everything else
  460. #define DBGFLAG_LMHOST (0x00000002)
  461. #define DBGFLAG_KDPRINTS (0x00000004) // Jim's KdPrint output
  462. #define DBGFLAG_ERROR (0x00000010)
  463. #define DBGFLAG_AUX_OUTPUT (0x00000080)
  464. #define DbgPrint( s ) \
  465. if ( DebugFlags & DBGFLAG_ALL ) \
  466. { \
  467. VxdSprintf( szOutput, s ) ; \
  468. VxdCopyToDBOut() ; \
  469. NbtDebugOut( DBOut+iCurPos ) ; \
  470. }
  471. #define DbgPrintNum( n ) \
  472. if ( DebugFlags & DBGFLAG_ALL ) \
  473. { \
  474. VxdSprintf( szOutput, "%x", n ) ; \
  475. VxdCopyToDBOut() ; \
  476. NbtDebugOut( DBOut+iCurPos ) ; \
  477. }
  478. #undef KdPrint
  479. #define KdPrint( s ) \
  480. if ( DebugFlags & DBGFLAG_KDPRINTS ) \
  481. { \
  482. VxdPrintf s ; \
  483. }
  484. //
  485. // Conditional print routines
  486. //
  487. #define CDbgPrint( flag, s ) \
  488. if ( DebugFlags & (flag) ) \
  489. { \
  490. VxdSprintf( szOutput, s ) ; \
  491. VxdCopyToDBOut() ; \
  492. NbtDebugOut( DBOut+iCurPos ) ; \
  493. }
  494. #define CDbgPrintNum( flag, n ) \
  495. if ( DebugFlags & (flag) ) \
  496. { \
  497. VxdSprintf( szOutput, "%x", n ) ; \
  498. VxdCopyToDBOut() ; \
  499. NbtDebugOut( DBOut+iCurPos ) ; \
  500. }
  501. #define DbgBreak() _asm int 3
  502. #define ASSERT( exp ) CTEAssert( exp )
  503. #define ASSERTMSG( msg, exp ) CTEAssert( exp )
  504. //
  505. // REQUIRE is an ASSERT that keeps the expression under non-debug
  506. // builds
  507. //
  508. #define REQUIRE( exp ) ASSERT( exp )
  509. //
  510. // Consistency checks of the interrupt vector table to help watch
  511. // for NULL pointer writes
  512. //
  513. extern BYTE abVecTbl[256] ;
  514. #define INIT_NULL_PTR_CHECK() memcpy( abVecTbl, 0, sizeof( abVecTbl ))
  515. #define CHECK_MEM() if ( sizeof(abVecTbl) != VxdRtlCompareMemory( 0, abVecTbl, sizeof(abVecTbl)) ) \
  516. { \
  517. DbgPrint("Vector table corrupt at " ) ; \
  518. DbgPrintNum( VxdRtlCompareMemory( 0, abVecTbl, sizeof(abVecTbl) ) ) ;\
  519. DbgPrint("\n\r") ; \
  520. _asm int 3 \
  521. } \
  522. CTECheckMem(__FILE__) ;
  523. #else
  524. #define DbgPrint( s )
  525. #define DbgPrintNum( n )
  526. #define DbgBreak()
  527. #undef KdPrint
  528. #define KdPrint( s )
  529. #define ASSERT( exp ) { ; }
  530. #define ASSERTMSG( msg, exp ) { ; }
  531. #define REQUIRE( exp ) { exp ; }
  532. #define INIT_NULL_PTR_CHECK()
  533. #define CHECK_MEM()
  534. #define CDbgPrint( flag, s )
  535. #define CDbgPrintNum( flag, n )
  536. #endif
  537. //---------------------------------------------------------------------
  538. //
  539. // FROM tdihndlr.c
  540. //
  541. TDI_STATUS
  542. TdiReceiveHandler (
  543. IN PVOID ReceiveEventContext,
  544. IN PVOID ConnectionContext,
  545. IN USHORT ReceiveFlags,
  546. IN ULONG BytesIndicated,
  547. IN ULONG BytesAvailable,
  548. OUT PULONG BytesTaken,
  549. IN PVOID Data,
  550. EventRcvBuffer * pevrcvbuf
  551. );
  552. TDI_STATUS
  553. ReceiveAnyHandler ( // Handles NCBRCVANY commands, is
  554. IN PVOID ReceiveEventContext, // called after all other receive
  555. IN PVOID ConnectionContext, // handlers
  556. IN USHORT ReceiveFlags,
  557. IN ULONG BytesIndicated,
  558. IN ULONG BytesAvailable,
  559. OUT PULONG BytesTaken,
  560. IN PVOID Data,
  561. PVOID * ppBuffer // Pointer to ListEntry of RCV_CONTEXT
  562. ) ;
  563. TDI_STATUS
  564. VxdDisconnectHandler ( // Cleans up Netbios stuff for remote
  565. IN PVOID DisconnectEventContext, // disconnects
  566. IN PVOID ConnectionContext,
  567. IN PVOID DisconnectData,
  568. IN ULONG DisconnectInformationLength,
  569. IN PVOID pDisconnectInformation,
  570. IN ULONG DisconnectIndicators
  571. ) ;
  572. VOID
  573. CompletionRcv(
  574. IN PVOID pContext,
  575. IN uint tdistatus,
  576. IN uint BytesRcvd
  577. );
  578. TDI_STATUS
  579. TdiConnectHandler (
  580. IN PVOID pConnectEventContext,
  581. IN int RemoteAddressLength,
  582. IN PVOID pRemoteAddress,
  583. IN int UserDataLength,
  584. IN PVOID pUserData,
  585. IN int OptionsLength,
  586. IN PVOID pOptions,
  587. IN PVOID * pAcceptingID,
  588. IN ConnectEventInfo * pEventInfo
  589. );
  590. TDI_STATUS
  591. TdiDisconnectHandler (
  592. PVOID EventContext,
  593. PVOID ConnectionContext,
  594. ULONG DisconnectDataLength,
  595. PVOID DisconnectData,
  596. ULONG DisconnectInformationLength,
  597. PVOID DisconnectInformation,
  598. ULONG DisconnectIndicators // Is this the Flags field?
  599. );
  600. TDI_STATUS
  601. TdiRcvDatagramHandler(
  602. IN PVOID pDgramEventContext,
  603. IN int SourceAddressLength,
  604. IN PVOID pSourceAddress,
  605. IN int OptionsLength,
  606. IN PVOID pOptions,
  607. IN UINT ReceiveDatagramFlags,
  608. IN ULONG BytesIndicated,
  609. IN ULONG BytesAvailable,
  610. OUT ULONG *pBytesTaken,
  611. IN PVOID pTsdu,
  612. OUT EventRcvBuffer * * ppBuffer //OUT PIRP *pIoRequestPacket
  613. );
  614. TDI_STATUS
  615. TdiRcvNameSrvHandler(
  616. IN PVOID pDgramEventContext,
  617. IN int SourceAddressLength,
  618. IN PVOID pSourceAddress,
  619. IN int OptionsLength,
  620. IN PVOID pOptions,
  621. IN UINT ReceiveDatagramFlags,
  622. IN ULONG BytesIndicated,
  623. IN ULONG BytesAvailable,
  624. OUT ULONG *pBytesTaken,
  625. IN PVOID pTsdu,
  626. OUT EventRcvBuffer * * ppBuffer //OUT PIRP *pIoRequestPacket
  627. );
  628. TDI_STATUS
  629. TdiErrorHandler (
  630. IN PVOID Context,
  631. IN ULONG Status
  632. );
  633. VOID
  634. CompletionRcvDgram(
  635. IN PVOID Context,
  636. IN UINT tdistatus,
  637. IN UINT RcvdSize
  638. ) ;
  639. //---------------------------------------------------------------------
  640. //
  641. // FROM init.c
  642. //
  643. PVOID
  644. CTEAllocInitMem(
  645. IN ULONG cbBuff ) ;
  646. NTSTATUS
  647. VxdReadIniString(
  648. IN LPTSTR pchKeyName,
  649. IN OUT LPTSTR * ppStringBuff
  650. ) ;
  651. NTSTATUS CreateDeviceObject(
  652. IN tNBTCONFIG *pConfig,
  653. IN ULONG IpAddr,
  654. IN ULONG IpMask,
  655. IN ULONG IpNameServer,
  656. IN ULONG IpBackupServer,
  657. IN ULONG IpDnsServer,
  658. IN ULONG IpDnsBackupServer,
  659. IN UCHAR MacAddr[],
  660. IN UCHAR IpIndex
  661. ) ;
  662. void GetNameServerAddress( ULONG IpAddr,
  663. PULONG pIpNameServer);
  664. void GetDnsServerAddress( ULONG IpAddr,
  665. PULONG pIpNameServer);
  666. #define COUNT_NS_ADDR 4 // Maximum number of name server addresses
  667. //---------------------------------------------------------------------
  668. //
  669. // FROM vxdfile.asm
  670. //
  671. HANDLE
  672. VxdFileOpen(
  673. IN char * pchFile ) ;
  674. ULONG
  675. VxdFileRead(
  676. IN HANDLE hFile,
  677. IN ULONG BytesToRead,
  678. IN BYTE * pBuff ) ;
  679. VOID
  680. VxdFileClose(
  681. IN HANDLE hFile ) ;
  682. PUCHAR
  683. VxdWindowsPath(
  684. );
  685. //---------------------------------------------------------------------
  686. //
  687. // FROM vnbtd.asm
  688. //
  689. ULONG
  690. GetProfileHex(
  691. IN HANDLE ParametersHandle, // Not used
  692. IN PCHAR ValueName,
  693. IN ULONG DefaultValue,
  694. IN ULONG MinimumValue
  695. );
  696. ULONG
  697. GetProfileInt(
  698. IN HANDLE ParametersHandle, // Not used
  699. IN PCHAR ValueName,
  700. IN ULONG DefaultValue,
  701. IN ULONG MinimumValue
  702. );
  703. TDI_STATUS DhcpQueryInfo( UINT Type, PVOID pBuff, UINT * pSize ) ;
  704. //---------------------------------------------------------------------
  705. //
  706. // FROM tdiout.c
  707. //
  708. NTSTATUS VxdDisconnectWait( tLOWERCONNECTION * pLowerConn,
  709. tDEVICECONTEXT * pDeviceContext,
  710. ULONG Flags,
  711. PVOID Timeout) ;
  712. NTSTATUS VxdScheduleDelayedCall( tDGRAM_SEND_TRACKING * pTracker,
  713. PVOID pClientContext,
  714. PVOID ClientCompletion,
  715. PVOID CallBackRoutine,
  716. tDEVICECONTEXT *pDeviceContext ) ;
  717. //---------------------------------------------------------------------
  718. //
  719. // FROM timer.c
  720. //
  721. BOOL CheckForTimedoutNCBs( CTEEvent *pEvent, PVOID pCont ) ;
  722. VOID StopTimeoutTimer( VOID );
  723. NTSTATUS StartRefreshTimer( VOID );
  724. //---------------------------------------------------------------------
  725. //
  726. // FROM tdicnct.c
  727. //
  728. NTSTATUS CloseAddress( HANDLE hAddress ) ;
  729. //---------------------------------------------------------------------
  730. //
  731. // FROM wfw.c - Snowball specific routines
  732. //
  733. #ifndef CHICAGO
  734. BOOL GetActiveLanasFromIP( VOID );
  735. #endif //!CHICAGO
  736. //---------------------------------------------------------------------
  737. //
  738. // FROM chic.c - Chicago specific routines
  739. //
  740. #ifdef CHICAGO
  741. NTSTATUS DestroyDeviceObject(
  742. tNBTCONFIG *pConfig,
  743. ULONG IpAddr
  744. );
  745. BOOL IPRegisterAddrChangeHandler( PVOID AddChangeHandler, BOOL );
  746. TDI_STATUS IPNotification( ULONG IpAddress,
  747. ULONG IpMask,
  748. PVOID pDevNode,
  749. USHORT IPContext,
  750. BOOL fNew );
  751. BOOL VxdInitLmHostsSupport( PUCHAR pchLmHostPath, USHORT ulPathSize );
  752. VOID SaveNameDnsServerAddrs( VOID );
  753. BOOL VxdOpenNdis( VOID );
  754. VOID VxdCloseNdis( VOID );
  755. VOID ReleaseNbtConfigMem( VOID );
  756. NTSTATUS VxdUnload( LPSTR pchModuleName );
  757. #endif //CHICAGO
  758. //--------------------------------------------------------------------
  759. //
  760. // Procedures in vxdisol.c
  761. //
  762. //
  763. NCBERR VxdOpenName( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  764. NCBERR VxdCloseName( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  765. NCBERR VxdCall( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  766. NCBERR VxdListen( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  767. NCBERR VxdDgramSend( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  768. NCBERR VxdDgramReceive( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  769. NCBERR VxdReceiveAny( tDEVICECONTEXT *pDeviceContext, NCB * pNCB ) ;
  770. NCBERR VxdReceive( tDEVICECONTEXT * pDeviceContext, NCB * pNCB, BOOL fReceive ) ;
  771. NCBERR VxdHangup( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  772. NCBERR VxdCancel( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  773. NCBERR VxdSend( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  774. NCBERR VxdSessionStatus( tDEVICECONTEXT * pDeviceContext, NCB * pNCB ) ;
  775. VOID DelayedSessEstablish( PVOID pContext );
  776. //--------------------------------------------------------------------
  777. //
  778. // Procedures in dns.c
  779. //
  780. //
  781. PCHAR
  782. DnsStoreName(
  783. OUT PCHAR pDest,
  784. IN PCHAR pName,
  785. IN PCHAR pDomainName,
  786. IN enum eNSTYPE eNsType
  787. );
  788. VOID
  789. DnsExtractName(
  790. IN PCHAR pNameHdr,
  791. IN LONG NumBytes,
  792. OUT PCHAR pName,
  793. OUT PULONG pNameSize
  794. );
  795. VOID
  796. ProcessDnsResponse(
  797. IN tDEVICECONTEXT *pDeviceContext,
  798. IN PVOID pSrcAddress,
  799. IN tNAMEHDR UNALIGNED *pNameHdr,
  800. IN LONG lNumBytes,
  801. IN USHORT OpCodeFlags
  802. );
  803. VOID
  804. DnsCompletion(
  805. PVOID pContext,
  806. PVOID pContext2,
  807. tTIMERQENTRY *pTimerQEntry
  808. );
  809. //
  810. // These routines all have "Direct" at the end of the routine name
  811. // because they are used exclusively for name queries to the DNS
  812. // server to resolve DNS names and not NetBIOS names.
  813. //
  814. VOID
  815. ProcessDnsResponseDirect(
  816. IN tDEVICECONTEXT *pDeviceContext,
  817. IN PVOID pSrcAddress,
  818. IN tNAMEHDR UNALIGNED *pNameHdr,
  819. IN LONG lNumBytes,
  820. IN USHORT OpCodeFlags
  821. );
  822. ULONG
  823. DoDnsResolveDirect(
  824. PNCB pncb,
  825. PUCHAR pzDnsName,
  826. PULONG pIpAddressList
  827. );
  828. BOOL
  829. DoDnsCancelDirect(
  830. PNCB pncb
  831. );
  832. VOID
  833. DnsCompletionDirect(
  834. PVOID pContext,
  835. PVOID pContext2,
  836. tTIMERQENTRY *pTimerQEntry
  837. );
  838. PDNS_DIRECT_WORK_ITEM_CONTEXT
  839. FindContextDirect(
  840. USHORT TransactionId
  841. );
  842. VOID
  843. DnsActualCompletionDirect(
  844. IN NBT_WORK_ITEM_CONTEXT * pnbtContext
  845. );
  846. VOID
  847. DnsUnlinkAndCompleteDirect(
  848. IN PDNS_DIRECT_WORK_ITEM_CONTEXT pContext
  849. );
  850. NTSTATUS
  851. UdpSendDNSBcastDirect(
  852. IN PDNS_DIRECT_WORK_ITEM_CONTEXT pContext,
  853. IN ULONG Retries,
  854. IN ULONG Timeout
  855. );
  856. VOID
  857. SendDNSBcastDoneDirect(
  858. IN PVOID pContext,
  859. IN NTSTATUS status,
  860. IN ULONG lInfo
  861. );
  862. PDNS_DIRECT_SEND_CONTEXT
  863. CreateSendContextDirect(
  864. IN PCHAR pName,
  865. IN PCHAR pchDomainName,
  866. OUT PVOID *pHdrs,
  867. OUT PULONG pLength,
  868. IN PDNS_DIRECT_WORK_ITEM_CONTEXT pContext
  869. );
  870. VOID
  871. IpToAscii(
  872. IN DWORD IpAddress,
  873. IN OUT PCHAR pzAscii
  874. );
  875. //
  876. // Flag passed to TdiSend indicating we are dealing with a chain send
  877. // and not a normal send.
  878. //
  879. #define CHAIN_SEND_FLAG 0x80
  880. typedef struct _tBUFFERCHAINSEND
  881. {
  882. tBUFFER tBuff ; // Must be first member of this structure!!
  883. PVOID pBuffer2 ;
  884. ULONG Length2 ;
  885. } tBUFFERCHAINSEND ;
  886. //
  887. // Flag for pConnectEle->Flags indicating whether the client has been
  888. // notified the session is dead (by completing an NCB with NRC_SCLOSED)
  889. //
  890. #define NB_CLIENT_NOTIFIED 0x01
  891. //
  892. // Translates the name number/logical session number to the appropriate
  893. // structure pointer
  894. //
  895. NCBERR VxdFindClientElement( tDEVICECONTEXT * pDeviceContext,
  896. UCHAR ncbnum,
  897. tCLIENTELE * * ppClientEle,
  898. enum CLIENT_TYPE Type ) ;
  899. NCBERR VxdFindConnectElement( tDEVICECONTEXT * pDeviceContext,
  900. NCB * pNCB,
  901. tCONNECTELE * * ppConnectEle ) ;
  902. NCBERR VxdFindLSN( tDEVICECONTEXT * pDeviceContext,
  903. tCONNECTELE * pConnectEle,
  904. UCHAR * plsn ) ;
  905. NCBERR VxdFindNameNum( tDEVICECONTEXT * pDeviceContext,
  906. tADDRESSELE * pAddressEle,
  907. UCHAR * pNum ) ;
  908. //
  909. // Used by Register/Unregister for selecting either the name table or the
  910. // session table from the device context
  911. //
  912. typedef enum
  913. {
  914. NB_NAME,
  915. NB_SESSION
  916. } NB_TABLE_TYPE ;
  917. BOOL NBRegister( tDEVICECONTEXT * pDeviceContext,
  918. UCHAR * pNCBNum,
  919. PVOID pElem,
  920. NB_TABLE_TYPE NbTable ) ;
  921. BOOL NBUnregister( tDEVICECONTEXT * pDeviceContext,
  922. UCHAR NCBNum,
  923. NB_TABLE_TYPE NbTable ) ;
  924. TDI_STATUS VxdCompleteSessionNcbs( tDEVICECONTEXT * pDeviceContext,
  925. tCONNECTELE * pConnEle ) ;
  926. NCBERR VxdCleanupAddress( tDEVICECONTEXT * pDeviceContext,
  927. NCB * pNCB,
  928. tCLIENTELE * pClientEle,
  929. UCHAR NameNum,
  930. BOOL fDeleteAddress ) ;
  931. BOOL ActiveSessions( tCLIENTELE * pClientEle ) ;
  932. //
  933. // This structure holds context information while we are waiting for
  934. // a session setup to complete (either listen or call)
  935. //
  936. // It is stored in the ncb_reserve field of the NCB
  937. //
  938. typedef struct _SESS_SETUP_CONTEXT
  939. {
  940. TDI_CONNECTION_INFORMATION * pRequestConnect ; //
  941. TDI_CONNECTION_INFORMATION * pReturnConnect ; // Name who answered the listen
  942. tCONNECTELE * pConnEle ;
  943. UCHAR fIsWorldListen ; // Listenning for '*'?
  944. } SESS_SETUP_CONTEXT, *PSESS_SETUP_CONTEXT ;
  945. void VxdTearDownSession( tDEVICECONTEXT * pDevCont,
  946. tCONNECTELE * pConnEle,
  947. PSESS_SETUP_CONTEXT pCont,
  948. NCB * pNCB ) ;
  949. //
  950. // Finishes off a Netbios request (fill in NCB fields, call the post
  951. // routine etc.). Is macroed as CTEIoComplete.
  952. //
  953. VOID VxdIoComplete( PCTE_IRP pirp, NTSTATUS status, ULONG cbExtra ) ;
  954. ULONG
  955. _stdcall
  956. VNBT_NCB_X( PNCB pNCB,
  957. PUCHAR pzDnsName,
  958. PULONG pIpAddress,
  959. PVOID pExtended,
  960. ULONG fFlag ) ;
  961. ULONG
  962. _stdcall
  963. VNBT_LANA_MASK(
  964. );
  965. #endif //_VXDPROCS_H_