Merged socket development branch:
[mirror_edk2.git] / AppPkg / Applications / Sockets / WebServer / WebServer.h
CommitLineData
4684b66f 1/** @file\r
2 Definitions for the web server.\r
3\r
4 Copyright (c) 2011, Intel Corporation\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _WEB_SERVER_H_\r
16#define _WEB_SERVER_H_\r
17\r
18#include <errno.h>\r
19#include <Uefi.h>\r
20\r
21#include <Guid/EventGroup.h>\r
22\r
23#include <Library/BaseMemoryLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/PcdLib.h>\r
26#include <Library/UefiApplicationEntryPoint.h>\r
27#include <Library/UefiBootServicesTableLib.h>\r
28#include <Library/UefiLib.h>\r
29#include <Protocol/BlockIo.h>\r
30\r
31#include <netinet/in.h>\r
32\r
33#include <sys/EfiSysCall.h>\r
34#include <sys/poll.h>\r
35#include <sys/socket.h>\r
36\r
37#pragma warning ( disable : 4054 )\r
38#pragma warning ( disable : 4152 )\r
39\r
40//------------------------------------------------------------------------------\r
41// Pages\r
42//------------------------------------------------------------------------------\r
43\r
44#define PAGE_ACPI_DSDT L"/DSDT"\r
45#define PAGE_ACPI_FADT L"/FADT"\r
46#define PAGE_ACPI_RSDP_10B L"/RSDP1.0b"\r
47#define PAGE_ACPI_RSDP_30 L"/RSDP3.0"\r
48#define PAGE_ACPI_RSDT L"/RSDT"\r
49#define PAGE_BOOT_SERVICES_TABLE L"/BootServicesTable"\r
50#define PAGE_CONFIGURATION_TABLE L"/ConfigurationTable"\r
51#define PAGE_DXE_SERVICES_TABLE L"/DxeServicesTable"\r
52#define PAGE_RUNTIME_SERVICES_TABLE L"/RuntimeServicesTable"\r
53\r
54//------------------------------------------------------------------------------\r
55// Signatures\r
56//------------------------------------------------------------------------------\r
57\r
58#define DSDT_SIGNATURE 0x54445344\r
59#define FADT_SIGNATURE 0x50434146\r
60\r
61//------------------------------------------------------------------------------\r
62// Macros\r
63//------------------------------------------------------------------------------\r
64\r
65#if defined(_MSC_VER) /* Handle Microsoft VC++ compiler specifics. */\r
66#define DBG_ENTER() DEBUG (( DEBUG_INFO, "Entering " __FUNCTION__ "\n" )) ///< Display routine entry\r
67#define DBG_EXIT() DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ "\n" )) ///< Display routine exit\r
68#define DBG_EXIT_DEC(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %d\n", Status )) ///< Display routine exit with decimal value\r
69#define DBG_EXIT_HEX(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: 0x%08x\n", Status )) ///< Display routine exit with hex value\r
70#define DBG_EXIT_STATUS(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", Status: %r\n", Status )) ///< Display routine exit with status value\r
71#define DBG_EXIT_TF(Status) DEBUG (( DEBUG_INFO, "Exiting " __FUNCTION__ ", returning %s\n", (FALSE == Status) ? L"FALSE" : L"TRUE" )) ///< Display routine with TRUE/FALSE value\r
72#else // _MSC_VER\r
73#define DBG_ENTER()\r
74#define DBG_EXIT()\r
75#define DBG_EXIT_DEC(Status)\r
76#define DBG_EXIT_HEX(Status)\r
77#define DBG_EXIT_STATUS(Status)\r
78#define DBG_EXIT_TF(Status)\r
79#endif // _MSC_VER\r
80\r
81#define DIM(x) ( sizeof ( x ) / sizeof ( x[0] )) ///< Compute the number of entries in an array\r
82\r
83//------------------------------------------------------------------------------\r
84// Constants\r
85//------------------------------------------------------------------------------\r
86\r
87#define DEBUG_SOCKET_POLL 0x00080000 ///< Display the socket poll messages\r
88#define DEBUG_PORT_WORK 0x00040000 ///< Display the port work messages\r
f6e5cdd5 89#define DEBUG_SERVER_LISTEN 0x00020000 ///< Display the socket poll messages\r
4684b66f 90#define DEBUG_HTTP_PORT 0x00010000 ///< Display HTTP port related messages\r
91#define DEBUG_REQUEST 0x00008000 ///< Display the HTTP request messages\r
92\r
93#define HTTP_PORT_POLL_DELAY ( 2 * 1000 ) ///< Delay in milliseconds for attempts to open the HTTP port\r
94#define CLIENT_POLL_DELAY 50 ///< Delay in milliseconds between client polls\r
95\r
96#define TPL_WEB_SERVER TPL_CALLBACK ///< TPL for routine synchronization\r
97\r
98/**\r
99 Verify new TPL value\r
100\r
101 This macro which is enabled when debug is enabled verifies that\r
102 the new TPL value is >= the current TPL value.\r
103**/\r
104#ifdef VERIFY_TPL\r
105#undef VERIFY_TPL\r
106#endif // VERIFY_TPL\r
107\r
108#if !defined(MDEPKG_NDEBUG)\r
109\r
110#define VERIFY_TPL(tpl) \\r
111{ \\r
112 EFI_TPL PreviousTpl; \\r
113 \\r
114 PreviousTpl = gBS->RaiseTPL ( TPL_HIGH_LEVEL ); \\r
115 gBS->RestoreTPL ( PreviousTpl ); \\r
116 if ( PreviousTpl > tpl ) { \\r
117 DEBUG (( DEBUG_ERROR, "Current TPL: %d, New TPL: %d\r\n", PreviousTpl, tpl )); \\r
118 ASSERT ( PreviousTpl <= tpl ); \\r
119 } \\r
120}\r
121\r
122#else // MDEPKG_NDEBUG\r
123\r
124#define VERIFY_TPL(tpl)\r
125\r
126#endif // MDEPKG_NDEBUG\r
127\r
59bc0593 128#define WEB_SERVER_SIGNATURE SIGNATURE_32 ('W','e','b','S') ///< DT_WEB_SERVER memory signature\r
4684b66f 129\r
130#define SPACES_ADDRESS_TO_DATA 2\r
131#define BYTES_ON_A_LINE 16\r
132#define SPACES_BETWEEN_BYTES 1\r
133#define SPACES_DATA_TO_ASCII 2\r
134\r
135\r
136//------------------------------------------------------------------------------\r
137// Protocol Declarations\r
138//------------------------------------------------------------------------------\r
139\r
140extern EFI_COMPONENT_NAME_PROTOCOL gComponentName; ///< Component name protocol declaration\r
141extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2; ///< Component name 2 protocol declaration\r
142extern EFI_DRIVER_BINDING_PROTOCOL gDriverBinding; ///< Driver binding protocol declaration\r
143\r
144//------------------------------------------------------------------------------\r
145// Data Types\r
146//------------------------------------------------------------------------------\r
147\r
148/**\r
149 Port control structure\r
150**/\r
151typedef struct {\r
152 //\r
153 // Buffer management\r
154 //\r
155 size_t RequestLength; ///< Request length in bytes\r
156 size_t TxBytes; ///< Bytes in the TX buffer\r
59bc0593 157 UINT8 Request[ 65536 ]; ///< Page request\r
158 UINT8 RxBuffer[ 65536 ]; ///< Receive buffer\r
159 UINT8 TxBuffer[ 65536 ]; ///< Transmit buffer\r
4684b66f 160} WSDT_PORT;\r
161\r
162/**\r
163 Web server control structure\r
164**/\r
165typedef struct {\r
166 UINTN Signature; ///< Structure identification\r
167\r
168 //\r
169 // Image attributes\r
170 //\r
171 EFI_HANDLE ImageHandle; ///< Image handle\r
172\r
173 //\r
174 // HTTP port management\r
175 //\r
f6e5cdd5 176 BOOLEAN bRunning; ///< Web server running\r
4684b66f 177 EFI_EVENT TimerEvent; ///< Timer to open HTTP port\r
f6e5cdd5 178 int HttpListenPort; ///< File descriptor for the HTTP listen port over TCP4\r
179 int HttpListenPort6; ///< File descriptor for the HTTP listen port over TCP6\r
4684b66f 180\r
181 //\r
182 // Client port management\r
183 //\r
184 nfds_t MaxEntries; ///< Maximum entries in the PortList array\r
185 nfds_t Entries; ///< The current number of entries in the PortList array\r
186 struct pollfd * pFdList; ///< List of socket file descriptors\r
187 WSDT_PORT ** ppPortList; ///< List of port management structures\r
188} DT_WEB_SERVER;\r
189\r
59bc0593 190//#define SERVER_FROM_SERVICE(a) CR (a, DT_WEB_SERVER, ServiceBinding, WEB_SERVER_SIGNATURE) ///< Locate DT_LAYER from service binding\r
4684b66f 191\r
192extern DT_WEB_SERVER mWebServer;\r
193\r
194/**\r
195 Process an HTTP request\r
196\r
197 @param [in] SocketFD The socket's file descriptor to add to the list.\r
198 @param [in] pPort The WSDT_PORT structure address\r
199 @param [out] pbDone Address to receive the request completion status\r
200\r
201 @retval EFI_SUCCESS The request was successfully processed\r
202\r
203**/\r
204typedef\r
205EFI_STATUS\r
206(* PFN_RESPONSE) (\r
207 IN int SocketFD,\r
208 IN WSDT_PORT * pPort,\r
209 IN BOOLEAN * pbDone\r
210 );\r
211\r
212/**\r
213 Data structure to delcare page support routines\r
214**/\r
215typedef struct {\r
216 UINT16 * pPageName; ///< Name of the page\r
217 PFN_RESPONSE pfnResponse; ///< Routine to generate the response\r
218 UINT16 * pDescription; ///< Description of the page\r
219} DT_PAGE;\r
220\r
59bc0593 221extern CONST DT_PAGE mPageList[]; ///< List of pages\r
4684b66f 222extern CONST UINTN mPageCount; ///< Number of pages\r
223\r
224//------------------------------------------------------------------------------\r
225// Web Pages\r
226//------------------------------------------------------------------------------\r
227\r
228/**\r
229 Respond with the ACPI DSDT table\r
230\r
231 @param [in] SocketFD The socket's file descriptor to add to the list.\r
232 @param [in] pPort The WSDT_PORT structure address\r
233 @param [out] pbDone Address to receive the request completion status\r
234\r
235 @retval EFI_SUCCESS The request was successfully processed\r
236\r
237**/\r
238EFI_STATUS\r
239AcpiDsdtPage (\r
240 IN int SocketFD,\r
241 IN WSDT_PORT * pPort,\r
242 OUT BOOLEAN * pbDone\r
243 );\r
244\r
245/**\r
246 Respond with the ACPI FADT table\r
247\r
248 @param [in] SocketFD The socket's file descriptor to add to the list.\r
249 @param [in] pPort The WSDT_PORT structure address\r
250 @param [out] pbDone Address to receive the request completion status\r
251\r
252 @retval EFI_SUCCESS The request was successfully processed\r
253\r
254**/\r
255EFI_STATUS\r
256AcpiFadtPage (\r
257 IN int SocketFD,\r
258 IN WSDT_PORT * pPort,\r
259 OUT BOOLEAN * pbDone\r
260 );\r
261\r
262/**\r
263 Respond with the ACPI RSDP 1.0b table\r
264\r
265 @param [in] SocketFD The socket's file descriptor to add to the list.\r
266 @param [in] pPort The WSDT_PORT structure address\r
267 @param [out] pbDone Address to receive the request completion status\r
268\r
269 @retval EFI_SUCCESS The request was successfully processed\r
270\r
271**/\r
272EFI_STATUS\r
273AcpiRsdp10Page (\r
274 IN int SocketFD,\r
275 IN WSDT_PORT * pPort,\r
276 OUT BOOLEAN * pbDone\r
277 );\r
278\r
279/**\r
280 Respond with the ACPI RSDP 3.0 table\r
281\r
282 @param [in] SocketFD The socket's file descriptor to add to the list.\r
283 @param [in] pPort The WSDT_PORT structure address\r
284 @param [out] pbDone Address to receive the request completion status\r
285\r
286 @retval EFI_SUCCESS The request was successfully processed\r
287\r
288**/\r
289EFI_STATUS\r
290AcpiRsdp30Page (\r
291 IN int SocketFD,\r
292 IN WSDT_PORT * pPort,\r
293 OUT BOOLEAN * pbDone\r
294 );\r
295\r
296/**\r
297 Respond with the ACPI RSDT table\r
298\r
299 @param [in] SocketFD The socket's file descriptor to add to the list.\r
300 @param [in] pPort The WSDT_PORT structure address\r
301 @param [out] pbDone Address to receive the request completion status\r
302\r
303 @retval EFI_SUCCESS The request was successfully processed\r
304\r
305**/\r
306EFI_STATUS\r
307AcpiRsdtPage (\r
308 IN int SocketFD,\r
309 IN WSDT_PORT * pPort,\r
310 OUT BOOLEAN * pbDone\r
311 );\r
312\r
313/**\r
314 Respond with the boot services table\r
315\r
316 @param [in] SocketFD The socket's file descriptor to add to the list.\r
317 @param [in] pPort The WSDT_PORT structure address\r
318 @param [out] pbDone Address to receive the request completion status\r
319\r
320 @retval EFI_SUCCESS The request was successfully processed\r
321\r
322**/\r
323EFI_STATUS\r
324BootServicesTablePage (\r
325 IN int SocketFD,\r
326 IN WSDT_PORT * pPort,\r
327 OUT BOOLEAN * pbDone\r
328 );\r
329\r
330/**\r
331 Respond with the configuration tables\r
332\r
333 @param [in] SocketFD The socket's file descriptor to add to the list.\r
334 @param [in] pPort The WSDT_PORT structure address\r
335 @param [out] pbDone Address to receive the request completion status\r
336\r
337 @retval EFI_SUCCESS The request was successfully processed\r
338\r
339**/\r
340EFI_STATUS\r
341ConfigurationTablePage (\r
342 IN int SocketFD,\r
343 IN WSDT_PORT * pPort,\r
344 OUT BOOLEAN * pbDone\r
345 );\r
346\r
347/**\r
348 Respond with the DHCP options\r
349\r
350 @param [in] SocketFD The socket's file descriptor to add to the list.\r
351 @param [in] pPort The WSDT_PORT structure address\r
352 @param [out] pbDone Address to receive the request completion status\r
353\r
354 @retval EFI_SUCCESS The request was successfully processed\r
355\r
356**/\r
357EFI_STATUS\r
358DhcpOptionsPage (\r
359 IN int SocketFD,\r
360 IN WSDT_PORT * pPort,\r
361 OUT BOOLEAN * pbDone\r
362 );\r
363\r
364/**\r
365 Respond with the DXE services table\r
366\r
367 @param [in] SocketFD The socket's file descriptor to add to the list.\r
368 @param [in] pPort The WSDT_PORT structure address\r
369 @param [out] pbDone Address to receive the request completion status\r
370\r
371 @retval EFI_SUCCESS The request was successfully processed\r
372\r
373**/\r
374EFI_STATUS\r
375DxeServicesTablePage (\r
376 IN int SocketFD,\r
377 IN WSDT_PORT * pPort,\r
378 OUT BOOLEAN * pbDone\r
379 );\r
380\r
f6e5cdd5 381/**\r
382 Respond with the Exit page\r
383\r
384 @param [in] SocketFD The socket's file descriptor to add to the list.\r
385 @param [in] pPort The WSDT_PORT structure address\r
386 @param [out] pbDone Address to receive the request completion status\r
387\r
388 @retval EFI_SUCCESS The request was successfully processed\r
389\r
390**/\r
391EFI_STATUS\r
392ExitPage (\r
393 IN int SocketFD,\r
394 IN WSDT_PORT * pPort,\r
395 OUT BOOLEAN * pbDone\r
396 );\r
397\r
4684b66f 398/**\r
399 Respond with the firmware status\r
400\r
401 @param [in] SocketFD The socket's file descriptor to add to the list.\r
402 @param [in] pPort The WSDT_PORT structure address\r
403 @param [out] pbDone Address to receive the request completion status\r
404\r
405 @retval EFI_SUCCESS The request was successfully processed\r
406\r
407**/\r
408EFI_STATUS\r
409FirmwarePage (\r
410 IN int SocketFD,\r
411 IN WSDT_PORT * pPort,\r
412 OUT BOOLEAN * pbDone\r
413 );\r
414\r
415/**\r
416 Respond with the handles in the system\r
417\r
418 @param [in] SocketFD The socket's file descriptor to add to the list.\r
419 @param [in] pPort The WSDT_PORT structure address\r
420 @param [out] pbDone Address to receive the request completion status\r
421\r
422 @retval EFI_SUCCESS The request was successfully processed\r
423\r
424**/\r
425EFI_STATUS\r
426HandlePage (\r
427 IN int SocketFD,\r
428 IN WSDT_PORT * pPort,\r
429 OUT BOOLEAN * pbDone\r
430 );\r
431\r
432/**\r
433 Respond with the Hello World page\r
434\r
435 @param [in] SocketFD The socket's file descriptor to add to the list.\r
436 @param [in] pPort The WSDT_PORT structure address\r
437 @param [out] pbDone Address to receive the request completion status\r
438\r
439 @retval EFI_SUCCESS The request was successfully processed\r
440\r
441**/\r
442EFI_STATUS\r
443HelloPage (\r
444 IN int SocketFD,\r
445 IN WSDT_PORT * pPort,\r
446 OUT BOOLEAN * pbDone\r
447 );\r
448\r
449/**\r
450 Respond with the list of known pages\r
451\r
452 @param [in] SocketFD The socket's file descriptor to add to the list.\r
453 @param [in] pPort The WSDT_PORT structure address\r
454 @param [out] pbDone Address to receive the request completion status\r
455\r
456 @retval EFI_SUCCESS The request was successfully processed\r
457\r
458**/\r
459EFI_STATUS\r
460IndexPage (\r
461 IN int SocketFD,\r
462 IN WSDT_PORT * pPort,\r
463 OUT BOOLEAN * pbDone\r
464 );\r
465\r
f6e5cdd5 466/**\r
467 Respond with the Ports page\r
468\r
469 @param [in] SocketFD The socket's file descriptor to add to the list.\r
470 @param [in] pPort The WSDT_PORT structure address\r
471 @param [out] pbDone Address to receive the request completion status\r
472\r
473 @retval EFI_SUCCESS The request was successfully processed\r
474\r
475**/\r
476EFI_STATUS\r
477PortsPage (\r
478 IN int SocketFD,\r
479 IN WSDT_PORT * pPort,\r
480 OUT BOOLEAN * pbDone\r
481 );\r
482\r
4684b66f 483/**\r
484 Page to reboot the system\r
485\r
486 @param [in] SocketFD The socket's file descriptor to add to the list.\r
487 @param [in] pPort The WSDT_PORT structure address\r
488 @param [out] pbDone Address to receive the request completion status\r
489\r
490 @retval EFI_SUCCESS The request was successfully processed\r
491\r
492**/\r
493EFI_STATUS\r
494RebootPage (\r
495 IN int SocketFD,\r
496 IN WSDT_PORT * pPort,\r
497 OUT BOOLEAN * pbDone\r
498 );\r
499\r
500/**\r
501 Respond with the runtime services table\r
502\r
503 @param [in] SocketFD The socket's file descriptor to add to the list.\r
504 @param [in] pPort The WSDT_PORT structure address\r
505 @param [out] pbDone Address to receive the request completion status\r
506\r
507 @retval EFI_SUCCESS The request was successfully processed\r
508\r
509**/\r
510EFI_STATUS\r
511RuntimeSservicesTablePage (\r
512 IN int SocketFD,\r
513 IN WSDT_PORT * pPort,\r
514 OUT BOOLEAN * pbDone\r
515 );\r
516\r
517/**\r
518 Respond with the system table\r
519\r
520 @param [in] SocketFD The socket's file descriptor to add to the list.\r
521 @param [in] pPort The WSDT_PORT structure address\r
522 @param [out] pbDone Address to receive the request completion status\r
523\r
524 @retval EFI_SUCCESS The request was successfully processed\r
525\r
526**/\r
527EFI_STATUS\r
528SystemTablePage (\r
529 IN int SocketFD,\r
530 IN WSDT_PORT * pPort,\r
531 OUT BOOLEAN * pbDone\r
532 );\r
533\r
534//------------------------------------------------------------------------------\r
535// Support routines\r
536//------------------------------------------------------------------------------\r
537\r
538/**\r
539 Display the EFI Table Header\r
540\r
541 @param [in] SocketFD The socket's file descriptor to add to the list.\r
542 @param [in] pPort The WSDT_PORT structure address\r
543 @param [in] pHeader Address of the EFI_TABLE_HEADER structure\r
544\r
545 @retval EFI_SUCCESS The request was successfully processed\r
546\r
547**/\r
548EFI_STATUS\r
549EfiTableHeader (\r
550 IN int SocketFD,\r
551 IN WSDT_PORT * pPort,\r
552 IN EFI_TABLE_HEADER * pHeader\r
553 );\r
554\r
555/**\r
556 Buffer the HTTP page header\r
557\r
558 @param [in] SocketFD The socket's file descriptor to add to the list.\r
559 @param [in] pPort The WSDT_PORT structure address\r
560 @param [in] pTitle A zero terminated Unicode title string\r
561\r
562 @retval EFI_SUCCESS The request was successfully processed\r
563\r
564**/\r
565EFI_STATUS\r
566HttpPageHeader (\r
567 IN int SocketFD,\r
568 IN WSDT_PORT * pPort,\r
569 IN CONST CHAR16 * pTitle\r
570 );\r
571\r
572/**\r
573 Buffer and send the HTTP page trailer\r
574\r
575 @param [in] SocketFD The socket's file descriptor to add to the list.\r
576 @param [in] pPort The WSDT_PORT structure address\r
577 @param [out] pbDone Address to receive the request completion status\r
578\r
579 @retval EFI_SUCCESS The request was successfully processed\r
580\r
581**/\r
582EFI_STATUS\r
583HttpPageTrailer (\r
584 IN int SocketFD,\r
585 IN WSDT_PORT * pPort,\r
586 IN BOOLEAN * pbDone\r
587 );\r
588\r
589/**\r
590 Process an HTTP request\r
591\r
592 @param [in] SocketFD The socket's file descriptor to add to the list.\r
593 @param [in] pPort The WSDT_PORT structure address\r
594 @param [out] pbDone Address to receive the request completion status\r
595\r
596 @retval EFI_SUCCESS The request was successfully processed\r
597\r
598**/\r
599EFI_STATUS\r
600HttpRequest (\r
601 IN int SocketFD,\r
602 IN WSDT_PORT * pPort,\r
603 IN BOOLEAN * pbDone\r
604 );\r
605\r
606/**\r
607 Buffer data for sending\r
608\r
609 @param [in] SocketFD The socket's file descriptor to add to the list.\r
610 @param [in] pPort The WSDT_PORT structure address\r
611 @param [in] LengthInBytes Length of valid data in the buffer\r
612 @param [in] pBuffer Buffer of data to send\r
613\r
614 @retval EFI_SUCCESS The request was successfully processed\r
615\r
616**/\r
617EFI_STATUS\r
618HttpSend (\r
619 IN int SocketFD,\r
620 IN WSDT_PORT * pPort,\r
621 IN size_t LengthInBytes,\r
622 IN CONST UINT8 * pBuffer\r
623 );\r
624\r
625/**\r
626 Send an ANSI string\r
627\r
628 @param [in] SocketFD The socket's file descriptor to add to the list.\r
629 @param [in] pPort The WSDT_PORT structure address\r
630 @param [in] pString A zero terminated Unicode string\r
631\r
632 @retval EFI_SUCCESS The request was successfully processed\r
633\r
634**/\r
635EFI_STATUS\r
636HttpSendAnsiString (\r
637 IN int SocketFD,\r
638 IN WSDT_PORT * pPort,\r
639 IN CONST char * pString\r
640 );\r
641\r
642/**\r
643 Buffer a single byte\r
644\r
645 @param [in] SocketFD The socket's file descriptor to add to the list.\r
646 @param [in] pPort The WSDT_PORT structure address\r
647 @param [in] Data The data byte to send\r
648\r
649 @retval EFI_SUCCESS The request was successfully processed\r
650\r
651**/\r
652EFI_STATUS\r
653HttpSendByte (\r
654 IN int SocketFD,\r
655 IN WSDT_PORT * pPort,\r
656 IN UINT8 Data\r
657 );\r
658\r
659/**\r
660 Display a character\r
661\r
662 @param [in] SocketFD The socket's file descriptor to add to the list.\r
663 @param [in] pPort The WSDT_PORT structure address\r
664 @param [in] Character Character to display\r
665 @param [in] pReplacement Replacement character string\r
666\r
667 @retval EFI_SUCCESS The request was successfully processed\r
668\r
669**/\r
670EFI_STATUS\r
671HttpSendCharacter (\r
672 IN int SocketFD,\r
673 IN WSDT_PORT * pPort,\r
674 IN CHAR8 Character,\r
675 IN CHAR8 * pReplacement\r
676 );\r
677\r
678/**\r
679 Send a buffer dump\r
680 \r
681 @param [in] SocketFD The socket's file descriptor to add to the list.\r
682 @param [in] pPort The WSDT_PORT structure address\r
683 @param [in] ByteCount The number of bytes to display\r
684 @param [in] pData Address of the byte array\r
685\r
686 @retval EFI_SUCCESS The request was successfully processed\r
687\r
688**/\r
689EFI_STATUS\r
690HttpSendDump (\r
691 IN int SocketFD,\r
692 IN WSDT_PORT * pPort,\r
693 IN UINTN ByteCount,\r
694 IN CONST UINT8 * pData\r
695 );\r
696\r
697/**\r
698 Display a row containing a GUID value\r
699\r
700 @param [in] SocketFD The socket's file descriptor to add to the list.\r
701 @param [in] pPort The WSDT_PORT structure address\r
702 @param [in] pGuid Address of the GUID to display\r
703\r
704 @retval EFI_SUCCESS The request was successfully processed\r
705\r
706**/\r
707EFI_STATUS\r
708HttpSendGuid (\r
709 IN int SocketFD,\r
710 IN WSDT_PORT * pPort,\r
711 IN CONST EFI_GUID * pGuid\r
712 );\r
713\r
714/**\r
715 Output a hex value to the HTML page\r
716\r
717 @param [in] SocketFD Socket file descriptor\r
718 @param [in] pPort The WSDT_PORT structure address\r
719 @param [in] Bits Number of bits to display\r
720 @param [in] Value Value to display\r
721\r
722 @retval EFI_SUCCESS Successfully displayed the address\r
723**/\r
724EFI_STATUS\r
725HttpSendHexBits (\r
726 IN int SocketFD,\r
727 IN WSDT_PORT * pPort,\r
728 IN INT32 Bits,\r
729 IN UINT64 Value\r
730 );\r
731\r
732/**\r
733 Output a hex value to the HTML page\r
734\r
735 @param [in] SocketFD Socket file descriptor\r
736 @param [in] pPort The WSDT_PORT structure address\r
737 @param [in] Value Value to display\r
738\r
739 @retval EFI_SUCCESS Successfully displayed the address\r
740**/\r
741EFI_STATUS\r
742HttpSendHexValue (\r
743 IN int SocketFD,\r
744 IN WSDT_PORT * pPort,\r
745 IN UINT64 Value\r
746 );\r
747\r
748/**\r
749 Output an IP address to the HTML page\r
750\r
751 @param [in] SocketFD Socket file descriptor\r
752 @param [in] pPort The WSDT_PORT structure address\r
753 @param [in] pAddress Address of the socket address\r
754\r
755 @retval EFI_SUCCESS Successfully displayed the address\r
756**/\r
757EFI_STATUS\r
758HttpSendIpAddress (\r
759 IN int SocketFD,\r
760 IN WSDT_PORT * pPort,\r
f6e5cdd5 761 IN struct sockaddr_in6 * pAddress\r
4684b66f 762 );\r
763\r
764/**\r
765 Send a Unicode string\r
766\r
767 @param [in] SocketFD The socket's file descriptor to add to the list.\r
768 @param [in] pPort The WSDT_PORT structure address\r
769 @param [in] pString A zero terminated Unicode string\r
770\r
771 @retval EFI_SUCCESS The request was successfully processed\r
772\r
773**/\r
774EFI_STATUS\r
775HttpSendUnicodeString (\r
776 IN int SocketFD,\r
777 IN WSDT_PORT * pPort,\r
778 IN CONST UINT16 * pString\r
779 );\r
780\r
781/**\r
782 Output a value to the HTML page\r
783\r
784 @param [in] SocketFD Socket file descriptor\r
785 @param [in] pPort The WSDT_PORT structure address\r
786 @param [in] Value Value to display\r
787\r
788 @retval EFI_SUCCESS Successfully displayed the address\r
789**/\r
790EFI_STATUS\r
791HttpSendValue (\r
792 IN int SocketFD,\r
793 IN WSDT_PORT * pPort,\r
794 IN UINT64 Value\r
795 );\r
796\r
797/**\r
798 Display a row containing a decimal value\r
799\r
800 @param [in] SocketFD The socket's file descriptor to add to the list.\r
801 @param [in] pPort The WSDT_PORT structure address\r
802 @param [in] pName Address of a zero terminated name string\r
803 @param [in] Value The value to display\r
804\r
805 @retval EFI_SUCCESS The request was successfully processed\r
806\r
807**/\r
808EFI_STATUS\r
809RowDecimalValue (\r
810 IN int SocketFD,\r
811 IN WSDT_PORT * pPort,\r
812 IN CONST CHAR8 * pName,\r
813 IN UINT64 Value\r
814 );\r
815\r
816/**\r
817 Display a row containing a GUID value\r
818\r
819 @param [in] SocketFD The socket's file descriptor to add to the list.\r
820 @param [in] pPort The WSDT_PORT structure address\r
821 @param [in] pName Address of a zero terminated name string\r
822 @param [in] pGuid Address of the GUID to display\r
823\r
824 @retval EFI_SUCCESS The request was successfully processed\r
825\r
826**/\r
827EFI_STATUS\r
828RowGuid (\r
829 IN int SocketFD,\r
830 IN WSDT_PORT * pPort,\r
831 IN CONST CHAR8 * pName,\r
832 IN CONST EFI_GUID * pGuid\r
833 );\r
834\r
835/**\r
836 Display a row containing a hex value\r
837\r
838 @param [in] SocketFD The socket's file descriptor to add to the list.\r
839 @param [in] pPort The WSDT_PORT structure address\r
840 @param [in] pName Address of a zero terminated name string\r
841 @param [in] Value The value to display\r
842 @param [in] pWebPage Address of a zero terminated web page name\r
843\r
844 @retval EFI_SUCCESS The request was successfully processed\r
845\r
846**/\r
847EFI_STATUS\r
848RowHexValue (\r
849 IN int SocketFD,\r
850 IN WSDT_PORT * pPort,\r
851 IN CONST CHAR8 * pName,\r
852 IN UINT64 Value,\r
853 IN CONST CHAR16 * pWebPage\r
854 );\r
855\r
856/**\r
857 Display a row containing a pointer\r
858\r
859 @param [in] SocketFD The socket's file descriptor to add to the list.\r
860 @param [in] pPort The WSDT_PORT structure address\r
861 @param [in] pName Address of a zero terminated name string\r
862 @param [in] pAddress The address to display\r
863 @param [in] pWebPage Address of a zero terminated web page name\r
864\r
865 @retval EFI_SUCCESS The request was successfully processed\r
866\r
867**/\r
868EFI_STATUS\r
869RowPointer (\r
870 IN int SocketFD,\r
871 IN WSDT_PORT * pPort,\r
872 IN CONST CHAR8 * pName,\r
873 IN CONST VOID * pAddress,\r
874 IN CONST CHAR16 * pWebPage\r
875 );\r
876\r
877/**\r
878 Display a row containing a revision\r
879\r
880 @param [in] SocketFD The socket's file descriptor to add to the list.\r
881 @param [in] pPort The WSDT_PORT structure address\r
882 @param [in] pName Address of a zero terminated name string\r
883 @param [in] Revision The revision to display\r
884\r
885 @retval EFI_SUCCESS The request was successfully processed\r
886\r
887**/\r
888EFI_STATUS\r
889RowRevision (\r
890 IN int SocketFD,\r
891 IN WSDT_PORT * pPort,\r
892 IN CONST CHAR8 * pName,\r
893 IN UINT32 Revision\r
894 );\r
895\r
896/**\r
897 Display a row containing a unicode string\r
898\r
899 @param [in] SocketFD The socket's file descriptor to add to the list.\r
900 @param [in] pPort The WSDT_PORT structure address\r
901 @param [in] pName Address of a zero terminated name string\r
902 @param [in] pString Address of a zero terminated unicode string\r
903\r
904 @retval EFI_SUCCESS The request was successfully processed\r
905\r
906**/\r
907EFI_STATUS\r
908RowUnicodeString (\r
909 IN int SocketFD,\r
910 IN WSDT_PORT * pPort,\r
911 IN CONST CHAR8 * pName,\r
912 IN CONST CHAR16 * pString\r
913 );\r
914\r
915/**\r
916 Start the table page\r
917\r
918 @param [in] SocketFD The socket's file descriptor to add to the list.\r
919 @param [in] pPort The WSDT_PORT structure address\r
920 @param [in] pName Address of a zero terminated name string\r
921 @param [in] pTable Address of the table\r
922\r
923 @retval EFI_SUCCESS The request was successfully processed\r
924\r
925**/\r
926EFI_STATUS\r
927TableHeader (\r
928 IN int SocketFD,\r
929 IN WSDT_PORT * pPort,\r
930 IN CONST CHAR16 * pName,\r
931 IN CONST VOID * pTable\r
932 );\r
933\r
934/**\r
935 End the table page\r
936\r
937 @param [in] SocketFD The socket's file descriptor to add to the list.\r
938 @param [in] pPort The WSDT_PORT structure address\r
939 @param [out] pbDone Address to receive the request completion status\r
940\r
941 @retval EFI_SUCCESS The request was successfully processed\r
942\r
943**/\r
944EFI_STATUS\r
945TableTrailer (\r
946 IN int SocketFD,\r
947 IN WSDT_PORT * pPort,\r
948 OUT BOOLEAN *pbDone\r
949 );\r
950\r
951/**\r
952 HTTP port creation timer routine\r
953\r
954 This routine polls the socket layer waiting for the initial network connection\r
955 which will enable the creation of the HTTP port. The socket layer will manage\r
956 the coming and going of the network connections after that until the last network\r
957 connection is broken.\r
958\r
959 @param [in] pWebServer The web server control structure address.\r
960\r
961**/\r
962VOID\r
963WebServerTimer (\r
964 IN DT_WEB_SERVER * pWebServer\r
965 );\r
966\r
967/**\r
968 Start the web server port creation timer\r
969\r
970 @param [in] pWebServer The web server control structure address.\r
971\r
972 @retval EFI_SUCCESS The timer was successfully started.\r
973 @retval EFI_ALREADY_STARTED The timer is already running.\r
974 @retval Other The timer failed to start.\r
975\r
976**/\r
977EFI_STATUS\r
978WebServerTimerStart (\r
979 IN DT_WEB_SERVER * pWebServer\r
980 );\r
981\r
982/**\r
983 Stop the web server port creation timer\r
984\r
985 @param [in] pWebServer The web server control structure address.\r
986\r
987 @retval EFI_SUCCESS The HTTP port timer is stopped\r
988 @retval Other Failed to stop the HTTP port timer\r
989\r
990**/\r
991EFI_STATUS\r
992WebServerTimerStop (\r
993 IN DT_WEB_SERVER * pWebServer\r
994 );\r
995\r
996//------------------------------------------------------------------------------\r
997// Driver Binding Protocol Support\r
998//------------------------------------------------------------------------------\r
999\r
1000/**\r
1001 Stop this driver on Controller by removing NetworkInterfaceIdentifier protocol and\r
1002 closing the DevicePath and PciIo protocols on Controller.\r
1003\r
1004 @param [in] pThis Protocol instance pointer.\r
1005 @param [in] Controller Handle of device to stop driver on.\r
1006 @param [in] NumberOfChildren How many children need to be stopped.\r
1007 @param [in] pChildHandleBuffer Not used.\r
1008\r
1009 @retval EFI_SUCCESS This driver is removed Controller.\r
1010 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
1011 @retval other This driver was not removed from this device.\r
1012\r
1013**/\r
1014EFI_STATUS\r
1015EFIAPI\r
1016DriverStop (\r
1017 IN EFI_DRIVER_BINDING_PROTOCOL * pThis,\r
1018 IN EFI_HANDLE Controller,\r
1019 IN UINTN NumberOfChildren,\r
1020 IN EFI_HANDLE * pChildHandleBuffer\r
1021 );\r
1022\r
1023//------------------------------------------------------------------------------\r
1024// EFI Component Name Protocol Support\r
1025//------------------------------------------------------------------------------\r
1026\r
1027/**\r
1028 Retrieves a Unicode string that is the user readable name of the driver.\r
1029\r
1030 This function retrieves the user readable name of a driver in the form of a\r
1031 Unicode string. If the driver specified by This has a user readable name in\r
1032 the language specified by Language, then a pointer to the driver name is\r
1033 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
1034 by This does not support the language specified by Language,\r
1035 then EFI_UNSUPPORTED is returned.\r
1036\r
1037 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
1038 EFI_COMPONENT_NAME_PROTOCOL instance.\r
1039 @param [in] pLanguage A pointer to a Null-terminated ASCII string\r
1040 array indicating the language. This is the\r
1041 language of the driver name that the caller is\r
1042 requesting, and it must match one of the\r
1043 languages specified in SupportedLanguages. The\r
1044 number of languages supported by a driver is up\r
1045 to the driver writer. Language is specified\r
1046 in RFC 3066 or ISO 639-2 language code format.\r
1047 @param [out] ppDriverName A pointer to the Unicode string to return.\r
1048 This Unicode string is the name of the\r
1049 driver specified by This in the language\r
1050 specified by Language.\r
1051\r
1052 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
1053 This and the language specified by Language was\r
1054 returned in DriverName.\r
1055 @retval EFI_INVALID_PARAMETER Language is NULL.\r
1056 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
1057 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
1058 the language specified by Language.\r
1059\r
1060**/\r
1061EFI_STATUS\r
1062EFIAPI\r
1063GetDriverName (\r
1064 IN EFI_COMPONENT_NAME_PROTOCOL * pThis,\r
1065 IN CHAR8 * pLanguage,\r
1066 OUT CHAR16 ** ppDriverName\r
1067 );\r
1068\r
1069\r
1070/**\r
1071 Retrieves a Unicode string that is the user readable name of the controller\r
1072 that is being managed by a driver.\r
1073\r
1074 This function retrieves the user readable name of the controller specified by\r
1075 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
1076 driver specified by This has a user readable name in the language specified by\r
1077 Language, then a pointer to the controller name is returned in ControllerName,\r
1078 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
1079 managing the controller specified by ControllerHandle and ChildHandle,\r
1080 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
1081 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
1082\r
1083 @param [in] pThis A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
1084 EFI_COMPONENT_NAME_PROTOCOL instance.\r
1085 @param [in] ControllerHandle The handle of a controller that the driver\r
1086 specified by This is managing. This handle\r
1087 specifies the controller whose name is to be\r
1088 returned.\r
1089 @param [in] ChildHandle The handle of the child controller to retrieve\r
1090 the name of. This is an optional parameter that\r
1091 may be NULL. It will be NULL for device\r
1092 drivers. It will also be NULL for a bus drivers\r
1093 that wish to retrieve the name of the bus\r
1094 controller. It will not be NULL for a bus\r
1095 driver that wishes to retrieve the name of a\r
1096 child controller.\r
1097 @param [in] pLanguage A pointer to a Null-terminated ASCII string\r
1098 array indicating the language. This is the\r
1099 language of the driver name that the caller is\r
1100 requesting, and it must match one of the\r
1101 languages specified in SupportedLanguages. The\r
1102 number of languages supported by a driver is up\r
1103 to the driver writer. Language is specified in\r
1104 RFC 3066 or ISO 639-2 language code format.\r
1105 @param [out] ppControllerName A pointer to the Unicode string to return.\r
1106 This Unicode string is the name of the\r
1107 controller specified by ControllerHandle and\r
1108 ChildHandle in the language specified by\r
1109 Language from the point of view of the driver\r
1110 specified by This.\r
1111\r
1112 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
1113 the language specified by Language for the\r
1114 driver specified by This was returned in\r
1115 DriverName.\r
1116 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
1117 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
1118 EFI_HANDLE.\r
1119 @retval EFI_INVALID_PARAMETER Language is NULL.\r
1120 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
1121 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
1122 managing the controller specified by\r
1123 ControllerHandle and ChildHandle.\r
1124 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
1125 the language specified by Language.\r
1126\r
1127**/\r
1128EFI_STATUS\r
1129EFIAPI\r
1130GetControllerName (\r
1131 IN EFI_COMPONENT_NAME_PROTOCOL * pThis,\r
1132 IN EFI_HANDLE ControllerHandle,\r
1133 IN OPTIONAL EFI_HANDLE ChildHandle,\r
1134 IN CHAR8 * pLanguage,\r
1135 OUT CHAR16 ** ppControllerName\r
1136 );\r
1137\r
1138//------------------------------------------------------------------------------\r
1139\r
1140#endif // _WEB_SERVER_H_\r