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