-/**
- @file
- Display the DHCP options
-
- Copyright (c) 2011-2012, Intel Corporation
- All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
- http://opensource.org/licenses/bsd-license.php
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <WebServer.h>
-#include <Guid/DxeServices.h>
-#include <pi/PiDxeCis.h>
-
-#include <protocol/Dhcp4.h>
-#include <protocol/ServiceBinding.h>
-
-/**
- Respond with the DHCP options
-
- @param [in] SocketFD The socket's file descriptor to add to the list.
- @param [in] pPort The WSDT_PORT structure address
- @param [out] pbDone Address to receive the request completion status
-
- @retval EFI_SUCCESS The request was successfully processed
-
-**/
-EFI_STATUS
-DhcpOptionsPage (
- IN int SocketFD,
- IN WSDT_PORT * pPort,
- OUT BOOLEAN * pbDone
- )
-{
-// EFI_HANDLE Dhcp4Handle;
- EFI_DHCP4_MODE_DATA Dhcp4Mode;
- UINTN HandleCount;
- EFI_DHCP4_PROTOCOL * pDhcp4;
- EFI_DHCP4_PACKET * pDhcp4Packet;
- EFI_HANDLE * pEnd;
- EFI_HANDLE * pHandle;
-// EFI_SERVICE_BINDING_PROTOCOL * pService;
- EFI_STATUS Status;
-
- DBG_ENTER ( );
-
- //
- // Send the DHCP options
- //
- for ( ; ; ) {
- //
- // Send the page header
- //
- Status = HttpPageHeader ( SocketFD, pPort, L"DHCP Options" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
-
- //
- // Build the header
- //
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "<h1>" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
- Status = HttpSendUnicodeString ( SocketFD,
- pPort,
- L"DHCP Options" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "</h1>\r\n" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
-
- //
- // Attempt to locate DHCP clients
- //
- Status = gBS->LocateHandleBuffer ( ByProtocol,
-// &gEfiDhcp4ServiceBindingProtocolGuid,
- &gEfiDhcp4ProtocolGuid,
- NULL,
- &HandleCount,
- &pHandle );
- if ( EFI_ERROR ( Status )) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "DHCP not in use" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
- }
- else {
- //
- // Walk the list of handles
- //
- pEnd = &pHandle [ HandleCount ];
- while ( pEnd > pHandle ) {
-/*
- //
- // Get the DHCP service binding
- //
- Status = gBS->OpenProtocol ( *pHandle,
- &gEfiDhcp4ServiceBindingProtocolGuid,
- &pService,
- NULL,
- gImageHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL );
- if ( EFI_ERROR ( Status )) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "Failed to open gEfiDhcp4ServiceBindingProtocolGuid" );
- break;
- }
-
- //
- // Get the DHCP handle
- //
- Status = pService->CreateChild ( pService,
- &Dhcp4Handle );
- if ( EFI_ERROR ( Status )) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "Failed to create DHCP4 child" );
- }
- else {
-*/
- //
- // Get the DHCP protocol
- //
- Status = gBS->OpenProtocol ( *pHandle,
-// Dhcp4Handle,
- &gEfiDhcp4ProtocolGuid,
- (VOID **)&pDhcp4,
- NULL,
- gImageHandle,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL );
- if ( EFI_ERROR ( Status )) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "Failed to open gEfiDhcp4ProtocolGuid" );
- }
- else {
- //
- // Get the DHCP packet
- //
- Status = pDhcp4->GetModeData ( pDhcp4,
- &Dhcp4Mode );
- if ( EFI_ERROR ( Status )) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "Failed to get DHCP4 mode" );
- }
- else {
- //
- // Get the last packet
- //
- pDhcp4Packet = Dhcp4Mode.ReplyPacket;
- if ( NULL == pDhcp4Packet ) {
- Status = HttpSendAnsiString ( SocketFD,
- pPort,
- "No DHCP reply received!<br/>DHCP Mode:<br/>" );
- if ( EFI_ERROR ( Status )) {
- break;
- }
-
- //
- // Display the DHCP mode data
- //
- Status = HttpSendDump ( SocketFD,
- pPort,
- sizeof ( Dhcp4Mode ),
- (UINT8 *)&Dhcp4Mode );
- }
- else {
- //
- // Display the DHCP packet
- //
- Status = HttpSendDump ( SocketFD,
- pPort,
- pDhcp4Packet->Length,
- (UINT8 *)&pDhcp4Packet->Dhcp4 );
- }
- }
-/*
- }
-
- //
- // Done with the DHCP protocol
- //
- pService->DestroyChild ( pService,
- Dhcp4Handle );
-*/
- }
-
- //
- // Set the next service binding
- //
- pHandle += 1;
- }
- }
-
- //
- // Send the page trailer
- //
- Status = HttpPageTrailer ( SocketFD, pPort, pbDone );
- break;
- }
-
- //
- // Return the operation status
- //
- DBG_EXIT_STATUS ( Status );
- return Status;
-}
+/** @file
+ Display the DHCP options
+
+ Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+#include <WebServer.h>\r
+#include <Guid/DxeServices.h>\r
+#include <Pi/PiDxeCis.h>\r
+\r
+#include <Protocol/Dhcp4.h>\r
+#include <Protocol/ServiceBinding.h>\r
+\r
+/**\r
+ Respond with the DHCP options\r
+\r
+ @param[in] SocketFD The socket's file descriptor to add to the list.\r
+ @param[in] pPort The WSDT_PORT structure address\r
+ @param[out] pbDone Address to receive the request completion status\r
+\r
+ @retval EFI_SUCCESS The request was successfully processed\r
+\r
+**/\r
+EFI_STATUS\r
+DhcpOptionsPage (\r
+ IN int SocketFD,\r
+ IN WSDT_PORT * pPort,\r
+ OUT BOOLEAN * pbDone\r
+ )\r
+{\r
+// EFI_HANDLE Dhcp4Handle;\r
+ EFI_DHCP4_MODE_DATA Dhcp4Mode;\r
+ UINTN HandleCount;\r
+ EFI_DHCP4_PROTOCOL * pDhcp4;\r
+ EFI_DHCP4_PACKET * pDhcp4Packet;\r
+ EFI_HANDLE * pEnd;\r
+ EFI_HANDLE * pHandle;\r
+// EFI_SERVICE_BINDING_PROTOCOL * pService;\r
+ EFI_STATUS Status;\r
+\r
+ DBG_ENTER ( );\r
+\r
+ //\r
+ // Send the DHCP options\r
+ //\r
+ for ( ; ; ) {\r
+ //\r
+ // Send the page header\r
+ //\r
+ Status = HttpPageHeader ( SocketFD, pPort, L"DHCP Options" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Build the header\r
+ //\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "<h1>" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+ Status = HttpSendUnicodeString ( SocketFD,\r
+ pPort,\r
+ L"DHCP Options" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "</h1>\r\n" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Attempt to locate DHCP clients\r
+ //\r
+ Status = gBS->LocateHandleBuffer ( ByProtocol,\r
+// &gEfiDhcp4ServiceBindingProtocolGuid,\r
+ &gEfiDhcp4ProtocolGuid,\r
+ NULL,\r
+ &HandleCount,\r
+ &pHandle );\r
+ if ( EFI_ERROR ( Status )) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "DHCP not in use" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+ }\r
+ else {\r
+ //\r
+ // Walk the list of handles\r
+ //\r
+ pEnd = &pHandle [ HandleCount ];\r
+ while ( pEnd > pHandle ) {\r
+/*\r
+ //\r
+ // Get the DHCP service binding\r
+ //\r
+ Status = gBS->OpenProtocol ( *pHandle,\r
+ &gEfiDhcp4ServiceBindingProtocolGuid,\r
+ &pService,\r
+ NULL,\r
+ gImageHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL );\r
+ if ( EFI_ERROR ( Status )) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "Failed to open gEfiDhcp4ServiceBindingProtocolGuid" );\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Get the DHCP handle\r
+ //\r
+ Status = pService->CreateChild ( pService,\r
+ &Dhcp4Handle );\r
+ if ( EFI_ERROR ( Status )) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "Failed to create DHCP4 child" );\r
+ }\r
+ else {\r
+*/\r
+ //\r
+ // Get the DHCP protocol\r
+ //\r
+ Status = gBS->OpenProtocol ( *pHandle,\r
+// Dhcp4Handle,\r
+ &gEfiDhcp4ProtocolGuid,\r
+ (VOID **)&pDhcp4,\r
+ NULL,\r
+ gImageHandle,\r
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL );\r
+ if ( EFI_ERROR ( Status )) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "Failed to open gEfiDhcp4ProtocolGuid" );\r
+ }\r
+ else {\r
+ //\r
+ // Get the DHCP packet\r
+ //\r
+ Status = pDhcp4->GetModeData ( pDhcp4,\r
+ &Dhcp4Mode );\r
+ if ( EFI_ERROR ( Status )) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "Failed to get DHCP4 mode" );\r
+ }\r
+ else {\r
+ //\r
+ // Get the last packet\r
+ //\r
+ pDhcp4Packet = Dhcp4Mode.ReplyPacket;\r
+ if ( NULL == pDhcp4Packet ) {\r
+ Status = HttpSendAnsiString ( SocketFD,\r
+ pPort,\r
+ "No DHCP reply received!<br/>DHCP Mode:<br/>" );\r
+ if ( EFI_ERROR ( Status )) {\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Display the DHCP mode data\r
+ //\r
+ Status = HttpSendDump ( SocketFD,\r
+ pPort,\r
+ sizeof ( Dhcp4Mode ),\r
+ (UINT8 *)&Dhcp4Mode );\r
+ }\r
+ else {\r
+ //\r
+ // Display the DHCP packet\r
+ //\r
+ Status = HttpSendDump ( SocketFD,\r
+ pPort,\r
+ pDhcp4Packet->Length,\r
+ (UINT8 *)&pDhcp4Packet->Dhcp4 );\r
+ }\r
+ }\r
+/*\r
+ }\r
+\r
+ //\r
+ // Done with the DHCP protocol\r
+ //\r
+ pService->DestroyChild ( pService,\r
+ Dhcp4Handle );\r
+*/\r
+ }\r
+\r
+ //\r
+ // Set the next service binding\r
+ //\r
+ pHandle += 1;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Send the page trailer\r
+ //\r
+ Status = HttpPageTrailer ( SocketFD, pPort, pbDone );\r
+ break;\r
+ }\r
+\r
+ //\r
+ // Return the operation status\r
+ //\r
+ DBG_EXIT_STATUS ( Status );\r
+ return Status;\r
+}\r