summaryrefslogtreecommitdiff
path: root/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-01-08 02:35:56 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2010-01-08 02:35:56 +0000
commit216a358c13ff3b1beafcdea77a9426f79c30c5e2 (patch)
treed6d31ae92c086792f9b08f1cb60119da6e25cd7c /edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
parent5a823d6d772045d3f8aab9b3a99499ff88fef7e8 (diff)
refine the code and add more security check.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk@9691 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c')
-rw-r--r--edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c92
1 files changed, 46 insertions, 46 deletions
diff --git a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
index 05fd96d63..ec545a6c5 100644
--- a/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
+++ b/edk2/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>
+Copyright (c) 2005 - 2010, Intel Corporation.<BR>
All rights reserved. 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
@@ -17,7 +17,7 @@ EFI_IPSEC_PROTOCOL *mIpSec = NULL;
/**
Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
-
+
The GetModeData() function returns the current operational mode data for this
driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
function is used optionally to retrieve the operational mode data of underlying
@@ -41,10 +41,10 @@ EfiIp4GetModeData (
OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
);
-
+
/**
Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
-
+
The Configure() function is used to set, change, or reset the operational
parameters and filter settings for this EFI IPv4 Protocol instance. Until these
parameters have been set, no network traffic can be sent or received by this
@@ -53,14 +53,14 @@ EfiIp4GetModeData (
parameters have been set again. Each EFI IPv4 Protocol instance can be started
and stopped independently of each other by enabling or disabling their receive
filter settings with the Configure() function.
-
+
When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
be appended as an alias address into the addresses list in the EFI IPv4 Protocol
driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
to retrieve the default IPv4 address if it is not available yet. Clients could
frequently call GetModeData() to check the status to ensure that the default IPv4
address is ready.
-
+
If operational parameters are reset or changed, any pending transmit and receive
requests will be cancelled. Their completion token status will be set to EFI_ABORTED
and their events will be signaled.
@@ -91,14 +91,14 @@ EfiIp4Configure (
IN EFI_IP4_PROTOCOL *This,
IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
);
-
+
/**
Joins and leaves multicast groups.
-
+
The Groups() function is used to join and leave multicast group sessions. Joining
a group will enable reception of matching multicast packets. Leaving a group will
disable the multicast packet reception.
-
+
If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
@param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
@@ -129,25 +129,25 @@ EfiIp4Groups (
IN BOOLEAN JoinFlag,
IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
);
-
+
/**
Adds and deletes routing table entries.
The Routes() function adds a route to or deletes a route from the routing table.
-
+
Routes are determined by comparing the SubnetAddress with the destination IPv4
address arithmetically AND-ed with the SubnetMask. The gateway address must be
on the same subnet as the configured station address.
-
+
The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
The default route matches all destination IPv4 addresses that do not match any
other routes.
-
+
A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
IP address if it can be found in the ARP cache or on the local subnet. One automatic
nonroute entry will be inserted into the routing table for outgoing packets that
are addressed to a local subnet (gateway address of 0.0.0.0).
-
+
Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
IPv4 Protocol instances that use the default IPv4 address will also have copies
of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
@@ -178,7 +178,7 @@ EfiIp4Groups (
@retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
@retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
DeleteRoute is FALSE).
-
+
**/
EFI_STATUS
EFIAPI
@@ -189,7 +189,7 @@ EfiIp4Routes (
IN EFI_IPv4_ADDRESS *SubnetMask,
IN EFI_IPv4_ADDRESS *GatewayAddress
);
-
+
/**
Places outgoing data packets into the transmit queue.
@@ -208,7 +208,7 @@ EfiIp4Routes (
@retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
was already in the transmit queue.
@retval EFI_NOT_READY The completion token could not be queued because the transmit
- queue is full.
+ queue is full.
@retval EFI_NOT_FOUND Not route is found to destination address.
@retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
@retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
@@ -225,13 +225,13 @@ EfiIp4Transmit (
IN EFI_IP4_PROTOCOL *This,
IN EFI_IP4_COMPLETION_TOKEN *Token
);
-
+
/**
Places a receiving request into the receiving queue.
-
+
The Receive() function places a completion token into the receive packet queue.
This function is always asynchronous.
-
+
The Token.Event field in the completion token must be filled in by the caller
and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
@@ -264,10 +264,10 @@ EfiIp4Receive (
IN EFI_IP4_PROTOCOL *This,
IN EFI_IP4_COMPLETION_TOKEN *Token
);
-
+
/**
Abort an asynchronous transmit or receive request.
-
+
The Cancel() function is used to abort a pending transmit or receive request.
If the token is in the transmit or receive request queues, after calling this
function, Token->Status will be set to EFI_ABORTED and then Token->Event will
@@ -300,15 +300,15 @@ EfiIp4Cancel (
IN EFI_IP4_PROTOCOL *This,
IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
);
-
+
/**
Polls for incoming data packets and processes outgoing data packets.
-
+
The Poll() function polls for incoming data packets and processes outgoing data
packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
function to increase the rate that data packets are moved between the communications
device and the transmit and receive queues.
-
+
In some systems the periodic timer event may not poll the underlying communications
device fast enough to transmit and/or receive all data packets without missing
incoming packets or dropping outgoing packets. Drivers and applications that are
@@ -348,7 +348,7 @@ mEfiIp4ProtocolTemplete = {
/**
Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
-
+
The GetModeData() function returns the current operational mode data for this
driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
function is used optionally to retrieve the operational mode data of underlying
@@ -687,7 +687,7 @@ ON_EXIT:
/**
Request Ip4AutoConfigCallBackDpc as a DPC at TPL_CALLBACK.
-
+
@param Event The event that is signalled.
@param Context The IP4 service binding instance.
@@ -1126,7 +1126,7 @@ Ip4StationAddressValid (
/**
Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
-
+
The Configure() function is used to set, change, or reset the operational
parameters and filter settings for this EFI IPv4 Protocol instance. Until these
parameters have been set, no network traffic can be sent or received by this
@@ -1135,14 +1135,14 @@ Ip4StationAddressValid (
parameters have been set again. Each EFI IPv4 Protocol instance can be started
and stopped independently of each other by enabling or disabling their receive
filter settings with the Configure() function.
-
+
When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
be appended as an alias address into the addresses list in the EFI IPv4 Protocol
driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
to retrieve the default IPv4 address if it is not available yet. Clients could
frequently call GetModeData() to check the status to ensure that the default IPv4
address is ready.
-
+
If operational parameters are reset or changed, any pending transmit and receive
requests will be cancelled. Their completion token status will be set to EFI_ABORTED
and their events will be signaled.
@@ -1318,7 +1318,7 @@ Ip4Groups (
// host byte order
//
if (JoinFlag) {
- //
+ //
// When JoinFlag is TRUE, GroupAddress shouldn't be NULL.
//
ASSERT (GroupAddress != NULL);
@@ -1386,11 +1386,11 @@ Ip4Groups (
/**
Joins and leaves multicast groups.
-
+
The Groups() function is used to join and leave multicast group sessions. Joining
a group will enable reception of matching multicast packets. Leaving a group will
disable the multicast packet reception.
-
+
If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
@param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
@@ -1464,20 +1464,20 @@ ON_EXIT:
Adds and deletes routing table entries.
The Routes() function adds a route to or deletes a route from the routing table.
-
+
Routes are determined by comparing the SubnetAddress with the destination IPv4
address arithmetically AND-ed with the SubnetMask. The gateway address must be
on the same subnet as the configured station address.
-
+
The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
The default route matches all destination IPv4 addresses that do not match any
other routes.
-
+
A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
IP address if it can be found in the ARP cache or on the local subnet. One automatic
nonroute entry will be inserted into the routing table for outgoing packets that
are addressed to a local subnet (gateway address of 0.0.0.0).
-
+
Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
IPv4 Protocol instances that use the default IPv4 address will also have copies
of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
@@ -1508,7 +1508,7 @@ ON_EXIT:
@retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
@retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
DeleteRoute is FALSE).
-
+
**/
EFI_STATUS
EFIAPI
@@ -1693,7 +1693,7 @@ Ip4TxTokenValid (
// Check the source and gateway: they must be a valid unicast.
// Gateway must also be on the connected network.
//
- if (TxData->OverrideData) {
+ if (TxData->OverrideData != NULL) {
Override = TxData->OverrideData;
CopyMem (&Src, &Override->SourceAddress, sizeof (IP4_ADDR));
@@ -1857,7 +1857,7 @@ Ip4OnPacketSent (
@retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
was already in the transmit queue.
@retval EFI_NOT_READY The completion token could not be queued because the transmit
- queue is full.
+ queue is full.
@retval EFI_NOT_FOUND Not route is found to destination address.
@retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
@retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
@@ -1936,7 +1936,7 @@ EfiIp4Transmit (
CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR));
Head.Dst = NTOHL (Head.Dst);
- if (TxData->OverrideData) {
+ if (TxData->OverrideData != NULL) {
Override = TxData->OverrideData;
Head.Protocol = Override->Protocol;
Head.Tos = Override->TypeOfService;
@@ -2039,10 +2039,10 @@ ON_EXIT:
/**
Places a receiving request into the receiving queue.
-
+
The Receive() function places a completion token into the receive packet queue.
This function is always asynchronous.
-
+
The Token.Event field in the completion token must be filled in by the caller
and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
@@ -2310,7 +2310,7 @@ Ip4Cancel (
/**
Abort an asynchronous transmit or receive request.
-
+
The Cancel() function is used to abort a pending transmit or receive request.
If the token is in the transmit or receive request queues, after calling this
function, Token->Status will be set to EFI_ABORTED and then Token->Event will
@@ -2376,12 +2376,12 @@ ON_EXIT:
/**
Polls for incoming data packets and processes outgoing data packets.
-
+
The Poll() function polls for incoming data packets and processes outgoing data
packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
function to increase the rate that data packets are moved between the communications
device and the transmit and receive queues.
-
+
In some systems the periodic timer event may not poll the underlying communications
device fast enough to transmit and/or receive all data packets without missing
incoming packets or dropping outgoing packets. Drivers and applications that are