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.

1038 lines
27 KiB

  1. /*****************************************************************************
  2. *
  3. * Copyright (c) 1998-1999 Microsoft Corporation
  4. *
  5. * RASPPTP.H - RASPPTP includes, defines, structures and prototypes
  6. *
  7. * Author: Stan Adermann (stana)
  8. *
  9. * Created: 7/28/1998
  10. *
  11. *****************************************************************************/
  12. #ifndef RASPPTP_H
  13. #define RASPPTP_H
  14. #ifndef SINGLE_LINE
  15. #define SINGLE_LINE 1
  16. #endif
  17. #include "osinc.h"
  18. #ifdef STATIC
  19. #undef STATIC
  20. #endif
  21. #define STATIC
  22. #include "debug.h"
  23. #include "protocol.h"
  24. #include "ctdi.h"
  25. #include "filelog.h"
  26. //
  27. // NDIS version compatibility in OSINC.H
  28. //
  29. // TAPI version compatibility
  30. #define TAPI_EXT_VERSION 0x00010000
  31. // Registry values
  32. extern ULONG PptpMaxTransmit;
  33. extern ULONG PptpWanEndpoints;
  34. extern ULONG PptpEchoTimeout;
  35. extern BOOLEAN PptpEchoAlways;
  36. extern USHORT PptpControlPort;
  37. extern USHORT PptpProtocolNumber;
  38. extern USHORT PptpUdpPort;
  39. extern ULONG PptpTunnelConfig;
  40. extern LONG PptpSendRecursionLimit;
  41. extern ULONG PptpValidateAddress;
  42. #define PPTP_SEND_RECURSION_LIMIT_DEFAULT 5
  43. #define CONFIG_INITIATE_UDP BIT(0)
  44. #define CONFIG_ACCEPT_UDP BIT(1)
  45. #define CONFIG_DONT_ACCEPT_GRE BIT(2)
  46. typedef struct {
  47. ULONG Address;
  48. ULONG Mask;
  49. } CLIENT_ADDRESS, *PCLIENT_ADDRESS;
  50. extern ULONG NumClientAddresses;
  51. extern PCLIENT_ADDRESS ClientList;
  52. extern BOOLEAN PptpAuthenticateIncomingCalls;
  53. extern ULONG CtdiTcpDisconnectTimeout;
  54. extern ULONG CtdiTcpConnectTimeout;
  55. #define TAPI_MAX_LINE_ADDRESS_LENGTH 32
  56. #define TAPI_ADDR_PER_LINE 1
  57. #define TAPI_ADDRESSID 0
  58. #define TAPI_DEVICECLASS_NAME "tapi/line"
  59. #define TAPI_DEVICECLASS_ID 1
  60. #define NDIS_DEVICECLASS_NAME "ndis"
  61. #define NDIS_DEVICECLASS_ID 2
  62. #define PPTP_CLOSE_TIMEOUT 1000 // ms
  63. #define MAX_TARGET_ADDRESSES 16
  64. #define CALL_STATES_MASK (LINECALLSTATE_UNKNOWN | \
  65. LINECALLSTATE_IDLE | \
  66. LINECALLSTATE_OFFERING | \
  67. LINECALLSTATE_DIALING | \
  68. LINECALLSTATE_PROCEEDING | \
  69. LINECALLSTATE_CONNECTED | \
  70. LINECALLSTATE_DISCONNECTED)
  71. // Memory allocation tags
  72. #define TAG(v) ((((v)&0xff)<<24) | (((v)&0xff00)<<8) | (((v)&0xff0000)>>8) | (((v)&0xff000000)>>24))
  73. #define TAG_PPTP_ADAPTER TAG('PTPa')
  74. #define TAG_PPTP_TUNNEL TAG('PTPT')
  75. #define TAG_PPTP_TIMEOUT TAG('PTPt')
  76. #define TAG_PPTP_CALL TAG('PTPC')
  77. #define TAG_PPTP_CALL_LIST TAG('PTPc')
  78. #define TAG_PPTP_ADDR_LIST TAG('PTPL')
  79. #define TAG_CTDI_DATA TAG('PTCD')
  80. #define TAG_CTDI_L_CONNECT TAG('PTCL')
  81. #define TAG_CTDI_CONNECT_INFO TAG('PTCN')
  82. #define TAG_CTDI_DGRAM TAG('PTCG')
  83. #define TAG_CTDI_ROUTE TAG('PTCR')
  84. #define TAG_CTDI_IRP TAG('PTCI')
  85. #define TAG_CTDI_MESSAGE TAG('PTCM')
  86. #define TAG_CTL_PACKET TAG('PTTP')
  87. #define TAG_CTL_CONNINFO TAG('PTTI')
  88. #define TAG_WORK_ITEM TAG('PTWI')
  89. #define TAG_THREAD TAG('PTTH')
  90. #define BIT(b) (1<<(b))
  91. #define LOCKED TRUE
  92. #define UNLOCKED FALSE
  93. /* Types and structs -------------------------------------------------------*/
  94. typedef void (*FREEFUNC)(PVOID);
  95. typedef struct {
  96. LONG Count;
  97. FREEFUNC FreeFunction;
  98. } REFERENCE_COUNT;
  99. #define INIT_REFERENCE_OBJECT(o,freefunc) \
  100. { \
  101. (o)->Reference.FreeFunction = (freefunc); \
  102. (o)->Reference.Count = 1; \
  103. DEBUGMSG(DBG_REF, (DTEXT("INIT REF (%08x, %d) %s\n"), (o), (o)->Reference.Count, #o)); \
  104. }
  105. #define REFERENCE_OBJECT(o) \
  106. { \
  107. NdisInterlockedIncrement(&(o)->Reference.Count); \
  108. DEBUGMSG(DBG_REF, (DTEXT("REFERENCE (%08x, %d) %s %d\n"), (o), (o)->Reference.Count, #o, __LINE__)); \
  109. }
  110. #define DEREFERENCE_OBJECT(o) \
  111. { \
  112. ULONG Ref = NdisInterlockedDecrement(&(o)->Reference.Count); \
  113. DEBUGMSG(DBG_REF, (DTEXT("DEREFERENCE(%08x, %d) %s %d\n"), (o), (o)->Reference.Count, #o, __LINE__)); \
  114. if (Ref==0) \
  115. { \
  116. ASSERT((o)->Reference.FreeFunction); \
  117. DEBUGMSG(DBG_REF, (DTEXT("Last reference released, freeing %08x\n"), (o))); \
  118. (o)->Reference.FreeFunction(o); \
  119. } \
  120. }
  121. #define REFERENCE_COUNT(o) ((o)->Reference.Count)
  122. #define IS_CALL(call) ((call) && (call)->Signature==TAG_PPTP_CALL)
  123. #define IS_CTL(ctl) ((ctl) && (ctl)->Signature==TAG_PPTP_TUNNEL)
  124. #define IS_LINE_UP(call) (!((call)->Close.Checklist&CALL_CLOSE_LINE_DOWN))
  125. // If you change this enum then be sure to change ControlStateToString() also.
  126. typedef enum {
  127. STATE_CTL_INVALID = 0,
  128. STATE_CTL_LISTEN,
  129. STATE_CTL_DIALING,
  130. STATE_CTL_WAIT_REQUEST,
  131. STATE_CTL_WAIT_REPLY,
  132. STATE_CTL_ESTABLISHED,
  133. STATE_CTL_WAIT_STOP,
  134. STATE_CTL_CLEANUP,
  135. NUM_CONTROL_STATES
  136. } CONTROL_STATE;
  137. // If you change this enum then be sure to change CallStateToString() also.
  138. typedef enum {
  139. STATE_CALL_INVALID = 0,
  140. STATE_CALL_CLOSED,
  141. STATE_CALL_IDLE,
  142. STATE_CALL_OFFHOOK,
  143. STATE_CALL_OFFERING,
  144. STATE_CALL_PAC_OFFERING,
  145. STATE_CALL_PAC_WAIT,
  146. STATE_CALL_DIALING,
  147. STATE_CALL_PROCEEDING,
  148. STATE_CALL_ESTABLISHED,
  149. STATE_CALL_WAIT_DISCONNECT,
  150. STATE_CALL_CLEANUP,
  151. NUM_CALL_STATES
  152. } CALL_STATE;
  153. typedef struct PPTP_ADAPTER *PPPTP_ADAPTER;
  154. typedef struct CONTROL_TUNNEL {
  155. LIST_ENTRY ListEntry;
  156. // Used to attach this control connection to the miniport context.
  157. REFERENCE_COUNT Reference;
  158. // Not protected by spinlock
  159. ULONG Signature;
  160. // PTPT
  161. PPPTP_ADAPTER pAdapter;
  162. // The associated adapter
  163. CONTROL_STATE State;
  164. // State of this control connection
  165. LIST_ENTRY CallList;
  166. // List of calls supported by this control connection.
  167. // Protected by adapter lock
  168. BOOLEAN Inbound;
  169. // Indicates whether this tunnel originated here or elsewhere
  170. UCHAR Padding[sizeof(ULONG_PTR)];
  171. // We pad to protect the portions of the struct protected by different locks
  172. // from alpha alignment problems.
  173. // ^^^^^^ Protected by Adapter->Lock^^^^^^^^
  174. //===================================================================
  175. NDIS_SPIN_LOCK Lock;
  176. // vvvvvv Protected by Ctl->Lock vvvvvvvvvvv
  177. BOOLEAN Cleanup;
  178. // True means a cleanup has been scheduled or is active.
  179. LIST_ENTRY MessageList;
  180. // Each entry represents a pptp message that has been sent and
  181. // is awaiting a response or at least waiting to be acknowledged
  182. // by the transport
  183. HANDLE hCtdiEndpoint;
  184. // Handle for the tunnel local endpoint. The connection must be closed first.
  185. HANDLE hCtdi;
  186. // Handle for control tunnel TCP connection.
  187. UCHAR PartialPacketBuffer[MAX_CONTROL_PACKET_LENGTH];
  188. ULONG BytesInPartialBuffer;
  189. // TCP data received that does not constitute a full packet.
  190. struct {
  191. TA_IP_ADDRESS Address;
  192. ULONG Version;
  193. ULONG Framing;
  194. ULONG Bearer;
  195. UCHAR HostName[MAX_HOSTNAME_LENGTH];
  196. UCHAR Vendor[MAX_VENDOR_LENGTH];
  197. } Remote;
  198. // Information provided by the remote.
  199. PULONG PptpMessageLength;
  200. // Points to an array of precalculated packet lengths, based on version
  201. struct {
  202. NDIS_MINIPORT_TIMER Timer;
  203. ULONG Identifier;
  204. BOOLEAN Needed;
  205. #define PPTP_ECHO_TIMEOUT_DEFAULT 60
  206. } Echo;
  207. #define PPTP_MESSAGE_TIMEOUT_DEFAULT 30
  208. NDIS_MINIPORT_TIMER WaitTimeout;
  209. NDIS_MINIPORT_TIMER StopTimeout;
  210. ULONG Speed;
  211. // Contains line speed of this connect in BPS
  212. } CONTROL_TUNNEL, *PCONTROL_TUNNEL;
  213. typedef struct CALL_SESSION {
  214. LIST_ENTRY ListEntry;
  215. // Used to attach a call session to a control connection
  216. ULONG Signature;
  217. // PTPC
  218. PPPTP_ADAPTER pAdapter;
  219. // The associated adapter
  220. LIST_ENTRY TxListEntry;
  221. // If we have packets to send, this connects us to the queue of the transmitting thread.
  222. PCONTROL_TUNNEL pCtl;
  223. // Pointer to this call's control connection.
  224. UCHAR Padding[sizeof(ULONG_PTR)];
  225. // We pad to protect the portions of the struct protected by different locks
  226. // from alpha alignment problems.
  227. // ^^^^^^^^^^ Protected by Adapter->Lock ^^^^^^^^^^^^^^
  228. // ============================================================================
  229. REFERENCE_COUNT Reference;
  230. // Not protected by spinlock
  231. NDIS_SPIN_LOCK Lock;
  232. // vvvvvvvvvv Protected by Call->Lock vvvvvvvvvvvvvvvvv
  233. CALL_STATE State;
  234. // State of this call.
  235. LIST_ENTRY TxPacketList;
  236. // Context for each send currently pending
  237. LIST_ENTRY RxPacketList;
  238. // Context for each datagram received but not processed
  239. ULONG_PTR RxPacketsPending;
  240. // Count of RxPackets in RxPacketList
  241. BOOLEAN Inbound;
  242. // TRUE indicates call did not originate here
  243. BOOLEAN Open;
  244. // Open has been called, but not close
  245. BOOLEAN Transferring;
  246. // TRUE means we are on the queue to transmit or receive packets.
  247. BOOLEAN UseUdp;
  248. // Datagrams will be sent via UDP.
  249. HTAPI_LINE hTapiLine;
  250. // Tapi's handle to the line device, for status callbacks
  251. HTAPI_CALL hTapiCall;
  252. // Tapi's handle to the specific call
  253. ULONG_PTR DeviceId;
  254. // The ID of this call, also used as the htCall parameter in TapiEvents
  255. USHORT SerialNumber;
  256. // Unique for this call
  257. NDIS_HANDLE NdisLinkContext;
  258. // Ndis's handle, used in MiniportReceive, etc.
  259. NDIS_WAN_SET_LINK_INFO WanLinkInfo;
  260. struct {
  261. ULONG SequenceNumber;
  262. // Last received GRE sequence number
  263. ULONG AckNumber;
  264. // Last received GRE Ack number
  265. TA_IP_ADDRESS Address;
  266. // Remote address for datagrams
  267. ULONG TxAccm;
  268. ULONG RxAccm;
  269. // PPP configuration
  270. USHORT CallId;
  271. // Peer ID as used in GRE packet
  272. } Remote;
  273. struct {
  274. USHORT CallId;
  275. // My ID as used in GRE packet
  276. ULONG SequenceNumber;
  277. // Next GRE Sequence number to send
  278. ULONG AckNumber;
  279. // Last sent GRE Ack number
  280. } Packet;
  281. // Struct for items used in creating/processing packets
  282. ULONG MediaModeMask;
  283. // Indicates what types of Tapi calls we accept,
  284. // set by OID_TAPI_SET_DEFAULT_MEDIA_DETECTION
  285. ULONG_PTR LineStateMask;
  286. // This is the list of line states tapi is interested in.
  287. // set by OID_TAPI_SET_STATUS_MESSAGES
  288. UCHAR CallerId[MAX_PHONE_NUMBER_LENGTH];
  289. // This is the remote phone number or IP if we recieved the call,
  290. // and the IP or phone number we dialed if we placed the call.
  291. struct {
  292. NDIS_MINIPORT_TIMER Timer;
  293. BOOLEAN Expedited;
  294. BOOLEAN Scheduled;
  295. ULONG Checklist;
  296. #define CALL_CLOSE_CLEANUP_STATE BIT(0)
  297. #define CALL_CLOSE_LINE_DOWN BIT(1)
  298. #define CALL_CLOSE_DROP BIT(2)
  299. #define CALL_CLOSE_DROP_COMPLETE BIT(3)
  300. #define CALL_CLOSE_DISCONNECT BIT(4)
  301. #define CALL_CLOSE_CLOSE_CALL BIT(5)
  302. #define CALL_CLOSE_CLOSE_LINE BIT(6)
  303. #define CALL_CLOSE_RESET BIT(7)
  304. #define CALL_CLOSE_COMPLETE \
  305. (CALL_CLOSE_CLEANUP_STATE |\
  306. CALL_CLOSE_DROP |\
  307. CALL_CLOSE_DROP_COMPLETE |\
  308. CALL_CLOSE_DISCONNECT |\
  309. CALL_CLOSE_CLOSE_CALL |\
  310. CALL_CLOSE_LINE_DOWN |\
  311. CALL_CLOSE_CLOSE_LINE |\
  312. CALL_CLOSE_RESET)
  313. } Close;
  314. ULONG Speed;
  315. // Connection speed
  316. struct {
  317. NDIS_MINIPORT_TIMER Timer;
  318. BOOLEAN PacketQueued;
  319. ULONG_PTR Padding;
  320. NDIS_WAN_PACKET Packet;
  321. ULONG_PTR Padding2;
  322. UCHAR PacketBuffer[sizeof(GRE_HEADER)+sizeof(ULONG)*2];
  323. ULONG_PTR Padding3;
  324. // When we want to send just an ack, we actually create a packet of
  325. // 0 bytes out of this buffer and pass it down. This buffer is touched
  326. // out of our control, so we pad it to protect us from alpha alignment
  327. // problems.
  328. } Ack;
  329. UCHAR LineAddress[TAPI_MAX_LINE_ADDRESS_LENGTH];
  330. LONG SendCompleteRecursion;
  331. NDIS_MINIPORT_TIMER DialTimer;
  332. PPTP_DPC ReceiveDpc;
  333. BOOLEAN Receiving;
  334. struct {
  335. BOOLEAN Cleanup;
  336. UCHAR CleanupReason[80];
  337. CALL_STATE FinalState;
  338. NDIS_STATUS FinalError;
  339. ULONG Event;
  340. #define CALL_EVENT_TAPI_ANSWER BIT(0)
  341. #define CALL_EVENT_TAPI_CLOSE_CALL BIT(1)
  342. #define CALL_EVENT_TAPI_DROP BIT(2)
  343. #define CALL_EVENT_TAPI_LINE_UP BIT(3)
  344. #define CALL_EVENT_TAPI_LINE_DOWN BIT(4)
  345. #define CALL_EVENT_TAPI_GET_CALL_INFO BIT(5)
  346. #define CALL_EVENT_TAPI_MAKE_CALL BIT(6)
  347. #define CALL_EVENT_PPTP_CLEAR_REQUEST BIT(7)
  348. #define CALL_EVENT_PPTP_DISCONNECT BIT(8)
  349. #define CALL_EVENT_PPTP_OUT_REQUEST BIT(9)
  350. #define CALL_EVENT_PPTP_OUT_REPLY BIT(10)
  351. #define CALL_EVENT_TCP_DISCONNECT BIT(11)
  352. #define CALL_EVENT_TCP_NO_ANSWER BIT(12)
  353. #define CALL_EVENT_TUNNEL_ESTABLISHED BIT(13)
  354. } History;
  355. } CALL_SESSION, *PCALL_SESSION;
  356. typedef struct PPTP_ADAPTER {
  357. NDIS_HANDLE hMiniportAdapter;
  358. // NDIS context
  359. NDIS_SPIN_LOCK Lock;
  360. REFERENCE_COUNT Reference;
  361. PCALL_SESSION *pCallArray;
  362. // Array of all call sessions.
  363. // Size of array is MaxOutboundCalls+MaxInboundCalls
  364. LIST_ENTRY ControlTunnelList;
  365. // List of all active control connections.
  366. HANDLE hCtdiListen;
  367. // This is the one listening handle
  368. HANDLE hCtdiDg;
  369. // Ctdi handle for PPTP datagram sends/recvs
  370. HANDLE hCtdiUdp;
  371. // Ctdi handle for PPTP datagram sends/recvs
  372. NDIS_WAN_INFO Info;
  373. // NdisWan related info
  374. // Info.Endpoint should equal MaxOutboundCalls+MaxInboundCalls
  375. struct {
  376. ULONG DeviceIdBase;
  377. #if SINGLE_LINE
  378. ULONG_PTR LineStateMask;
  379. // This is the list of line states tapi is interested in.
  380. // set by OID_TAPI_SET_STATUS_MESSAGES
  381. BOOLEAN Open;
  382. HTAPI_LINE hTapiLine;
  383. // Tapi's handle to the line device, for status callbacks
  384. ULONG NumActiveCalls;
  385. #endif
  386. } Tapi;
  387. // Struct to track Tapi specific info.
  388. NDIS_MINIPORT_TIMER CleanupTimer;
  389. } PPTP_ADAPTER, *PPPTP_ADAPTER;
  390. typedef struct {
  391. ULONG InboundConnectAttempts;
  392. ULONG InboundConnectComplete;
  393. ULONG OutboundConnectAttempts;
  394. ULONG OutboundConnectComplete;
  395. ULONG TunnelsMade;
  396. ULONG TunnelsAccepted;
  397. ULONG CallsMade;
  398. ULONG CallsAccepted;
  399. ULONG PacketsSent;
  400. ULONG PacketsSentError;
  401. ULONG PacketsReceived;
  402. ULONG PacketsRejected;
  403. ULONG PacketsMissed;
  404. NDIS_SPIN_LOCK Lock;
  405. } COUNTERS;
  406. typedef struct {
  407. LIST_ENTRY ListEntry;
  408. PVOID pBuffer;
  409. PGRE_HEADER pGreHeader;
  410. HANDLE hCtdi;
  411. } DGRAM_CONTEXT, *PDGRAM_CONTEXT;
  412. extern PPPTP_ADAPTER pgAdapter;
  413. extern COUNTERS Counters;
  414. /* Prototypes --------------------------------------------------------------*/
  415. PPPTP_ADAPTER
  416. AdapterAlloc(NDIS_HANDLE NdisAdapterHandle);
  417. VOID
  418. AdapterFree(PPPTP_ADAPTER pAdapter);
  419. PCALL_SESSION
  420. CallAlloc(PPPTP_ADAPTER pAdapter);
  421. VOID
  422. CallAssignSerialNumber(PCALL_SESSION pCall);
  423. VOID
  424. CallCleanup(
  425. PCALL_SESSION pCall,
  426. BOOLEAN Locked
  427. );
  428. VOID
  429. CallDetachFromAdapter(PCALL_SESSION pCall);
  430. PCALL_SESSION
  431. CallFindAndLock(
  432. IN PPPTP_ADAPTER pAdapter,
  433. IN CALL_STATE State,
  434. IN ULONG Flags
  435. );
  436. #define FIND_INCOMING BIT(0)
  437. #define FIND_OUTGOING BIT(1)
  438. VOID
  439. CallFree(PCALL_SESSION pCall);
  440. NDIS_STATUS
  441. CallEventCallClearRequest(
  442. PCALL_SESSION pCall,
  443. UNALIGNED PPTP_CALL_CLEAR_REQUEST_PACKET *pPacket,
  444. PCONTROL_TUNNEL pCtl
  445. );
  446. NDIS_STATUS
  447. CallEventCallDisconnectNotify(
  448. PCALL_SESSION pCall,
  449. UNALIGNED PPTP_CALL_DISCONNECT_NOTIFY_PACKET *pPacket
  450. );
  451. NDIS_STATUS
  452. CallEventCallInConnect(
  453. IN PCALL_SESSION pCall,
  454. IN UNALIGNED PPTP_CALL_IN_CONNECT_PACKET *pPacket
  455. );
  456. NDIS_STATUS
  457. CallEventCallInRequest(
  458. IN PPPTP_ADAPTER pAdapter,
  459. IN PCONTROL_TUNNEL pCtl,
  460. IN UNALIGNED PPTP_CALL_IN_REQUEST_PACKET *pPacket
  461. );
  462. NDIS_STATUS
  463. CallEventCallOutReply(
  464. IN PCALL_SESSION pCall,
  465. IN UNALIGNED PPTP_CALL_OUT_REPLY_PACKET *pPacket
  466. );
  467. NDIS_STATUS
  468. CallEventCallOutRequest(
  469. IN PPPTP_ADAPTER pAdapter,
  470. IN PCONTROL_TUNNEL pCtl,
  471. IN UNALIGNED PPTP_CALL_OUT_REQUEST_PACKET *pPacket
  472. );
  473. NDIS_STATUS
  474. CallEventDisconnect(
  475. PCALL_SESSION pCall
  476. );
  477. NDIS_STATUS
  478. CallEventConnectFailure(
  479. PCALL_SESSION pCall,
  480. NDIS_STATUS FailureReason
  481. );
  482. NDIS_STATUS
  483. CallEventOutboundTunnelEstablished(
  484. IN PCALL_SESSION pCall,
  485. IN NDIS_STATUS EventStatus
  486. );
  487. PCALL_SESSION FASTCALL
  488. CallGetCall(
  489. IN PPPTP_ADAPTER pAdapter,
  490. IN ULONG_PTR ulDeviceId
  491. );
  492. BOOLEAN FASTCALL
  493. CallIsValidCall(
  494. IN PPPTP_ADAPTER pAdapter,
  495. IN ULONG_PTR ulDeviceId
  496. );
  497. #define DeviceIdToIndex(pAdapter, id) ((id)-(pAdapter)->Tapi.DeviceIdBase)
  498. #define CallGetLineCallState(State) (((ULONG)(State)<NUM_CALL_STATES) ? CallStateToLineCallStateMap[State] : LINECALLSTATE_UNKNOWN)
  499. extern ULONG CallStateToLineCallStateMap[];
  500. #define CALL_ID_INDEX_BITS 14
  501. #define CallIdToDeviceId(CallId) ((CallId)&((1<<CALL_ID_INDEX_BITS)-1))
  502. #define GreCallIdToId(id) ((ULONG)(id)&((1<<CALL_ID_INDEX_BITS)-1))
  503. NDIS_STATUS
  504. CallReceiveDatagramCallback(
  505. IN PVOID pContext,
  506. IN PTRANSPORT_ADDRESS pAddress,
  507. IN PUCHAR pBuffer,
  508. IN ULONG ulLength
  509. );
  510. NDIS_STATUS
  511. CallReceiveUdpCallback(
  512. IN PVOID pContext,
  513. IN PTRANSPORT_ADDRESS pAddress,
  514. IN PUCHAR pBuffer,
  515. IN ULONG ulLength
  516. );
  517. NDIS_STATUS
  518. CallQueueReceivePacket(
  519. PCALL_SESSION pCall,
  520. PDGRAM_CONTEXT pDgContext
  521. );
  522. NDIS_STATUS
  523. CallQueueTransmitPacket(
  524. PCALL_SESSION pCall,
  525. PNDIS_WAN_PACKET pWanPacket
  526. );
  527. // CallQueueTransmitPacket is OS-specific and not found in COMMON directory
  528. BOOLEAN
  529. CallConnectToCtl(
  530. IN PCALL_SESSION pCall,
  531. IN PCONTROL_TUNNEL pCtl,
  532. IN BOOLEAN CallLocked
  533. );
  534. VOID
  535. CallDisconnectFromCtl(
  536. IN PCALL_SESSION pCall,
  537. IN PCONTROL_TUNNEL pCtl
  538. );
  539. NDIS_STATUS
  540. CallSetLinkInfo(
  541. PPPTP_ADAPTER pAdapter,
  542. IN PNDIS_WAN_SET_LINK_INFO pRequest
  543. );
  544. VOID
  545. CallSetState(
  546. IN PCALL_SESSION pCall,
  547. IN CALL_STATE State,
  548. IN ULONG_PTR StateParam,
  549. IN BOOLEAN Locked
  550. );
  551. BOOLEAN
  552. CallProcessPackets(
  553. PCALL_SESSION pCall,
  554. ULONG TransferMax
  555. );
  556. PCONTROL_TUNNEL
  557. CtlAlloc(
  558. PPPTP_ADAPTER pAdapter
  559. );
  560. PVOID
  561. CtlAllocPacket(
  562. PCONTROL_TUNNEL pCtl,
  563. PPTP_MESSAGE_TYPE Message
  564. );
  565. VOID
  566. CtlFree(PCONTROL_TUNNEL pCtl);
  567. VOID
  568. CtlFreePacket(
  569. PCONTROL_TUNNEL pCtl,
  570. PVOID pPacket
  571. );
  572. NDIS_STATUS
  573. CtlListen(
  574. IN PPPTP_ADAPTER pAdapter
  575. );
  576. VOID
  577. CtlCleanup(
  578. PCONTROL_TUNNEL pCtl,
  579. BOOLEAN Locked
  580. );
  581. NDIS_STATUS
  582. CtlConnectCall(
  583. IN PPPTP_ADAPTER pAdapter,
  584. IN PCALL_SESSION pCall,
  585. IN PTA_IP_ADDRESS pTargetAddress
  586. );
  587. NDIS_STATUS
  588. CtlDisconnectCall(
  589. IN PCALL_SESSION pCall
  590. );
  591. NDIS_STATUS
  592. CtlSend(
  593. IN PCONTROL_TUNNEL pCtl,
  594. IN PVOID pPacketBuffer
  595. );
  596. VOID
  597. CtlpCleanupCtls(
  598. PPPTP_ADAPTER pAdapter
  599. );
  600. VOID
  601. DeinitThreading();
  602. VOID
  603. FreeWorkItem(
  604. PPPTP_WORK_ITEM pItem
  605. );
  606. VOID
  607. InitCallLayer();
  608. NDIS_STATUS
  609. InitThreading(
  610. IN NDIS_HANDLE hMiniportAdapter
  611. );
  612. VOID
  613. IpAddressToString(
  614. IN ULONG ulIpAddress,
  615. OUT CHAR* pszIpAddress );
  616. VOID
  617. MiniportHalt(
  618. IN NDIS_HANDLE MiniportAdapterContext
  619. );
  620. NDIS_STATUS
  621. MiniportInitialize(
  622. OUT PNDIS_STATUS OpenErrorStatus,
  623. OUT PUINT SelectedMediumIndex,
  624. IN PNDIS_MEDIUM MediumArray,
  625. IN UINT MediumArraySize,
  626. IN NDIS_HANDLE NdisAdapterHandle,
  627. IN NDIS_HANDLE WrapperConfigurationContext
  628. );
  629. NDIS_STATUS
  630. MiniportQueryInformation(
  631. IN NDIS_HANDLE MiniportAdapterContext,
  632. IN NDIS_OID Oid,
  633. IN PVOID InformationBuffer,
  634. IN ULONG InformationBufferLength,
  635. OUT PULONG BytesWritten,
  636. OUT PULONG BytesNeeded
  637. );
  638. NDIS_STATUS
  639. MiniportReset(
  640. OUT PBOOLEAN AddressingReset,
  641. IN NDIS_HANDLE MiniportAdapterContext
  642. );
  643. NDIS_STATUS
  644. MiniportSetInformation(
  645. IN NDIS_HANDLE MiniportAdapterContext,
  646. IN NDIS_OID Oid,
  647. IN PVOID InformationBuffer,
  648. IN ULONG InformationBufferLength,
  649. OUT PULONG BytesRead,
  650. OUT PULONG BytesNeeded
  651. );
  652. NDIS_STATUS
  653. MiniportWanSend(
  654. IN NDIS_HANDLE MiniportAdapterContext,
  655. IN NDIS_HANDLE NdisLinkHandle,
  656. IN PNDIS_WAN_PACKET WanPacket
  657. );
  658. VOID
  659. OsGetTapiLineAddress(ULONG Index, PUCHAR s, ULONG Length);
  660. VOID
  661. OsReadConfig(
  662. NDIS_HANDLE hConfig
  663. );
  664. NDIS_STATUS
  665. OsSpecificTapiGetDevCaps(
  666. ULONG_PTR ulDeviceId,
  667. IN OUT PNDIS_TAPI_GET_DEV_CAPS pRequest
  668. );
  669. extern BOOLEAN PptpInitialized;
  670. NDIS_STATUS
  671. PptpInitialize(
  672. PPPTP_ADAPTER pAdapter
  673. );
  674. NDIS_STATUS
  675. ScheduleWorkItem(
  676. WORK_PROC Callback,
  677. PVOID Context,
  678. PVOID InfoBuf,
  679. ULONG InfoBufLen
  680. );
  681. PUCHAR
  682. StringToIpAddress(
  683. IN PUCHAR pszIpAddress,
  684. IN OUT PTA_IP_ADDRESS pAddress,
  685. OUT PBOOLEAN pValidAddress
  686. );
  687. PWCHAR
  688. StringToIpAddressW(
  689. IN PWCHAR pszIpAddress,
  690. IN OUT PTA_IP_ADDRESS pAddress,
  691. OUT PBOOLEAN pValidAddress
  692. );
  693. NDIS_STATUS
  694. TapiAnswer(
  695. IN PPPTP_ADAPTER pAdapter,
  696. IN PNDIS_TAPI_ANSWER pRequest
  697. );
  698. NDIS_STATUS
  699. TapiClose(
  700. IN PPPTP_ADAPTER pAdapter,
  701. IN PNDIS_TAPI_CLOSE pRequest
  702. );
  703. NDIS_STATUS
  704. TapiCloseCall(
  705. IN PPPTP_ADAPTER pAdapter,
  706. IN PNDIS_TAPI_CLOSE_CALL pRequest
  707. );
  708. NDIS_STATUS
  709. TapiDrop(
  710. IN PPPTP_ADAPTER pAdapter,
  711. IN PNDIS_TAPI_DROP pRequest
  712. );
  713. NDIS_STATUS
  714. TapiGetAddressCaps(
  715. IN PPPTP_ADAPTER pAdapter,
  716. IN OUT PNDIS_TAPI_GET_ADDRESS_CAPS pRequest
  717. );
  718. NDIS_STATUS
  719. TapiGetAddressStatus(
  720. IN PPPTP_ADAPTER pAdapter,
  721. IN OUT PNDIS_TAPI_GET_ADDRESS_STATUS pExtIdQuery
  722. );
  723. NDIS_STATUS
  724. TapiGetCallInfo(
  725. IN PPPTP_ADAPTER pAdapter,
  726. IN OUT PNDIS_TAPI_GET_CALL_INFO pRequest,
  727. IN OUT PULONG pRequiredLength
  728. );
  729. NDIS_STATUS
  730. TapiGetCallStatus(
  731. IN PPPTP_ADAPTER pAdapter,
  732. IN OUT PNDIS_TAPI_GET_CALL_STATUS pRequest
  733. );
  734. NDIS_STATUS
  735. TapiGetDevCaps(
  736. IN PPPTP_ADAPTER pAdapter,
  737. IN OUT PNDIS_TAPI_GET_DEV_CAPS pRequest
  738. );
  739. NDIS_STATUS
  740. TapiGetExtensionId(
  741. IN PPPTP_ADAPTER pAdapter,
  742. IN OUT PNDIS_TAPI_GET_EXTENSION_ID pExtIdQuery
  743. );
  744. NDIS_STATUS
  745. TapiGetId(
  746. IN PPPTP_ADAPTER pAdapter,
  747. IN OUT PNDIS_TAPI_GET_ID pRequest
  748. );
  749. #define TapiLineHandleToId(h) ((h)&0x7fffffff)
  750. #define TapiIdToLineHandle(id) ((id)|0x80000000)
  751. #define LinkHandleToId(h) ((ULONG_PTR)(((ULONG_PTR)(h))&0x7fffffff))
  752. #define DeviceIdToLinkHandle(id) ((id)|0x80000000)
  753. VOID
  754. TapiLineDown(
  755. PCALL_SESSION pCall
  756. );
  757. VOID
  758. TapiLineUp(
  759. PCALL_SESSION pCall
  760. );
  761. NDIS_STATUS
  762. TapiMakeCall(
  763. IN PPPTP_ADAPTER pAdapter,
  764. IN OUT PNDIS_TAPI_MAKE_CALL pRequest
  765. );
  766. NDIS_STATUS
  767. TapiNegotiateExtVersion(
  768. IN PPPTP_ADAPTER pAdapter,
  769. IN OUT PNDIS_TAPI_NEGOTIATE_EXT_VERSION pExtVersion
  770. );
  771. NDIS_STATUS
  772. TapiOpen(
  773. IN PPPTP_ADAPTER pAdapter,
  774. IN OUT PNDIS_TAPI_OPEN pRequest
  775. );
  776. NDIS_STATUS
  777. TapiProviderInitialize(
  778. IN PPPTP_ADAPTER pAdapter,
  779. IN OUT PNDIS_TAPI_PROVIDER_INITIALIZE pInitData
  780. );
  781. NDIS_STATUS
  782. TapiProviderShutdown(
  783. IN PPPTP_ADAPTER pAdapter,
  784. IN OUT PNDIS_TAPI_PROVIDER_SHUTDOWN pRequest
  785. );
  786. NDIS_STATUS
  787. TapiSetDefaultMediaDetection(
  788. IN PPPTP_ADAPTER pAdapter,
  789. IN OUT PNDIS_TAPI_SET_DEFAULT_MEDIA_DETECTION pRequest
  790. );
  791. NDIS_STATUS
  792. TapiSetStatusMessages(
  793. IN PPPTP_ADAPTER pAdapter,
  794. IN OUT PNDIS_TAPI_SET_STATUS_MESSAGES pRequest
  795. );
  796. // Enum
  797. #define ENUM_SIGNATURE TAG('ENUM')
  798. typedef struct {
  799. LIST_ENTRY ListEntry;
  800. ULONG Signature;
  801. } ENUM_CONTEXT, *PENUM_CONTEXT;
  802. #define InitEnumContext(e) \
  803. { \
  804. (e)->ListEntry.Flink = (e)->ListEntry.Blink = NULL; \
  805. (e)->Signature = ENUM_SIGNATURE; \
  806. }
  807. PLIST_ENTRY FASTCALL
  808. EnumListEntry(
  809. IN PLIST_ENTRY pHead,
  810. IN PENUM_CONTEXT pEnum,
  811. IN PNDIS_SPIN_LOCK pLock
  812. );
  813. VOID
  814. EnumComplete(
  815. IN PENUM_CONTEXT pEnum,
  816. IN PNDIS_SPIN_LOCK pLock
  817. );
  818. int
  819. axtol(
  820. LPSTR psz,
  821. ULONG *pResult
  822. );
  823. #endif // RASPPTP_H