]>
Commit | Line | Data |
---|---|---|
a3bcde70 HT |
1 | /** @file\r |
2 | The implementation of dump policy entry function in IpSecConfig application.\r | |
3 | \r | |
22441982 | 4 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r |
a3bcde70 | 5 | \r |
ecf98fbc | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
a3bcde70 HT |
7 | \r |
8 | **/\r | |
9 | \r | |
10 | #include "IpSecConfig.h"\r | |
11 | #include "Dump.h"\r | |
12 | #include "ForEach.h"\r | |
13 | #include "Helper.h"\r | |
14 | \r | |
15 | /**\r | |
16 | Private function called to get the version infomation from an EFI_IP_ADDRESS_INFO structure.\r | |
17 | \r | |
18 | @param[in] AddressInfo The pointer to the EFI_IP_ADDRESS_INFO structure.\r | |
19 | \r | |
20 | @return the value of version.\r | |
21 | **/\r | |
22 | UINTN\r | |
23 | GetVerFromAddrInfo (\r | |
24 | IN EFI_IP_ADDRESS_INFO *AddressInfo\r | |
25 | )\r | |
26 | {\r | |
27 | if((AddressInfo->PrefixLength <= 32) && (AddressInfo->Address.Addr[1] == 0) &&\r | |
28 | (AddressInfo->Address.Addr[2] == 0) && (AddressInfo->Address.Addr[3] == 0)) {\r | |
29 | return IP_VERSION_4;\r | |
30 | } else {\r | |
31 | return IP_VERSION_6;\r | |
32 | }\r | |
33 | }\r | |
34 | \r | |
35 | /**\r | |
36 | Private function called to get the version information from a EFI_IP_ADDRESS structure.\r | |
37 | \r | |
38 | @param[in] Address The pointer to the EFI_IP_ADDRESS structure.\r | |
39 | \r | |
40 | @return The value of the version.\r | |
41 | **/\r | |
42 | UINTN\r | |
43 | GetVerFromIpAddr (\r | |
44 | IN EFI_IP_ADDRESS *Address\r | |
45 | )\r | |
46 | {\r | |
47 | if ((Address->Addr[1] == 0) && (Address->Addr[2] == 0) && (Address->Addr[3] == 0)) {\r | |
48 | return IP_VERSION_4;\r | |
49 | } else {\r | |
50 | return IP_VERSION_6;\r | |
51 | }\r | |
52 | }\r | |
53 | \r | |
54 | /**\r | |
55 | Private function called to print an ASCII string in unicode char format.\r | |
56 | \r | |
57 | @param[in] Str The pointer to the ASCII string.\r | |
58 | @param[in] Length The value of the ASCII string length.\r | |
59 | **/\r | |
60 | VOID\r | |
61 | DumpAsciiString (\r | |
62 | IN CHAR8 *Str,\r | |
63 | IN UINTN Length\r | |
64 | )\r | |
65 | {\r | |
66 | UINTN Index;\r | |
22441982 | 67 | Print (L"\"");\r |
a3bcde70 HT |
68 | for (Index = 0; Index < Length; Index++) {\r |
69 | Print (L"%c", (CHAR16) Str[Index]);\r | |
70 | }\r | |
22441982 | 71 | Print (L"\"");\r |
72 | }\r | |
73 | \r | |
74 | /**\r | |
75 | Private function called to print a buffer in Hex format.\r | |
76 | \r | |
77 | @param[in] Data The pointer to the buffer.\r | |
78 | @param[in] Length The size of the buffer.\r | |
79 | \r | |
80 | **/\r | |
81 | VOID\r | |
82 | DumpBuf (\r | |
83 | IN UINT8 *Data,\r | |
84 | IN UINTN Length\r | |
85 | )\r | |
86 | {\r | |
87 | UINTN Index;\r | |
88 | for (Index = 0; Index < Length; Index++) {\r | |
da7c529c | 89 | Print (L"%02x ", Data[Index]);\r |
22441982 | 90 | }\r |
a3bcde70 HT |
91 | }\r |
92 | \r | |
93 | /**\r | |
94 | Private function called to print EFI_IP_ADDRESS_INFO content.\r | |
95 | \r | |
96 | @param[in] AddressInfo The pointer to the EFI_IP_ADDRESS_INFO structure.\r | |
97 | **/\r | |
98 | VOID\r | |
99 | DumpAddressInfo (\r | |
100 | IN EFI_IP_ADDRESS_INFO *AddressInfo\r | |
101 | )\r | |
102 | {\r | |
103 | if (IP_VERSION_4 == GetVerFromAddrInfo (AddressInfo)) {\r | |
104 | Print (\r | |
105 | L"%d.%d.%d.%d",\r | |
106 | (UINTN) AddressInfo->Address.v4.Addr[0],\r | |
107 | (UINTN) AddressInfo->Address.v4.Addr[1],\r | |
108 | (UINTN) AddressInfo->Address.v4.Addr[2],\r | |
109 | (UINTN) AddressInfo->Address.v4.Addr[3]\r | |
110 | );\r | |
111 | if (AddressInfo->PrefixLength != 32) {\r | |
112 | Print (L"/%d", (UINTN) AddressInfo->PrefixLength);\r | |
113 | }\r | |
114 | }\r | |
115 | \r | |
116 | if (IP_VERSION_6 == GetVerFromAddrInfo (AddressInfo)) {\r | |
117 | Print (\r | |
118 | L"%x:%x:%x:%x:%x:%x:%x:%x",\r | |
119 | (((UINT16) AddressInfo->Address.v6.Addr[0]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[1]),\r | |
120 | (((UINT16) AddressInfo->Address.v6.Addr[2]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[3]),\r | |
121 | (((UINT16) AddressInfo->Address.v6.Addr[4]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[5]),\r | |
122 | (((UINT16) AddressInfo->Address.v6.Addr[6]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[7]),\r | |
123 | (((UINT16) AddressInfo->Address.v6.Addr[8]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[9]),\r | |
124 | (((UINT16) AddressInfo->Address.v6.Addr[10]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[11]),\r | |
125 | (((UINT16) AddressInfo->Address.v6.Addr[12]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[13]),\r | |
126 | (((UINT16) AddressInfo->Address.v6.Addr[14]) << 8) | ((UINT16) AddressInfo->Address.v6.Addr[15])\r | |
127 | );\r | |
128 | if (AddressInfo->PrefixLength != 128) {\r | |
129 | Print (L"/%d", AddressInfo->PrefixLength);\r | |
130 | }\r | |
131 | }\r | |
132 | }\r | |
133 | \r | |
134 | /**\r | |
135 | Private function called to print EFI_IP_ADDRESS content.\r | |
136 | \r | |
137 | @param[in] IpAddress The pointer to the EFI_IP_ADDRESS structure.\r | |
138 | **/\r | |
139 | VOID\r | |
140 | DumpIpAddress (\r | |
141 | IN EFI_IP_ADDRESS *IpAddress\r | |
142 | )\r | |
143 | {\r | |
144 | if (IP_VERSION_4 == GetVerFromIpAddr (IpAddress)) {\r | |
145 | Print (\r | |
146 | L"%d.%d.%d.%d",\r | |
147 | (UINTN) IpAddress->v4.Addr[0],\r | |
148 | (UINTN) IpAddress->v4.Addr[1],\r | |
149 | (UINTN) IpAddress->v4.Addr[2],\r | |
150 | (UINTN) IpAddress->v4.Addr[3]\r | |
151 | );\r | |
152 | }\r | |
153 | \r | |
154 | if (IP_VERSION_6 == GetVerFromIpAddr (IpAddress)) {\r | |
155 | Print (\r | |
156 | L"%x:%x:%x:%x:%x:%x:%x:%x",\r | |
157 | (((UINT16) IpAddress->v6.Addr[0]) << 8) | ((UINT16) IpAddress->v6.Addr[1]),\r | |
158 | (((UINT16) IpAddress->v6.Addr[2]) << 8) | ((UINT16) IpAddress->v6.Addr[3]),\r | |
159 | (((UINT16) IpAddress->v6.Addr[4]) << 8) | ((UINT16) IpAddress->v6.Addr[5]),\r | |
160 | (((UINT16) IpAddress->v6.Addr[6]) << 8) | ((UINT16) IpAddress->v6.Addr[7]),\r | |
161 | (((UINT16) IpAddress->v6.Addr[8]) << 8) | ((UINT16) IpAddress->v6.Addr[9]),\r | |
162 | (((UINT16) IpAddress->v6.Addr[10]) << 8) | ((UINT16) IpAddress->v6.Addr[11]),\r | |
163 | (((UINT16) IpAddress->v6.Addr[12]) << 8) | ((UINT16) IpAddress->v6.Addr[13]),\r | |
164 | (((UINT16) IpAddress->v6.Addr[14]) << 8) | ((UINT16) IpAddress->v6.Addr[15])\r | |
165 | );\r | |
166 | }\r | |
167 | \r | |
168 | }\r | |
169 | \r | |
170 | /**\r | |
171 | Private function called to print EFI_IPSEC_SPD_SELECTOR content.\r | |
172 | \r | |
173 | @param[in] Selector The pointer to the EFI_IPSEC_SPD_SELECTOR structure.\r | |
174 | **/\r | |
175 | VOID\r | |
176 | DumpSpdSelector (\r | |
177 | IN EFI_IPSEC_SPD_SELECTOR *Selector\r | |
178 | )\r | |
179 | {\r | |
180 | UINT32 Index;\r | |
181 | CHAR16 *Str;\r | |
182 | \r | |
183 | for (Index = 0; Index < Selector->LocalAddressCount; Index++) {\r | |
184 | if (Index > 0) {\r | |
185 | Print (L",");\r | |
186 | }\r | |
187 | \r | |
188 | DumpAddressInfo (&Selector->LocalAddress[Index]);\r | |
189 | }\r | |
190 | \r | |
191 | if (Index == 0) {\r | |
192 | Print (L"localhost");\r | |
193 | }\r | |
194 | \r | |
195 | Print (L" -> ");\r | |
196 | \r | |
197 | for (Index = 0; Index < Selector->RemoteAddressCount; Index++) {\r | |
198 | if (Index > 0) {\r | |
199 | Print (L",");\r | |
200 | }\r | |
201 | \r | |
202 | DumpAddressInfo (&Selector->RemoteAddress[Index]);\r | |
203 | }\r | |
204 | \r | |
205 | Str = MapIntegerToString (Selector->NextLayerProtocol, mMapIpProtocol);\r | |
206 | if (Str != NULL) {\r | |
207 | Print (L" %s", Str);\r | |
208 | } else {\r | |
209 | Print (L" proto:%d", (UINTN) Selector->NextLayerProtocol);\r | |
210 | }\r | |
211 | \r | |
212 | if ((Selector->NextLayerProtocol == EFI_IP4_PROTO_TCP) || (Selector->NextLayerProtocol == EFI_IP4_PROTO_UDP)) {\r | |
213 | Print (L" port:");\r | |
214 | if (Selector->LocalPort != EFI_IPSEC_ANY_PORT) {\r | |
215 | Print (L"%d", Selector->LocalPort);\r | |
216 | if (Selector->LocalPortRange != 0) {\r | |
217 | Print (L"~%d", (UINTN) Selector->LocalPort + Selector->LocalPortRange);\r | |
218 | }\r | |
219 | } else {\r | |
220 | Print (L"any");\r | |
221 | }\r | |
222 | \r | |
223 | Print (L" -> ");\r | |
224 | if (Selector->RemotePort != EFI_IPSEC_ANY_PORT) {\r | |
225 | Print (L"%d", Selector->RemotePort);\r | |
226 | if (Selector->RemotePortRange != 0) {\r | |
227 | Print (L"~%d", (UINTN) Selector->RemotePort + Selector->RemotePortRange);\r | |
228 | }\r | |
229 | } else {\r | |
230 | Print (L"any");\r | |
231 | }\r | |
232 | } else if (Selector->NextLayerProtocol == EFI_IP4_PROTO_ICMP) {\r | |
233 | Print (L" class/code:");\r | |
234 | if (Selector->LocalPort != 0) {\r | |
235 | Print (L"%d", (UINTN) (UINT8) Selector->LocalPort);\r | |
236 | } else {\r | |
237 | Print (L"any");\r | |
238 | }\r | |
239 | \r | |
240 | Print (L"/");\r | |
241 | if (Selector->RemotePort != 0) {\r | |
242 | Print (L"%d", (UINTN) (UINT8) Selector->RemotePort);\r | |
243 | } else {\r | |
244 | Print (L"any");\r | |
245 | }\r | |
246 | }\r | |
247 | }\r | |
248 | \r | |
249 | /**\r | |
250 | Print EFI_IPSEC_SPD_SELECTOR and EFI_IPSEC_SPD_DATA content.\r | |
251 | \r | |
252 | @param[in] Selector The pointer to the EFI_IPSEC_SPD_SELECTOR structure.\r | |
253 | @param[in] Data The pointer to the EFI_IPSEC_SPD_DATA structure.\r | |
254 | @param[in] EntryIndex The pointer to the Index in SPD Database.\r | |
255 | \r | |
256 | @retval EFI_SUCCESS Dump SPD information successfully.\r | |
257 | **/\r | |
258 | EFI_STATUS\r | |
259 | DumpSpdEntry (\r | |
260 | IN EFI_IPSEC_SPD_SELECTOR *Selector,\r | |
261 | IN EFI_IPSEC_SPD_DATA *Data,\r | |
262 | IN UINTN *EntryIndex\r | |
263 | )\r | |
264 | {\r | |
265 | BOOLEAN HasPre;\r | |
266 | CHAR16 DataName[128];\r | |
267 | CHAR16 *String1;\r | |
268 | CHAR16 *String2;\r | |
269 | CHAR16 *String3;\r | |
270 | UINT8 Index;\r | |
271 | \r | |
272 | Print (L"%d.", (*EntryIndex)++);\r | |
273 | \r | |
274 | //\r | |
275 | // xxx.xxx.xxx.xxx/yy -> xxx.xxx.xxx.xx/yy proto:23 port:100~300 -> 300~400\r | |
276 | // Protect PF:0x34323423 Name:First Entry\r | |
277 | // ext-sequence sequence-overflow fragcheck life:[B0,S1024,H3600]\r | |
278 | // ESP algo1 algo2 Tunnel [xxx.xxx.xxx.xxx xxx.xxx.xxx.xxx set]\r | |
279 | //\r | |
280 | \r | |
281 | DumpSpdSelector (Selector);\r | |
282 | Print (L"\n ");\r | |
283 | \r | |
284 | Print (L"%s ", MapIntegerToString (Data->Action, mMapIpSecAction));\r | |
285 | Print (L"PF:%08x ", Data->PackageFlag);\r | |
286 | \r | |
287 | Index = 0;\r | |
288 | while (Data->Name[Index] != 0) {\r | |
289 | DataName[Index] = (CHAR16) Data->Name[Index];\r | |
290 | Index++;\r | |
291 | ASSERT (Index < 128);\r | |
292 | }\r | |
293 | DataName[Index] = L'\0';\r | |
294 | \r | |
295 | Print (L"Name:%s", DataName);\r | |
296 | \r | |
297 | if (Data->Action == EfiIPsecActionProtect) {\r | |
298 | Print (L"\n ");\r | |
299 | if (Data->ProcessingPolicy->ExtSeqNum) {\r | |
300 | Print (L"ext-sequence ");\r | |
301 | }\r | |
302 | \r | |
303 | if (Data->ProcessingPolicy->SeqOverflow) {\r | |
304 | Print (L"sequence-overflow ");\r | |
305 | }\r | |
306 | \r | |
307 | if (Data->ProcessingPolicy->FragCheck) {\r | |
308 | Print (L"fragment-check ");\r | |
309 | }\r | |
310 | \r | |
311 | HasPre = FALSE;\r | |
312 | if (Data->ProcessingPolicy->SaLifetime.ByteCount != 0) {\r | |
313 | Print (HasPre ? L"," : L"life:[");\r | |
314 | Print (L"%lxB", Data->ProcessingPolicy->SaLifetime.ByteCount);\r | |
315 | HasPre = TRUE;\r | |
316 | }\r | |
317 | \r | |
318 | if (Data->ProcessingPolicy->SaLifetime.SoftLifetime != 0) {\r | |
319 | Print (HasPre ? L"," : L"life:[");\r | |
320 | Print (L"%lxs", Data->ProcessingPolicy->SaLifetime.SoftLifetime);\r | |
321 | HasPre = TRUE;\r | |
322 | }\r | |
323 | \r | |
324 | if (Data->ProcessingPolicy->SaLifetime.HardLifetime != 0) {\r | |
325 | Print (HasPre ? L"," : L"life:[");\r | |
326 | Print (L"%lxS", Data->ProcessingPolicy->SaLifetime.HardLifetime);\r | |
327 | HasPre = TRUE;\r | |
328 | }\r | |
329 | \r | |
330 | if (HasPre) {\r | |
331 | Print (L"]");\r | |
332 | }\r | |
333 | \r | |
334 | if (HasPre || Data->ProcessingPolicy->ExtSeqNum ||\r | |
335 | Data->ProcessingPolicy->SeqOverflow || Data->ProcessingPolicy->FragCheck) {\r | |
336 | Print (L"\n ");\r | |
337 | }\r | |
338 | \r | |
339 | String1 = MapIntegerToString (Data->ProcessingPolicy->Proto, mMapIpSecProtocol);\r | |
340 | String2 = MapIntegerToString (Data->ProcessingPolicy->AuthAlgoId, mMapAuthAlgo);\r | |
341 | String3 = MapIntegerToString (Data->ProcessingPolicy->EncAlgoId, mMapEncAlgo);\r | |
342 | Print (\r | |
343 | L"%s Auth:%s Encrypt:%s ",\r | |
344 | String1,\r | |
345 | String2,\r | |
346 | String3\r | |
347 | );\r | |
348 | \r | |
349 | Print (L"%s ", MapIntegerToString (Data->ProcessingPolicy->Mode, mMapIpSecMode));\r | |
350 | if (Data->ProcessingPolicy->Mode == EfiIPsecTunnel) {\r | |
351 | Print (L"[");\r | |
352 | DumpIpAddress (&Data->ProcessingPolicy->TunnelOption->LocalTunnelAddress);\r | |
353 | Print (L" -> ");\r | |
354 | DumpIpAddress (&Data->ProcessingPolicy->TunnelOption->RemoteTunnelAddress);\r | |
355 | Print (L" %s]", MapIntegerToString (Data->ProcessingPolicy->TunnelOption->DF, mMapDfOption));\r | |
356 | }\r | |
357 | }\r | |
358 | \r | |
359 | Print (L"\n");\r | |
360 | \r | |
361 | return EFI_SUCCESS;\r | |
362 | }\r | |
363 | \r | |
364 | /**\r | |
64b2d0e5 | 365 | Print EFI_IPSEC_SA_ID and EFI_IPSEC_SA_DATA2 content.\r |
a3bcde70 HT |
366 | \r |
367 | @param[in] SaId The pointer to the EFI_IPSEC_SA_ID structure.\r | |
64b2d0e5 | 368 | @param[in] Data The pointer to the EFI_IPSEC_SA_DATA2 structure.\r |
a3bcde70 HT |
369 | @param[in] EntryIndex The pointer to the Index in the SAD Database.\r |
370 | \r | |
371 | @retval EFI_SUCCESS Dump SAD information successfully.\r | |
372 | **/\r | |
373 | EFI_STATUS\r | |
374 | DumpSadEntry (\r | |
375 | IN EFI_IPSEC_SA_ID *SaId,\r | |
64b2d0e5 | 376 | IN EFI_IPSEC_SA_DATA2 *Data,\r |
a3bcde70 HT |
377 | IN UINTN *EntryIndex\r |
378 | )\r | |
379 | {\r | |
380 | BOOLEAN HasPre;\r | |
64b2d0e5 | 381 | CHAR16 *AuthAlgoStr;\r |
382 | CHAR16 *EncAlgoStr;\r | |
64b2d0e5 | 383 | \r |
384 | AuthAlgoStr = NULL;\r | |
385 | EncAlgoStr = NULL;\r | |
a3bcde70 HT |
386 | \r |
387 | //\r | |
388 | // SPI:1234 ESP Destination:xxx.xxx.xxx.xxx\r | |
389 | // Mode:Transport SeqNum:134 AntiReplayWin:64 life:[0B,1023s,3400S] PathMTU:34\r | |
390 | // Auth:xxxx/password Encrypt:yyyy/password\r | |
391 | // xxx.xxx.xxx.xxx/yy -> xxx.xxx.xxx.xx/yy proto:23 port:100~300 -> 300~400\r | |
392 | //\r | |
393 | \r | |
394 | Print (L"%d.", (*EntryIndex)++);\r | |
395 | Print (L"0x%x %s ", (UINTN) SaId->Spi, MapIntegerToString (SaId->Proto, mMapIpSecProtocol));\r | |
64b2d0e5 | 396 | if (Data->Mode == EfiIPsecTunnel) {\r |
397 | Print (L"TunnelSourceAddress:");\r | |
398 | DumpIpAddress (&Data->TunnelSourceAddress);\r | |
399 | Print (L"\n");\r | |
22441982 | 400 | Print (L" TunnelDestination:");\r |
64b2d0e5 | 401 | DumpIpAddress (&Data->TunnelDestinationAddress);\r |
402 | Print (L"\n");\r | |
403 | }\r | |
a3bcde70 HT |
404 | \r |
405 | Print (\r | |
406 | L" Mode:%s SeqNum:%lx AntiReplayWin:%d ",\r | |
407 | MapIntegerToString (Data->Mode, mMapIpSecMode),\r | |
408 | Data->SNCount,\r | |
409 | (UINTN) Data->AntiReplayWindows\r | |
410 | );\r | |
411 | \r | |
412 | HasPre = FALSE;\r | |
413 | if (Data->SaLifetime.ByteCount != 0) {\r | |
414 | Print (HasPre ? L"," : L"life:[");\r | |
415 | Print (L"%lxB", Data->SaLifetime.ByteCount);\r | |
416 | HasPre = TRUE;\r | |
417 | }\r | |
418 | \r | |
419 | if (Data->SaLifetime.SoftLifetime != 0) {\r | |
420 | Print (HasPre ? L"," : L"life:[");\r | |
421 | Print (L"%lxs", Data->SaLifetime.SoftLifetime);\r | |
422 | HasPre = TRUE;\r | |
423 | }\r | |
424 | \r | |
425 | if (Data->SaLifetime.HardLifetime != 0) {\r | |
426 | Print (HasPre ? L"," : L"life:[");\r | |
427 | Print (L"%lxS", Data->SaLifetime.HardLifetime);\r | |
428 | HasPre = TRUE;\r | |
429 | }\r | |
430 | \r | |
431 | if (HasPre) {\r | |
432 | Print (L"] ");\r | |
433 | }\r | |
434 | \r | |
435 | Print (L"PathMTU:%d\n", (UINTN) Data->PathMTU);\r | |
436 | \r | |
437 | if (SaId->Proto == EfiIPsecAH) {\r | |
438 | Print (\r | |
439 | L" Auth:%s/%s\n",\r | |
440 | MapIntegerToString (Data->AlgoInfo.AhAlgoInfo.AuthAlgoId, mMapAuthAlgo),\r | |
441 | Data->AlgoInfo.AhAlgoInfo.AuthKey\r | |
442 | );\r | |
443 | } else {\r | |
64b2d0e5 | 444 | AuthAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo);\r |
445 | EncAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo);\r | |
446 | \r | |
22441982 | 447 | if (Data->ManualSet) {\r |
448 | //\r | |
449 | // if the SAD is set manually the key is a Ascii string in most of time.\r | |
450 | // Print the Key in Ascii string format.\r | |
451 | //\r | |
452 | Print (L" Auth:%s/",AuthAlgoStr);\r | |
453 | DumpAsciiString (\r | |
da7c529c | 454 | Data->AlgoInfo.EspAlgoInfo.AuthKey,\r |
22441982 | 455 | Data->AlgoInfo.EspAlgoInfo.AuthKeyLength\r |
456 | );\r | |
457 | Print (L"\n Encrypt:%s/",EncAlgoStr);\r | |
458 | DumpAsciiString (\r | |
da7c529c | 459 | Data->AlgoInfo.EspAlgoInfo.EncKey,\r |
22441982 | 460 | Data->AlgoInfo.EspAlgoInfo.EncKeyLength\r |
461 | );\r | |
462 | } else {\r | |
463 | //\r | |
464 | // if the SAD is created by IKE, the key is a set of hex value in buffer.\r | |
465 | // Print the Key in Hex format.\r | |
466 | //\r | |
467 | Print (L" Auth:%s/",AuthAlgoStr);\r | |
468 | DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.AuthKey), Data->AlgoInfo.EspAlgoInfo.AuthKeyLength);\r | |
da7c529c | 469 | \r |
22441982 | 470 | Print (L"\n Encrypt:%s/",EncAlgoStr);\r |
da7c529c | 471 | DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.EncKey), Data->AlgoInfo.EspAlgoInfo.EncKeyLength);\r |
22441982 | 472 | }\r |
a3bcde70 | 473 | }\r |
da7c529c | 474 | Print (L"\n");\r |
a3bcde70 | 475 | if (Data->SpdSelector != NULL) {\r |
da7c529c | 476 | Print (L" ");\r |
a3bcde70 HT |
477 | DumpSpdSelector (Data->SpdSelector);\r |
478 | Print (L"\n");\r | |
479 | }\r | |
480 | \r | |
481 | return EFI_SUCCESS;\r | |
482 | }\r | |
483 | \r | |
484 | /**\r | |
485 | Print EFI_IPSEC_PAD_ID and EFI_IPSEC_PAD_DATA content.\r | |
486 | \r | |
487 | @param[in] PadId The pointer to the EFI_IPSEC_PAD_ID structure.\r | |
488 | @param[in] Data The pointer to the EFI_IPSEC_PAD_DATA structure.\r | |
489 | @param[in] EntryIndex The pointer to the Index in the PAD Database.\r | |
490 | \r | |
491 | @retval EFI_SUCCESS Dump PAD information successfully.\r | |
492 | **/\r | |
493 | EFI_STATUS\r | |
494 | DumpPadEntry (\r | |
495 | IN EFI_IPSEC_PAD_ID *PadId,\r | |
496 | IN EFI_IPSEC_PAD_DATA *Data,\r | |
497 | IN UINTN *EntryIndex\r | |
498 | )\r | |
499 | {\r | |
500 | CHAR16 *String1;\r | |
501 | CHAR16 *String2;\r | |
502 | \r | |
503 | //\r | |
504 | // ADDR:10.23.17.34/15\r | |
505 | // IDEv1 PreSharedSecret IKE-ID\r | |
506 | // password\r | |
507 | //\r | |
508 | \r | |
509 | Print (L"%d.", (*EntryIndex)++);\r | |
510 | \r | |
511 | if (PadId->PeerIdValid) {\r | |
512 | Print (L"ID:%s", PadId->Id.PeerId);\r | |
513 | } else {\r | |
514 | Print (L"ADDR:");\r | |
515 | DumpAddressInfo (&PadId->Id.IpAddress);\r | |
516 | }\r | |
517 | \r | |
518 | Print (L"\n");\r | |
519 | \r | |
520 | String1 = MapIntegerToString (Data->AuthProtocol, mMapAuthProto);\r | |
521 | String2 = MapIntegerToString (Data->AuthMethod, mMapAuthMethod);\r | |
522 | Print (\r | |
523 | L" %s %s",\r | |
524 | String1,\r | |
525 | String2\r | |
526 | );\r | |
527 | \r | |
528 | if (Data->IkeIdFlag) {\r | |
529 | Print (L"IKE-ID");\r | |
530 | }\r | |
531 | \r | |
532 | Print (L"\n");\r | |
533 | \r | |
534 | if (Data->AuthData != NULL) {\r | |
535 | DumpAsciiString (Data->AuthData, Data->AuthDataSize);\r | |
536 | Print (L"\n");\r | |
537 | }\r | |
538 | \r | |
539 | if (Data->RevocationData != NULL) {\r | |
540 | Print (L" %s\n", Data->RevocationData);\r | |
541 | }\r | |
542 | \r | |
543 | return EFI_SUCCESS;\r | |
544 | \r | |
545 | }\r | |
546 | \r | |
547 | VISIT_POLICY_ENTRY mDumpPolicyEntry[] = {\r | |
548 | (VISIT_POLICY_ENTRY) DumpSpdEntry,\r | |
549 | (VISIT_POLICY_ENTRY) DumpSadEntry,\r | |
550 | (VISIT_POLICY_ENTRY) DumpPadEntry\r | |
551 | };\r | |
552 | \r | |
553 | /**\r | |
554 | Print all entry information in the database according to datatype.\r | |
555 | \r | |
556 | @param[in] DataType The value of EFI_IPSEC_CONFIG_DATA_TYPE.\r | |
557 | @param[in] ParamPackage The pointer to the ParamPackage list.\r | |
558 | \r | |
559 | @retval EFI_SUCCESS Dump all information successfully.\r | |
560 | @retval Others Some mistaken case.\r | |
561 | **/\r | |
562 | EFI_STATUS\r | |
563 | ListPolicyEntry (\r | |
564 | IN EFI_IPSEC_CONFIG_DATA_TYPE DataType,\r | |
565 | IN LIST_ENTRY *ParamPackage\r | |
566 | )\r | |
567 | {\r | |
568 | UINTN EntryIndex;\r | |
569 | \r | |
570 | EntryIndex = 0;\r | |
571 | return ForeachPolicyEntry (DataType, mDumpPolicyEntry[DataType], &EntryIndex);\r | |
572 | }\r | |
573 | \r |