]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
1. Sync the latest network stack. Add NetLibCreateIPv4DPathNode () in netlib library.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.h
CommitLineData
772db4bb 1/** @file
2
3Copyright (c) 2006, Intel Corporation
4All rights reserved. This program and the accompanying materials
5are licensed and made available under the terms and conditions of the BSD License
6which accompanies this distribution. The full text of the license may be found at
7http://opensource.org/licenses/bsd-license.php
8
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12Module Name:
13
14 Dhcp4Impl.h
15
16Abstract:
17
18 EFI DHCP protocol implementation
19 RFCs supported are:
20 RFC 2131: Dynamic Host Configuration Protocol
21 RFC 2132: DHCP Options and BOOTP Vendor Extensions
22 RFC 1534: Interoperation Between DHCP and BOOTP
23 RFC 3396: Encoding Long Options in DHCP
24
25
26**/
27
28#ifndef __EFI_DHCP4_IMPL_H__
29#define __EFI_DHCP4_IMPL_H__
30
31
32\r
33#include <PiDxe.h>\r
34\r
35#include <Protocol/Dhcp4.h>\r
36#include <Protocol/Udp4.h>\r
37\r
38#include <Library/DebugLib.h>\r
39#include <Library/UefiDriverEntryPoint.h>\r
40#include <Library/UefiBootServicesTableLib.h>\r
41#include <Library/UefiLib.h>\r
42#include <Library/BaseLib.h>
43#include <Library/NetLib.h>
44
45typedef struct _DHCP_SERVICE DHCP_SERVICE;
46typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
47
48#include "Dhcp4Option.h"
49#include "Dhcp4Io.h"
50
51enum {
52 DHCP_SERVICE_SIGNATURE = EFI_SIGNATURE_32 ('D', 'H', 'C', 'P'),
53 DHCP_PROTOCOL_SIGNATURE = EFI_SIGNATURE_32 ('d', 'h', 'c', 'p'),
54
55 //
56 // The state of the DHCP service. It starts as UNCONFIGED. If
57 // and active child configures the service successfully, it
58 // goes to CONFIGED. If the active child configures NULL, it
59 // goes back to UNCONFIGED. It becomes DESTORY if it is (partly)
60 // destoried.
61 //
62 DHCP_UNCONFIGED = 0,
63 DHCP_CONFIGED,
687a2e5f 64 DHCP_DESTORY
772db4bb 65};
66
687a2e5f 67struct _DHCP_PROTOCOL {
772db4bb 68 UINT32 Signature;
69 EFI_DHCP4_PROTOCOL Dhcp4Protocol;
70 NET_LIST_ENTRY Link;
71 EFI_HANDLE Handle;
72 DHCP_SERVICE *Service;
73
74 BOOLEAN InDestory;
75
76 EFI_EVENT CompletionEvent;
77 EFI_EVENT RenewRebindEvent;
78
79 EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token;
80};
81
82//
83// DHCP driver is specical in that it is a singleton. Although it
84// has a service binding, there can be only one active child.
85//
687a2e5f 86struct _DHCP_SERVICE {
772db4bb 87 UINT32 Signature;
88 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
89
90 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
91 BOOLEAN InDestory;
92
93 EFI_HANDLE Controller;
94 EFI_HANDLE Image;
95
96 NET_LIST_ENTRY Children;
97 UINTN NumChildren;
98
99 INTN DhcpState;
100 EFI_STATUS IoStatus; // the result of last user operation
101 UINT32 Xid;
102
103 IP4_ADDR ClientAddr; // lease IP or configured client address
104 IP4_ADDR Netmask;
105 IP4_ADDR ServerAddr;
106
107 EFI_DHCP4_PACKET *LastOffer; // The last received offer
108 EFI_DHCP4_PACKET *Selected;
109 DHCP_PARAMETER *Para;
110
111 UINT32 Lease;
112 UINT32 T1;
113 UINT32 T2;
114 INTN ExtraRefresh; // This refresh is reqested by user
115
116 UDP_IO_PORT *UdpIo; // Udp child receiving all DHCP message
117 UDP_IO_PORT *LeaseIoPort; // Udp child with lease IP
118 NET_BUF *LastPacket; // The last sent packet for retransmission
119 EFI_MAC_ADDRESS Mac;
120 UINT8 HwType;
121 UINT8 HwLen;
122
123 DHCP_PROTOCOL *ActiveChild;
124 EFI_DHCP4_CONFIG_DATA ActiveConfig;
125 UINT32 UserOptionLen;
126
127 //
128 // Timer event and various timer
129 //
130 EFI_EVENT Timer;
131
132 UINT32 PacketToLive; // Retransmission timer for our packets
133 INTN CurRetry;
134 INTN MaxRetries;
135
136 UINT32 WaitOffer; // Time to collect the offers
137 UINT32 LeaseLife;
138};
139
140typedef struct {
141 EFI_DHCP4_PACKET_OPTION **Option;
142 UINT32 OptionCount;
143 UINT32 Index;
144} DHCP_PARSE_CONTEXT;
145
146#define DHCP_INSTANCE_FROM_THIS(Proto) \
147 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
148
149#define DHCP_SERVICE_FROM_THIS(Sb) \
150 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
151
152extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
153
154VOID
155DhcpYieldControl (
156 IN DHCP_SERVICE *DhcpSb
157 );
158
159#endif