TianoCore EDK2 master
Loading...
Searching...
No Matches
Dhcp4Io.h File Reference

Go to the source code of this file.

Macros

#define DHCP_WAIT_OFFER   3
 
#define DHCP_DEFAULT_LEASE   7 * 24 * 60 * 60
 
#define DHCP_SERVER_PORT   67
 
#define DHCP_CLIENT_PORT   68
 
#define BOOTP_REQUEST   1
 
#define BOOTP_REPLY   2
 
#define DHCP_MSG_DISCOVER   1
 
#define DHCP_MSG_OFFER   2
 
#define DHCP_MSG_REQUEST   3
 
#define DHCP_MSG_DECLINE   4
 
#define DHCP_MSG_ACK   5
 
#define DHCP_MSG_NAK   6
 
#define DHCP_MSG_RELEASE   7
 
#define DHCP_MSG_INFORM   8
 
#define DHCP_NOTIFY_COMPLETION   1
 
#define DHCP_NOTIFY_RENEWREBIND   2
 
#define DHCP_NOTIFY_ALL   3
 
#define DHCP_IS_BOOTP(Parameter)   (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))
 
#define DHCP_CONNECTED(State)    (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))
 

Functions

EFI_STATUS DhcpSetState (IN OUT 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 EFIAPI DhcpInput (NET_BUF *UdpPacket, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
 
EFI_STATUS DhcpInitRequest (IN DHCP_SERVICE *DhcpSb)
 
VOID DhcpCleanLease (IN DHCP_SERVICE *DhcpSb)
 
VOID EFIAPI DhcpOnPacketSent (NET_BUF *Packet, UDP_END_POINT *EndPoint, EFI_STATUS IoStatus, VOID *Context)
 

Detailed Description

The DHCP4 protocol implementation.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Dhcp4Io.h.

Macro Definition Documentation

◆ BOOTP_REPLY

#define BOOTP_REPLY   2

Definition at line 30 of file Dhcp4Io.h.

◆ BOOTP_REQUEST

#define BOOTP_REQUEST   1

Definition at line 29 of file Dhcp4Io.h.

◆ DHCP_CLIENT_PORT

#define DHCP_CLIENT_PORT   68

Definition at line 24 of file Dhcp4Io.h.

◆ DHCP_CONNECTED

#define DHCP_CONNECTED (   State)     (((State) == Dhcp4Bound) || ((State) == (Dhcp4Renewing)) || ((State) == Dhcp4Rebinding))

Definition at line 53 of file Dhcp4Io.h.

◆ DHCP_DEFAULT_LEASE

#define DHCP_DEFAULT_LEASE   7 * 24 * 60 * 60

Definition at line 22 of file Dhcp4Io.h.

◆ DHCP_IS_BOOTP

#define DHCP_IS_BOOTP (   Parameter)    (((Parameter) == NULL) || ((Parameter)->DhcpType == 0))

Definition at line 51 of file Dhcp4Io.h.

◆ DHCP_MSG_ACK

#define DHCP_MSG_ACK   5

Definition at line 39 of file Dhcp4Io.h.

◆ DHCP_MSG_DECLINE

#define DHCP_MSG_DECLINE   4

Definition at line 38 of file Dhcp4Io.h.

◆ DHCP_MSG_DISCOVER

#define DHCP_MSG_DISCOVER   1

Definition at line 35 of file Dhcp4Io.h.

◆ DHCP_MSG_INFORM

#define DHCP_MSG_INFORM   8

Definition at line 42 of file Dhcp4Io.h.

◆ DHCP_MSG_NAK

#define DHCP_MSG_NAK   6

Definition at line 40 of file Dhcp4Io.h.

◆ DHCP_MSG_OFFER

#define DHCP_MSG_OFFER   2

Definition at line 36 of file Dhcp4Io.h.

◆ DHCP_MSG_RELEASE

#define DHCP_MSG_RELEASE   7

Definition at line 41 of file Dhcp4Io.h.

◆ DHCP_MSG_REQUEST

#define DHCP_MSG_REQUEST   3

Definition at line 37 of file Dhcp4Io.h.

◆ DHCP_NOTIFY_ALL

#define DHCP_NOTIFY_ALL   3

Definition at line 49 of file Dhcp4Io.h.

◆ DHCP_NOTIFY_COMPLETION

#define DHCP_NOTIFY_COMPLETION   1

Definition at line 47 of file Dhcp4Io.h.

◆ DHCP_NOTIFY_RENEWREBIND

#define DHCP_NOTIFY_RENEWREBIND   2

Definition at line 48 of file Dhcp4Io.h.

◆ DHCP_SERVER_PORT

#define DHCP_SERVER_PORT   67

Definition at line 23 of file Dhcp4Io.h.

◆ DHCP_WAIT_OFFER

#define DHCP_WAIT_OFFER   3

Definition at line 21 of file Dhcp4Io.h.

Function Documentation

◆ DhcpCleanLease()

VOID DhcpCleanLease ( IN DHCP_SERVICE DhcpSb)

Clean up the DHCP related states, IoStatus isn't reset.

Parameters
DhcpSbThe DHCP instance service.

Definition at line 424 of file Dhcp4Io.c.

◆ DhcpInitRequest()

EFI_STATUS DhcpInitRequest ( IN DHCP_SERVICE DhcpSb)

Send an initial DISCOVER or REQUEST message according to the DHCP service's current state.

Parameters
[in]DhcpSbThe DHCP service instance
Return values
EFI_SUCCESSThe request has been sent
otherSome error occurs when sending the request.

Definition at line 24 of file Dhcp4Io.c.

◆ DhcpInput()

VOID EFIAPI DhcpInput ( NET_BUF UdpPacket,
UDP_END_POINT EndPoint,
EFI_STATUS  IoStatus,
VOID *  Context 
)

Handle the received DHCP packets. This function drives the DHCP state machine.

Parameters
UdpPacketThe UDP packets received.
EndPointThe local/remote UDP access point
IoStatusThe status of the UDP receive
ContextThe opaque parameter to the function.

Definition at line 927 of file Dhcp4Io.c.

◆ DhcpOnPacketSent()

VOID EFIAPI DhcpOnPacketSent ( NET_BUF Packet,
UDP_END_POINT EndPoint,
EFI_STATUS  IoStatus,
VOID *  Context 
)

Release the net buffer when packet is sent.

Parameters
UdpPacketThe UDP packets received.
EndPointThe local/remote UDP access point
IoStatusThe status of the UDP receive
ContextThe opaque parameter to the function.

Definition at line 1084 of file Dhcp4Io.c.

◆ DhcpOnTimerTick()

VOID EFIAPI DhcpOnTimerTick ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

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 increments 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.

Parameters
[in]EventThe timer event
[in]ContextThe context, which is the DHCP service instance.

Definition at line 1459 of file Dhcp4Io.c.

◆ DhcpSendMessage()

EFI_STATUS DhcpSendMessage ( IN DHCP_SERVICE DhcpSb,
IN EFI_DHCP4_PACKET Seed,
IN DHCP_PARAMETER Para,
IN UINT8  Type,
IN UINT8 *  Msg 
)

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.

Parameters
[in]DhcpSbThe DHCP service instance
[in]SeedThe seed packet which the new packet is based on
[in]ParaThe DHCP parameter of the Seed packet
[in]TypeThe message type to send
[in]MsgThe human readable message to include in the packet sent.
Return values
EFI_OUT_OF_RESOURCESFailed to allocate resources for the packet
EFI_ACCESS_DENIEDFailed to transmit the packet through UDP
EFI_SUCCESSThe message is sent
otherOther error occurs

Definition at line 1114 of file Dhcp4Io.c.

◆ DhcpSetState()

EFI_STATUS DhcpSetState ( IN OUT DHCP_SERVICE DhcpSb,
IN INTN  State,
IN BOOLEAN  CallUser 
)

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.

Parameters
DhcpSbThe DHCP service instance
StateThe new DHCP state to change to
CallUserWhether we need to call user
Return values
EFI_SUCCESSThe state is changed
EFI_ABORTEDThe user asks to abort the DHCP process.

Definition at line 179 of file Dhcp4Io.c.