85{
86 PIP_ADAPTER_ADDRESSES pAdapterAddresses =
NULL,
Ptr;
87 PIP_ADAPTER_UNICAST_ADDRESS pUnicastAddress;
88 PIP_ADAPTER_PREFIX pPrefix;
89 PIP_ADAPTER_DNS_SERVER_ADDRESS pDnsServer;
90 WCHAR IpBuffer[17], MaskBuffer[17];
92 ULONG adaptOutBufLen = 15000;
94 ULONG Flags = GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_INCLUDE_PREFIX;
95
96
97 pAdapterAddresses = (PIP_ADAPTER_ADDRESSES)
malloc(adaptOutBufLen);
98 if (pAdapterAddresses ==
NULL)
99 {
101 goto done;
102 }
103
106 {
107 free(pAdapterAddresses);
108 pAdapterAddresses = (PIP_ADAPTER_ADDRESSES)
malloc(adaptOutBufLen);
109 if (pAdapterAddresses ==
NULL)
110 {
112 goto done;
113 }
114 }
115
118 goto done;
119
120 Ptr = pAdapterAddresses;
122 {
124 {
126
128 {
130
131 if (
Ptr->FirstUnicastAddress ==
NULL)
132 {
134 }
135 else
136 {
138 pUnicastAddress =
Ptr->FirstUnicastAddress;
139 while (pUnicastAddress)
140 {
142 {
144#if 0
146 {
148 }
149 else
150 {
152 }
154#endif
155 }
156
157 pUnicastAddress = pUnicastAddress->Next;
158 }
159 }
160
162 {
164 }
165 else
166 {
168 pPrefix =
Ptr->FirstPrefix;
169 while (pPrefix)
170 {
173#if 0
175 {
177
179 {
180 if (pPrefix->Next)
181 PrintMessage(
L" SubnetMasks: %s/%lu (Mask: %s)\n", IpBuffer, pPrefix->PrefixLength, MaskBuffer);
182 else
183 PrintMessage(
L" SubnetMask: %s/%lu (Mask: %s)\n", IpBuffer, pPrefix->PrefixLength, MaskBuffer);
184 }
185 else
186 {
187 PrintMessage(
L" %s/%lu (Mask: %s)\n", IpBuffer, pPrefix->PrefixLength, MaskBuffer);
188 }
190 }
191#endif
192 pPrefix = pPrefix->Next;
193 }
194 }
195
196
197
198
199 }
200
202 {
203 if (
Ptr->FirstDnsServerAddress ==
NULL)
204 {
205 if (
Ptr->Flags & IP_ADAPTER_DHCP_ENABLED)
206 PrintMessage(
L" DNS servers configured through DHCP: %s\n",
L"None");
207 else
208 PrintMessage(
L" Statically configured DNS Servers: %s\n",
L"None");
209 }
210 else
211 {
213 pDnsServer =
Ptr->FirstDnsServerAddress;
214 while (pDnsServer)
215 {
217 {
219 {
220 if (
Ptr->Flags & IP_ADAPTER_DHCP_ENABLED)
221 PrintMessage(
L" DNS servers configured through DHCP: %s\n", IpBuffer);
222 else
223 PrintMessage(
L" Statically configured DNS Servers: %s\n", IpBuffer);
224 }
225 else
226 {
228 }
229
231 }
232
233 pDnsServer = pDnsServer->Next;
234 }
235 }
236
237
238 }
239 }
240
242 }
243
245
246done:
247 if (pAdapterAddresses)
248 free(pAdapterAddresses);
249
251}
static BOOL FormatIPv4NetMask(_Out_ PWCHAR pBuffer, _In_ ULONG PrefixLength)
BOOL WINAPI MatchToken(_In_ LPCWSTR pwszUserToken, _In_ LPCWSTR pwszCmdToken)