]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Impl.h
Clean codes per ECC.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Dhcp4Dxe / Dhcp4Impl.h
1 /** @file
2
3 Copyright (c) 2006 - 2008, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Dhcp4Impl.h
15
16 Abstract:
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
33 #include <PiDxe.h>
34
35 #include <Protocol/Dhcp4.h>
36 #include <Protocol/Udp4.h>
37
38 #include <Library/DebugLib.h>
39 #include <Library/UefiDriverEntryPoint.h>
40 #include <Library/UefiBootServicesTableLib.h>
41 #include <Library/UefiLib.h>
42 #include <Library/BaseLib.h>
43 #include <Library/NetLib.h>
44
45 typedef struct _DHCP_SERVICE DHCP_SERVICE;
46 typedef struct _DHCP_PROTOCOL DHCP_PROTOCOL;
47
48 #include "Dhcp4Option.h"
49 #include "Dhcp4Io.h"
50
51 #define DHCP_SERVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'H', 'C', 'P')
52 #define DHCP_PROTOCOL_SIGNATURE EFI_SIGNATURE_32 ('d', 'h', 'c', 'p')
53
54 typedef enum {
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,
64 DHCP_DESTORY
65 } DHCP_STATE;
66
67 struct _DHCP_PROTOCOL {
68 UINT32 Signature;
69 EFI_DHCP4_PROTOCOL Dhcp4Protocol;
70 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 UDP_IO_PORT *UdpIo; // The UDP IO used for TransmitReceive.
81 UINT32 Timeout;
82 NET_BUF_QUEUE ResponseQueue;
83 };
84
85 //
86 // DHCP driver is specical in that it is a singleton. Although it
87 // has a service binding, there can be only one active child.
88 //
89 struct _DHCP_SERVICE {
90 UINT32 Signature;
91 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;
92
93 INTN ServiceState; // CONFIGED, UNCONFIGED, and DESTORY
94 BOOLEAN InDestory;
95
96 EFI_HANDLE Controller;
97 EFI_HANDLE Image;
98
99 LIST_ENTRY Children;
100 UINTN NumChildren;
101
102 INTN DhcpState;
103 EFI_STATUS IoStatus; // the result of last user operation
104 UINT32 Xid;
105
106 IP4_ADDR ClientAddr; // lease IP or configured client address
107 IP4_ADDR Netmask;
108 IP4_ADDR ServerAddr;
109
110 EFI_DHCP4_PACKET *LastOffer; // The last received offer
111 EFI_DHCP4_PACKET *Selected;
112 DHCP_PARAMETER *Para;
113
114 UINT32 Lease;
115 UINT32 T1;
116 UINT32 T2;
117 INTN ExtraRefresh; // This refresh is reqested by user
118
119 UDP_IO_PORT *UdpIo; // Udp child receiving all DHCP message
120 UDP_IO_PORT *LeaseIoPort; // Udp child with lease IP
121 NET_BUF *LastPacket; // The last sent packet for retransmission
122 EFI_MAC_ADDRESS Mac;
123 UINT8 HwType;
124 UINT8 HwLen;
125 UINT8 ClientAddressSendOut[16];
126
127 DHCP_PROTOCOL *ActiveChild;
128 EFI_DHCP4_CONFIG_DATA ActiveConfig;
129 UINT32 UserOptionLen;
130
131 //
132 // Timer event and various timer
133 //
134 EFI_EVENT Timer;
135
136 UINT32 PacketToLive; // Retransmission timer for our packets
137 INTN CurRetry;
138 INTN MaxRetries;
139 UINT32 LeaseLife;
140 };
141
142 typedef struct {
143 EFI_DHCP4_PACKET_OPTION **Option;
144 UINT32 OptionCount;
145 UINT32 Index;
146 } DHCP_PARSE_CONTEXT;
147
148 #define DHCP_INSTANCE_FROM_THIS(Proto) \
149 CR ((Proto), DHCP_PROTOCOL, Dhcp4Protocol, DHCP_PROTOCOL_SIGNATURE)
150
151 #define DHCP_SERVICE_FROM_THIS(Sb) \
152 CR ((Sb), DHCP_SERVICE, ServiceBinding, DHCP_SERVICE_SIGNATURE)
153
154 extern EFI_DHCP4_PROTOCOL mDhcp4ProtocolTemplate;
155
156 /**
157 Give up the control of the DHCP service to let other child
158 resume. Don't change the service's DHCP state and the Client
159 address and option list configure as required by RFC2131.
160
161 @param DhcpSb The DHCP service instance.
162
163 @return None
164
165 **/
166 VOID
167 DhcpYieldControl (
168 IN DHCP_SERVICE *DhcpSb
169 );
170
171 VOID
172 PxeDhcpDone (
173 IN DHCP_PROTOCOL *Instance
174 );
175
176 #endif