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.

256 lines
5.4 KiB

  1. /*******************************************************************/
  2. /* Copyright(c) 1996 Microsoft Corporation */
  3. /*******************************************************************/
  4. //***
  5. //
  6. // Filename: ipxwanif.c
  7. //
  8. // Description: routines for interfacing with ipxwan
  9. //
  10. // Author: Stefan Solomon (stefans) March 12, 1996
  11. //
  12. // Revision History:
  13. //
  14. //***
  15. #include "precomp.h"
  16. #pragma hdrstop
  17. HINSTANCE IpxWanDllHandle;
  18. PIPXWAN_BIND IpxwanBind;
  19. PIPXWAN_UNBIND IpxwanUnbind;
  20. VOID
  21. IpxcpConfigDoneCompletion(ULONG_PTR ConnectionId);
  22. DWORD
  23. IpxcpConfigDone(ULONG ConnectionId,
  24. PUCHAR Network,
  25. PUCHAR LocalNode,
  26. PUCHAR RemoteNode,
  27. BOOL Success);
  28. ULONG
  29. IpxcpGetInterfaceType(ULONG ConnectionId);
  30. DWORD
  31. IpxcpGetRemoteNode(ULONG ConnectionId,
  32. PUCHAR RemoteNode);
  33. /*++
  34. Function: LoadIpxWan
  35. Descr: Load the ipxwan.dll and bind to it if present
  36. --*/
  37. VOID
  38. LoadIpxWan(VOID)
  39. {
  40. IPXWAN_INTERFACE IpxwanIf;
  41. if((IpxWanDllHandle = LoadLibrary(IPXWANDLLNAME)) == NULL) {
  42. TraceIpx(IPXWANIF_TRACE, "LoadIpxWan: IPXWAN DLL not present\n");
  43. return;
  44. }
  45. if( ((IpxwanBind = (PIPXWAN_BIND)GetProcAddress(IpxWanDllHandle,
  46. IPXWAN_BIND_ENTRY_POINT_STRING)) == NULL)
  47. || ((IpxwanUnbind = (PIPXWAN_UNBIND)GetProcAddress(IpxWanDllHandle,
  48. IPXWAN_UNBIND_ENTRY_POINT_STRING)) == NULL)){
  49. TraceIpx(IPXWANIF_TRACE, "LoadIpxWan: Failed to get IPXWAN Entry point!\n");
  50. FreeLibrary (IpxWanDllHandle);
  51. IpxWanDllHandle = NULL;
  52. return;
  53. }
  54. IpxwanIf.EnableUnnumberedWanLinks = GlobalConfig.EnableUnnumberedWanLinks;
  55. IpxwanIf.IpxcpGetWanNetNumber = GetWanNetNumber;
  56. IpxwanIf.IpxcpReleaseWanNetNumber = ReleaseWanNetNumber;
  57. IpxwanIf.IpxcpConfigDone = IpxcpConfigDone;
  58. IpxwanIf.IpxcpGetInternalNetNumber = GetInternalNetNumber;
  59. IpxwanIf.IpxcpGetInterfaceType = IpxcpGetInterfaceType;
  60. IpxwanIf.IpxcpGetRemoteNode = IpxcpGetRemoteNode;
  61. IpxwanIf.IpxcpIsRoute = IsRoute;
  62. if(IpxwanBind(&IpxwanIf) == NO_ERROR) {
  63. TraceIpx(IPXWANIF_TRACE, "LoadIpxWan: IPXWAN DLL loaded OK");
  64. }
  65. else
  66. {
  67. TraceIpx(IPXWANIF_TRACE, "LoadIpxWan: IpxwanBind failed!");
  68. FreeLibrary (IpxWanDllHandle);
  69. IpxWanDllHandle = NULL;
  70. }
  71. }
  72. VOID
  73. UnloadIpxWan(VOID)
  74. {
  75. if (IpxWanDllHandle!=NULL) {
  76. IpxwanUnbind ();
  77. FreeLibrary (IpxWanDllHandle);
  78. }
  79. }
  80. /*++
  81. Function: IpxcpConfigDone
  82. Descr: Tells IPXCP that the link has been configured OR that it
  83. should be terminated.
  84. If configured, the config parameters will be copied into the
  85. work buffer so that they are available for reporting to PPP
  86. (IpxCpGetNetworkAddress)
  87. --*/
  88. DWORD
  89. IpxcpConfigDone(ULONG ConnectionId,
  90. PUCHAR Network,
  91. PUCHAR LocalNode,
  92. PUCHAR RemoteNode,
  93. BOOL Success)
  94. {
  95. PIPXCP_CONTEXT contextp;
  96. TraceIpx(IPXWANIF_TRACE, "IpxcpConfigDone: Entered for ConectionId %d\n", ConnectionId);
  97. ACQUIRE_DATABASE_LOCK;
  98. if((contextp = GetContextBuffer(ConnectionId)) == NULL) {
  99. TraceIpx(IPXWANIF_TRACE, "IpxcpConfigDone: ConectionId %d not present\n", ConnectionId);
  100. RELEASE_DATABASE_LOCK;
  101. return ERROR_CAN_NOT_COMPLETE;
  102. }
  103. contextp->IpxwanState = IPXWAN_DONE;
  104. if(!Success) {
  105. contextp->IpxwanConfigResult = ERROR_CAN_NOT_COMPLETE;
  106. }
  107. else
  108. {
  109. contextp->IpxwanConfigResult = NO_ERROR;
  110. memcpy(contextp->Config.Network, Network, 4);
  111. memcpy(contextp->Config.LocalNode, LocalNode, 6);
  112. memcpy(contextp->Config.RemoteNode, RemoteNode, 6);
  113. }
  114. RELEASE_DATABASE_LOCK;
  115. if(!QueueUserAPC(IpxcpConfigDoneCompletion,
  116. PPPThreadHandle,
  117. ConnectionId)) {
  118. TraceIpx(IPXWANIF_TRACE, "IpxcpConfigDone: Error queueing the APC to PPP\n");
  119. return ERROR_CAN_NOT_COMPLETE;
  120. }
  121. return NO_ERROR;
  122. }
  123. /*++
  124. Function: IpxcpGetInterfaceType
  125. Descr:
  126. --*/
  127. ULONG
  128. IpxcpGetInterfaceType(ULONG ConnectionId)
  129. {
  130. ULONG InterfaceType;
  131. PIPXCP_CONTEXT contextp;
  132. ACQUIRE_DATABASE_LOCK;
  133. if((contextp = GetContextBuffer(ConnectionId)) == NULL) {
  134. TraceIpx(IPXWANIF_TRACE, "IpxcpGetInterfaceType: ConectionId %d not present\n", ConnectionId);
  135. RELEASE_DATABASE_LOCK;
  136. return IF_TYPE_OTHER;
  137. }
  138. InterfaceType = contextp->InterfaceType;
  139. RELEASE_DATABASE_LOCK;
  140. return InterfaceType;
  141. }
  142. /*++
  143. Function: IpxcpGetRemoteNode
  144. Descr: Called when the remote peer is a workstation.
  145. Returns the node number assigned to it by the local router.
  146. --*/
  147. DWORD
  148. IpxcpGetRemoteNode(ULONG ConnectionId,
  149. PUCHAR RemoteNode)
  150. {
  151. ULONG InterfaceType;
  152. PIPXCP_CONTEXT contextp;
  153. ACQUIRE_DATABASE_LOCK;
  154. if((contextp = GetContextBuffer(ConnectionId)) == NULL) {
  155. TraceIpx(IPXWANIF_TRACE, "IpxcpGetRemoteNode: ConectionId %d not present\n", ConnectionId);
  156. RELEASE_DATABASE_LOCK;
  157. return ERROR_CAN_NOT_COMPLETE;
  158. }
  159. memcpy(RemoteNode, contextp->Config.RemoteNode, 6);
  160. RELEASE_DATABASE_LOCK;
  161. return NO_ERROR;
  162. }
  163. VOID
  164. IpxcpConfigDoneCompletion(ULONG_PTR ConnectionId)
  165. {
  166. PIPXCP_CONTEXT contextp;
  167. DWORD Error;
  168. DWORD rc;
  169. ACQUIRE_DATABASE_LOCK;
  170. if((contextp = GetContextBuffer(ConnectionId)) == NULL) {
  171. RELEASE_DATABASE_LOCK;
  172. return;
  173. }
  174. Error = contextp->IpxwanConfigResult;
  175. RELEASE_DATABASE_LOCK;
  176. TraceIpx(IPXWANIF_TRACE, "IpxcpConfigDoneCompletion: Calling PPPCompletionRoutine with ConnId=%d, Error=%d\n",
  177. ConnectionId,
  178. Error);
  179. (*PPPCompletionRoutine)((HCONN)ConnectionId,
  180. PPP_IPXCP_PROTOCOL,
  181. NULL,
  182. Error);
  183. }