Leaked source code of windows server 2003
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.

115 lines
3.6 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. if (IpxDriverHandle == NULL)
  33. {
  34. return ERROR_CAN_NOT_COMPLETE;
  35. }
  36. //TracePrintf(g_dwTraceId, "Entered PnpGetCurrentInternalNetNum\n");
  37. // Prepare to send an ioctl to the stack to get the internal
  38. // net information along with the global adapter information
  39. action = (PNWLINK_ACTION)IoctlBuffer;
  40. action->Header.TransportId = ISN_ACTION_TRANSPORT_ID;
  41. action->OptionType = NWLINK_OPTION_CONTROL;
  42. action->BufferLength = sizeof(action->Option) + sizeof(ISN_ACTION_GET_DETAILS);
  43. action->Option = MIPX_CONFIG;
  44. details = (PISN_ACTION_GET_DETAILS)action->Data;
  45. // Nic id 0 will return internal net information and
  46. // total number of adapters
  47. details->NicId = 0;
  48. // Send the ioctl
  49. status = NtDeviceIoControlFile(
  50. IpxDriverHandle,
  51. NULL,
  52. NULL,
  53. NULL,
  54. &IoStatus,
  55. IOCTL_TDI_ACTION,
  56. NULL,
  57. 0,
  58. action,
  59. sizeof(NWLINK_ACTION) + sizeof(ISN_ACTION_GET_DETAILS));
  60. // Wait for the ioctl to complete
  61. if (status==STATUS_PENDING) {
  62. status = NtWaitForSingleObject (IpxDriverHandle, FALSE, NULL);
  63. if (NT_SUCCESS (status))
  64. status = IoStatus.Status;
  65. }
  66. // Output the new net number
  67. //TracePrintf(g_dwTraceId, "PnpGetCurrentInternalNetNum: Stack has returned internal net num: %x\n",
  68. // details->NetworkNumber);
  69. // If the stack reports all the requested information without error,
  70. // update global variables with the information retrieved.
  71. if (NT_SUCCESS (status)) {
  72. NumAdapters = details->NicId;
  73. *lpdwNetNum = details->NetworkNumber;
  74. //TracePrintf(g_dwTraceId, "PnpGetCurrentInternalNetNum: Returning success\n");
  75. return NO_ERROR;
  76. }
  77. return ERROR_CAN_NOT_COMPLETE;
  78. }
  79. // Notifies all clients to adptif (rtrmgr, sap, rip) that the internal
  80. // network number has changed.
  81. DWORD PnpHandleInternalNetNumChange(DWORD dwNewNetNum) {
  82. PCONFIG_PORT pPort;
  83. PLIST_ENTRY cur;
  84. TracePrintf(g_dwTraceId, "PnpHandleInternalNetNumChange: Entered with number: %x", dwNewNetNum);
  85. // Signal each client (as in rtrmgr, sap, rip) to update
  86. // the internal network number.
  87. for (cur=PortListHead.Flink; cur != &PortListHead; cur = cur->Flink) {
  88. pPort = CONTAINING_RECORD (cur, CONFIG_PORT, link);
  89. IpxPostIntNetNumMessage(pPort, dwNewNetNum);
  90. }
  91. TracePrintf(g_dwTraceId, "\n");
  92. return NO_ERROR;
  93. }