TianoCore EDK2 master
Loading...
Searching...
No Matches
PxeBcDhcp4.h
Go to the documentation of this file.
1
10#ifndef __EFI_PXEBC_DHCP4_H__
11#define __EFI_PXEBC_DHCP4_H__
12
13#define PXEBC_DHCP4_OPTION_MAX_NUM 16
14#define PXEBC_DHCP4_OPTION_MAX_SIZE 312
15#define PXEBC_DHCP4_PACKET_MAX_SIZE (sizeof (EFI_PXE_BASE_CODE_PACKET))
16#define PXEBC_DHCP4_S_PORT 67
17#define PXEBC_DHCP4_C_PORT 68
18#define PXEBC_BS_DOWNLOAD_PORT 69
19#define PXEBC_BS_DISCOVER_PORT 4011
20#define PXEBC_DHCP4_OPCODE_REQUEST 1
21#define PXEBC_DHCP4_OPCODE_REPLY 2
22#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
23#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
24
25//
26// Sub-Options in Dhcp Vendor Option
27//
28#define PXEBC_VENDOR_TAG_MTFTP_IP 1
29#define PXEBC_VENDOR_TAG_MTFTP_CPORT 2
30#define PXEBC_VENDOR_TAG_MTFTP_SPORT 3
31#define PXEBC_VENDOR_TAG_MTFTP_TIMEOUT 4
32#define PXEBC_VENDOR_TAG_MTFTP_DELAY 5
33#define PXEBC_VENDOR_TAG_DISCOVER_CTRL 6
34#define PXEBC_VENDOR_TAG_DISCOVER_MCAST 7
35#define PXEBC_VENDOR_TAG_BOOT_SERVERS 8
36#define PXEBC_VENDOR_TAG_BOOT_MENU 9
37#define PXEBC_VENDOR_TAG_MENU_PROMPT 10
38#define PXEBC_VENDOR_TAG_MCAST_ALLOC 11
39#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12
40#define PXEBC_VENDOR_TAG_BOOT_ITEM 71
41
42#define PXEBC_BOOT_REQUEST_TIMEOUT 1
43#define PXEBC_BOOT_REQUEST_RETRIES 4
44
45#define PXEBC_DHCP4_OVERLOAD_FILE 1
46#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
47
48//
49// The array index of the DHCP4 option tag interested
50//
51#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
52#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
53#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
54#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
55#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
56#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
57#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
58#define PXEBC_DHCP4_TAG_INDEX_MAX 7
59
60//
61// Dhcp4 and Dhcp6 share this definition, and corresponding
62// relationship is as follows:
63//
64// Dhcp4Discover <> Dhcp6Solicit
65// Dhcp4Offer <> Dhcp6Advertise
66// Dhcp4Request <> Dhcp6Request
67// Dhcp4Ack <> DHcp6Reply
68//
69typedef enum {
70 PxeOfferTypeDhcpOnly,
71 PxeOfferTypeDhcpPxe10,
72 PxeOfferTypeDhcpWfm11a,
73 PxeOfferTypeDhcpBinl,
74 PxeOfferTypeProxyPxe10,
75 PxeOfferTypeProxyWfm11a,
76 PxeOfferTypeProxyBinl,
77 PxeOfferTypeBootp,
78 PxeOfferTypeMax
79} PXEBC_OFFER_TYPE;
80
81#define BIT(x) (1 << x)
82#define CTRL(x) (0x1F & (x))
83#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
84#define DEFAULT_UNDI_TYPE 1
85#define DEFAULT_UNDI_MAJOR 3
86#define DEFAULT_UNDI_MINOR 0
87
88#define MTFTP_VENDOR_OPTION_BIT_MAP \
89 (BIT (PXEBC_VENDOR_TAG_MTFTP_IP) | \
90 BIT (PXEBC_VENDOR_TAG_MTFTP_CPORT) | \
91 BIT (PXEBC_VENDOR_TAG_MTFTP_SPORT) | \
92 BIT (PXEBC_VENDOR_TAG_MTFTP_TIMEOUT) | \
93 BIT (PXEBC_VENDOR_TAG_MTFTP_DELAY))
94
95#define DISCOVER_VENDOR_OPTION_BIT_MAP \
96 (BIT (PXEBC_VENDOR_TAG_DISCOVER_CTRL) | \
97 BIT (PXEBC_VENDOR_TAG_DISCOVER_MCAST) | \
98 BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS) | \
99 BIT (PXEBC_VENDOR_TAG_BOOT_MENU) | \
100 BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
101
102#define IS_VALID_BOOT_SERVERS(x) \
103 ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS)) \
104 == BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS))
105
106#define IS_VALID_BOOT_PROMPT(x) \
107 ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) \
108 == BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
109
110#define IS_VALID_BOOT_MENU(x) \
111 ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_MENU)) \
112 == BIT (PXEBC_VENDOR_TAG_BOOT_MENU))
113
114#define IS_VALID_MTFTP_VENDOR_OPTION(x) \
115 (((UINT32) ((x)[0]) & MTFTP_VENDOR_OPTION_BIT_MAP) \
116 == MTFTP_VENDOR_OPTION_BIT_MAP)
117
118#define IS_VALID_DISCOVER_VENDOR_OPTION(x) \
119 (((UINT32) ((x)[0]) & DISCOVER_VENDOR_OPTION_BIT_MAP) != 0)
120
121#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \
122 (((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) \
123 == BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES))
124
125#define IS_VALID_BOOTITEM_VENDOR_OPTION(x) \
126 (((UINT32) ((x)[PXEBC_VENDOR_TAG_BOOT_ITEM / 32]) & \
127 BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32)) \
128 == BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32))
129
130#define SET_VENDOR_OPTION_BIT_MAP(x, y) \
131 (*(x + ((y) / 32)) = (UINT32) ((UINT32) ((x)[(y) / 32]) | BIT ((y) % 32)))
132
133#define GET_NEXT_DHCP_OPTION(Opt) \
134 (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
135 sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
136
137#define GET_OPTION_BUFFER_LEN(Pkt) \
138 ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
139
140#define GET_NEXT_BOOT_SVR_ENTRY(Ent) \
141 (PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + \
142 ((Ent)->IpCnt - 1) * sizeof (EFI_IPv4_ADDRESS))
143
144#define IS_PROXY_DHCP_OFFER(Offer) \
145 EFI_IP4_EQUAL (&(Offer)->Dhcp4.Header.YourAddr, &mZeroIp4Addr)
146
147#define IS_DISABLE_BCAST_DISCOVER(x) \
148 (((x) & BIT (0)) == BIT (0))
149
150#define IS_DISABLE_MCAST_DISCOVER(x) \
151 (((x) & BIT (1)) == BIT (1))
152
153#define IS_ENABLE_USE_SERVER_LIST(x) \
154 (((x) & BIT (2)) == BIT (2))
155
156#define IS_DISABLE_PROMPT_MENU(x) \
157 (((x) & BIT (3)) == BIT (3))
158
159#pragma pack(1)
160typedef struct {
161 UINT8 ParaList[135];
163
164typedef struct {
165 UINT16 Size;
167
168typedef struct {
169 UINT8 Type;
170 UINT8 MajorVer;
171 UINT8 MinorVer;
173
174typedef struct {
175 UINT8 Type;
177
178typedef struct {
179 UINT16 Type;
181
182typedef struct {
183 UINT8 ClassIdentifier[10];
184 UINT8 ArchitecturePrefix[5];
185 UINT8 ArchitectureType[5];
186 UINT8 Lit3[1];
187 UINT8 InterfaceName[4];
188 UINT8 Lit4[1];
189 UINT8 UndiMajor[3];
190 UINT8 UndiMinor[3];
192
193typedef struct {
194 UINT8 Type;
195 UINT8 Guid[16];
197
198typedef struct {
199 UINT16 Type;
200 UINT16 Layer;
202
203#pragma pack()
204
205typedef union {
214
215#pragma pack(1)
216typedef struct {
217 UINT16 Type;
218 UINT8 IpCnt;
219 EFI_IPv4_ADDRESS IpAddr[1];
221
222typedef struct {
223 UINT16 Type;
224 UINT8 DescLen;
225 UINT8 DescStr[1];
227
228typedef struct {
229 UINT8 Timeout;
230 UINT8 Prompt[1];
232#pragma pack()
233
234typedef struct {
235 UINT32 BitMap[8];
236 EFI_IPv4_ADDRESS MtftpIp;
237 UINT16 MtftpCPort;
238 UINT16 MtftpSPort;
239 UINT8 MtftpTimeout;
240 UINT8 MtftpDelay;
241 UINT8 DiscoverCtrl;
242 EFI_IPv4_ADDRESS DiscoverMcastIp;
243 EFI_IPv4_ADDRESS McastIpBase;
244 UINT16 McastIpBlock;
245 UINT16 McastIpRange;
246 UINT16 BootSrvType;
247 UINT16 BootSrvLayer;
248 PXEBC_BOOT_SVR_ENTRY *BootSvr;
249 UINT8 BootSvrLen;
250 PXEBC_BOOT_MENU_ENTRY *BootMenu;
251 UINT8 BootMenuLen;
252 PXEBC_MENU_PROMPT *MenuPrompt;
253 UINT8 MenuPromptLen;
254 UINT32 *CredType;
255 UINT8 CredTypeLen;
257
258#define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_PACKET_MAX_SIZE)
259
260typedef union {
261 EFI_DHCP4_PACKET Offer;
263 UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE];
265
266typedef struct {
267 PXEBC_DHCP4_PACKET Packet;
268 PXEBC_OFFER_TYPE OfferType;
269 EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_TAG_INDEX_MAX];
270 PXEBC_VENDOR_OPTION VendorOpt;
272
280VOID
282 OUT EFI_DHCP4_PACKET *Seed,
284 );
285
298 );
299
319 IN PXEBC_PRIVATE_DATA *Private,
320 IN UINT16 Type,
321 IN UINT16 *Layer,
322 IN BOOLEAN UseBis,
323 IN EFI_IP_ADDRESS *DestIp,
324 IN UINT16 IpCount,
326 );
327
339 IN PXEBC_PRIVATE_DATA *Private
340 );
341
354 IN PXEBC_PRIVATE_DATA *Private,
356 );
357
358#endif
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS PxeBcDhcp4Discover(IN PXEBC_PRIVATE_DATA *Private, IN UINT16 Type, IN UINT16 *Layer, IN BOOLEAN UseBis, IN EFI_IP_ADDRESS *DestIp, IN UINT16 IpCount, IN EFI_PXE_BASE_CODE_SRVLIST *SrvList)
Definition: PxeBcDhcp4.c:1355
EFI_STATUS PxeBcSetIp4Policy(IN PXEBC_PRIVATE_DATA *Private)
Definition: PxeBcDhcp4.c:1609
VOID PxeBcSeedDhcp4Packet(OUT EFI_DHCP4_PACKET *Seed, IN EFI_UDP4_PROTOCOL *Udp4)
Definition: PxeBcDhcp4.c:383
EFI_STATUS PxeBcDhcp4Dora(IN PXEBC_PRIVATE_DATA *Private, IN EFI_DHCP4_PROTOCOL *Dhcp4)
Definition: PxeBcDhcp4.c:1657
EFI_STATUS PxeBcParseDhcp4Packet(IN PXEBC_DHCP4_PACKET_CACHE *Cache4)
Definition: PxeBcDhcp4.c:445
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29