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