2007-09-30 05:08:02 +02:00
|
|
|
/** @file
|
2009-01-16 01:09:52 +01:00
|
|
|
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.
|
|
|
|
|
2009-06-08 04:13:36 +02:00
|
|
|
Copyright (c) 2006 - 2009, Intel Corporation.<BR>
|
2007-09-30 05:08:02 +02:00
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#ifndef __EFI_DHCP4_IMPL_H__
|
|
|
|
#define __EFI_DHCP4_IMPL_H__
|
|
|
|
|
|
|
|
|
2007-07-30 04:37:10 +02:00
|
|
|
|
2009-02-09 03:59:07 +01:00
|
|
|
#include <Uefi.h>
|
2007-07-30 04:37:10 +02:00
|
|
|
|
|
|
|
#include <Protocol/Dhcp4.h>
|
|
|
|
#include <Protocol/Udp4.h>
|
|
|
|
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiDriverEntryPoint.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/UefiLib.h>
|
2007-09-30 05:08:02 +02:00
|
|
|
#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"
|
|
|
|
|
2008-12-16 16:34:21 +01:00
|
|
|
#define DHCP_SERVICE_SIGNATURE SIGNATURE_32 ('D', 'H', 'C', 'P')
|
|
|
|
#define DHCP_PROTOCOL_SIGNATURE SIGNATURE_32 ('d', 'h', 'c', 'p')
|
2007-09-30 05:08:02 +02:00
|
|
|
|
2008-06-30 09:20:33 +02:00
|
|
|
typedef enum {
|
2007-09-30 05:08:02 +02:00
|
|
|
//
|
|
|
|
// 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
|
2008-06-30 09:20:33 +02:00
|
|
|
} DHCP_STATE;
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
struct _DHCP_PROTOCOL {
|
|
|
|
UINT32 Signature;
|
|
|
|
EFI_DHCP4_PROTOCOL Dhcp4Protocol;
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY Link;
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_HANDLE Handle;
|
|
|
|
DHCP_SERVICE *Service;
|
|
|
|
|
|
|
|
BOOLEAN InDestory;
|
|
|
|
|
|
|
|
EFI_EVENT CompletionEvent;
|
|
|
|
EFI_EVENT RenewRebindEvent;
|
|
|
|
|
|
|
|
EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
|
2007-12-18 08:01:23 +01:00
|
|
|
UDP_IO_PORT *UdpIo; // The UDP IO used for TransmitReceive.
|
|
|
|
UINT32 Timeout;
|
|
|
|
NET_BUF_QUEUE ResponseQueue;
|
2007-09-30 05:08:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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;
|
|
|
|
|
2008-02-14 10:40:22 +01:00
|
|
|
LIST_ENTRY Children;
|
2007-09-30 05:08:02 +02:00
|
|
|
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
|
2009-06-08 04:13:36 +02:00
|
|
|
EFI_DHCP4_PACKET *LastPacket; // The last sent packet for retransmission
|
2007-09-30 05:08:02 +02:00
|
|
|
EFI_MAC_ADDRESS Mac;
|
|
|
|
UINT8 HwType;
|
|
|
|
UINT8 HwLen;
|
2008-04-02 10:45:36 +02:00
|
|
|
UINT8 ClientAddressSendOut[16];
|
2007-09-30 05:08:02 +02:00
|
|
|
|
|
|
|
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
|
2009-06-08 04:13:36 +02:00
|
|
|
UINT32 LastTimeout; // Record the init value of PacketToLive every time
|
2007-09-30 05:08:02 +02:00
|
|
|
INTN CurRetry;
|
|
|
|
INTN MaxRetries;
|
|
|
|
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;
|
|
|
|
|
2008-06-30 09:20:33 +02:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
|
|
|
|
**/
|
2007-09-30 05:08:02 +02:00
|
|
|
VOID
|
|
|
|
DhcpYieldControl (
|
2008-11-18 15:30:46 +01:00
|
|
|
IN DHCP_SERVICE *DhcpSb
|
2007-09-30 05:08:02 +02:00
|
|
|
);
|
|
|
|
|
2008-11-18 15:30:46 +01:00
|
|
|
/**
|
|
|
|
Complete a Dhcp4 transaction and signal the upper layer.
|
|
|
|
|
|
|
|
@param Instance Dhcp4 instance.
|
|
|
|
|
|
|
|
**/
|
2007-12-18 08:01:23 +01:00
|
|
|
VOID
|
|
|
|
PxeDhcpDone (
|
|
|
|
IN DHCP_PROTOCOL *Instance
|
|
|
|
);
|
|
|
|
|
2007-09-30 05:08:02 +02:00
|
|
|
#endif
|