mirror of https://github.com/acidanthera/audk.git
MdeModulePkg: Did some code enhancement for DxeIpIoLib.
* In DxeIpIo, there are several places use ASSERT() to check input parameters without and descriptions or error handling. This patch fixed this issue. * Fixed some incorrect descriptions in code commence. * Remove unneeded Exit tag in function IpIoOpen and IpIoConfigIp. * Add EFIAPI tag for function IpIoRefreshNeighbor. Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Ye Ting <ting.ye@intel.com> Cc: Fu Siyuan <siyuan.fu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan <fan.wang@intel.com> Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com> Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
This commit is contained in:
parent
0a1bd0a35d
commit
2b2087478c
|
@ -310,6 +310,8 @@ typedef struct _IP_IO_IP_INFO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a new IP_IO instance.
|
Create a new IP_IO instance.
|
||||||
|
|
||||||
|
If IpVersion is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function uses IP4/IP6 service binding protocol in Controller to create
|
This function uses IP4/IP6 service binding protocol in Controller to create
|
||||||
an IP4/IP6 child (aka IP4/IP6 instance).
|
an IP4/IP6 child (aka IP4/IP6 instance).
|
||||||
|
@ -353,6 +355,8 @@ IpIoDestroy (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Stop an IP_IO instance.
|
Stop an IP_IO instance.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function is paired with IpIoOpen(). The IP_IO will be unconfigured, and all
|
This function is paired with IpIoOpen(). The IP_IO will be unconfigured, and all
|
||||||
pending send/receive tokens will be canceled.
|
pending send/receive tokens will be canceled.
|
||||||
|
@ -372,7 +376,9 @@ IpIoStop (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Open an IP_IO instance for use.
|
Open an IP_IO instance for use.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function is called after IpIoCreate(). It is used for configuring the IP
|
This function is called after IpIoCreate(). It is used for configuring the IP
|
||||||
instance and register the callbacks and their context data for sending and
|
instance and register the callbacks and their context data for sending and
|
||||||
receiving IP packets.
|
receiving IP packets.
|
||||||
|
@ -401,7 +407,7 @@ IpIoOpen (
|
||||||
/**
|
/**
|
||||||
Send out an IP packet.
|
Send out an IP packet.
|
||||||
|
|
||||||
This function is called after IpIoOpen(). The data to be sent are wrapped in
|
This function is called after IpIoOpen(). The data to be sent is wrapped in
|
||||||
Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
|
Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
|
||||||
overriden by Sender. Other sending configs, like source address and gateway
|
overriden by Sender. Other sending configs, like source address and gateway
|
||||||
address etc., are specified in OverrideData.
|
address etc., are specified in OverrideData.
|
||||||
|
@ -439,6 +445,9 @@ IpIoSend (
|
||||||
/**
|
/**
|
||||||
Cancel the IP transmit token that wraps this Packet.
|
Cancel the IP transmit token that wraps this Packet.
|
||||||
|
|
||||||
|
If IpIo is NULL, then ASSERT().
|
||||||
|
If Packet is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] IpIo The pointer to the IP_IO instance.
|
@param[in] IpIo The pointer to the IP_IO instance.
|
||||||
@param[in] Packet The pointer to the packet of NET_BUF to cancel.
|
@param[in] Packet The pointer to the packet of NET_BUF to cancel.
|
||||||
|
|
||||||
|
@ -452,6 +461,9 @@ IpIoCancelTxToken (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a new IP instance for sending data.
|
Add a new IP instance for sending data.
|
||||||
|
|
||||||
|
If IpIo is NULL, then ASSERT().
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
The function is used to add the IP_IO to the IP_IO sending list. The caller
|
The function is used to add the IP_IO to the IP_IO sending list. The caller
|
||||||
can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send
|
can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send
|
||||||
|
@ -473,6 +485,8 @@ IpIoAddIp (
|
||||||
Configure the IP instance of this IpInfo and start the receiving if IpConfigData
|
Configure the IP instance of this IpInfo and start the receiving if IpConfigData
|
||||||
is not NULL.
|
is not NULL.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] IpInfo The pointer to the IP_IO_IP_INFO instance.
|
@param[in, out] IpInfo The pointer to the IP_IO_IP_INFO instance.
|
||||||
@param[in, out] IpConfigData The IP4 or IP6 configure data used to configure
|
@param[in, out] IpConfigData The IP4 or IP6 configure data used to configure
|
||||||
the IP instance. If NULL, the IP instance is reset.
|
the IP instance. If NULL, the IP instance is reset.
|
||||||
|
@ -495,6 +509,8 @@ IpIoConfigIp (
|
||||||
/**
|
/**
|
||||||
Destroy an IP instance maintained in IpIo->IpList for
|
Destroy an IP instance maintained in IpIo->IpList for
|
||||||
sending purpose.
|
sending purpose.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function pairs with IpIoAddIp(). The IpInfo is previously created by
|
This function pairs with IpIoAddIp(). The IpInfo is previously created by
|
||||||
IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance
|
IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance
|
||||||
|
@ -586,6 +602,7 @@ IpIoGetIcmpErrStatus (
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
IpIoRefreshNeighbor (
|
IpIoRefreshNeighbor (
|
||||||
IN IP_IO *IpIo,
|
IN IP_IO *IpIo,
|
||||||
IN EFI_IP_ADDRESS *Neighbor,
|
IN EFI_IP_ADDRESS *Neighbor,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
IpIo Library.
|
IpIo Library.
|
||||||
|
|
||||||
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
|
||||||
Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
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
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
@ -634,8 +634,8 @@ IpIoExtFree (
|
||||||
@param[in] Dest Pointer to the destination IP address.
|
@param[in] Dest Pointer to the destination IP address.
|
||||||
@param[in] Override Pointer to the overriden IP_IO data.
|
@param[in] Override Pointer to the overriden IP_IO data.
|
||||||
|
|
||||||
@return Pointer to the data structure created to wrap the packet. If NULL,
|
@return Pointer to the data structure created to wrap the packet. If any error occurs,
|
||||||
@return resource limit occurred.
|
then return NULL.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
IP_IO_SEND_ENTRY *
|
IP_IO_SEND_ENTRY *
|
||||||
|
@ -1075,7 +1075,7 @@ IpIoListenHandlerDpc (
|
||||||
IP4_NET_EQUAL (IpIo->StationIp, EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask) &&
|
IP4_NET_EQUAL (IpIo->StationIp, EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask) &&
|
||||||
!NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask)) {
|
!NetIp4IsUnicast (EFI_NTOHL (((EFI_IP4_RECEIVE_DATA *) RxData)->Header->SourceAddress), IpIo->SubnetMask)) {
|
||||||
//
|
//
|
||||||
// The source address is not zero and it's not a unicast IP address, discard it.
|
// The source address doesn't match StationIp and it's not a unicast IP address, discard it.
|
||||||
//
|
//
|
||||||
goto CleanUp;
|
goto CleanUp;
|
||||||
}
|
}
|
||||||
|
@ -1221,6 +1221,8 @@ IpIoListenHandler (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a new IP_IO instance.
|
Create a new IP_IO instance.
|
||||||
|
|
||||||
|
If IpVersion is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function uses IP4/IP6 service binding protocol in Controller to create
|
This function uses IP4/IP6 service binding protocol in Controller to create
|
||||||
an IP4/IP6 child (aka IP4/IP6 instance).
|
an IP4/IP6 child (aka IP4/IP6 instance).
|
||||||
|
@ -1286,7 +1288,7 @@ IpIoCreate (
|
||||||
Image,
|
Image,
|
||||||
&IpIo->ChildHandle,
|
&IpIo->ChildHandle,
|
||||||
IpVersion,
|
IpVersion,
|
||||||
(VOID **)&(IpIo->Ip)
|
(VOID **) & (IpIo->Ip)
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto ReleaseIpIo;
|
goto ReleaseIpIo;
|
||||||
|
@ -1308,7 +1310,9 @@ ReleaseIpIo:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Open an IP_IO instance for use.
|
Open an IP_IO instance for use.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function is called after IpIoCreate(). It is used for configuring the IP
|
This function is called after IpIoCreate(). It is used for configuring the IP
|
||||||
instance and register the callbacks and their context data for sending and
|
instance and register the callbacks and their context data for sending and
|
||||||
receiving IP packets.
|
receiving IP packets.
|
||||||
|
@ -1419,7 +1423,7 @@ IpIoOpen (
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
IpIo->Ip.Ip4->Configure (IpIo->Ip.Ip4, NULL);
|
IpIo->Ip.Ip4->Configure (IpIo->Ip.Ip4, NULL);
|
||||||
goto ErrorExit;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1431,21 +1435,21 @@ IpIoOpen (
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
IpIo->Ip.Ip6->Configure (IpIo->Ip.Ip6, NULL);
|
IpIo->Ip.Ip6->Configure (IpIo->Ip.Ip6, NULL);
|
||||||
goto ErrorExit;
|
return Status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IpIo->IsConfigured = TRUE;
|
IpIo->IsConfigured = TRUE;
|
||||||
InsertTailList (&mActiveIpIoList, &IpIo->Entry);
|
InsertTailList (&mActiveIpIoList, &IpIo->Entry);
|
||||||
|
|
||||||
ErrorExit:
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Stop an IP_IO instance.
|
Stop an IP_IO instance.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function is paired with IpIoOpen(). The IP_IO will be unconfigured and all
|
This function is paired with IpIoOpen(). The IP_IO will be unconfigured and all
|
||||||
the pending send/receive tokens will be canceled.
|
the pending send/receive tokens will be canceled.
|
||||||
|
@ -1577,7 +1581,7 @@ IpIoDestroy (
|
||||||
/**
|
/**
|
||||||
Send out an IP packet.
|
Send out an IP packet.
|
||||||
|
|
||||||
This function is called after IpIoOpen(). The data to be sent are wrapped in
|
This function is called after IpIoOpen(). The data to be sent is wrapped in
|
||||||
Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
|
Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
|
||||||
overriden by Sender. Other sending configs, like source address and gateway
|
overriden by Sender. Other sending configs, like source address and gateway
|
||||||
address etc., are specified in OverrideData.
|
address etc., are specified in OverrideData.
|
||||||
|
@ -1664,6 +1668,9 @@ IpIoSend (
|
||||||
/**
|
/**
|
||||||
Cancel the IP transmit token which wraps this Packet.
|
Cancel the IP transmit token which wraps this Packet.
|
||||||
|
|
||||||
|
If IpIo is NULL, then ASSERT().
|
||||||
|
If Packet is NULL, then ASSERT().
|
||||||
|
|
||||||
@param[in] IpIo Pointer to the IP_IO instance.
|
@param[in] IpIo Pointer to the IP_IO instance.
|
||||||
@param[in] Packet Pointer to the packet of NET_BUF to cancel.
|
@param[in] Packet Pointer to the packet of NET_BUF to cancel.
|
||||||
|
|
||||||
|
@ -1710,6 +1717,9 @@ IpIoCancelTxToken (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a new IP instance for sending data.
|
Add a new IP instance for sending data.
|
||||||
|
|
||||||
|
If IpIo is NULL, then ASSERT().
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
The function is used to add the IP_IO to the IP_IO sending list. The caller
|
The function is used to add the IP_IO to the IP_IO sending list. The caller
|
||||||
can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send
|
can later use IpIoFindSender() to get the IP_IO and call IpIoSend() to send
|
||||||
|
@ -1737,6 +1747,7 @@ IpIoAddIp (
|
||||||
if (IpInfo == NULL) {
|
if (IpInfo == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
ASSERT ((IpInfo->IpVersion == IP_VERSION_4) || (IpInfo->IpVersion == IP_VERSION_6));
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init this IpInfo, set the Addr and SubnetMask to 0 before we configure the IP
|
// Init this IpInfo, set the Addr and SubnetMask to 0 before we configure the IP
|
||||||
|
@ -1812,6 +1823,9 @@ ReleaseIpInfo:
|
||||||
Configure the IP instance of this IpInfo and start the receiving if IpConfigData
|
Configure the IP instance of this IpInfo and start the receiving if IpConfigData
|
||||||
is not NULL.
|
is not NULL.
|
||||||
|
|
||||||
|
If IpInfo is NULL, then ASSERT().
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
@param[in, out] IpInfo Pointer to the IP_IO_IP_INFO instance.
|
@param[in, out] IpInfo Pointer to the IP_IO_IP_INFO instance.
|
||||||
@param[in, out] IpConfigData The IP configure data used to configure the IP
|
@param[in, out] IpConfigData The IP configure data used to configure the IP
|
||||||
instance, if NULL the IP instance is reset. If
|
instance, if NULL the IP instance is reset. If
|
||||||
|
@ -1861,7 +1875,7 @@ IpIoConfigIp (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
goto OnExit;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IpConfigData != NULL) {
|
if (IpConfigData != NULL) {
|
||||||
|
@ -1876,7 +1890,7 @@ IpIoConfigIp (
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Ip.Ip4->Configure (Ip.Ip4, NULL);
|
Ip.Ip4->Configure (Ip.Ip4, NULL);
|
||||||
goto OnExit;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)->StationAddress, &Ip4ModeData.ConfigData.StationAddress);
|
IP4_COPY_ADDRESS (&((EFI_IP4_CONFIG_DATA*) IpConfigData)->StationAddress, &Ip4ModeData.ConfigData.StationAddress);
|
||||||
|
@ -1910,7 +1924,7 @@ IpIoConfigIp (
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
Ip.Ip6->Configure (Ip.Ip6, NULL);
|
Ip.Ip6->Configure (Ip.Ip6, NULL);
|
||||||
goto OnExit;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ip6ModeData.IsConfigured) {
|
if (Ip6ModeData.IsConfigured) {
|
||||||
|
@ -1946,7 +1960,7 @@ IpIoConfigIp (
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Status = EFI_NO_MAPPING;
|
Status = EFI_NO_MAPPING;
|
||||||
goto OnExit;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (
|
CopyMem (
|
||||||
|
@ -1971,8 +1985,6 @@ IpIoConfigIp (
|
||||||
ZeroMem (&IpInfo->PreMask, sizeof (IpInfo->PreMask));
|
ZeroMem (&IpInfo->PreMask, sizeof (IpInfo->PreMask));
|
||||||
}
|
}
|
||||||
|
|
||||||
OnExit:
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1980,6 +1992,8 @@ OnExit:
|
||||||
/**
|
/**
|
||||||
Destroy an IP instance maintained in IpIo->IpList for
|
Destroy an IP instance maintained in IpIo->IpList for
|
||||||
sending purpose.
|
sending purpose.
|
||||||
|
|
||||||
|
If Ip version is not IP_VERSION_4 or IP_VERSION_6, then ASSERT().
|
||||||
|
|
||||||
This function pairs with IpIoAddIp(). The IpInfo is previously created by
|
This function pairs with IpIoAddIp(). The IpInfo is previously created by
|
||||||
IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance
|
IpIoAddIp(). The IP_IO_IP_INFO::RefCnt is decremented and the IP instance
|
||||||
|
@ -2112,8 +2126,7 @@ IpIoFindSender (
|
||||||
*IpIo = IpIoPtr;
|
*IpIo = IpIoPtr;
|
||||||
return IpInfo;
|
return IpInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2260,6 +2273,7 @@ IpIoGetIcmpErrStatus (
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
IpIoRefreshNeighbor (
|
IpIoRefreshNeighbor (
|
||||||
IN IP_IO *IpIo,
|
IN IP_IO *IpIo,
|
||||||
IN EFI_IP_ADDRESS *Neighbor,
|
IN EFI_IP_ADDRESS *Neighbor,
|
||||||
|
|
Loading…
Reference in New Issue