summaryrefslogtreecommitdiff
path: root/MdeModulePkg
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg')
-rw-r--r--MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c32
-rw-r--r--MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.h73
-rw-r--r--MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c10
-rw-r--r--MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h349
-rw-r--r--MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c4
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c30
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h73
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c15
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h18
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c16
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h109
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c12
-rw-r--r--MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h98
-rw-r--r--MdeModulePkg/Universal/Network/DpcDxe/Dpc.c30
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c13
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h30
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c30
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c4
-rw-r--r--MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h54
19 files changed, 843 insertions, 157 deletions
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
index c33ce4d..49352c0 100644
--- a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
+++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -45,7 +45,6 @@ EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding = {
@retval other Failed to initialize the arp service context.
**/
-STATIC
EFI_STATUS
ArpCreateService (
IN EFI_HANDLE ImageHandle,
@@ -200,7 +199,6 @@ ERROR_EXIT:
@return None.
**/
-STATIC
VOID
ArpCleanService (
IN ARP_SERVICE_DATA *ArpService
@@ -706,31 +704,23 @@ ArpServiceBindingDestroyChild (
return Status;
}
+/**
+ The entry point for Arp driver which installs the driver binding and component name
+ protocol on its ImageHandle.
+
+ @param ImageHandle The image handle of the driver.
+ @param SystemTable The system table.
+ @retval EFI_SUCCES if the driver binding and component name protocols are successfully
+ @retval Others Failed to install the protocols.
+
+**/
EFI_STATUS
EFIAPI
ArpDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
-/*++
-
-Routine Description:
-
- The entry point for Arp driver which installs the driver binding and component name
- protocol on its ImageHandle.
-
-Arguments:
-
- ImageHandle - The image handle of the driver.
- SystemTable - The system table.
-
-Returns:
-
- EFI_SUCCESS - if the driver binding and component name protocols are successfully
- installed, otherwise if failed.
-
---*/
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.h b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.h
index 8c938e9..aa22cc1 100644
--- a/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.h
+++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpDriver.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -41,6 +41,19 @@ extern EFI_DRIVER_BINDING_PROTOCOL gArpDriverBinding;
extern EFI_COMPONENT_NAME_PROTOCOL gArpComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gArpComponentName2;
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to test.
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver supports this device
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
EFI_STATUS
EFIAPI
ArpDriverBindingSupported (
@@ -49,6 +62,19 @@ ArpDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Start this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to bind driver to
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval other This driver does not support this device
+
+**/
EFI_STATUS
EFIAPI
ArpDriverBindingStart (
@@ -57,6 +83,19 @@ ArpDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Stop this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to stop driver on
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number
+ of children is zero stop the entire bus driver.
+ @param ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCES This driver is removed ControllerHandle
+ @retval other This driver was not removed from this device
+
+**/
EFI_STATUS
EFIAPI
ArpDriverBindingStop (
@@ -66,6 +105,22 @@ ArpDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
);
+/**
+ Creates a child handle with a set of I/O services.
+
+ @param This Protocol instance pointer.
+ @param ChildHandle Pointer to the handle of the child to create. If
+ it is NULL, then a new handle is created. If it is
+ not NULL, then the I/O services are added to the
+ existing child handle.
+
+ @retval EFI_SUCCES The child handle was created with the I/O
+ services.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
+ the child.
+ @retval other The child handle was not created.
+
+**/
EFI_STATUS
EFIAPI
ArpServiceBindingCreateChild (
@@ -73,6 +128,22 @@ ArpServiceBindingCreateChild (
IN EFI_HANDLE *ChildHandle
);
+/**
+ Destroys a child handle with a set of I/O services.
+
+ @param This Protocol instance pointer.
+ @param ChildHandle Handle of the child to destroy.
+
+ @retval EFI_SUCCES The I/O services were removed from the child
+ handle.
+ @retval EFI_UNSUPPORTED The child handle does not support the I/O services
+ that are being removed.
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.
+ @retval EFI_ACCESS_DENIED The child handle could not be destroyed because
+ its I/O services are being used.
+ @retval other The child handle was not destroyed.
+
+**/
EFI_STATUS
EFIAPI
ArpServiceBindingDestroyChild (
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
index 797ebd0..e29fbf8 100644
--- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
+++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -531,7 +531,6 @@ ArpTimerHandler (
@return The two addresses match or not.
**/
-STATIC
BOOLEAN
ArpMatchAddress (
IN NET_ARP_ADDRESS *AddressOne,
@@ -597,7 +596,7 @@ ArpFindNextCacheEntryInTable (
for (Entry = StartEntry->ForwardLink; Entry != CacheTable; Entry = Entry->ForwardLink) {
CacheEntry = NET_LIST_USER_STRUCT (Entry, ARP_CACHE_ENTRY, List);
- if (FindOpType & MATCH_SW_ADDRESS) {
+ if ((FindOpType & MATCH_SW_ADDRESS) != 0) {
//
// Find by the software address.
//
@@ -609,7 +608,7 @@ ArpFindNextCacheEntryInTable (
}
}
- if (FindOpType & MATCH_HW_ADDRESS) {
+ if ((FindOpType & MATCH_HW_ADDRESS) != 0) {
//
// Find by the hardware address.
//
@@ -930,7 +929,7 @@ ArpConfigureInstance (
// The instance is not configured.
//
- if (ConfigData->SwAddressType == IPv4_ETHER_PROTO_TYPE) {
+ if (ConfigData->SwAddressType == IPV4_ETHER_PROTO_TYPE) {
CopyMem (&Ip, ConfigData->StationAddress, sizeof (IP4_ADDR));
if (!Ip4IsUnicast (NTOHL (Ip), 0)) {
@@ -1224,7 +1223,6 @@ CLEAN_EXIT:
@return The count of the deleted cache entries.
**/
-STATIC
UINTN
ArpDeleteCacheEntryInTable (
IN LIST_ENTRY *CacheTable,
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h
index 1db6d34..935d788 100644
--- a/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h
+++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpImpl.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -39,8 +39,8 @@ Abstract:
#define ARP_ETHER_PROTO_TYPE 0x0806
-#define IPv4_ETHER_PROTO_TYPE 0x0800
-#define IPv6_ETHER_PROTO_TYPE 0x86DD
+#define IPV4_ETHER_PROTO_TYPE 0x0800
+#define IPV6_ETHER_PROTO_TYPE 0x86DD
#define ARP_OPCODE_REQUEST 0x0001
#define ARP_OPCODE_REPLY 0x0002
@@ -172,6 +172,27 @@ typedef struct _ARP_CACHE_ENTRY {
LIST_ENTRY UserRequestList;
} ARP_CACHE_ENTRY;
+/**
+ This function is used to assign a station address to the ARP cache for this instance
+ of the ARP driver. A call to this function with the ConfigData field set to NULL
+ will reset this ARP instance.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param ConfigData Pointer to the EFI_ARP_CONFIG_DATA structure.
+
+ @retval EFI_SUCCESS The new station address was successfully
+ registered.
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+ This is NULL. SwAddressLength is zero when
+ ConfigData is not NULL. StationAddress is NULL
+ when ConfigData is not NULL.
+ @retval EFI_ACCESS_DENIED The SwAddressType, SwAddressLength, or
+ StationAddress is different from the one that is
+ already registered.
+ @retval EFI_OUT_OF_RESOURCES Storage for the new StationAddress could not be
+ allocated.
+
+**/
EFI_STATUS
EFIAPI
ArpConfigure (
@@ -179,6 +200,40 @@ ArpConfigure (
IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
);
+/**
+ This function is used to insert entries into the ARP cache.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param DenyFlag Set to TRUE if this entry is a deny entry. Set to
+ FALSE if this entry is a normal entry.
+ @param TargetSwAddress Pointer to a protocol address to add (or deny).
+ May be set to NULL if DenyFlag is TRUE.
+ @param TargetHwAddress Pointer to a hardware address to add (or deny).
+ May be set to NULL if DenyFlag is TRUE.
+ @param TimeoutValue Time in 100-ns units that this entry will remain
+ in the ARP cache. A value of zero means that the
+ entry is permanent. A nonzero value will override
+ the one given by Configure() if the entry to be
+ added is a dynamic entry.
+ @param Overwrite If TRUE, the matching cache entry will be
+ overwritten with the supplied parameters. If
+ FALSE, EFI_ACCESS_DENIED is returned if the
+ corresponding cache entry already exists.
+
+ @retval EFI_SUCCESS The entry has been added or updated.
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+ This is NULL. DenyFlag is FALSE and
+ TargetHwAddress is NULL. DenyFlag is FALSE and
+ TargetSwAddress is NULL. TargetHwAddress is NULL
+ and TargetSwAddress is NULL. Both TargetSwAddress
+ and TargetHwAddress are not NULL when DenyFlag is
+ TRUE.
+ @retval EFI_OUT_OF_RESOURCES The new ARP cache entry could not be allocated.
+ @retval EFI_ACCESS_DENIED The ARP cache entry already exists and Overwrite
+ is not true.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+
+**/
EFI_STATUS
EFIAPI
ArpAdd (
@@ -190,6 +245,33 @@ ArpAdd (
IN BOOLEAN Overwrite
);
+/**
+ This function searches the ARP cache for matching entries and allocates a buffer into
+ which those entries are copied.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param BySwAddress Set to TRUE to look for matching software protocol
+ addresses. Set to FALSE to look for matching
+ hardware protocol addresses.
+ @param AddressBuffer Pointer to address buffer. Set to NULL to match
+ all addresses.
+ @param EntryLength The size of an entry in the entries buffer.
+ @param EntryCount The number of ARP cache entries that are found by
+ the specified criteria.
+ @param Entries Pointer to the buffer that will receive the ARP
+ cache entries.
+ @param Refresh Set to TRUE to refresh the timeout value of the
+ matching ARP cache entry.
+
+ @retval EFI_SUCCESS The requested ARP cache entries were copied into
+ the buffer.
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+ This is NULL. Both EntryCount and EntryLength are
+ NULL, when Refresh is FALSE.
+ @retval EFI_NOT_FOUND No matching entries were found.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+
+**/
EFI_STATUS
EFIAPI
ArpFind (
@@ -202,6 +284,23 @@ ArpFind (
IN BOOLEAN Refresh
);
+/**
+ This function removes specified ARP cache entries.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param BySwAddress Set to TRUE to delete matching protocol addresses.
+ Set to FALSE to delete matching hardware
+ addresses.
+ @param AddressBuffer Pointer to the address buffer that is used as a
+ key to look for the cache entry. Set to NULL to
+ delete all entries.
+
+ @retval EFI_SUCCESS The entry was removed from the ARP cache.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_NOT_FOUND The specified deletion key was not found.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+
+**/
EFI_STATUS
EFIAPI
ArpDelete (
@@ -210,12 +309,46 @@ ArpDelete (
IN VOID *AddressBuffer OPTIONAL
);
+/**
+ This function delete all dynamic entries from the ARP cache that match the specified
+ software protocol type.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+
+ @retval EFI_SUCCESS The cache has been flushed.
+ @retval EFI_INVALID_PARAMETER This is NULL.
+ @retval EFI_NOT_FOUND There are no matching dynamic cache entries.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+
+**/
EFI_STATUS
EFIAPI
ArpFlush (
IN EFI_ARP_PROTOCOL *This
);
+/**
+ This function tries to resolve the TargetSwAddress and optionally returns a
+ TargetHwAddress if it already exists in the ARP cache.
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param TargetSwAddress Pointer to the protocol address to resolve.
+ @param ResolvedEvent Pointer to the event that will be signaled when
+ the address is resolved or some error occurs.
+ @param TargetHwAddress Pointer to the buffer for the resolved hardware
+ address in network byte order.
+
+ @retval EFI_SUCCESS The data is copied from the ARP cache into the
+ TargetHwAddress buffer.
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+ This is NULL. TargetHwAddress is NULL.
+ @retval EFI_ACCESS_DENIED The requested address is not present in the normal
+ ARP cache but is present in the deny address list.
+ Outgoing traffic to that address is forbidden.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+ @retval EFI_NOT_READY The request has been started and is not finished.
+
+**/
EFI_STATUS
EFIAPI
ArpRequest (
@@ -225,6 +358,27 @@ ArpRequest (
OUT VOID *TargetHwAddress
);
+/**
+ This function aborts the previous ARP request (identified by This, TargetSwAddress
+ and ResolvedEvent) that is issued by EFI_ARP_PROTOCOL.Request().
+
+ @param This Pointer to the EFI_ARP_PROTOCOL instance.
+ @param TargetSwAddress Pointer to the protocol address in previous
+ request session.
+ @param ResolvedEvent Pointer to the event that is used as the
+ notification event in previous request session.
+
+ @retval EFI_SUCCESS The pending request session(s) is/are aborted and
+ corresponding event(s) is/are signaled.
+ @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
+ This is NULL. TargetSwAddress is not NULL and
+ ResolvedEvent is NULL. TargetSwAddress is NULL and
+ ResolvedEvent is not NULL.
+ @retval EFI_NOT_STARTED The ARP driver instance has not been configured.
+ @retval EFI_NOT_FOUND The request is not issued by
+ EFI_ARP_PROTOCOL.Request().
+
+**/
EFI_STATUS
EFIAPI
ArpCancel (
@@ -233,12 +387,41 @@ ArpCancel (
IN EFI_EVENT ResolvedEvent OPTIONAL
);
+/**
+ Configure the instance using the ConfigData. ConfigData is already validated.
+
+ @param Instance Pointer to the instance context data to be
+ configured.
+ @param ConfigData Pointer to the configuration data used to
+ configure the instance.
+
+ @retval EFI_SUCCESS The instance is configured with the ConfigData.
+ @retval EFI_ACCESS_DENIED The instance is already configured and the
+ ConfigData tries to reset some unchangeable
+ fields.
+ @retval EFI_INVALID_PARAMETER The ConfigData provides a non-unicast IPv4 address
+ when the SwAddressType is IPv4.
+ @retval EFI_OUT_OF_RESOURCES The instance fails to configure due to memory
+ limitation.
+
+**/
EFI_STATUS
ArpConfigureInstance (
IN ARP_INSTANCE_DATA *Instance,
IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
);
+/**
+ Find the CacheEntry, using ProtocolAddress or HardwareAddress or both, as the keyword,
+ in the DeniedCacheTable.
+
+ @param ArpService Pointer to the arp service context data.
+ @param ProtocolAddress Pointer to the protocol address.
+ @param HardwareAddress Pointer to the hardware address.
+
+ @return Pointer to the matched cache entry, if NULL no match is found.
+
+**/
ARP_CACHE_ENTRY *
ArpFindDeniedCacheEntry (
IN ARP_SERVICE_DATA *ArpService,
@@ -246,6 +429,19 @@ ArpFindDeniedCacheEntry (
IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL
);
+/**
+ Find the CacheEntry which matches the requirements in the specified CacheTable.
+
+ @param CacheTable Pointer to the arp cache table.
+ @param StartEntry Pointer to the start entry this search begins with
+ in the cache table.
+ @param FindOpType The search type.
+ @param ProtocolAddress Pointer to the protocol address to match.
+ @param HardwareAddress Pointer to the hardware address to match.
+
+ @return Pointer to the matched arp cache entry, if NULL, no match is found.
+
+**/
ARP_CACHE_ENTRY *
ArpFindNextCacheEntryInTable (
IN LIST_ENTRY *CacheTable,
@@ -255,11 +451,30 @@ ArpFindNextCacheEntryInTable (
IN NET_ARP_ADDRESS *HardwareAddress OPTIONAL
);
+/**
+ Allocate a cache entry and initialize it.
+
+ @param Instance Pointer to the instance context data.
+
+ @return Pointer to the new created cache entry.
+
+**/
ARP_CACHE_ENTRY *
ArpAllocCacheEntry (
IN ARP_INSTANCE_DATA *Instance
);
+/**
+ Fill the addresses in the CacheEntry using the information passed in by
+ HwAddr and SwAddr.
+
+ @param CacheEntry Pointer to the cache entry.
+ @param HwAddr Pointer to the software address.
+ @param SwAddr Pointer to the hardware address.
+
+ @return None.
+
+**/
VOID
ArpFillAddressInCacheEntry (
IN ARP_CACHE_ENTRY *CacheEntry,
@@ -267,6 +482,16 @@ ArpFillAddressInCacheEntry (
IN NET_ARP_ADDRESS *SwAddr OPTIONAL
);
+/**
+ Turn the CacheEntry into the resolved status.
+
+ @param CacheEntry Pointer to the resolved cache entry.
+ @param Instance Pointer to the instance context data.
+ @param UserEvent Pointer to the UserEvent to notify.
+
+ @return The count of notifications sent to the instance.
+
+**/
UINTN
ArpAddressResolved (
IN ARP_CACHE_ENTRY *CacheEntry,
@@ -274,6 +499,19 @@ ArpAddressResolved (
IN EFI_EVENT UserEvent OPTIONAL
);
+/**
+ Delete cache entries in all the cache tables.
+
+ @param Instance Pointer to the instance context data.
+ @param BySwAddress Delete the cache entry by software address or by
+ hardware address.
+ @param AddressBuffer Pointer to the buffer containing the address to
+ match for the deletion.
+ @param Force This deletion is forced or not.
+
+ @return The count of the deleted cache entries.
+
+**/
UINTN
ArpDeleteCacheEntry (
IN ARP_INSTANCE_DATA *Instance,
@@ -282,6 +520,18 @@ ArpDeleteCacheEntry (
IN BOOLEAN Force
);
+/**
+ Send out an arp frame using the CachEntry and the ArpOpCode.
+
+ @param Instance Pointer to the instance context data.
+ @param CacheEntry Pointer to the configuration data used to
+ configure the instance.
+ @param ArpOpCode The opcode used to send out this Arp frame, either
+ request or reply.
+
+ @return None.
+
+**/
VOID
ArpSendFrame (
IN ARP_INSTANCE_DATA *Instance,
@@ -289,18 +539,47 @@ ArpSendFrame (
IN UINT16 ArpOpCode
);
+/**
+ Initialize the instance context data.
+
+ @param ArpService Pointer to the arp service context data this
+ instance belongs to.
+ @param Instance Pointer to the instance context data.
+
+ @return None.
+
+**/
VOID
ArpInitInstance (
IN ARP_SERVICE_DATA *ArpService,
IN ARP_INSTANCE_DATA *Instance
);
+/**
+ Process the Arp packets received from Mnp, the procedure conforms to RFC826.
+
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
VOID
EFIAPI
ArpOnFrameRcvdDpc (
IN VOID *Context
);
+/**
+ Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.
+
+ @param Event The Event this notify function registered to.
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
VOID
EFIAPI
ArpOnFrameRcvd (
@@ -308,12 +587,31 @@ ArpOnFrameRcvd (
IN VOID *Context
);
+/**
+ Process the already sent arp packets.
+
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
VOID
EFIAPI
ArpOnFrameSentDpc (
IN VOID *Context
);
+/**
+ Queue ArpOnFrameRcvdDpc as a DPC at TPL_CALLBACK.
+
+ @param Event The Event this notify function registered to.
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
VOID
EFIAPI
ArpOnFrameSent (
@@ -321,6 +619,16 @@ ArpOnFrameSent (
IN VOID *Context
);
+/**
+ Process the arp cache olding and drive the retrying arp requests.
+
+ @param Event The Event this notify function registered to.
+ @param Context Pointer to the context data registerd to the
+ Event.
+
+ @return None.
+
+**/
VOID
EFIAPI
ArpTimerHandler (
@@ -328,6 +636,18 @@ ArpTimerHandler (
IN VOID *Context
);
+/**
+ Cancel the arp request.
+
+ @param Instance Pointer to the instance context data.
+ @param TargetSwAddress Pointer to the buffer containing the target
+ software address to match the arp request.
+ @param UserEvent The user event used to notify this request
+ cancellation.
+
+ @return The count of the cancelled requests.
+
+**/
UINTN
ArpCancelRequest (
IN ARP_INSTANCE_DATA *Instance,
@@ -335,6 +655,29 @@ ArpCancelRequest (
IN EFI_EVENT UserEvent OPTIONAL
);
+/**
+ Find the cache entry in the cache table.
+
+ @param Instance Pointer to the instance context data.
+ @param BySwAddress Set to TRUE to look for matching software protocol
+ addresses. Set to FALSE to look for matching
+ hardware protocol addresses.
+ @param AddressBuffer Pointer to address buffer. Set to NULL to match
+ all addresses.
+ @param EntryLength The size of an entry in the entries buffer.
+ @param EntryCount The number of ARP cache entries that are found by
+ the specified criteria.
+ @param Entries Pointer to the buffer that will receive the ARP
+ cache entries.
+ @param Refresh Set to TRUE to refresh the timeout value of the
+ matching ARP cache entry.
+
+ @retval EFI_SUCCESS The requested ARP cache entries are copied into
+ the buffer.
+ @retval EFI_NOT_FOUND No matching entries found.
+ @retval EFI_OUT_OF_RESOURCE There is a memory allocation failure.
+
+**/
EFI_STATUS
ArpFindCacheEntry (
IN ARP_INSTANCE_DATA *Instance,
diff --git a/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c b/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c
index 46aa192..2d607fb 100644
--- a/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c
+++ b/MdeModulePkg/Universal/Network/ArpDxe/ArpMain.c
@@ -495,7 +495,7 @@ ArpRequest (
SnpMode = &ArpService->SnpMode;
if ((TargetSwAddress == NULL) ||
- ((Instance->ConfigData.SwAddressType == IPv4_ETHER_PROTO_TYPE) &&
+ ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) &&
IP4_IS_LOCAL_BROADCAST (*((UINT32 *)TargetSwAddress)))) {
//
// Return the hardware broadcast address.
@@ -505,7 +505,7 @@ ArpRequest (
goto SIGNAL_USER;
}
- if ((Instance->ConfigData.SwAddressType == IPv4_ETHER_PROTO_TYPE) &&
+ if ((Instance->ConfigData.SwAddressType == IPV4_ETHER_PROTO_TYPE) &&
IP4_IS_MULTICAST (NTOHL (*((UINT32 *)TargetSwAddress)))) {
//
// If the software address is an IPv4 multicast address, invoke Mnp to
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
index d278103..360193e 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -36,30 +36,22 @@ EFI_SERVICE_BINDING_PROTOCOL mDhcp4ServiceBindingTemplete = {
Dhcp4ServiceBindingDestroyChild
};
+/**
+ Entry point of the DHCP driver to install various protocols.
+
+ @param ImageHandle The image handle of the driver.
+ @param SystemTable The system table.
+
+ @retval EFI_SUCCES if the driver binding and component name protocols are successfully
+ @retval Others Failed to install the protocols.
+**/
EFI_STATUS
EFIAPI
Dhcp4DriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
-/*++
-
-Routine Description:
-
- Entry point of the DHCP driver to install various protocols.
-
-Arguments:
-
- ImageHandle - The driver's image handle
- SystemTable - The system table
-
-Returns:
-
- EFI_SUCCESS - All the related protocols are installed.
- Others - Failed to install the protocols.
-
---*/
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
@@ -432,7 +424,7 @@ Dhcp4DriverBindingStop (
/**
- Initialize a new DHCP child
+ Initialize a new DHCP child.
@param DhcpSb The dhcp service instance
@param Instance The dhcp instance to initialize
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h
index 845a284..b0052be 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Driver.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -26,6 +26,19 @@ Abstract:
extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2;
+/**
+ Test to see if this driver supports ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to test.
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver supports this device
+ @retval EFI_ALREADY_STARTED This driver is already running on this device.
+ @retval other This driver does not support this device.
+
+**/
EFI_STATUS
EFIAPI
Dhcp4DriverBindingSupported (
@@ -34,6 +47,19 @@ Dhcp4DriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Start this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to bind driver to
+ @param RemainingDevicePath Optional parameter use to pick a specific child
+ device to start.
+
+ @retval EFI_SUCCES This driver is added to ControllerHandle
+ @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
+ @retval other This driver does not support this device
+
+**/
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStart (
@@ -42,6 +68,19 @@ Dhcp4DriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
+/**
+ Stop this driver on ControllerHandle.
+
+ @param This Protocol instance pointer.
+ @param ControllerHandle Handle of device to stop driver on
+ @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number
+ of children is zero stop the entire bus driver.
+ @param ChildHandleBuffer List of Child Handles to Stop.
+
+ @retval EFI_SUCCES This driver is removed ControllerHandle
+ @retval other This driver was not removed from this device
+
+**/
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStop (
@@ -51,6 +90,22 @@ Dhcp4DriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer
);
+/**
+ Creates a child handle with a set of I/O services.
+
+ @param This Protocol instance pointer.
+ @param ChildHandle Pointer to the handle of the child to create. If
+ it is NULL, then a new handle is created. If it is
+ not NULL, then the I/O services are added to the
+ existing child handle.
+
+ @retval EFI_SUCCES The child handle was created with the I/O
+ services.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resources availabe to create
+ the child.
+ @retval other The child handle was not created.
+
+**/
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingCreateChild (
@@ -58,6 +113,22 @@ Dhcp4ServiceBindingCreateChild (
IN EFI_HANDLE *ChildHandle
);
+/**
+ Destroys a child handle with a set of I/O services.
+
+ @param This Protocol instance pointer.
+ @param ChildHandle Handle of the child to destroy.
+
+ @retval EFI_SUCCES The I/O services were removed from the child
+ handle.
+ @retval EFI_UNSUPPORTED The child handle does not support the I/O services
+ that are being removed.
+ @retval EFI_INVALID_PARAMETER Child handle is not a valid EFI Handle.
+ @retval EFI_ACCESS_DENIED The child handle could not be destroyed because
+ its I/O services are being used.
+ @retval other The child handle was not destroyed.
+
+**/
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingDestroyChild (
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
index 77f65d5..6097f0d 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -35,7 +35,6 @@ Abstract:
operation parameter.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4GetModeData (
@@ -286,7 +285,6 @@ DhcpYieldControl (
@retval EFI_SUCCESS The child is configured.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Configure (
@@ -407,7 +405,6 @@ ON_EXIT:
@retval EFI_SUCCESS The DHCP process is started.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Start (
@@ -497,7 +494,6 @@ ON_ERROR:
@retval EFI_SUCCESS The DHCP is renewed/rebound.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4RenewRebind (
@@ -597,7 +593,6 @@ ON_ERROR:
@retval EFI_SUCCESS The lease is released.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Release (
@@ -664,7 +659,6 @@ ON_EXIT:
@retval EFI_SUCCESS The DHCP process is stopped.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Stop (
@@ -719,7 +713,6 @@ EfiDhcp4Stop (
@retval EFI_SUCCESS The packet is build.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Build (
@@ -762,7 +755,6 @@ EfiDhcp4Build (
);
}
-STATIC
EFI_STATUS
Dhcp4InstanceConfigUdpIo (
IN UDP_IO_PORT *UdpIo,
@@ -801,7 +793,6 @@ Dhcp4InstanceConfigUdpIo (
return UdpIo->Udp->Configure (UdpIo->Udp, &UdpConfigData);
}
-STATIC
EFI_STATUS
Dhcp4InstanceCreateUdpIo (
IN DHCP_PROTOCOL *Instance
@@ -820,7 +811,6 @@ Dhcp4InstanceCreateUdpIo (
}
}
-STATIC
VOID
DhcpDummyExtFree (
IN VOID *Arg
@@ -998,7 +988,6 @@ SIGNAL_USER:
@retval Others Some other unexpected error occurred.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4TransmitReceive (
@@ -1165,7 +1154,6 @@ ON_ERROR:
@retval EFI_SUCCESS It always returns EFI_SUCCESS
**/
-STATIC
EFI_STATUS
Dhcp4ParseCheckOption (
IN UINT8 Tag,
@@ -1207,7 +1195,6 @@ Dhcp4ParseCheckOption (
@retval EFI_SUCCESS The options are parsed.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiDhcp4Parse (
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
index bf401bd..16ea493 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
@@ -48,10 +48,10 @@ typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
#include "Dhcp4Option.h"
#include "Dhcp4Io.h"
-enum {
- DHCP_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('D', 'H', 'C', 'P'),
- DHCP_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('d', 'h', 'c', 'p'),
+#define DHCP_SERVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'H', 'C', 'P')
+#define DHCP_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('d', 'h', 'c', 'p')
+typedef enum {
//
// The state of the DHCP service. It starts as UNCONFIGED. If
// and active child configures the service successfully, it
@@ -62,7 +62,7 @@ enum {
DHCP_UNCONFIGED = 0,
DHCP_CONFIGED,
DHCP_DESTORY
-};
+} DHCP_STATE;
struct _DHCP_PROTOCOL {
UINT32 Signature;
@@ -153,6 +153,16 @@ typedef struct {
extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
+/**
+ Give up the control of the DHCP service to let other child
+ resume. Don't change the service's DHCP state and the Client
+ address and option list configure as required by RFC2131.
+
+ @param DhcpSb The DHCP service instance.
+
+ @return None
+
+**/
VOID
DhcpYieldControl (
IN DHCP_SERVICE *DhcpSb
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
index 415ffa8..1f168c6 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.c
@@ -82,7 +82,6 @@ DhcpInitRequest (
@retval EFI_ABORTED The user function ask it to abort.
**/
-STATIC
EFI_STATUS
DhcpCallUser (
IN DHCP_SERVICE *DhcpSb,
@@ -250,7 +249,6 @@ DhcpSetState (
@return None
**/
-STATIC
VOID
DhcpSetTransmitTimer (
IN DHCP_SERVICE *DhcpSb
@@ -287,7 +285,6 @@ DhcpSetTransmitTimer (
@return None
**/
-STATIC
VOID
DhcpComputeLease (
IN DHCP_SERVICE *DhcpSb,
@@ -396,7 +393,6 @@ DhcpConfigLeaseIoPort (
@retval EFI_SUCCESS The lease is recorded.
**/
-STATIC
EFI_STATUS
DhcpLeaseAcquired (
IN DHCP_SERVICE *DhcpSb
@@ -509,7 +505,6 @@ DhcpCleanLease (
@retval EFI_SUCCESS One of the offer is selected.
**/
-STATIC
EFI_STATUS
DhcpChooseOffer (
IN DHCP_SERVICE *DhcpSb
@@ -591,7 +586,6 @@ DhcpChooseOffer (
@return None
**/
-STATIC
VOID
DhcpEndSession (
IN DHCP_SERVICE *DhcpSb,
@@ -623,7 +617,6 @@ DhcpEndSession (
@retval Others Some error occured.
**/
-STATIC
EFI_STATUS
DhcpHandleSelect (
IN DHCP_SERVICE *DhcpSb,
@@ -698,7 +691,6 @@ ON_EXIT:
@retval Others Some error occured.
**/
-STATIC
EFI_STATUS
DhcpHandleRequest (
IN DHCP_SERVICE *DhcpSb,
@@ -791,7 +783,6 @@ ON_EXIT:
@retval Others Some error occured.
**/
-STATIC
EFI_STATUS
DhcpHandleRenewRebind (
IN DHCP_SERVICE *DhcpSb,
@@ -850,7 +841,7 @@ DhcpHandleRenewRebind (
DhcpSb->LeaseLife = 0;
DhcpSetState (DhcpSb, Dhcp4Bound, TRUE);
- if (DhcpSb->ExtraRefresh) {
+ if (DhcpSb->ExtraRefresh != 0) {
DhcpSb->ExtraRefresh = FALSE;
DhcpSb->IoStatus = EFI_SUCCESS;
@@ -875,7 +866,6 @@ ON_EXIT:
@retval Others Some error occured.
**/
-STATIC
EFI_STATUS
DhcpHandleReboot (
IN DHCP_SERVICE *DhcpSb,
@@ -1528,7 +1518,7 @@ DhcpOnTimerTick (
// user, adjust the current state according to the lease life.
// Otherwise do nothing to wait the lease to timeout
//
- if (DhcpSb->ExtraRefresh) {
+ if (DhcpSb->ExtraRefresh != 0) {
Status = EFI_SUCCESS;
if (DhcpSb->LeaseLife < DhcpSb->T1) {
@@ -1564,7 +1554,7 @@ DhcpOnTimerTick (
// Don't timeout the lease, only count the life if user is
// requesting extra renew/rebind. Adjust the state after that.
//
- if (DhcpSb->ExtraRefresh) {
+ if (DhcpSb->ExtraRefresh != 0) {
return ;
}
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
index 1caba3a..c041ba8 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Io.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -34,18 +34,21 @@ Abstract:
#include <Library/MemoryAllocationLib.h>
-enum {
- DHCP_WAIT_OFFER = 3, // Time to wait the offers
- DHCP_DEFAULT_LEASE = 7 *24 *60 *60, // Seven days as default.
- DHCP_SERVER_PORT = 67,
- DHCP_CLIENT_PORT = 68,
+#define DHCP_WAIT_OFFER 3 // Time to wait the offers
+#define DHCP_DEFAULT_LEASE 7 *24 *60 *60 // Seven days as default.
+#define DHCP_SERVER_PORT 67
+#define DHCP_CLIENT_PORT 68
+
+typedef enum {
//
// BOOTP header "op" field
//
BOOTP_REQUEST = 1,
- BOOTP_REPLY = 2,
+ BOOTP_REPLY = 2
+} DHCP_OP_TYPE;
+typedef enum {
//
// DHCP message types
//
@@ -56,21 +59,38 @@ enum {
DHCP_MSG_ACK = 5,
DHCP_MSG_NAK = 6,
DHCP_MSG_RELEASE = 7,
- DHCP_MSG_INFORM = 8,
+ DHCP_MSG_INFORM = 8
+} DHCP_MSG_TYPE;
+typedef enum {
//
// DHCP notify user type
//
DHCP_NOTIFY_COMPLETION = 1,
DHCP_NOTIFY_RENEWREBIND,
DHCP_NOTIFY_ALL
-};
+} DHCP_NOTIFY_TYPE;
#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
#define DHCP_CONNECTED(State) \
(((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
+/**
+ Set the DHCP state. If CallUser is true, it will try to notify
+ the user before change the state by DhcpNotifyUser. It returns
+ EFI_ABORTED if the user return EFI_ABORTED, otherwise, it returns
+ EFI_SUCCESS. If CallUser is FALSE, it isn't necessary to test
+ the return value of this function.
+
+ @param DhcpSb The DHCP service instance
+ @param State The new DHCP state to change to
+ @param CallUser Whether we need to call user
+
+ @retval EFI_SUCCESS The state is changed
+ @retval EFI_ABORTED The user asks to abort the DHCP process.
+
+**/
EFI_STATUS
DhcpSetState (
IN DHCP_SERVICE *DhcpSb,
@@ -78,6 +98,24 @@ DhcpSetState (
IN BOOLEAN CallUser
);
+/**
+ Build and transmit a DHCP message according to the current states.
+ This function implement the Table 5. of RFC 2131. Always transits
+ the state (as defined in Figure 5. of the same RFC) before sending
+ a DHCP message. The table is adjusted accordingly.
+
+ @param DhcpSb The DHCP service instance
+ @param Seed The seed packet which the new packet is based on
+ @param Para The DHCP parameter of the Seed packet
+ @param Type The message type to send
+ @param Msg The human readable message to include in the packet
+ sent.
+
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources for the packet
+ @retval EFI_ACCESS_DENIED Failed to transmit the packet through UDP
+ @retval EFI_SUCCESS The message is sent
+
+**/
EFI_STATUS
DhcpSendMessage (
IN DHCP_SERVICE *DhcpSb,
@@ -87,6 +125,19 @@ DhcpSendMessage (
IN UINT8 *Msg
);
+/**
+ Each DHCP service has three timer. Two of them are count down timer.
+ One for the packet retransmission. The other is to collect the offers.
+ The third timer increaments the lease life which is compared to T1, T2,
+ and lease to determine the time to renew and rebind the lease.
+ DhcpOnTimerTick will be called once every second.
+
+ @param Event The timer event
+ @param Context The context, which is the DHCP service instance.
+
+ @return None
+
+**/
VOID
EFIAPI
DhcpOnTimerTick (
@@ -94,6 +145,18 @@ DhcpOnTimerTick (
IN VOID *Context
);
+/**
+ Handle the received DHCP packets. This function drivers the DHCP
+ state machine.
+
+ @param UdpPacket The UDP packets received.
+ @param Points The local/remote UDP access points
+ @param IoStatus The status of the UDP receive
+ @param Context The opaque parameter to the function.
+
+ @return None
+
+**/
VOID
DhcpInput (
NET_BUF *UdpPacket,
@@ -102,16 +165,44 @@ DhcpInput (
VOID *Context
);
+/**
+ Send an initial DISCOVER or REQUEST message according to the
+ DHCP service's current state.
+
+ @param DhcpSb The DHCP service instance
+
+ @retval EFI_SUCCESS The request has been sent
+
+**/
EFI_STATUS
DhcpInitRequest (
IN DHCP_SERVICE *DhcpSb
);
+/**
+ Clean up the DHCP related states, IoStatus isn't reset.
+
+ @param DhcpSb The DHCP instance service.
+
+ @return None
+
+**/
VOID
DhcpCleanLease (
IN DHCP_SERVICE *DhcpSb
);
+/**
+ Release the net buffer when packet is sent.
+
+ @param UdpPacket The UDP packets received.
+ @param Points The local/remote UDP access points
+ @param IoStatus The status of the UDP receive
+ @param Context The opaque parameter to the function.
+
+ @return None
+
+**/
VOID
DhcpOnPacketSent (
NET_BUF *Packet,
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
index 04a4007..b2d2505 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -27,9 +27,7 @@ Abstract:
// to validate a dhcp message. Refere the comments of the
// DHCP_OPTION_FORMAT structure.
//
-STATIC
-DHCP_OPTION_FORMAT
-DhcpOptionFormats [] = {
+STATIC DHCP_OPTION_FORMAT DhcpOptionFormats[] = {
{DHCP_TAG_NETMASK, DHCP_OPTION_IP, 1, 1 , TRUE},
{DHCP_TAG_TIME_OFFSET, DHCP_OPTION_INT32, 1, 1 , FALSE},
{DHCP_TAG_ROUTER, DHCP_OPTION_IP, 1, -1 , TRUE},
@@ -127,7 +125,6 @@ DhcpOptionFormats [] = {
@return The point to the option's format, NULL if not found.
**/
-STATIC
DHCP_OPTION_FORMAT *
DhcpFindOptionFormat (
IN UINT8 Tag
@@ -168,7 +165,6 @@ DhcpFindOptionFormat (
@return TRUE is the option is valid, otherwise FALSE.
**/
-STATIC
BOOLEAN
DhcpOptionIsValid (
IN DHCP_OPTION_FORMAT *Format,
@@ -249,7 +245,6 @@ DhcpOptionIsValid (
@retval EFI_INVALID_PARAMETER The DHCP option is mal-formated
**/
-STATIC
EFI_STATUS
DhcpGetParameter (
IN UINT8 Tag,
@@ -323,7 +318,6 @@ DhcpGetParameter (
@retval EFI_INVALID_PARAMETER The options are mal-formated.
**/
-STATIC
EFI_STATUS
DhcpIterateBufferOptions (
IN UINT8 *Buffer,
@@ -468,7 +462,6 @@ DhcpIterateOptions (
@retval EFI_SUCCESS It always returns EFI_SUCCESS.
**/
-STATIC
EFI_STATUS
DhcpGetOptionLen (
IN UINT8 Tag,
@@ -499,7 +492,6 @@ DhcpGetOptionLen (
@retval EFI_SUCCESS It always returns EFI_SUCCESS
**/
-STATIC
EFI_STATUS
DhcpFillOption (
IN UINT8 Tag,
diff --git a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h
index 9db2e0a..d3c596c 100644
--- a/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h
+++ b/MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Option.h
@@ -27,7 +27,7 @@ Abstract:
//
// DHCP option tags (types)
//
-enum {
+typedef enum {
//
// RFC1497 vendor extensions
//
@@ -132,12 +132,12 @@ enum {
DHCP_TAG_T2 = 59, // Rebinding (T2) Time Value
DHCP_TAG_VENDOR_CLASS = 60, // Vendor class identifier
DHCP_TAG_CLIENT_ID = 61 // Client-identifier
-};
+} DHCP_TAGS;
-enum {
- DHCP_OPTION_MAGIC = 0x63538263, // Network byte order
- DHCP_MAX_OPTIONS = 256,
+#define DHCP_OPTION_MAGIC 0x63538263 // Network byte order
+#define DHCP_MAX_OPTIONS 256
+typedef enum {
//
// DHCP option types, this is used to validate the DHCP options.
//
@@ -146,15 +146,17 @@ enum {
DHCP_OPTION_INT16,
DHCP_OPTION_INT32,
DHCP_OPTION_IP,
- DHCP_OPTION_IPPAIR,
+ DHCP_OPTION_IPPAIR
+} DHCP_OPTION_TYPE;
+typedef enum {
//
// Value of DHCP overload option
//
DHCP_OVERLOAD_FILENAME = 1,
DHCP_OVERLOAD_SVRNAME = 2,
DHCP_OVERLOAD_BOTH = 3
-};
+} DHCP_OVERLOAD_TYPE;
//
// The DHCP option structure. This structure extends the EFI_DHCP_OPTION
@@ -225,6 +227,21 @@ EFI_STATUS
IN VOID *Context
);
+/**
+ Iterate through a DHCP message to visit each option. First inspect
+ all the options in the OPTION field. Then if overloaded, inspect
+ the options in FILENAME and SERVERNAME fields. One option may be
+ encoded in several places. See RFC 3396 Encoding Long Options in DHCP
+
+ @param Packet The DHCP packet to check the options for
+ @param Check The callback function to be called for each option
+ found
+ @param Context The opaque parameter for Check
+
+ @retval EFI_SUCCESS The DHCP packet's options are well formated
+ @retval Others The DHCP packet's options are not well formated
+
+**/
EFI_STATUS
DhcpIterateOptions (
IN EFI_DHCP4_PACKET *Packet,
@@ -232,12 +249,51 @@ DhcpIterateOptions (
IN VOID *Context
);
+/**
+ Validate the packet's options. If necessary, allocate
+ and fill in the interested parameters.
+
+ @param Packet The packet to validate the options
+ @param Para The variable to save the DHCP parameters.
+
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory to validate the packet.
+ @retval EFI_INVALID_PARAMETER The options are mal-formated
+ @retval EFI_SUCCESS The options are parsed into OptionPoint
+
+**/
EFI_STATUS
DhcpValidateOptions (
IN EFI_DHCP4_PACKET *Packet,
OUT DHCP_PARAMETER **Para OPTIONAL
);
+/**
+ Parse the options of a DHCP packet. It supports RFC 3396: Encoding
+ Long Options in DHCP. That is, it will combine all the option value
+ of all the occurances of each option.
+ A little bit of implemenation:
+ It adopts the "Key indexed counting" algorithm. First, it allocates
+ an array of 256 DHCP_OPTION_COUNTs because DHCP option tag is encoded
+ as a UINT8. It then iterates the DHCP packet to get data length of
+ each option by calling DhcpIterOptions with DhcpGetOptionLen. Now, it
+ knows the number of present options and their length. It allocates a
+ array of DHCP_OPTION and a continous buffer after the array to put
+ all the options' data. Each option's data is pointed to by the Data
+ field in DHCP_OPTION structure. At last, it call DhcpIterateOptions
+ with DhcpFillOption to fill each option's data to its position in the
+ buffer.
+
+ @param Packet The DHCP packet to parse the options
+ @param Count The number of valid dhcp options present in the
+ packet
+ @param OptionPoint The array that contains the DHCP options. Caller
+ should free it.
+
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory to parse the packet.
+ @retval EFI_INVALID_PARAMETER The options are mal-formated
+ @retval EFI_SUCCESS The options are parsed into OptionPoint
+
+**/
EFI_STATUS
DhcpParseOption (
IN EFI_DHCP4_PACKET *Packet,
@@ -245,6 +301,18 @@ DhcpParseOption (
OUT DHCP_OPTION **OptionPoint
);
+/**
+ Append an option to the memory, if the option is longer than
+ 255 bytes, splits it into several options.
+
+ @param Buf The buffer to append the option to
+ @param Tag The option's tag
+ @param DataLen The length of the option's data
+ @param Data The option's data
+
+ @return The position to append the next option
+
+**/
UINT8 *
DhcpAppendOption (
IN UINT8 *Buf,
@@ -253,6 +321,22 @@ DhcpAppendOption (
IN UINT8 *Data
);
+/**
+ Build a new DHCP packet from a seed packet. Options may be deleted or
+ appended. The caller should free the NewPacket when finished using it.
+
+ @param SeedPacket The seed packet to start with
+ @param DeleteCount The number of options to delete
+ @param DeleteList The options to delete from the packet
+ @param AppendCount The number of options to append
+ @param AppendList The options to append to the packet
+ @param NewPacket The new packet, allocated and built by this
+ function.
+
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate memory
+ @retval EFI_SUCCESS The packet is build.
+
+**/
EFI_STATUS
DhcpBuild (
IN EFI_DHCP4_PACKET *SeedPacket,
diff --git a/MdeModulePkg/Universal/Network/DpcDxe/Dpc.c b/MdeModulePkg/Universal/Network/DpcDxe/Dpc.c
index b6a8261..d75edcd 100644
--- a/MdeModulePkg/Universal/Network/DpcDxe/Dpc.c
+++ b/MdeModulePkg/Universal/Network/DpcDxe/Dpc.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007, Intel Corporation
+Copyright (c) 2007 - 2008, Intel Corporation
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
@@ -299,29 +299,23 @@ DpcDispatchDpc (
return ReturnStatus;
}
+/**
+ The entry point for DPC driver which installs the EFI_DPC_PROTOCOL onto a new handle.
+
+ @param ImageHandle The image handle of the driver.
+ @param SystemTable The system table.
+
+ @retval EFI_SUCCES The DPC queues were initialized and the EFI_DPC_PROTOCOL was
+ installed onto a new handle.
+ @retval Others Failed to install EFI_DPC_PROTOCOL.
+
+**/
EFI_STATUS
EFIAPI
DpcDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
-/*++
-
-Routine Description:
-
- The entry point for DPC driver which installs the EFI_DPC_PROTOCOL onto a new handle.
-
-Arguments:
-
- ImageHandle - The image handle of the driver.
- SystemTable - The system table.
-
-Returns:
-
- EFI_SUCCESS - The DPC queues were initialized and the EFI_DPC_PROTOCOL was
- installed onto a new handle.
-
---*/
{
EFI_STATUS Status;
UINTN Index;
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
index be006a8..736299b 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.c
@@ -24,6 +24,16 @@ Abstract:
IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIABLE];
+/**
+ Callback function when DHCP process finished. It will save the
+ retrieved IP configure parameter from DHCP to the NVRam.
+
+ @param Event The callback event
+ @param Context Opaque context to the callback
+
+ @return None
+
+**/
VOID
EFIAPI
Ip4ConfigOnDhcp4Complete (
@@ -44,7 +54,6 @@ Ip4ConfigOnDhcp4Complete (
@retval EFI_SUCCESS The name or address of the NIC are returned.
**/
-STATIC
EFI_STATUS
EFIAPI
EfiNicIp4ConfigGetName (
@@ -733,7 +742,7 @@ Ip4ConfigCleanDhcp4 (
/**
- Clean up all the configuration parameters
+ Clean up all the configuration parameters.
@param Instance The IP4 configure instance
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
index 4400c8e..46e9f89 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4Config.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -42,18 +42,20 @@ Abstract:
typedef struct _IP4_CONFIG_INSTANCE IP4_CONFIG_INSTANCE;
-enum {
+typedef enum {
IP4_CONFIG_STATE_IDLE = 0,
IP4_CONFIG_STATE_STARTED,
- IP4_CONFIG_STATE_CONFIGURED,
+ IP4_CONFIG_STATE_CONFIGURED
+} IP4_CONFIG_STATE;
- IP4_PROTO_ICMP = 0x01,
- IP4_CONFIG_INSTANCE_SIGNATURE = EFI_SIGNATURE_32 ('I', 'P', '4', 'C'),
+#define IP4_PROTO_ICMP 0x01
+#define IP4_CONFIG_INSTANCE_SIGNATURE EFI_SIGNATURE_32 ('I', 'P', '4', 'C')
+typedef enum {
DHCP_TAG_PARA_LIST = 55,
DHCP_TAG_NETMASK = 1,
DHCP_TAG_ROUTER = 3
-};
+} DHCP_TAGS;
//
// Configure the DHCP to request the routers and netmask
@@ -121,11 +123,27 @@ extern IP4_CONFIG_INSTANCE *mIp4ConfigNicList[MAX_IP4_CONFIG_IN_VARIAB
extern EFI_IP4_CONFIG_PROTOCOL mIp4ConfigProtocolTemplate;
extern EFI_NIC_IP4_CONFIG_PROTOCOL mNicIp4ConfigProtocolTemplate;
+/**
+ Release all the DHCP related resources.
+
+ @param This The IP4 configure instance
+
+ @return None
+
+**/
VOID
Ip4ConfigCleanDhcp4 (
IN IP4_CONFIG_INSTANCE *This
);
+/**
+ Clean up all the configuration parameters.
+
+ @param Instance The IP4 configure instance
+
+ @return None
+
+**/
VOID
Ip4ConfigCleanConfig (
IN IP4_CONFIG_INSTANCE *Instance
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
index 7f0149f..34dc96f 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/Ip4ConfigDriver.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2008, Intel Corporation
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
@@ -60,30 +60,22 @@ EfiIp4ConfigUnload (
return NetLibDefaultUnload (ImageHandle);
}
+/**
+ The entry point for IP4 config driver which install the driver
+ binding and component name protocol on its image.
+
+ @param ImageHandle The image handle of the driver.
+ @param SystemTable The system table.
+ @retval EFI_SUCCES All the related protocols are installed on the driver.
+ @retval Others Failed to install protocols.
+
+**/
EFI_STATUS
Ip4ConfigDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
-/*++
-
-Routine Description:
-
- The entry point for IP4 config driver which install the driver
- binding and component name protocol on its image.
-
-Arguments:
-
- ImageHandle - The Image handle of the driver
- SystemTable - The system table
-
-Returns:
-
- EFI_SUCCESS - All the related protocols are installed on the driver
- Others - Failed to install the protocol
-
---*/
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c
index 65c2f84..72c3a72 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.c
@@ -91,7 +91,7 @@ Ip4ConfigIsValid (
/**
- Read the ip4 configure variable from the EFI variable
+ Read the ip4 configure variable from the EFI variable.
None
@@ -186,7 +186,7 @@ ON_ERROR:
**/
EFI_STATUS
Ip4ConfigWriteVariable (
- IN IP4_CONFIG_VARIABLE * Config OPTIONAL
+ IN IP4_CONFIG_VARIABLE *Config OPTIONAL
)
{
EFI_STATUS Status;
diff --git a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
index 953f6ed..4b14627 100644
--- a/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
+++ b/MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
@@ -45,27 +45,81 @@ Abstract:
(((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \
NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len))
+/**
+ Check whether the configure parameter is valid.
+
+ @param NicConfig The configure parameter to check
+
+ @return TRUE if the parameter is valid for the interface, otherwise FALSE.
+
+**/
BOOLEAN
Ip4ConfigIsValid (
IN NIC_IP4_CONFIG_INFO *NicConfig
);
+/**
+ Read the ip4 configure variable from the EFI variable.
+
+ None
+
+ @return The IP4 configure read if it is there and is valid, otherwise NULL
+
+**/
IP4_CONFIG_VARIABLE *
Ip4ConfigReadVariable (
VOID
);
+/**
+ Write the IP4 configure variable to the NVRAM. If Config
+ is NULL, remove the variable.
+
+ @param Config The IP4 configure data to write
+
+ @retval EFI_SUCCESS The variable is written to the NVRam
+ @retval Others Failed to write the variable.
+
+**/
EFI_STATUS
Ip4ConfigWriteVariable (
IN IP4_CONFIG_VARIABLE *Config OPTIONAL
);
+/**
+ Locate the IP4 configure parameters from the variable.If a
+ configuration is found, copy it to a newly allocated block
+ of memory to avoid the alignment problem. Caller should
+ release the memory after use.
+
+ @param Variable The IP4 configure variable to search in
+ @param NicAddr The interface address to check
+
+ @return The point to the NIC's IP4 configure info if it is found
+ @return in the IP4 variable, otherwise NULL.
+
+**/
NIC_IP4_CONFIG_INFO *
Ip4ConfigFindNicVariable (
IN IP4_CONFIG_VARIABLE *Variable,
IN NIC_ADDR *NicAddr
);
+/**
+ Modify the configuration parameter for the NIC in the variable.
+ If Config is NULL, old configuration will be remove from the new
+ variable. Otherwise, append it or replace the old one.
+
+ @param Variable The IP4 variable to change
+ @param NicAddr The interface to search
+ @param Config The new configuration parameter (NULL to remove the old)
+
+ @return The new IP4_CONFIG_VARIABLE variable if the new variable has at
+ @return least one NIC configure and no EFI_OUT_OF_RESOURCES failure.
+ @return Return NULL either because failed to locate memory for new variable
+ @return or the only NIC configure is removed from the Variable.
+
+**/
IP4_CONFIG_VARIABLE *
Ip4ConfigModifyVariable (
IN IP4_CONFIG_VARIABLE *Variable, OPTIONAL