2 This file contains an 'Intel UEFI Application' and is
3 licensed for Intel CPUs and chipsets under the terms of your
4 license agreement with Intel or your vendor. This file may
5 be modified by the user, subject to additional terms of the
10 Copyright (c) 2011 Intel Corporation. All rights reserved
11 This software and associated documentation (if any) is furnished
12 under a license and may only be used or copied in accordance
13 with the terms of the license. Except as permitted by such
14 license, no part of this software or documentation may be
15 reproduced, stored in a retrieval system, or transmitted in any
16 form or by any means without the express written consent of
22 Display the DHCP options
26 #include <WebServer.h>
27 #include <Guid/DxeServices.h>
28 #include <pi/PiDxeCis.h>
30 #include <protocol/Dhcp4.h>
31 #include <protocol/ServiceBinding.h>
34 Respond with the DHCP options
36 @param [in] SocketFD The socket's file descriptor to add to the list.
37 @param [in] pPort The WSDT_PORT structure address
38 @param [out] pbDone Address to receive the request completion status
40 @retval EFI_SUCCESS The request was successfully processed
50 // EFI_HANDLE Dhcp4Handle;
51 EFI_DHCP4_MODE_DATA Dhcp4Mode
;
53 EFI_DHCP4_PROTOCOL
* pDhcp4
;
54 EFI_DHCP4_PACKET
* pDhcp4Packet
;
57 // EFI_SERVICE_BINDING_PROTOCOL * pService;
63 // Send the DHCP options
67 // Send the page header
69 Status
= HttpPageHeader ( SocketFD
, pPort
, L
"DHCP Options" );
70 if ( EFI_ERROR ( Status
)) {
77 Status
= HttpSendAnsiString ( SocketFD
,
80 if ( EFI_ERROR ( Status
)) {
83 Status
= HttpSendUnicodeString ( SocketFD
,
86 if ( EFI_ERROR ( Status
)) {
89 Status
= HttpSendAnsiString ( SocketFD
,
92 if ( EFI_ERROR ( Status
)) {
97 // Attempt to locate DHCP clients
99 Status
= gBS
->LocateHandleBuffer ( ByProtocol
,
100 // &gEfiDhcp4ServiceBindingProtocolGuid,
101 &gEfiDhcp4ProtocolGuid
,
105 if ( EFI_ERROR ( Status
)) {
106 Status
= HttpSendAnsiString ( SocketFD
,
109 if ( EFI_ERROR ( Status
)) {
115 // Walk the list of handles
117 pEnd
= &pHandle
[ HandleCount
];
118 while ( pEnd
> pHandle
) {
121 // Get the DHCP service binding
123 Status = gBS->OpenProtocol ( *pHandle,
124 &gEfiDhcp4ServiceBindingProtocolGuid,
128 EFI_OPEN_PROTOCOL_GET_PROTOCOL );
129 if ( EFI_ERROR ( Status )) {
130 Status = HttpSendAnsiString ( SocketFD,
132 "Failed to open gEfiDhcp4ServiceBindingProtocolGuid" );
137 // Get the DHCP handle
139 Status = pService->CreateChild ( pService,
141 if ( EFI_ERROR ( Status )) {
142 Status = HttpSendAnsiString ( SocketFD,
144 "Failed to create DHCP4 child" );
149 // Get the DHCP protocol
151 Status
= gBS
->OpenProtocol ( *pHandle
,
153 &gEfiDhcp4ProtocolGuid
,
157 EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
158 if ( EFI_ERROR ( Status
)) {
159 Status
= HttpSendAnsiString ( SocketFD
,
161 "Failed to open gEfiDhcp4ProtocolGuid" );
165 // Get the DHCP packet
167 Status
= pDhcp4
->GetModeData ( pDhcp4
,
169 if ( EFI_ERROR ( Status
)) {
170 Status
= HttpSendAnsiString ( SocketFD
,
172 "Failed to get DHCP4 mode" );
176 // Get the last packet
178 pDhcp4Packet
= Dhcp4Mode
.ReplyPacket
;
179 if ( NULL
== pDhcp4Packet
) {
180 Status
= HttpSendAnsiString ( SocketFD
,
182 "No DHCP reply received!<br/>DHCP Mode:<br/>" );
183 if ( EFI_ERROR ( Status
)) {
188 // Display the DHCP mode data
190 Status
= HttpSendDump ( SocketFD
,
192 sizeof ( Dhcp4Mode
),
193 (UINT8
*)&Dhcp4Mode
);
197 // Display the DHCP packet
199 Status
= HttpSendDump ( SocketFD
,
201 pDhcp4Packet
->Length
,
202 (UINT8
*)&pDhcp4Packet
->Dhcp4
);
209 // Done with the DHCP protocol
211 pService->DestroyChild ( pService,
217 // Set the next service binding
224 // Send the page trailer
226 Status
= HttpPageTrailer ( SocketFD
, pPort
, pbDone
);
231 // Return the operation status
233 DBG_EXIT_STATUS ( Status
);