/** @file\r
The implementation of dump policy entry function in IpSecConfig application.\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
)\r
{\r
UINTN Index;\r
+ Print (L"\"");\r
for (Index = 0; Index < Length; Index++) {\r
Print (L"%c", (CHAR16) Str[Index]);\r
}\r
+ Print (L"\"");\r
+}\r
+\r
+/**\r
+ Private function called to print a buffer in Hex format.\r
+\r
+ @param[in] Data The pointer to the buffer.\r
+ @param[in] Length The size of the buffer.\r
+\r
+**/\r
+VOID\r
+DumpBuf (\r
+ IN UINT8 *Data,\r
+ IN UINTN Length\r
+ )\r
+{\r
+ UINTN Index;\r
+ for (Index = 0; Index < Length; Index++) {\r
+ Print (L"%02x ", Data[Index]); \r
+ }\r
}\r
\r
/**\r
}\r
\r
/**\r
- Print EFI_IPSEC_SA_ID and EFI_IPSEC_SA_DATA content.\r
+ Print EFI_IPSEC_SA_ID and EFI_IPSEC_SA_DATA2 content.\r
\r
@param[in] SaId The pointer to the EFI_IPSEC_SA_ID structure.\r
- @param[in] Data The pointer to the EFI_IPSEC_SA_DATA structure.\r
+ @param[in] Data The pointer to the EFI_IPSEC_SA_DATA2 structure.\r
@param[in] EntryIndex The pointer to the Index in the SAD Database.\r
\r
@retval EFI_SUCCESS Dump SAD information successfully.\r
EFI_STATUS\r
DumpSadEntry (\r
IN EFI_IPSEC_SA_ID *SaId,\r
- IN EFI_IPSEC_SA_DATA *Data,\r
+ IN EFI_IPSEC_SA_DATA2 *Data,\r
IN UINTN *EntryIndex\r
)\r
{\r
BOOLEAN HasPre;\r
- CHAR16 *String1;\r
- CHAR16 *String2;\r
+ CHAR16 *AuthAlgoStr;\r
+ CHAR16 *EncAlgoStr;\r
+\r
+ AuthAlgoStr = NULL;\r
+ EncAlgoStr = NULL;\r
\r
//\r
// SPI:1234 ESP Destination:xxx.xxx.xxx.xxx\r
\r
Print (L"%d.", (*EntryIndex)++);\r
Print (L"0x%x %s ", (UINTN) SaId->Spi, MapIntegerToString (SaId->Proto, mMapIpSecProtocol));\r
- Print (L"Destination:");\r
- DumpIpAddress (&SaId->DestAddress);\r
- Print (L"\n");\r
+ if (Data->Mode == EfiIPsecTunnel) {\r
+ Print (L"TunnelSourceAddress:");\r
+ DumpIpAddress (&Data->TunnelSourceAddress);\r
+ Print (L"\n");\r
+ Print (L" TunnelDestination:");\r
+ DumpIpAddress (&Data->TunnelDestinationAddress);\r
+ Print (L"\n");\r
+ }\r
\r
Print (\r
L" Mode:%s SeqNum:%lx AntiReplayWin:%d ",\r
Data->AlgoInfo.AhAlgoInfo.AuthKey\r
);\r
} else {\r
- String1 = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo);\r
- String2 = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo);\r
- Print (\r
- L" Auth:%s/%s Encrypt:%s/%s\n",\r
- String1,\r
- Data->AlgoInfo.EspAlgoInfo.AuthKey,\r
- String2,\r
- Data->AlgoInfo.EspAlgoInfo.EncKey\r
- );\r
+ AuthAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.AuthAlgoId, mMapAuthAlgo);\r
+ EncAlgoStr = MapIntegerToString (Data->AlgoInfo.EspAlgoInfo.EncAlgoId, mMapEncAlgo);\r
+\r
+ if (Data->ManualSet) {\r
+ //\r
+ // if the SAD is set manually the key is a Ascii string in most of time.\r
+ // Print the Key in Ascii string format.\r
+ //\r
+ Print (L" Auth:%s/",AuthAlgoStr);\r
+ DumpAsciiString (\r
+ Data->AlgoInfo.EspAlgoInfo.AuthKey, \r
+ Data->AlgoInfo.EspAlgoInfo.AuthKeyLength\r
+ );\r
+ Print (L"\n Encrypt:%s/",EncAlgoStr);\r
+ DumpAsciiString (\r
+ Data->AlgoInfo.EspAlgoInfo.EncKey, \r
+ Data->AlgoInfo.EspAlgoInfo.EncKeyLength\r
+ );\r
+ } else {\r
+ //\r
+ // if the SAD is created by IKE, the key is a set of hex value in buffer.\r
+ // Print the Key in Hex format.\r
+ //\r
+ Print (L" Auth:%s/",AuthAlgoStr);\r
+ DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.AuthKey), Data->AlgoInfo.EspAlgoInfo.AuthKeyLength);\r
+ \r
+ Print (L"\n Encrypt:%s/",EncAlgoStr);\r
+ DumpBuf ((UINT8 *)(Data->AlgoInfo.EspAlgoInfo.EncKey), Data->AlgoInfo.EspAlgoInfo.EncKeyLength); \r
+ }\r
}\r
-\r
if (Data->SpdSelector != NULL) {\r
- Print (L" ");\r
+ Print (L"\n ");\r
DumpSpdSelector (Data->SpdSelector);\r
Print (L"\n");\r
}\r