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.

111 lines
3.4 KiB

  1. /*
  2. File PnP.c
  3. Implementation of pnp enhancements of the interface between the IPX stack and
  4. the IPX user-mode router components software PnP enabled.
  5. Paul Mayfield, 11/5/97.
  6. */
  7. #include "ipxdefs.h"
  8. #include "pnp.h"
  9. // Globals from other files
  10. extern WCHAR ISN_IPX_NAME[];
  11. extern ULONG InternalNetworkNumber;
  12. extern UCHAR INTERNAL_NODE_ADDRESS[6];
  13. extern IO_STATUS_BLOCK IoctlStatus;
  14. extern HANDLE IpxDriverHandle;
  15. extern LONG AdapterChangeApcPending;
  16. extern LIST_ENTRY PortListHead;
  17. extern PCONFIG_PORT IpxWanPort;
  18. extern CRITICAL_SECTION ConfigInfoLock;
  19. extern ULONG NumAdapters;
  20. // [pmay] The global trace id.
  21. extern DWORD g_dwTraceId;
  22. DWORD IpxPostIntNetNumMessage(PCONFIG_PORT pPort, DWORD dwNewNetNum);
  23. // Queries the ipx stack for the current ipx internal net number. This code was
  24. // stolen from OpenAdapterConfigPort.
  25. DWORD PnpGetCurrentInternalNetNum(LPDWORD lpdwNetNum) {
  26. PISN_ACTION_GET_DETAILS details;
  27. PNWLINK_ACTION action;
  28. CHAR IoctlBuffer[sizeof (NWLINK_ACTION)
  29. +sizeof (ISN_ACTION_GET_DETAILS)];
  30. NTSTATUS status;
  31. IO_STATUS_BLOCK IoStatus;
  32. //TracePrintf(g_dwTraceId, "Entered PnpGetCurrentInternalNetNum\n");
  33. // Prepare to send an ioctl to the stack to get the internal
  34. // net information along with the global adapter information
  35. action = (PNWLINK_ACTION)IoctlBuffer;
  36. action->Header.TransportId = ISN_ACTION_TRANSPORT_ID;
  37. action->OptionType = NWLINK_OPTION_CONTROL;
  38. action->BufferLength = sizeof(action->Option) + sizeof(ISN_ACTION_GET_DETAILS);
  39. action->Option = MIPX_CONFIG;
  40. details = (PISN_ACTION_GET_DETAILS)action->Data;
  41. // Nic id 0 will return internal net information and
  42. // total number of adapters
  43. details->NicId = 0;
  44. // Send the ioctl
  45. status = NtDeviceIoControlFile(
  46. IpxDriverHandle,
  47. NULL,
  48. NULL,
  49. NULL,
  50. &IoStatus,
  51. IOCTL_TDI_ACTION,
  52. NULL,
  53. 0,
  54. action,
  55. sizeof(NWLINK_ACTION) + sizeof(ISN_ACTION_GET_DETAILS));
  56. // Wait for the ioctl to complete
  57. if (status==STATUS_PENDING) {
  58. status = NtWaitForSingleObject (IpxDriverHandle, FALSE, NULL);
  59. if (NT_SUCCESS (status))
  60. status = IoStatus.Status;
  61. }
  62. // Output the new net number
  63. //TracePrintf(g_dwTraceId, "PnpGetCurrentInternalNetNum: Stack has returned internal net num: %x\n",
  64. // details->NetworkNumber);
  65. // If the stack reports all the requested information without error,
  66. // update global variables with the information retrieved.
  67. if (NT_SUCCESS (status)) {
  68. NumAdapters = details->NicId;
  69. *lpdwNetNum = details->NetworkNumber;
  70. //TracePrintf(g_dwTraceId, "PnpGetCurrentInternalNetNum: Returning success\n");
  71. return NO_ERROR;
  72. }
  73. return ERROR_CAN_NOT_COMPLETE;
  74. }
  75. // Notifies all clients to adptif (rtrmgr, sap, rip) that the internal
  76. // network number has changed.
  77. DWORD PnpHandleInternalNetNumChange(DWORD dwNewNetNum) {
  78. PCONFIG_PORT pPort;
  79. PLIST_ENTRY cur;
  80. TracePrintf(g_dwTraceId, "PnpHandleInternalNetNumChange: Entered with number: %x", dwNewNetNum);
  81. // Signal each client (as in rtrmgr, sap, rip) to update
  82. // the internal network number.
  83. for (cur=PortListHead.Flink; cur != &PortListHead; cur = cur->Flink) {
  84. pPort = CONTAINING_RECORD (cur, CONFIG_PORT, link);
  85. IpxPostIntNetNumMessage(pPort, dwNewNetNum);
  86. }
  87. TracePrintf(g_dwTraceId, "\n");
  88. return NO_ERROR;
  89. }