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.

338 lines
11 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corp., 1994 **/
  4. /**********************************************************************/
  5. /*
  6. vxdprocs.h
  7. This file contains VxD specific types/manifests for the DHCP driver
  8. FILE HISTORY:
  9. Johnl 29-Mar-1993 Created
  10. */
  11. #ifndef _VXDPROCS_H_
  12. #define _VXDPROCS_H_
  13. #ifdef DEBUG
  14. #define DBG 1
  15. #endif
  16. #define _NETTYPES_ // Keep tcp\h\nettypes.h from being included
  17. #include <dhcpcli.h>
  18. #include <oscfg.h>
  19. #include <cxport.h>
  20. #include <tdi.h>
  21. //--------------------------------------------------------------------
  22. //
  23. // Define some ndis stuff here because tdivxd.h needs it however we can't
  24. // include ndis3\inc\ndis.h because it conflicts with ntconfig.h and we
  25. // can't take out ntconfig.h because it has definitions needed by other
  26. // header files...grrrr....
  27. //
  28. #ifdef CHICAGO
  29. #ifndef NDIS_STDCALL
  30. #define NDIS_STDCALL 1
  31. #endif
  32. #endif
  33. #ifdef NDIS_STDCALL
  34. #define NDIS_API __stdcall
  35. #else
  36. #define NDIS_API
  37. #endif
  38. //
  39. // Ndis Buffer
  40. //
  41. #define BUFFER_POOL_SIGN (UINT)0X4C50424E /* NBPL */
  42. #define BUFFER_SIGN (UINT)0x4655424e /* NBUF */
  43. typedef INT NDIS_SPIN_LOCK, * PNDIS_SPIN_LOCK;
  44. struct _NDIS_BUFFER;
  45. typedef struct _NDIS_BUFFER_POOL {
  46. UINT Signature; //character signature for debug "NBPL"
  47. NDIS_SPIN_LOCK SpinLock; //to serialize access to the buffer pool
  48. struct _NDIS_BUFFER *FreeList; //linked list of free slots in pool
  49. UINT BufferLength; //amount needed for each buffer descriptor
  50. UCHAR Buffer[1]; //actual pool memory
  51. } NDIS_BUFFER_POOL, * PNDIS_BUFFER_POOL;
  52. #ifdef NDIS_STDCALL
  53. typedef struct _NDIS_BUFFER {
  54. struct _NDIS_BUFFER *Next; //pointer to next buffer descriptor in chain
  55. PVOID VirtualAddress; //linear address of this buffer
  56. PNDIS_BUFFER_POOL Pool; //pointer to pool so we can free to correct pool
  57. UINT Length; //length of this buffer
  58. UINT Signature; //character signature for debug "NBUF"
  59. } NDIS_BUFFER, * PNDIS_BUFFER;
  60. #else
  61. typedef struct _NDIS_BUFFER {
  62. UINT Signature; //character signature for debug "NBUF"
  63. struct _NDIS_BUFFER *Next; //pointer to next buffer descriptor in chain
  64. PVOID VirtualAddress; //linear address of this buffer
  65. PNDIS_BUFFER_POOL Pool; //pointer to pool so we can free to correct pool
  66. UINT Length; //length of this buffer
  67. } NDIS_BUFFER, * PNDIS_BUFFER;
  68. #endif
  69. #define NDIS_STATUS_SUCCESS 1 // Used by CTEinitBlockStruc macro
  70. #include <tdivxd.h>
  71. #include <tdistat.h>
  72. //--------------------------------------------------------------------
  73. //
  74. // Initializes an NDIS buffer (doesn't allocate memory)
  75. //
  76. // pndisBuff - Pointer to NDIS buffer to initialize
  77. // pvData - Pointer to buffer data
  78. // cbLen - Length of user data (in bytes)
  79. // pndisBuffnext - Next NDIS buffer in chain (or NULL if last)
  80. //
  81. #define InitNDISBuff( pndisBuff, pvData, cbLen, pndisBuffNext ) \
  82. { \
  83. (pndisBuff)->Signature = BUFFER_SIGN ; \
  84. (pndisBuff)->Next = (pndisBuffNext) ; \
  85. (pndisBuff)->Length = (cbLen) ; \
  86. (pndisBuff)->VirtualAddress = (pvData) ; \
  87. (pndisBuff)->Pool = NULL ; \
  88. }
  89. //--------------------------------------------------------------------
  90. //
  91. // Initializes a TA_ADDRESS_IP structure
  92. //
  93. // ptanb - Pointer to the TA_ADDRESS_IP
  94. // pName - Pointer to the IP information
  95. //
  96. #define InitIPAddress( ptaip, port, addr ) \
  97. { \
  98. (ptaip)->TAAddressCount = 1 ; \
  99. (ptaip)->Address[0].AddressLength = sizeof( TDI_ADDRESS_IP ); \
  100. (ptaip)->Address[0].AddressType = TDI_ADDRESS_TYPE_IP ; \
  101. (ptaip)->Address[0].Address[0].sin_port = (port) ; \
  102. (ptaip)->Address[0].Address[0].in_addr = (addr) ; \
  103. memset((ptaip)->Address[0].Address[0].sin_zero, 8, 0) ; \
  104. }
  105. //
  106. // Initializes a TDI_CONNECTION_INFORMATION structure for IP
  107. //
  108. // pConnInfo - Pointer to TDI_CONNECTION_INFORMATION structure
  109. // ptaip - pointer to TA_IP_ADDRESS to initialize
  110. // port - IP Port to use
  111. // addr - IP Addr to use
  112. //
  113. #define InitIPTDIConnectInfo( pConnInfo, ptaip, port, addr ) \
  114. { \
  115. InitIPAddress( ((PTA_IP_ADDRESS)ptaip), (port), (addr) ) ; \
  116. (pConnInfo)->RemoteAddressLength = sizeof( TA_IP_ADDRESS ) ; \
  117. (pConnInfo)->RemoteAddress = (ptaip) ; \
  118. }
  119. //--------------------------------------------------------------------
  120. //
  121. // TDI Dispatch table (exported from vtdi.386)
  122. //
  123. extern TDIDispatchTable * TdiDispatch ;
  124. //
  125. // Wrappers for interfacing to the TDI Dispatch table
  126. //
  127. #define TdiVxdOpenAddress TdiDispatch->TdiOpenAddressEntry
  128. #define TdiVxdCloseAddress TdiDispatch->TdiCloseAddressEntry
  129. #define TdiVxdOpenConnection TdiDispatch->TdiOpenConnectionEntry
  130. #define TdiVxdCloseConnection TdiDispatch->TdiCloseConnectionEntry
  131. #define TdiVxdAssociateAddress TdiDispatch->TdiAssociateAddressEntry
  132. #define TdiVxdDisAssociateAddress TdiDispatch->TdiDisAssociateAddressEntry
  133. #define TdiVxdConnect TdiDispatch->TdiConnectEntry
  134. #define TdiVxdDisconnect TdiDispatch->TdiDisconnectEntry
  135. #define TdiVxdListen TdiDispatch->TdiListenEntry
  136. #define TdiVxdAccept TdiDispatch->TdiAcceptEntry
  137. #define TdiVxdReceive TdiDispatch->TdiReceiveEntry
  138. #define TdiVxdSend TdiDispatch->TdiSendEntry
  139. #define TdiVxdSendDatagram TdiDispatch->TdiSendDatagramEntry
  140. #define TdiVxdReceiveDatagram TdiDispatch->TdiReceiveDatagramEntry
  141. #define TdiVxdSetEventHandler TdiDispatch->TdiSetEventEntry
  142. #define TdiVxdQueryInformationEx TdiDispatch->TdiQueryInformationExEntry
  143. #define TdiVxdSetInformationEx TdiDispatch->TdiSetInformationExEntry
  144. //--------------------------------------------------------------------
  145. //
  146. // Debug helper macros
  147. //
  148. #undef ASSERT
  149. #undef ASSERTMSG
  150. #ifdef DEBUG
  151. #include <vxddebug.h>
  152. extern DWORD DebugFlags ;
  153. extern char DBOut[4096] ;
  154. extern int iCurPos ;
  155. void NbtDebugOut( char * ) ;
  156. #define DBGFLAG_ALL (0x00000001) // Everything else
  157. #define DBGFLAG_KDPRINTS (0x00000004) // KdPrint output
  158. #define DBGFLAG_AUX_OUTPUT (0x00000080)
  159. #define DbgPrint( s ) \
  160. if ( DebugFlags & DBGFLAG_ALL ) \
  161. { \
  162. VxdSprintf( DBOut+iCurPos, s ) ; \
  163. NbtDebugOut( DBOut+iCurPos ) ; \
  164. }
  165. #define DbgPrintNum( n ) \
  166. if ( DebugFlags & DBGFLAG_ALL ) \
  167. { \
  168. VxdSprintf( DBOut+iCurPos, "%x", n ) ; \
  169. NbtDebugOut( DBOut+iCurPos ) ; \
  170. }
  171. #undef KdPrint
  172. #define KdPrint( s ) \
  173. if ( DebugFlags & DBGFLAG_KDPRINTS ) \
  174. { \
  175. VxdPrintf s ; \
  176. }
  177. //
  178. // Conditional print routines
  179. //
  180. #define CDbgPrint( flag, s ) \
  181. if ( DebugFlags & (flag) ) \
  182. { \
  183. VxdSprintf( DBOut+iCurPos, s ) ; \
  184. NbtDebugOut( DBOut+iCurPos ) ; \
  185. }
  186. #define CDbgPrintNum( flag, n ) \
  187. if ( DebugFlags & (flag) ) \
  188. { \
  189. VxdSprintf( DBOut+iCurPos, "%x", n ) ; \
  190. NbtDebugOut( DBOut+iCurPos ) ; \
  191. }
  192. #define DbgBreak() _asm int 3
  193. #define ASSERT( exp ) CTEAssert( exp )
  194. #define ASSERTMSG( msg, exp ) CTEAssert( exp )
  195. #undef DhcpAssert
  196. #define DhcpAssert( exp ) ASSERT( exp )
  197. #define DhcpGlobalDebugFlag DebugFlags
  198. //
  199. // REQUIRE is an ASSERT that keeps the expression under non-debug
  200. // builds
  201. //
  202. #define REQUIRE( exp ) ASSERT( exp )
  203. //
  204. // Consistency checks of the interrupt vector table to help watch
  205. // for NULL pointer writes
  206. //
  207. extern BYTE abVecTbl[256] ;
  208. #define INIT_NULL_PTR_CHECK() memcpy( abVecTbl, 0, sizeof( abVecTbl ))
  209. #define CHECK_MEM() if ( sizeof(abVecTbl) != VxdRtlCompareMemory( 0, abVecTbl, sizeof(abVecTbl)) ) \
  210. { \
  211. DbgPrint("Vector table corrupt at " ) ; \
  212. DbgPrintNum( VxdRtlCompareMemory( 0, abVecTbl, sizeof(abVecTbl) ) ) ;\
  213. DbgPrint("\n\r") ; \
  214. _asm int 3 \
  215. } \
  216. CTECheckMem(__FILE__) ;
  217. #else
  218. #define DbgPrint( s )
  219. #define DbgPrintNum( n )
  220. #define DbgBreak()
  221. #define ASSERT( exp ) { ; }
  222. #define ASSERTMSG( msg, exp ) { ; }
  223. #define REQUIRE( exp ) { exp ; }
  224. #define INIT_NULL_PTR_CHECK()
  225. #define CHECK_MEM()
  226. #define CDbgPrint( flag, s )
  227. #define CDbgPrintNum( flag, n )
  228. #endif
  229. //---------------------------------------------------------------------
  230. //
  231. // FROM init.c
  232. //
  233. BOOL DhcpInit( void ) ;
  234. VOID
  235. ProcessDhcpRequestForever(
  236. CTEEvent * pCTEEvent,
  237. PVOID pContext
  238. ) ;
  239. PVOID
  240. CTEAllocInitMem(
  241. IN USHORT cbBuff ) ;
  242. NTSTATUS
  243. VxdReadIniString(
  244. IN LPTSTR pchKeyName,
  245. IN OUT LPTSTR * ppStringBuff
  246. ) ;
  247. //---------------------------------------------------------------------
  248. //
  249. // FROM utils.c
  250. //
  251. NTSTATUS
  252. ConvertDottedDecimalToUlong(
  253. IN PUCHAR pInString,
  254. OUT PULONG IpAddress
  255. ) ;
  256. TDI_STATUS CopyBuff( PVOID Dest,
  257. int DestSize,
  258. PVOID Src,
  259. int SrcSize,
  260. int *pSize ) ;
  261. VOID DhcpSleep( DWORD Milliseconds ) ;
  262. //---------------------------------------------------------------------
  263. //
  264. // FROM fileio.c
  265. //
  266. BOOL InitFileSupport( void ) ;
  267. DWORD WriteParamsToFile( PDHCP_CONTEXT pDhcpContext, HANDLE hFile ) ;
  268. DWORD RewriteConfigFile( PVOID pEvent, PVOID pContext ) ;
  269. //---------------------------------------------------------------------
  270. //
  271. // FROM msg.c
  272. //
  273. BOOL InitMsgSupport( VOID ) ;
  274. PUCHAR DhcpGetMessage( DWORD MsgId ) ;
  275. //---------------------------------------------------------------------
  276. //
  277. // FROM dhcpinfo.c
  278. //
  279. void NotifyClients( PDHCP_CONTEXT DhcpContext,
  280. ULONG OldAddress,
  281. ULONG IpAddress,
  282. ULONG IpMask ) ;
  283. #endif //_VXDPROCS_H_