Update to support to produce Component Name and & Component Name 2 protocol based on Feature flag PcdComponentNameDisable & PcdComponentName2Disable.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4006 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qhuang8
2007-09-30 03:08:02 +00:00
parent 5bca971e54
commit 83cbd279b6
68 changed files with 11129 additions and 9421 deletions

View File

@@ -24,6 +24,45 @@ Abstract:
//
// EFI Component Name Functions
//
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
DhcpComponentNameGetDriverName (
@@ -32,6 +71,75 @@ DhcpComponentNameGetDriverName (
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
DhcpComponentNameGetControllerName (
@@ -42,18 +150,29 @@ DhcpComponentNameGetControllerName (
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName = {
EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName = {
DhcpComponentNameGetDriverName,
DhcpComponentNameGetControllerName,
"eng"
};
};
//
// EFI Component Name 2 Protocol
//
EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) DhcpComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) DhcpComponentNameGetControllerName,
"en"
};
static EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
{
"eng",
"eng;en",
L"DHCP Protocol Driver"
},
{
@@ -62,6 +181,45 @@ static EFI_UNICODE_STRING_TABLE mDhcpDriverNameTable[] = {
}
};
/**
Retrieves a Unicode string that is the user readable name of the driver.
This function retrieves the user readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 3066 or ISO 639-2 language code format.
@param DriverName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
DhcpComponentNameGetDriverName (
@@ -69,41 +227,84 @@ DhcpComponentNameGetDriverName (
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
/*++
Routine Description:
Retrieves a Unicode string that is the user readable name of the EFI Driver.
Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
Language - A pointer to a three character ISO 639-2 language identifier.
This is the language of the driver name that that the caller
is requesting, and it must match one of the languages specified
in SupportedLanguages. The number of languages supported by a
driver is up to the driver writer.
DriverName - A pointer to the Unicode string to return. This Unicode string
is the name of the driver specified by This in the language
specified by Language.
Returns:
EFI_SUCCES - The Unicode string for the Driver specified by This
and the language specified by Language was returned
in DriverName.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - DriverName is NULL.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
{
return LookupUnicodeString (
Language,
gDhcp4ComponentName.SupportedLanguages,
mDhcpDriverNameTable,
DriverName
);
return LookupUnicodeString2 (
Language,
This->SupportedLanguages,
mDhcpDriverNameTable,
DriverName,
(BOOLEAN)(This == &gDhcp4ComponentName)
);
}
/**
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by a driver.
This function retrieves the user readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param ControllerHandle[in] The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param ChildHandle[in] The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param Language[in] A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 3066 or ISO 639-2 language code format.
@param ControllerName[out] A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
@retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
EFI_HANDLE.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER ControllerName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
DhcpComponentNameGetControllerName (
@@ -113,50 +314,6 @@ DhcpComponentNameGetControllerName (
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
/*++
Routine Description:
Retrieves a Unicode string that is the user readable name of the controller
that is being managed by an EFI Driver.
Arguments:
This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
ControllerHandle - The handle of a controller that the driver specified by
This is managing. This handle specifies the controller
whose name is to be returned.
ChildHandle - The handle of the child controller to retrieve the name
of. This is an optional parameter that may be NULL. It
will be NULL for device drivers. It will also be NULL
for a bus drivers that wish to retrieve the name of the
bus controller. It will not be NULL for a bus driver
that wishes to retrieve the name of a child controller.
Language - A pointer to a three character ISO 639-2 language
identifier. This is the language of the controller name
that that the caller is requesting, and it must match one
of the languages specified in SupportedLanguages. The
number of languages supported by a driver is up to the
driver writer.
ControllerName - A pointer to the Unicode string to return. This Unicode
string is the name of the controller specified by
ControllerHandle and ChildHandle in the language
specified by Language from the point of view of the
driver specified by This.
Returns:
EFI_SUCCESS - The Unicode string for the user readable name in the
language specified by Language for the driver
specified by This was returned in DriverName.
EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - ChildHandle isn't NULL and isn't a valid EFI_HANDLE.
EFI_INVALID_PARAMETER - Language is NULL.
EFI_INVALID_PARAMETER - ControllerName is NULL.
EFI_UNSUPPORTED - The driver specified by This is not currently
managing the controller specified by
ControllerHandle and ChildHandle.
EFI_UNSUPPORTED - The driver specified by This does not support the
language specified by Language.
--*/
{
return EFI_UNSUPPORTED;
}

View File

@@ -61,14 +61,13 @@ Returns:
--*/
{
return EfiLibInstallAllDriverProtocols (
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gDhcp4DriverBinding,
ImageHandle,
&gDhcp4ComponentName,
NULL,
NULL
&gDhcp4ComponentName2
);
}

View File

@@ -1,67 +1,68 @@
/** @file
Copyright (c) 2006 - 2007, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Driver.h
Abstract:
Header for the DHCP4 driver
**/
#ifndef __EFI_DHCP4_DRIVER_H__
#define __EFI_DHCP4_DRIVER_H__
extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName;
EFI_STATUS
EFIAPI
Dhcp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE *ChildHandle
);
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
);
#endif
/** @file
Copyright (c) 2006 - 2007, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Driver.h
Abstract:
Header for the DHCP4 driver
**/
#ifndef __EFI_DHCP4_DRIVER_H__
#define __EFI_DHCP4_DRIVER_H__
extern EFI_COMPONENT_NAME_PROTOCOL gDhcp4ComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gDhcp4ComponentName2;
EFI_STATUS
EFIAPI
Dhcp4DriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
EFI_STATUS
EFIAPI
Dhcp4DriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingCreateChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE *ChildHandle
);
EFI_STATUS
EFIAPI
Dhcp4ServiceBindingDestroyChild (
IN EFI_SERVICE_BINDING_PROTOCOL *This,
IN EFI_HANDLE ChildHandle
);
#endif

View File

@@ -1,34 +1,34 @@
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Impl.h
Abstract:
EFI DHCP protocol implementation
RFCs supported are:
RFC 2131: Dynamic Host Configuration Protocol
RFC 2132: DHCP Options and BOOTP Vendor Extensions
RFC 1534: Interoperation Between DHCP and BOOTP
RFC 3396: Encoding Long Options in DHCP
**/
#ifndef __EFI_DHCP4_IMPL_H__
#define __EFI_DHCP4_IMPL_H__
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Impl.h
Abstract:
EFI DHCP protocol implementation
RFCs supported are:
RFC 2131: Dynamic Host Configuration Protocol
RFC 2132: DHCP Options and BOOTP Vendor Extensions
RFC 1534: Interoperation Between DHCP and BOOTP
RFC 3396: Encoding Long Options in DHCP
**/
#ifndef __EFI_DHCP4_IMPL_H__
#define __EFI_DHCP4_IMPL_H__
#include <PiDxe.h>
@@ -39,121 +39,121 @@ Abstract:
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/NetLib.h>
typedef struct _DHCP_SERVICE DHCP_SERVICE;
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'),
//
// The state of the DHCP service. It starts as UNCONFIGED. If
// and active child configures the service successfully, it
// goes to CONFIGED. If the active child configures NULL, it
// goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
// destoried.
//
DHCP_UNCONFIGED = 0,
DHCP_CONFIGED,
DHCP_DESTORY
};
struct _DHCP_PROTOCOL {
UINT32 Signature;
EFI_DHCP4_PROTOCOL Dhcp4Protocol;
NET_LIST_ENTRY Link;
EFI_HANDLE Handle;
DHCP_SERVICE *Service;
BOOLEAN InDestory;
EFI_EVENT CompletionEvent;
EFI_EVENT RenewRebindEvent;
EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
};
//
// DHCP driver is specical in that it is a singleton. Although it
// has a service binding, there can be only one active child.
//
struct _DHCP_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
BOOLEAN InDestory;
EFI_HANDLE Controller;
EFI_HANDLE Image;
NET_LIST_ENTRY Children;
UINTN NumChildren;
INTN DhcpState;
EFI_STATUS IoStatus; // the result of last user operation
UINT32 Xid;
IP4_ADDR ClientAddr; // lease IP or configured client address
IP4_ADDR Netmask;
IP4_ADDR ServerAddr;
EFI_DHCP4_PACKET *LastOffer; // The last received offer
EFI_DHCP4_PACKET *Selected;
DHCP_PARAMETER *Para;
UINT32 Lease;
UINT32 T1;
UINT32 T2;
INTN ExtraRefresh; // This refresh is reqested by user
UDP_IO_PORT *UdpIo; // Udp child receiving all DHCP message
UDP_IO_PORT *LeaseIoPort; // Udp child with lease IP
NET_BUF *LastPacket; // The last sent packet for retransmission
EFI_MAC_ADDRESS Mac;
UINT8 HwType;
UINT8 HwLen;
DHCP_PROTOCOL *ActiveChild;
EFI_DHCP4_CONFIG_DATA ActiveConfig;
UINT32 UserOptionLen;
//
// Timer event and various timer
//
EFI_EVENT Timer;
UINT32 PacketToLive; // Retransmission timer for our packets
INTN CurRetry;
INTN MaxRetries;
UINT32 WaitOffer; // Time to collect the offers
UINT32 LeaseLife;
};
typedef struct {
EFI_DHCP4_PACKET_OPTION **Option;
UINT32 OptionCount;
UINT32 Index;
} DHCP_PARSE_CONTEXT;
#define DHCP_INSTANCE_FROM_THIS(Proto) \
CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
#define DHCP_SERVICE_FROM_THIS(Sb) \
CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
VOID
DhcpYieldControl (
IN DHCP_SERVICE *DhcpSb
);
#endif
#include <Library/BaseLib.h>
#include <Library/NetLib.h>
typedef struct _DHCP_SERVICE DHCP_SERVICE;
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'),
//
// The state of the DHCP service. It starts as UNCONFIGED. If
// and active child configures the service successfully, it
// goes to CONFIGED. If the active child configures NULL, it
// goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
// destoried.
//
DHCP_UNCONFIGED = 0,
DHCP_CONFIGED,
DHCP_DESTORY
};
struct _DHCP_PROTOCOL {
UINT32 Signature;
EFI_DHCP4_PROTOCOL Dhcp4Protocol;
NET_LIST_ENTRY Link;
EFI_HANDLE Handle;
DHCP_SERVICE *Service;
BOOLEAN InDestory;
EFI_EVENT CompletionEvent;
EFI_EVENT RenewRebindEvent;
EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
};
//
// DHCP driver is specical in that it is a singleton. Although it
// has a service binding, there can be only one active child.
//
struct _DHCP_SERVICE {
UINT32 Signature;
EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
BOOLEAN InDestory;
EFI_HANDLE Controller;
EFI_HANDLE Image;
NET_LIST_ENTRY Children;
UINTN NumChildren;
INTN DhcpState;
EFI_STATUS IoStatus; // the result of last user operation
UINT32 Xid;
IP4_ADDR ClientAddr; // lease IP or configured client address
IP4_ADDR Netmask;
IP4_ADDR ServerAddr;
EFI_DHCP4_PACKET *LastOffer; // The last received offer
EFI_DHCP4_PACKET *Selected;
DHCP_PARAMETER *Para;
UINT32 Lease;
UINT32 T1;
UINT32 T2;
INTN ExtraRefresh; // This refresh is reqested by user
UDP_IO_PORT *UdpIo; // Udp child receiving all DHCP message
UDP_IO_PORT *LeaseIoPort; // Udp child with lease IP
NET_BUF *LastPacket; // The last sent packet for retransmission
EFI_MAC_ADDRESS Mac;
UINT8 HwType;
UINT8 HwLen;
DHCP_PROTOCOL *ActiveChild;
EFI_DHCP4_CONFIG_DATA ActiveConfig;
UINT32 UserOptionLen;
//
// Timer event and various timer
//
EFI_EVENT Timer;
UINT32 PacketToLive; // Retransmission timer for our packets
INTN CurRetry;
INTN MaxRetries;
UINT32 WaitOffer; // Time to collect the offers
UINT32 LeaseLife;
};
typedef struct {
EFI_DHCP4_PACKET_OPTION **Option;
UINT32 OptionCount;
UINT32 Index;
} DHCP_PARSE_CONTEXT;
#define DHCP_INSTANCE_FROM_THIS(Proto) \
CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
#define DHCP_SERVICE_FROM_THIS(Sb) \
CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
VOID
DhcpYieldControl (
IN DHCP_SERVICE *DhcpSb
);
#endif

View File

@@ -1,115 +1,115 @@
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Io.h
Abstract:
The DHCP4 protocol implementation.
**/
#ifndef __EFI_DHCP4_IO_H__
#define __EFI_DHCP4_IO_H__
#include <PiDxe.h>
#include <Protocol/ServiceBinding.h>
#include <Library/NetLib.h>
#include <Library/UdpIoLib.h>
#include <Library/BaseMemoryLib.h>
#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,
//
// BOOTP header "op" field
//
BOOTP_REQUEST = 1,
BOOTP_REPLY = 2,
//
// DHCP message types
//
DHCP_MSG_DISCOVER = 1,
DHCP_MSG_OFFER = 2,
DHCP_MSG_REQUEST = 3,
DHCP_MSG_DECLINE = 4,
DHCP_MSG_ACK = 5,
DHCP_MSG_NAK = 6,
DHCP_MSG_RELEASE = 7,
DHCP_MSG_INFORM = 8,
//
// DHCP notify user type
//
DHCP_NOTIFY_COMPLETION = 1,
DHCP_NOTIFY_RENEWREBIND,
DHCP_NOTIFY_ALL
};
#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
#define DHCP_CONNECTED(State) \
(((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
EFI_STATUS
DhcpSetState (
IN DHCP_SERVICE *DhcpSb,
IN INTN State,
IN BOOLEAN CallUser
);
EFI_STATUS
DhcpSendMessage (
IN DHCP_SERVICE *DhcpSb,
IN EFI_DHCP4_PACKET *Seed,
IN DHCP_PARAMETER *Para,
IN UINT8 Type,
IN UINT8 *Msg
);
VOID
EFIAPI
DhcpOnTimerTick (
IN EFI_EVENT Event,
IN VOID *Context
);
VOID
DhcpInput (
NET_BUF *UdpPacket,
UDP_POINTS *Points,
EFI_STATUS IoStatus,
VOID *Context
);
EFI_STATUS
DhcpInitRequest (
IN DHCP_SERVICE *DhcpSb
);
VOID
DhcpCleanLease (
IN DHCP_SERVICE *DhcpSb
);
#endif
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Io.h
Abstract:
The DHCP4 protocol implementation.
**/
#ifndef __EFI_DHCP4_IO_H__
#define __EFI_DHCP4_IO_H__
#include <PiDxe.h>
#include <Protocol/ServiceBinding.h>
#include <Library/NetLib.h>
#include <Library/UdpIoLib.h>
#include <Library/BaseMemoryLib.h>
#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,
//
// BOOTP header "op" field
//
BOOTP_REQUEST = 1,
BOOTP_REPLY = 2,
//
// DHCP message types
//
DHCP_MSG_DISCOVER = 1,
DHCP_MSG_OFFER = 2,
DHCP_MSG_REQUEST = 3,
DHCP_MSG_DECLINE = 4,
DHCP_MSG_ACK = 5,
DHCP_MSG_NAK = 6,
DHCP_MSG_RELEASE = 7,
DHCP_MSG_INFORM = 8,
//
// DHCP notify user type
//
DHCP_NOTIFY_COMPLETION = 1,
DHCP_NOTIFY_RENEWREBIND,
DHCP_NOTIFY_ALL
};
#define DHCP_IS_BOOTP(Parameter) (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
#define DHCP_CONNECTED(State) \
(((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
EFI_STATUS
DhcpSetState (
IN DHCP_SERVICE *DhcpSb,
IN INTN State,
IN BOOLEAN CallUser
);
EFI_STATUS
DhcpSendMessage (
IN DHCP_SERVICE *DhcpSb,
IN EFI_DHCP4_PACKET *Seed,
IN DHCP_PARAMETER *Para,
IN UINT8 Type,
IN UINT8 *Msg
);
VOID
EFIAPI
DhcpOnTimerTick (
IN EFI_EVENT Event,
IN VOID *Context
);
VOID
DhcpInput (
NET_BUF *UdpPacket,
UDP_POINTS *Points,
EFI_STATUS IoStatus,
VOID *Context
);
EFI_STATUS
DhcpInitRequest (
IN DHCP_SERVICE *DhcpSb
);
VOID
DhcpCleanLease (
IN DHCP_SERVICE *DhcpSb
);
#endif

View File

@@ -1,266 +1,266 @@
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Option.h
Abstract:
To validate, parse and process the DHCP options
**/
#ifndef __EFI_DHCP4_OPTION_H__
#define __EFI_DHCP4_OPTION_H__
//
// DHCP option tags (types)
//
enum {
//
// RFC1497 vendor extensions
//
DHCP_TAG_PAD = 0, // Pad Option
DHCP_TAG_EOP = 255, // End Option
DHCP_TAG_NETMASK = 1, // Subnet Mask
DHCP_TAG_TIME_OFFSET = 2, // Time Offset from UTC
DHCP_TAG_ROUTER = 3, // Router option,
DHCP_TAG_TIME_SERVER = 4, // Time Server
DHCP_TAG_NAME_SERVER = 5, // Name Server
DHCP_TAG_DNS_SERVER = 6, // Domain Name Server
DHCP_TAG_LOG_SERVER = 7, // Log Server
DHCP_TAG_COOKIE_SERVER = 8, // Cookie Server
DHCP_TAG_LPR_SERVER = 9, // LPR Print Server
DHCP_TAG_IMPRESS_SERVER = 10, // Impress Server
DHCP_TAG_RL_SERVER = 11, // Resource Location Server
DHCP_TAG_HOSTNAME = 12, // Host Name
DHCP_TAG_BOOTFILE_LEN = 13, // Boot File Size
DHCP_TAG_DUMP = 14, // Merit Dump File
DHCP_TAG_DOMAINNAME = 15, // Domain Name
DHCP_TAG_SWAP_SERVER = 16, // Swap Server
DHCP_TAG_ROOTPATH = 17, // Root path
DHCP_TAG_EXTEND_PATH = 18, // Extensions Path
//
// IP Layer Parameters per Host
//
DHCP_TAG_IPFORWARD = 19, // IP Forwarding Enable/Disable
DHCP_TAG_NONLOCAL_SRR = 20, // on-Local Source Routing Enable/Disable
DHCP_TAG_POLICY_SRR = 21, // Policy Filter
DHCP_TAG_EMTU = 22, // Maximum Datagram Reassembly Size
DHCP_TAG_TTL = 23, // Default IP Time-to-live
DHCP_TAG_PATHMTU_AGE = 24, // Path MTU Aging Timeout
DHCP_TAG_PATHMTU_PLATEAU = 25, // Path MTU Plateau Table
//
// IP Layer Parameters per Interface
//
DHCP_TAG_IFMTU = 26, // Interface MTU
DHCP_TAG_SUBNET_LOCAL = 27, // All Subnets are Local
DHCP_TAG_BROADCAST = 28, // Broadcast Address
DHCP_TAG_DISCOVER_MASK = 29, // Perform Mask Discovery
DHCP_TAG_SUPPLY_MASK = 30, // Mask Supplier
DHCP_TAG_DISCOVER_ROUTE = 31, // Perform Router Discovery
DHCP_TAG_ROUTER_SOLICIT = 32, // Router Solicitation Address
DHCP_TAG_STATIC_ROUTE = 33, // Static Route
//
// Link Layer Parameters per Interface
//
DHCP_TAG_TRAILER = 34, // Trailer Encapsulation
DHCP_TAG_ARPAGE = 35, // ARP Cache Timeout
DHCP_TAG_ETHER_ENCAP = 36, // Ethernet Encapsulation
//
// TCP Parameters
//
DHCP_TAG_TCP_TTL = 37, // TCP Default TTL
DHCP_TAG_KEEP_INTERVAL = 38, // TCP Keepalive Interval
DHCP_TAG_KEEP_GARBAGE = 39, // TCP Keepalive Garbage
//
// Application and Service Parameters
//
DHCP_TAG_NIS_DOMAIN = 40, // Network Information Service Domain
DHCP_TAG_NIS_SERVER = 41, // Network Information Servers
DHCP_TAG_NTP_SERVER = 42, // Network Time Protocol Servers
DHCP_TAG_VENDOR = 43, // Vendor Specific Information
DHCP_TAG_NBNS = 44, // NetBIOS over TCP/IP Name Server
DHCP_TAG_NBDD = 45, // NetBIOS Datagram Distribution Server
DHCP_TAG_NBTYPE = 46, // NetBIOS over TCP/IP Node Type
DHCP_TAG_NBSCOPE = 47, // NetBIOS over TCP/IP Scope
DHCP_TAG_XFONT = 48, // X Window System Font Server
DHCP_TAG_XDM = 49, // X Window System Display Manager
DHCP_TAG_NISPLUS = 64, // Network Information Service+ Domain
DHCP_TAG_NISPLUS_SERVER = 65, // Network Information Service+ Servers
DHCP_TAG_MOBILEIP = 68, // Mobile IP Home Agent
DHCP_TAG_SMTP = 69, // Simple Mail Transport Protocol Server
DHCP_TAG_POP3 = 70, // Post Office Protocol (POP3) Server
DHCP_TAG_NNTP = 71, // Network News Transport Protocol Server
DHCP_TAG_WWW = 72, // Default World Wide Web (WWW) Server
DHCP_TAG_FINGER = 73, // Default Finger Server
DHCP_TAG_IRC = 74, // Default Internet Relay Chat (IRC) Server
DHCP_TAG_STTALK = 75, // StreetTalk Server
DHCP_TAG_STDA = 76, // StreetTalk Directory Assistance Server
DHCP_TAG_CLASSLESS_ROUTE = 121, // Classless Route
//
// DHCP Extensions
//
DHCP_TAG_REQUEST_IP = 50, // Requested IP Address
DHCP_TAG_LEASE = 51, // IP Address Lease Time
DHCP_TAG_OVERLOAD = 52, // Option Overload
DHCP_TAG_TFTP = 66, // TFTP server name
DHCP_TAG_BOOTFILE = 67, // Bootfile name
DHCP_TAG_TYPE = 53, // DHCP Message Type
DHCP_TAG_SERVER_ID = 54, // Server Identifier
DHCP_TAG_PARA_LIST = 55, // Parameter Request List
DHCP_TAG_MESSAGE = 56, // Message
DHCP_TAG_MAXMSG = 57, // Maximum DHCP Message Size
DHCP_TAG_T1 = 58, // Renewal (T1) Time Value
DHCP_TAG_T2 = 59, // Rebinding (T2) Time Value
DHCP_TAG_VENDOR_CLASS = 60, // Vendor class identifier
DHCP_TAG_CLIENT_ID = 61 // Client-identifier
};
enum {
DHCP_OPTION_MAGIC = 0x63538263, // Network byte order
DHCP_MAX_OPTIONS = 256,
//
// DHCP option types, this is used to validate the DHCP options.
//
DHCP_OPTION_SWITCH = 1,
DHCP_OPTION_INT8,
DHCP_OPTION_INT16,
DHCP_OPTION_INT32,
DHCP_OPTION_IP,
DHCP_OPTION_IPPAIR,
//
// Value of DHCP overload option
//
DHCP_OVERLOAD_FILENAME = 1,
DHCP_OVERLOAD_SVRNAME = 2,
DHCP_OVERLOAD_BOTH = 3
};
//
// The DHCP option structure. This structure extends the EFI_DHCP_OPTION
// structure to support options longer than 255 bytes, such as classless route.
//
typedef struct {
UINT8 Tag;
UINT16 Len;
UINT8 *Data;
} DHCP_OPTION;
//
// Structures used to parse the DHCP options with RFC3396 support.
//
typedef struct {
UINT8 Index;
UINT16 Offset;
} DHCP_OPTION_COUNT;
typedef struct {
DHCP_OPTION_COUNT *OpCount;
DHCP_OPTION *Options;
UINT8 *Buf;
} DHCP_OPTION_CONTEXT;
//
// The options that matters to DHCP driver itself. The user of
// DHCP clients may be interested in other options, such as
// classless route, who can parse the DHCP offer to get them.
//
typedef struct {
IP4_ADDR NetMask; // DHCP_TAG_NETMASK
IP4_ADDR Router; // DHCP_TAG_ROUTER, only the first router is used
//
// DHCP specific options
//
UINT8 DhcpType; // DHCP_TAG_TYPE
UINT8 Overload; // DHCP_TAG_OVERLOAD
IP4_ADDR ServerId; // DHCP_TAG_SERVER_ID
UINT32 Lease; // DHCP_TAG_LEASE
UINT32 T1; // DHCP_TAG_T1
UINT32 T2; // DHCP_TAG_T2
} DHCP_PARAMETER;
//
// Structure used to describe and validate the format of DHCP options.
// Type is the options' data type, such as DHCP_OPTION_INT8. MinOccur
// is the minium occurance of this data type. MaxOccur is defined
// similarly. If MaxOccur is -1, it means that there is no limit on the
// maximum occurance. Alert tells whether DHCP client should further
// inspect the option to parse DHCP_PARAMETER.
//
typedef struct {
UINT8 Tag;
INTN Type;
INTN MinOccur;
INTN MaxOccur;
BOOLEAN Alert;
} DHCP_OPTION_FORMAT;
typedef
EFI_STATUS
(*DHCP_CHECK_OPTION) (
IN UINT8 Tag,
IN UINT8 Len,
IN UINT8 *Data,
IN VOID *Context
);
EFI_STATUS
DhcpIterateOptions (
IN EFI_DHCP4_PACKET *Packet,
IN DHCP_CHECK_OPTION Check, OPTIONAL
IN VOID *Context
);
EFI_STATUS
DhcpValidateOptions (
IN EFI_DHCP4_PACKET *Packet,
OUT DHCP_PARAMETER **Para OPTIONAL
);
EFI_STATUS
DhcpParseOption (
IN EFI_DHCP4_PACKET *Packet,
OUT INTN *Count,
OUT DHCP_OPTION **OptionPoint
);
UINT8 *
DhcpAppendOption (
IN UINT8 *Buf,
IN UINT8 Tag,
IN UINT16 DataLen,
IN UINT8 *Data
);
EFI_STATUS
DhcpBuild (
IN EFI_DHCP4_PACKET *SeedPacket,
IN UINT32 DeleteCount,
IN UINT8 *DeleteList OPTIONAL,
IN UINT32 AppendCount,
IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
OUT EFI_DHCP4_PACKET **NewPacket
);
#endif
/** @file
Copyright (c) 2006, 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Dhcp4Option.h
Abstract:
To validate, parse and process the DHCP options
**/
#ifndef __EFI_DHCP4_OPTION_H__
#define __EFI_DHCP4_OPTION_H__
//
// DHCP option tags (types)
//
enum {
//
// RFC1497 vendor extensions
//
DHCP_TAG_PAD = 0, // Pad Option
DHCP_TAG_EOP = 255, // End Option
DHCP_TAG_NETMASK = 1, // Subnet Mask
DHCP_TAG_TIME_OFFSET = 2, // Time Offset from UTC
DHCP_TAG_ROUTER = 3, // Router option,
DHCP_TAG_TIME_SERVER = 4, // Time Server
DHCP_TAG_NAME_SERVER = 5, // Name Server
DHCP_TAG_DNS_SERVER = 6, // Domain Name Server
DHCP_TAG_LOG_SERVER = 7, // Log Server
DHCP_TAG_COOKIE_SERVER = 8, // Cookie Server
DHCP_TAG_LPR_SERVER = 9, // LPR Print Server
DHCP_TAG_IMPRESS_SERVER = 10, // Impress Server
DHCP_TAG_RL_SERVER = 11, // Resource Location Server
DHCP_TAG_HOSTNAME = 12, // Host Name
DHCP_TAG_BOOTFILE_LEN = 13, // Boot File Size
DHCP_TAG_DUMP = 14, // Merit Dump File
DHCP_TAG_DOMAINNAME = 15, // Domain Name
DHCP_TAG_SWAP_SERVER = 16, // Swap Server
DHCP_TAG_ROOTPATH = 17, // Root path
DHCP_TAG_EXTEND_PATH = 18, // Extensions Path
//
// IP Layer Parameters per Host
//
DHCP_TAG_IPFORWARD = 19, // IP Forwarding Enable/Disable
DHCP_TAG_NONLOCAL_SRR = 20, // on-Local Source Routing Enable/Disable
DHCP_TAG_POLICY_SRR = 21, // Policy Filter
DHCP_TAG_EMTU = 22, // Maximum Datagram Reassembly Size
DHCP_TAG_TTL = 23, // Default IP Time-to-live
DHCP_TAG_PATHMTU_AGE = 24, // Path MTU Aging Timeout
DHCP_TAG_PATHMTU_PLATEAU = 25, // Path MTU Plateau Table
//
// IP Layer Parameters per Interface
//
DHCP_TAG_IFMTU = 26, // Interface MTU
DHCP_TAG_SUBNET_LOCAL = 27, // All Subnets are Local
DHCP_TAG_BROADCAST = 28, // Broadcast Address
DHCP_TAG_DISCOVER_MASK = 29, // Perform Mask Discovery
DHCP_TAG_SUPPLY_MASK = 30, // Mask Supplier
DHCP_TAG_DISCOVER_ROUTE = 31, // Perform Router Discovery
DHCP_TAG_ROUTER_SOLICIT = 32, // Router Solicitation Address
DHCP_TAG_STATIC_ROUTE = 33, // Static Route
//
// Link Layer Parameters per Interface
//
DHCP_TAG_TRAILER = 34, // Trailer Encapsulation
DHCP_TAG_ARPAGE = 35, // ARP Cache Timeout
DHCP_TAG_ETHER_ENCAP = 36, // Ethernet Encapsulation
//
// TCP Parameters
//
DHCP_TAG_TCP_TTL = 37, // TCP Default TTL
DHCP_TAG_KEEP_INTERVAL = 38, // TCP Keepalive Interval
DHCP_TAG_KEEP_GARBAGE = 39, // TCP Keepalive Garbage
//
// Application and Service Parameters
//
DHCP_TAG_NIS_DOMAIN = 40, // Network Information Service Domain
DHCP_TAG_NIS_SERVER = 41, // Network Information Servers
DHCP_TAG_NTP_SERVER = 42, // Network Time Protocol Servers
DHCP_TAG_VENDOR = 43, // Vendor Specific Information
DHCP_TAG_NBNS = 44, // NetBIOS over TCP/IP Name Server
DHCP_TAG_NBDD = 45, // NetBIOS Datagram Distribution Server
DHCP_TAG_NBTYPE = 46, // NetBIOS over TCP/IP Node Type
DHCP_TAG_NBSCOPE = 47, // NetBIOS over TCP/IP Scope
DHCP_TAG_XFONT = 48, // X Window System Font Server
DHCP_TAG_XDM = 49, // X Window System Display Manager
DHCP_TAG_NISPLUS = 64, // Network Information Service+ Domain
DHCP_TAG_NISPLUS_SERVER = 65, // Network Information Service+ Servers
DHCP_TAG_MOBILEIP = 68, // Mobile IP Home Agent
DHCP_TAG_SMTP = 69, // Simple Mail Transport Protocol Server
DHCP_TAG_POP3 = 70, // Post Office Protocol (POP3) Server
DHCP_TAG_NNTP = 71, // Network News Transport Protocol Server
DHCP_TAG_WWW = 72, // Default World Wide Web (WWW) Server
DHCP_TAG_FINGER = 73, // Default Finger Server
DHCP_TAG_IRC = 74, // Default Internet Relay Chat (IRC) Server
DHCP_TAG_STTALK = 75, // StreetTalk Server
DHCP_TAG_STDA = 76, // StreetTalk Directory Assistance Server
DHCP_TAG_CLASSLESS_ROUTE = 121, // Classless Route
//
// DHCP Extensions
//
DHCP_TAG_REQUEST_IP = 50, // Requested IP Address
DHCP_TAG_LEASE = 51, // IP Address Lease Time
DHCP_TAG_OVERLOAD = 52, // Option Overload
DHCP_TAG_TFTP = 66, // TFTP server name
DHCP_TAG_BOOTFILE = 67, // Bootfile name
DHCP_TAG_TYPE = 53, // DHCP Message Type
DHCP_TAG_SERVER_ID = 54, // Server Identifier
DHCP_TAG_PARA_LIST = 55, // Parameter Request List
DHCP_TAG_MESSAGE = 56, // Message
DHCP_TAG_MAXMSG = 57, // Maximum DHCP Message Size
DHCP_TAG_T1 = 58, // Renewal (T1) Time Value
DHCP_TAG_T2 = 59, // Rebinding (T2) Time Value
DHCP_TAG_VENDOR_CLASS = 60, // Vendor class identifier
DHCP_TAG_CLIENT_ID = 61 // Client-identifier
};
enum {
DHCP_OPTION_MAGIC = 0x63538263, // Network byte order
DHCP_MAX_OPTIONS = 256,
//
// DHCP option types, this is used to validate the DHCP options.
//
DHCP_OPTION_SWITCH = 1,
DHCP_OPTION_INT8,
DHCP_OPTION_INT16,
DHCP_OPTION_INT32,
DHCP_OPTION_IP,
DHCP_OPTION_IPPAIR,
//
// Value of DHCP overload option
//
DHCP_OVERLOAD_FILENAME = 1,
DHCP_OVERLOAD_SVRNAME = 2,
DHCP_OVERLOAD_BOTH = 3
};
//
// The DHCP option structure. This structure extends the EFI_DHCP_OPTION
// structure to support options longer than 255 bytes, such as classless route.
//
typedef struct {
UINT8 Tag;
UINT16 Len;
UINT8 *Data;
} DHCP_OPTION;
//
// Structures used to parse the DHCP options with RFC3396 support.
//
typedef struct {
UINT8 Index;
UINT16 Offset;
} DHCP_OPTION_COUNT;
typedef struct {
DHCP_OPTION_COUNT *OpCount;
DHCP_OPTION *Options;
UINT8 *Buf;
} DHCP_OPTION_CONTEXT;
//
// The options that matters to DHCP driver itself. The user of
// DHCP clients may be interested in other options, such as
// classless route, who can parse the DHCP offer to get them.
//
typedef struct {
IP4_ADDR NetMask; // DHCP_TAG_NETMASK
IP4_ADDR Router; // DHCP_TAG_ROUTER, only the first router is used
//
// DHCP specific options
//
UINT8 DhcpType; // DHCP_TAG_TYPE
UINT8 Overload; // DHCP_TAG_OVERLOAD
IP4_ADDR ServerId; // DHCP_TAG_SERVER_ID
UINT32 Lease; // DHCP_TAG_LEASE
UINT32 T1; // DHCP_TAG_T1
UINT32 T2; // DHCP_TAG_T2
} DHCP_PARAMETER;
//
// Structure used to describe and validate the format of DHCP options.
// Type is the options' data type, such as DHCP_OPTION_INT8. MinOccur
// is the minium occurance of this data type. MaxOccur is defined
// similarly. If MaxOccur is -1, it means that there is no limit on the
// maximum occurance. Alert tells whether DHCP client should further
// inspect the option to parse DHCP_PARAMETER.
//
typedef struct {
UINT8 Tag;
INTN Type;
INTN MinOccur;
INTN MaxOccur;
BOOLEAN Alert;
} DHCP_OPTION_FORMAT;
typedef
EFI_STATUS
(*DHCP_CHECK_OPTION) (
IN UINT8 Tag,
IN UINT8 Len,
IN UINT8 *Data,
IN VOID *Context
);
EFI_STATUS
DhcpIterateOptions (
IN EFI_DHCP4_PACKET *Packet,
IN DHCP_CHECK_OPTION Check, OPTIONAL
IN VOID *Context
);
EFI_STATUS
DhcpValidateOptions (
IN EFI_DHCP4_PACKET *Packet,
OUT DHCP_PARAMETER **Para OPTIONAL
);
EFI_STATUS
DhcpParseOption (
IN EFI_DHCP4_PACKET *Packet,
OUT INTN *Count,
OUT DHCP_OPTION **OptionPoint
);
UINT8 *
DhcpAppendOption (
IN UINT8 *Buf,
IN UINT8 Tag,
IN UINT16 DataLen,
IN UINT8 *Data
);
EFI_STATUS
DhcpBuild (
IN EFI_DHCP4_PACKET *SeedPacket,
IN UINT32 DeleteCount,
IN UINT8 *DeleteList OPTIONAL,
IN UINT32 AppendCount,
IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
OUT EFI_DHCP4_PACKET **NewPacket
);
#endif