Discussion:
[edk2] [Patch] NetworkPkg: Remove IpSecDxe and Ip4Config Protocol dependency.
jiaxinwu
2015-07-05 15:06:39 UTC
Permalink
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: jiaxinwu <***@intel.com>
---
NetworkPkg/IpSecDxe/IkeCommon.h | 4 ++--
NetworkPkg/IpSecDxe/IkeService.c | 51 ++++++++++++++++++++++++++--------------
NetworkPkg/IpSecDxe/IpSecDxe.inf | 4 ++--
3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/IkeCommon.h b/NetworkPkg/IpSecDxe/IkeCommon.h
index 6832642..8be54ea 100644
--- a/NetworkPkg/IpSecDxe/IkeCommon.h
+++ b/NetworkPkg/IpSecDxe/IkeCommon.h
@@ -1,9 +1,9 @@
/** @file
Common operation of the IKE.

- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -16,11 +16,11 @@
#ifndef _IKE_COMMON_H_
#define _IKE_COMMON_H_

#include <Protocol/Udp4.h>
#include <Protocol/Udp6.h>
-#include <Protocol/Ip4Config.h>
+#include <Protocol/Ip4Config2.h>

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
diff --git a/NetworkPkg/IpSecDxe/IkeService.c b/NetworkPkg/IpSecDxe/IkeService.c
index 8e2c794..6594963 100644
--- a/NetworkPkg/IpSecDxe/IkeService.c
+++ b/NetworkPkg/IpSecDxe/IkeService.c
@@ -1,9 +1,9 @@
/** @file
Provide IPsec Key Exchange (IKE) service general interfaces.

- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -210,19 +210,19 @@ EFI_STATUS
IkeOpenOutputUdp (
IN IKE_UDP_SERVICE *UdpService,
IN EFI_IP_ADDRESS *RemoteIp
)
{
- EFI_STATUS Status;
- EFI_IP4_CONFIG_PROTOCOL *Ip4Cfg;
- EFI_IP4_IPCONFIG_DATA *Ip4CfgData;
- UINTN BufSize;
- EFI_IP6_MODE_DATA Ip6ModeData;
- EFI_UDP6_PROTOCOL *Udp6;
+ EFI_STATUS Status;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
+ EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
+ UINTN BufSize;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ EFI_UDP6_PROTOCOL *Udp6;

Status = EFI_SUCCESS;
- Ip4CfgData = NULL;
+ IfInfo = NULL;
BufSize = 0;

//
// Check whether the input and output udp io are both configured.
//
@@ -234,39 +234,56 @@ IkeOpenOutputUdp (
//
// Handle ip4config protocol to get local default address.
//
Status = gBS->HandleProtocol (
UdpService->NicHandle,
- &gEfiIp4ConfigProtocolGuid,
- (VOID **) &Ip4Cfg
+ &gEfiIp4Config2ProtocolGuid,
+ (VOID **) &Ip4Cfg2
);

if (EFI_ERROR (Status)) {
goto ON_EXIT;
}

- Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, NULL);
+ //
+ // Get the interface information size.
+ //
+ Status = Ip4Cfg2->GetData (
+ Ip4Cfg2,
+ Ip4Config2DataTypeInterfaceInfo,
+ &BufSize,
+ NULL
+ );

if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
goto ON_EXIT;
}

- Ip4CfgData = AllocateZeroPool (BufSize);
+ IfInfo = AllocateZeroPool (BufSize);

- if (Ip4CfgData == NULL) {
+ if (IfInfo == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}

- Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, Ip4CfgData);
+ //
+ // Get the interface info.
+ //
+ Status = Ip4Cfg2->GetData (
+ Ip4Cfg2,
+ Ip4Config2DataTypeInterfaceInfo,
+ &BufSize,
+ IfInfo
+ );
+
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}

CopyMem (
&UdpService->DefaultAddress.v4,
- &Ip4CfgData->StationAddress,
+ &IfInfo->StationAddress,
sizeof (EFI_IPv4_ADDRESS)
);

//
// Create udp4 io for output with local default address.
@@ -329,12 +346,12 @@ IkeOpenOutputUdp (
}

UdpService->IsConfigured = TRUE;

ON_EXIT:
- if (Ip4CfgData != NULL) {
- FreePool (Ip4CfgData);
+ if (IfInfo != NULL) {
+ FreePool (IfInfo);
}

return Status;
}

diff --git a/NetworkPkg/IpSecDxe/IpSecDxe.inf b/NetworkPkg/IpSecDxe/IpSecDxe.inf
index c587c8c..583305b 100644
--- a/NetworkPkg/IpSecDxe/IpSecDxe.inf
+++ b/NetworkPkg/IpSecDxe/IpSecDxe.inf
@@ -4,11 +4,11 @@
# This driver provides EFI IPsec2 Protocol which is used to abstract the ability
# to deal with the individual packets sent and received by the host and provide
# packet-level security for IP datagram. It provides the IP packet protection via
# ESP and it supports IKEv2 for key negotiation.
#
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
@@ -87,11 +87,11 @@
UdpIoLib
NetLib
PcdLib

[Protocols]
- gEfiIp4ConfigProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp4ProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp6ProtocolGuid ## SOMETIMES_CONSUMES
gEfiIpSecConfigProtocolGuid ## PRODUCES
--
1.9.5.msysgit.1
Ye, Ting
2015-07-06 02:21:11 UTC
Permalink
Looks good.
Reviewed-by: Ye Ting <***@intel.com>


-----Original Message-----
From: jiaxinwu [mailto:***@intel.com]
Sent: Sunday, July 05, 2015 11:07 PM
To: edk2-***@lists.sourceforge.net
Subject: [edk2] [Patch] NetworkPkg: Remove IpSecDxe and Ip4Config Protocol dependency.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: jiaxinwu <***@intel.com>
---
NetworkPkg/IpSecDxe/IkeCommon.h | 4 ++--
NetworkPkg/IpSecDxe/IkeService.c | 51 ++++++++++++++++++++++++++--------------
NetworkPkg/IpSecDxe/IpSecDxe.inf | 4 ++--
3 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/NetworkPkg/IpSecDxe/IkeCommon.h b/NetworkPkg/IpSecDxe/IkeCommon.h
index 6832642..8be54ea 100644
--- a/NetworkPkg/IpSecDxe/IkeCommon.h
+++ b/NetworkPkg/IpSecDxe/IkeCommon.h
@@ -1,9 +1,9 @@
/** @file
Common operation of the IKE.

- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -16,11 +16,11 @@
#ifndef _IKE_COMMON_H_
#define _IKE_COMMON_H_

#include <Protocol/Udp4.h>
#include <Protocol/Udp6.h>
-#include <Protocol/Ip4Config.h>
+#include <Protocol/Ip4Config2.h>

#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
diff --git a/NetworkPkg/IpSecDxe/IkeService.c b/NetworkPkg/IpSecDxe/IkeService.c
index 8e2c794..6594963 100644
--- a/NetworkPkg/IpSecDxe/IkeService.c
+++ b/NetworkPkg/IpSecDxe/IkeService.c
@@ -1,9 +1,9 @@
/** @file
Provide IPsec Key Exchange (IKE) service general interfaces.

- Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>

This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
@@ -210,19 +210,19 @@ EFI_STATUS
IkeOpenOutputUdp (
IN IKE_UDP_SERVICE *UdpService,
IN EFI_IP_ADDRESS *RemoteIp
)
{
- EFI_STATUS Status;
- EFI_IP4_CONFIG_PROTOCOL *Ip4Cfg;
- EFI_IP4_IPCONFIG_DATA *Ip4CfgData;
- UINTN BufSize;
- EFI_IP6_MODE_DATA Ip6ModeData;
- EFI_UDP6_PROTOCOL *Udp6;
+ EFI_STATUS Status;
+ EFI_IP4_CONFIG2_PROTOCOL *Ip4Cfg2;
+ EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;
+ UINTN BufSize;
+ EFI_IP6_MODE_DATA Ip6ModeData;
+ EFI_UDP6_PROTOCOL *Udp6;

Status = EFI_SUCCESS;
- Ip4CfgData = NULL;
+ IfInfo = NULL;
BufSize = 0;

//
// Check whether the input and output udp io are both configured.
//
@@ -234,39 +234,56 @@ IkeOpenOutputUdp (
//
// Handle ip4config protocol to get local default address.
//
Status = gBS->HandleProtocol (
UdpService->NicHandle,
- &gEfiIp4ConfigProtocolGuid,
- (VOID **) &Ip4Cfg
+ &gEfiIp4Config2ProtocolGuid,
+ (VOID **) &Ip4Cfg2
);

if (EFI_ERROR (Status)) {
goto ON_EXIT;
}

- Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, NULL);
+ //
+ // Get the interface information size.
+ //
+ Status = Ip4Cfg2->GetData (
+ Ip4Cfg2,
+ Ip4Config2DataTypeInterfaceInfo,
+ &BufSize,
+ NULL
+ );

if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
goto ON_EXIT;
}

- Ip4CfgData = AllocateZeroPool (BufSize);
+ IfInfo = AllocateZeroPool (BufSize);

- if (Ip4CfgData == NULL) {
+ if (IfInfo == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}

- Status = Ip4Cfg->GetData (Ip4Cfg, &BufSize, Ip4CfgData);
+ //
+ // Get the interface info.
+ //
+ Status = Ip4Cfg2->GetData (
+ Ip4Cfg2,
+ Ip4Config2DataTypeInterfaceInfo,
+ &BufSize,
+ IfInfo
+ );
+
if (EFI_ERROR (Status)) {
goto ON_EXIT;
}

CopyMem (
&UdpService->DefaultAddress.v4,
- &Ip4CfgData->StationAddress,
+ &IfInfo->StationAddress,
sizeof (EFI_IPv4_ADDRESS)
);

//
// Create udp4 io for output with local default address.
@@ -329,12 +346,12 @@ IkeOpenOutputUdp (
}

UdpService->IsConfigured = TRUE;

ON_EXIT:
- if (Ip4CfgData != NULL) {
- FreePool (Ip4CfgData);
+ if (IfInfo != NULL) {
+ FreePool (IfInfo);
}

return Status;
}

diff --git a/NetworkPkg/IpSecDxe/IpSecDxe.inf b/NetworkPkg/IpSecDxe/IpSecDxe.inf
index c587c8c..583305b 100644
--- a/NetworkPkg/IpSecDxe/IpSecDxe.inf
+++ b/NetworkPkg/IpSecDxe/IpSecDxe.inf
@@ -4,11 +4,11 @@
# This driver provides EFI IPsec2 Protocol which is used to abstract the ability
# to deal with the individual packets sent and received by the host and provide
# packet-level security for IP datagram. It provides the IP packet protection via
# ESP and it supports IKEv2 for key negotiation.
#
-# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
@@ -87,11 +87,11 @@
UdpIoLib
NetLib
PcdLib

[Protocols]
- gEfiIp4ConfigProtocolGuid ## SOMETIMES_CONSUMES
+ gEfiIp4Config2ProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp4ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp4ProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp6ServiceBindingProtocolGuid ## SOMETIMES_CONSUMES
gEfiUdp6ProtocolGuid ## SOMETIMES_CONSUMES
gEfiIpSecConfigProtocolGuid ## PRODUCES
--
1.9.5.msysgit.1


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
edk2-devel mailing list
edk2-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel
Loading...