]>
Commit | Line | Data |
---|---|---|
9f7f5161 | 1 | /** |
2 | @file | |
3 | Ports response page | |
f6e5cdd5 | 4 | |
bcb96695 MK |
5 | Copyright (c) 2011-2012, Intel Corporation. All rights reserved. |
6 | SPDX-License-Identifier: BSD-2-Clause-Patent | |
f6e5cdd5 | 7 | |
8 | **/ | |
9 | ||
10 | #include <WebServer.h> | |
11 | ||
12 | ||
13 | /** | |
14 | Respond with the Ports page | |
15 | ||
16 | @param [in] SocketFD The socket's file descriptor to add to the list. | |
17 | @param [in] pPort The WSDT_PORT structure address | |
18 | @param [out] pbDone Address to receive the request completion status | |
19 | ||
20 | @retval EFI_SUCCESS The request was successfully processed | |
21 | ||
22 | **/ | |
23 | EFI_STATUS | |
24 | PortsPage ( | |
25 | IN int SocketFD, | |
26 | IN WSDT_PORT * pPort, | |
27 | OUT BOOLEAN * pbDone | |
28 | ) | |
29 | { | |
30 | socklen_t AddressLength; | |
31 | struct sockaddr_in6 LocalAddress; | |
32 | DT_WEB_SERVER * pWebServer; | |
33 | EFI_STATUS Status; | |
34 | ||
35 | DBG_ENTER ( ); | |
36 | ||
37 | // | |
38 | // Send the Hello World page | |
39 | // | |
40 | pWebServer = &mWebServer; | |
41 | for ( ; ; ) { | |
42 | // | |
43 | // Send the page header | |
44 | // | |
45 | Status = HttpPageHeader ( SocketFD, pPort, L"Ports" ); | |
46 | if ( EFI_ERROR ( Status )) { | |
47 | break; | |
48 | } | |
49 | ||
50 | // | |
51 | // Send the page body | |
52 | // | |
53 | Status = HttpSendAnsiString ( SocketFD, | |
54 | pPort, | |
55 | "<h1>Web-Server Ports</h1>\r\n" ); | |
56 | if ( EFI_ERROR ( Status )) { | |
57 | break; | |
58 | } | |
59 | ||
60 | // | |
61 | // Check for TCP v4 | |
62 | // | |
63 | if ( -1 != pWebServer->HttpListenPort ) { | |
64 | AddressLength = sizeof ( LocalAddress ); | |
65 | if ( 0 == getsockname ( pWebServer->HttpListenPort, | |
66 | (struct sockaddr *)&LocalAddress, | |
67 | &AddressLength )) { | |
68 | Status = HttpSendAnsiString ( SocketFD, | |
69 | pPort, | |
70 | "<a href=\"http://" ); | |
71 | if ( EFI_ERROR ( Status )) { | |
72 | break; | |
73 | } | |
74 | Status = HttpSendIpAddress ( SocketFD, | |
75 | pPort, | |
76 | &LocalAddress ); | |
77 | if ( EFI_ERROR ( Status )) { | |
78 | break; | |
79 | } | |
80 | Status = HttpSendAnsiString ( SocketFD, | |
81 | pPort, | |
82 | "\">Tcp4</a><br>\r\n" ); | |
83 | if ( EFI_ERROR ( Status )) { | |
84 | break; | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
89 | // | |
90 | // Check for TCP v6 | |
91 | // | |
92 | if ( -1 != pWebServer->HttpListenPort6 ) { | |
93 | AddressLength = sizeof ( LocalAddress ); | |
94 | if ( 0 == getsockname ( pWebServer->HttpListenPort6, | |
95 | (struct sockaddr *)&LocalAddress, | |
96 | &AddressLength )) { | |
97 | Status = HttpSendAnsiString ( SocketFD, | |
98 | pPort, | |
99 | "<a href=\"http://" ); | |
100 | if ( EFI_ERROR ( Status )) { | |
101 | break; | |
102 | } | |
103 | Status = HttpSendIpAddress ( SocketFD, | |
104 | pPort, | |
105 | &LocalAddress ); | |
106 | if ( EFI_ERROR ( Status )) { | |
107 | break; | |
108 | } | |
109 | Status = HttpSendAnsiString ( SocketFD, | |
110 | pPort, | |
111 | "\">Tcp6</a><br>\r\n" ); | |
112 | if ( EFI_ERROR ( Status )) { | |
113 | break; | |
114 | } | |
115 | } | |
116 | } | |
117 | ||
118 | // | |
119 | // Send the page trailer | |
120 | // | |
121 | Status = HttpPageTrailer ( SocketFD, pPort, pbDone ); | |
122 | break; | |
123 | } | |
124 | ||
125 | // | |
126 | // Return the operation status | |
127 | // | |
128 | DBG_EXIT_STATUS ( Status ); | |
129 | return Status; | |
130 | } |