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