Reactos
1/*
2 * PROJECT: ReactOS IF Monitor DLL
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: NetSh Helper interface context functions
5 * COPYRIGHT: Copyright 2025 Eric Kohl <eric.kohl@reactos.org>
6 */
7
8#include "precomp.h"
9
10#include <guiddef.h>
11
12#define NDEBUG
13#include <debug.h>
14
15#include "guid.h"
16#include "resource.h"
17
18static FN_HANDLE_CMD InterfaceShowInterface;
19
20static
21CMD_ENTRY
22InterfaceShowCommands[] =
23{
24 {L"interface", InterfaceShowInterface, IDS_HLP_INTERFACE_SHOW_INTERFACE, IDS_HLP_INTERFACE_SHOW_INTERFACE_EX, 0}
25};
26
27static
28CMD_GROUP_ENTRY
29InterfaceGroups[] =
30{
31 {L"show", IDS_HLP_INTERFACE_SHOW, sizeof(InterfaceShowCommands) / sizeof(CMD_ENTRY), 0, InterfaceShowCommands, NULL},
32};
33
34
35static
36DWORD
37WINAPI
38InterfaceShowInterface(
39 LPCWSTR pwszMachine,
40 LPWSTR *argv,
41 DWORD dwCurrentIndex,
42 DWORD dwArgCount,
43 DWORD dwFlags,
44 LPCVOID pvData,
45 BOOL *pbDone)
46{
47 PrintMessage(L"InterfaceShowInterface(): Not implemented yet!\n");
48
49 return ERROR_SUCCESS;
50}
51
52
53static
54DWORD
55WINAPI
56InterfaceDumpFn(
57 _In_ LPCWSTR pwszRouter,
58 _In_ LPWSTR *ppwcArguments,
59 _In_ DWORD dwArgCount,
60 _In_ LPCVOID pvData)
61{
62 DPRINT("InterfaceDumpFn(%S %p %lu %p)\n", pwszRouter, ppwcArguments, dwArgCount, pvData);
63
64 PrintMessageFromModule(hDllInstance, IDS_DUMP_HEADERLINE);
65 PrintMessage(L"# Interface Configuration\n");
66 PrintMessageFromModule(hDllInstance, IDS_DUMP_HEADERLINE);
67 PrintMessage(L"pushd interface\n");
68 PrintMessageFromModule(hDllInstance, IDS_DUMP_NEWLINE);
69
70 PrintMessageFromModule(hDllInstance, IDS_DUMP_NEWLINE);
71 PrintMessage(L"popd\n");
72 PrintMessage(L"# End of Interface Configuration\n");
73 PrintMessageFromModule(hDllInstance, IDS_DUMP_NEWLINE);
74
75 return ERROR_SUCCESS;
76}
77
78
79DWORD
80WINAPI
81InterfaceStart(
82 _In_ const GUID *pguidParent,
83 _In_ DWORD dwVersion)
84{
85 NS_CONTEXT_ATTRIBUTES ContextAttributes;
86
87 DPRINT("InterfaceStart()\n");
88
89 ZeroMemory(&ContextAttributes, sizeof(ContextAttributes));
90 ContextAttributes.dwVersion = 1;
91 ContextAttributes.pwszContext = L"interface";
92 ContextAttributes.guidHelper = GUID_IFMON_INTERFACE;
93
94 ContextAttributes.ulNumTopCmds = 0;
95 ContextAttributes.pTopCmds = NULL;
96
97 ContextAttributes.ulNumGroups = sizeof(InterfaceGroups) / sizeof(CMD_GROUP_ENTRY);
98 ContextAttributes.pCmdGroups = InterfaceGroups;
99
100 ContextAttributes.pfnDumpFn = InterfaceDumpFn;
101
102 RegisterContext(&ContextAttributes);
103
104 return ERROR_SUCCESS;
105}
106
107
108DWORD
109WINAPI
110RegisterInterfaceHelper(VOID)
111{
112 NS_HELPER_ATTRIBUTES HelperAttributes;
113
114 DPRINT("RegisterInterfaceHelper()\n");
115
116 ZeroMemory(&HelperAttributes, sizeof(HelperAttributes));
117 HelperAttributes.dwVersion = 1;
118 HelperAttributes.guidHelper = GUID_IFMON_INTERFACE;
119 HelperAttributes.pfnStart = InterfaceStart;
120 HelperAttributes.pfnStop = NULL;
121 RegisterHelper(NULL, &HelperAttributes);
122
123 return ERROR_SUCCESS;
124}