Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 1 | #pragma once |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 2 | #include "app.hpp" |
| 3 | #include "async_resp.hpp" |
Ed Tanous | faf100f | 2023-05-25 10:03:14 -0700 | [diff] [blame] | 4 | #include "websocket.hpp" |
Ed Tanous | 3ccb3ad | 2023-01-13 17:40:03 -0800 | [diff] [blame] | 5 | |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 6 | #include <sys/socket.h> |
| 7 | |
Ed Tanous | d4d77e3 | 2020-08-18 00:07:28 -0700 | [diff] [blame] | 8 | #include <boost/asio/local/stream_protocol.hpp> |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 9 | #include <boost/container/flat_map.hpp> |
Gunnar Mills | 8b901d7 | 2024-05-03 16:58:32 -0500 | [diff] [blame] | 10 | #include <boost/system/error_code.hpp> |
| 11 | |
| 12 | #include <array> |
| 13 | #include <memory> |
| 14 | #include <string> |
| 15 | #include <string_view> |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 16 | |
| 17 | namespace crow |
| 18 | { |
| 19 | namespace obmc_console |
| 20 | { |
| 21 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 22 | // Update this value each time we add new console route. |
| 23 | static constexpr const uint maxSessions = 32; |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 24 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 25 | class ConsoleHandler : public std::enable_shared_from_this<ConsoleHandler> |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 26 | { |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 27 | public: |
| 28 | ConsoleHandler(boost::asio::io_context& ioc, |
| 29 | crow::websocket::Connection& connIn) : |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 30 | hostSocket(ioc), conn(connIn) |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 31 | {} |
| 32 | |
| 33 | ~ConsoleHandler() = default; |
| 34 | |
| 35 | ConsoleHandler(const ConsoleHandler&) = delete; |
| 36 | ConsoleHandler(ConsoleHandler&&) = delete; |
| 37 | ConsoleHandler& operator=(const ConsoleHandler&) = delete; |
| 38 | ConsoleHandler& operator=(ConsoleHandler&&) = delete; |
| 39 | |
| 40 | void doWrite() |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 41 | { |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 42 | if (doingWrite) |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 43 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 44 | BMCWEB_LOG_DEBUG("Already writing. Bailing out"); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 45 | return; |
| 46 | } |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 47 | |
| 48 | if (inputBuffer.empty()) |
| 49 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 50 | BMCWEB_LOG_DEBUG("Outbuffer empty. Bailing out"); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 51 | return; |
| 52 | } |
| 53 | |
| 54 | doingWrite = true; |
| 55 | hostSocket.async_write_some( |
| 56 | boost::asio::buffer(inputBuffer.data(), inputBuffer.size()), |
| 57 | [weak(weak_from_this())](const boost::beast::error_code& ec, |
| 58 | std::size_t bytesWritten) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 59 | std::shared_ptr<ConsoleHandler> self = weak.lock(); |
| 60 | if (self == nullptr) |
| 61 | { |
| 62 | return; |
| 63 | } |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 64 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 65 | self->doingWrite = false; |
| 66 | self->inputBuffer.erase(0, bytesWritten); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 67 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 68 | if (ec == boost::asio::error::eof) |
| 69 | { |
| 70 | self->conn.close("Error in reading to host port"); |
| 71 | return; |
| 72 | } |
| 73 | if (ec) |
| 74 | { |
| 75 | BMCWEB_LOG_ERROR("Error in host serial write {}", |
| 76 | ec.message()); |
| 77 | return; |
| 78 | } |
| 79 | self->doWrite(); |
| 80 | }); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Ed Tanous | 099793f | 2023-05-31 08:54:26 -0700 | [diff] [blame] | 83 | static void afterSendEx(const std::weak_ptr<ConsoleHandler>& weak) |
| 84 | { |
| 85 | std::shared_ptr<ConsoleHandler> self = weak.lock(); |
| 86 | if (self == nullptr) |
| 87 | { |
| 88 | return; |
| 89 | } |
| 90 | self->doRead(); |
| 91 | } |
| 92 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 93 | void doRead() |
| 94 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 95 | BMCWEB_LOG_DEBUG("Reading from socket"); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 96 | hostSocket.async_read_some( |
Ed Tanous | 099793f | 2023-05-31 08:54:26 -0700 | [diff] [blame] | 97 | boost::asio::buffer(outputBuffer), |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 98 | [this, weakSelf(weak_from_this())]( |
| 99 | const boost::system::error_code& ec, std::size_t bytesRead) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 100 | BMCWEB_LOG_DEBUG("read done. Read {} bytes", bytesRead); |
| 101 | std::shared_ptr<ConsoleHandler> self = weakSelf.lock(); |
| 102 | if (self == nullptr) |
| 103 | { |
| 104 | return; |
| 105 | } |
| 106 | if (ec) |
| 107 | { |
| 108 | BMCWEB_LOG_ERROR("Couldn't read from host serial port: {}", |
| 109 | ec.message()); |
| 110 | conn.close("Error connecting to host port"); |
| 111 | return; |
| 112 | } |
| 113 | std::string_view payload(outputBuffer.data(), bytesRead); |
| 114 | self->conn.sendEx( |
| 115 | crow::websocket::MessageType::Binary, payload, |
| 116 | std::bind_front(afterSendEx, weak_from_this())); |
| 117 | }); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | bool connect(int fd) |
| 121 | { |
| 122 | boost::system::error_code ec; |
| 123 | boost::asio::local::stream_protocol proto; |
| 124 | |
| 125 | hostSocket.assign(proto, fd, ec); |
| 126 | |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 127 | if (ec) |
| 128 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 129 | BMCWEB_LOG_ERROR( |
| 130 | "Failed to assign the DBUS socket Socket assign error: {}", |
| 131 | ec.message()); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 132 | return false; |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 133 | } |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 134 | |
| 135 | conn.resumeRead(); |
Ed Tanous | 002d39b | 2022-05-31 08:59:27 -0700 | [diff] [blame] | 136 | doWrite(); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 137 | doRead(); |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | boost::asio::local::stream_protocol::socket hostSocket; |
| 142 | |
Ed Tanous | 099793f | 2023-05-31 08:54:26 -0700 | [diff] [blame] | 143 | std::array<char, 4096> outputBuffer{}; |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 144 | |
| 145 | std::string inputBuffer; |
| 146 | bool doingWrite = false; |
| 147 | crow::websocket::Connection& conn; |
| 148 | }; |
| 149 | |
| 150 | using ObmcConsoleMap = boost::container::flat_map< |
| 151 | crow::websocket::Connection*, std::shared_ptr<ConsoleHandler>, std::less<>, |
| 152 | std::vector<std::pair<crow::websocket::Connection*, |
| 153 | std::shared_ptr<ConsoleHandler>>>>; |
| 154 | |
| 155 | inline ObmcConsoleMap& getConsoleHandlerMap() |
| 156 | { |
| 157 | static ObmcConsoleMap map; |
| 158 | return map; |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 161 | // Remove connection from the connection map and if connection map is empty |
| 162 | // then remove the handler from handlers map. |
| 163 | inline void onClose(crow::websocket::Connection& conn, const std::string& err) |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 164 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 165 | BMCWEB_LOG_INFO("Closing websocket. Reason: {}", err); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 166 | |
| 167 | auto iter = getConsoleHandlerMap().find(&conn); |
| 168 | if (iter == getConsoleHandlerMap().end()) |
AppaRao Puli | 5238bd3 | 2020-11-17 11:03:11 +0530 | [diff] [blame] | 169 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 170 | BMCWEB_LOG_CRITICAL("Unable to find connection {}", logPtr(&conn)); |
AppaRao Puli | 5238bd3 | 2020-11-17 11:03:11 +0530 | [diff] [blame] | 171 | return; |
| 172 | } |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 173 | BMCWEB_LOG_DEBUG("Remove connection {} from obmc console", logPtr(&conn)); |
AppaRao Puli | 5238bd3 | 2020-11-17 11:03:11 +0530 | [diff] [blame] | 174 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 175 | // Removed last connection so remove the path |
| 176 | getConsoleHandlerMap().erase(iter); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | inline void connectConsoleSocket(crow::websocket::Connection& conn, |
| 180 | const boost::system::error_code& ec, |
| 181 | const sdbusplus::message::unix_fd& unixfd) |
| 182 | { |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 183 | if (ec) |
| 184 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 185 | BMCWEB_LOG_ERROR( |
| 186 | "Failed to call console Connect() method DBUS error: {}", |
| 187 | ec.message()); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 188 | conn.close("Failed to connect"); |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 189 | return; |
| 190 | } |
| 191 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 192 | // Look up the handler |
| 193 | auto iter = getConsoleHandlerMap().find(&conn); |
| 194 | if (iter == getConsoleHandlerMap().end()) |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 195 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 196 | BMCWEB_LOG_ERROR("Connection was already closed"); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 197 | return; |
| 198 | } |
| 199 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 200 | int fd = dup(unixfd); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 201 | if (fd == -1) |
| 202 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 203 | BMCWEB_LOG_ERROR("Failed to dup the DBUS unixfd error: {}", |
| 204 | strerror(errno)); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 205 | conn.close("Internal error"); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 206 | return; |
| 207 | } |
| 208 | |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 209 | BMCWEB_LOG_DEBUG("Console duped FD: {}", fd); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 210 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 211 | if (!iter->second->connect(fd)) |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 212 | { |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 213 | close(fd); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 214 | conn.close("Internal Error"); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 215 | } |
| 216 | } |
| 217 | |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 218 | inline void processConsoleObject( |
| 219 | crow::websocket::Connection& conn, const std::string& consoleObjPath, |
| 220 | const boost::system::error_code& ec, |
| 221 | const ::dbus::utility::MapperGetObject& objInfo) |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 222 | { |
| 223 | // Look up the handler |
| 224 | auto iter = getConsoleHandlerMap().find(&conn); |
| 225 | if (iter == getConsoleHandlerMap().end()) |
| 226 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 227 | BMCWEB_LOG_ERROR("Connection was already closed"); |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 228 | return; |
| 229 | } |
| 230 | |
| 231 | if (ec) |
| 232 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 233 | BMCWEB_LOG_WARNING("getDbusObject() for consoles failed. DBUS error:{}", |
| 234 | ec.message()); |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 235 | conn.close("getDbusObject() for consoles failed."); |
| 236 | return; |
| 237 | } |
| 238 | |
| 239 | const auto valueIface = objInfo.begin(); |
| 240 | if (valueIface == objInfo.end()) |
| 241 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 242 | BMCWEB_LOG_WARNING("getDbusObject() returned unexpected size: {}", |
| 243 | objInfo.size()); |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 244 | conn.close("getDbusObject() returned unexpected size"); |
| 245 | return; |
| 246 | } |
| 247 | |
| 248 | const std::string& consoleService = valueIface->first; |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 249 | BMCWEB_LOG_DEBUG("Looking up unixFD for Service {} Path {}", consoleService, |
| 250 | consoleObjPath); |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 251 | // Call Connect() method to get the unix FD |
| 252 | crow::connections::systemBus->async_method_call( |
| 253 | [&conn](const boost::system::error_code& ec1, |
| 254 | const sdbusplus::message::unix_fd& unixfd) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 255 | connectConsoleSocket(conn, ec1, unixfd); |
| 256 | }, |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 257 | consoleService, consoleObjPath, "xyz.openbmc_project.Console.Access", |
| 258 | "Connect"); |
| 259 | } |
| 260 | |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 261 | // Query consoles from DBUS and find the matching to the |
| 262 | // rules string. |
| 263 | inline void onOpen(crow::websocket::Connection& conn) |
| 264 | { |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 265 | std::string consoleLeaf; |
| 266 | |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 267 | BMCWEB_LOG_DEBUG("Connection {} opened", logPtr(&conn)); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 268 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 269 | if (getConsoleHandlerMap().size() >= maxSessions) |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 270 | { |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 271 | conn.close("Max sessions are already connected"); |
| 272 | return; |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 273 | } |
| 274 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 275 | std::shared_ptr<ConsoleHandler> handler = |
| 276 | std::make_shared<ConsoleHandler>(conn.getIoContext(), conn); |
| 277 | getConsoleHandlerMap().emplace(&conn, handler); |
| 278 | |
| 279 | conn.deferRead(); |
| 280 | |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 281 | // Keep old path for backward compatibility |
| 282 | if (conn.url().path() == "/console0") |
| 283 | { |
| 284 | consoleLeaf = "default"; |
| 285 | } |
| 286 | else |
| 287 | { |
| 288 | // Get the console id from console router path and prepare the console |
| 289 | // object path and console service. |
| 290 | consoleLeaf = conn.url().segments().back(); |
| 291 | } |
| 292 | std::string consolePath = |
| 293 | sdbusplus::message::object_path("/xyz/openbmc_project/console") / |
| 294 | consoleLeaf; |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 295 | |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 296 | BMCWEB_LOG_DEBUG("Console Object path = {} Request target = {}", |
| 297 | consolePath, conn.url().path()); |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 298 | |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 299 | // mapper call lambda |
| 300 | constexpr std::array<std::string_view, 1> interfaces = { |
| 301 | "xyz.openbmc_project.Console.Access"}; |
| 302 | |
| 303 | dbus::utility::getDbusObject( |
| 304 | consolePath, interfaces, |
| 305 | [&conn, consolePath](const boost::system::error_code& ec, |
| 306 | const ::dbus::utility::MapperGetObject& objInfo) { |
Patrick Williams | bd79bce | 2024-08-16 15:22:20 -0400 | [diff] [blame] | 307 | processConsoleObject(conn, consolePath, ec, objInfo); |
| 308 | }); |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 309 | } |
| 310 | |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 311 | inline void onMessage(crow::websocket::Connection& conn, |
| 312 | const std::string& data, bool /*isBinary*/) |
| 313 | { |
| 314 | auto handler = getConsoleHandlerMap().find(&conn); |
| 315 | if (handler == getConsoleHandlerMap().end()) |
| 316 | { |
Ed Tanous | 62598e3 | 2023-07-17 17:06:25 -0700 | [diff] [blame] | 317 | BMCWEB_LOG_CRITICAL("Unable to find connection {}", logPtr(&conn)); |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 318 | return; |
| 319 | } |
| 320 | handler->second->inputBuffer += data; |
| 321 | handler->second->doWrite(); |
| 322 | } |
| 323 | |
Ed Tanous | 23a21a1 | 2020-07-25 04:45:05 +0000 | [diff] [blame] | 324 | inline void requestRoutes(App& app) |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 325 | { |
| 326 | BMCWEB_ROUTE(app, "/console0") |
Ninad Palsule | 3e72c20 | 2023-03-27 17:19:55 -0500 | [diff] [blame] | 327 | .privileges({{"OpenBMCHostConsole"}}) |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 328 | .websocket() |
Ninad Palsule | a8d4b8e | 2023-04-10 16:40:00 -0500 | [diff] [blame] | 329 | .onopen(onOpen) |
Ninad Palsule | f948d81 | 2023-05-25 16:53:01 -0500 | [diff] [blame] | 330 | .onclose(onClose) |
| 331 | .onmessage(onMessage); |
Ninad Palsule | 052bcbf | 2023-05-30 11:10:58 -0500 | [diff] [blame] | 332 | |
| 333 | BMCWEB_ROUTE(app, "/console/<str>") |
| 334 | .privileges({{"OpenBMCHostConsole"}}) |
| 335 | .websocket() |
| 336 | .onopen(onOpen) |
| 337 | .onclose(onClose) |
| 338 | .onmessage(onMessage); |
Ed Tanous | 2daf672 | 2018-08-23 11:27:23 -0700 | [diff] [blame] | 339 | } |
| 340 | } // namespace obmc_console |
| 341 | } // namespace crow |