| 259 | } |
| 260 | |
| 261 | GCodeResult Network::DisableProtocol(unsigned int interface, NetworkProtocol protocol, const StringRef& reply) noexcept |
| 262 | { |
| 263 | #if HAS_NETWORKING |
| 264 | if (interface < GetNumNetworkInterfaces()) |
| 265 | { |
| 266 | bool client = false; |
| 267 | |
| 268 | # if HAS_CLIENTS |
| 269 | // Check if a client handles the protocol. If so, termination is handled |
| 270 | // by the client itself, after attempting to disconnect gracefully. |
| 271 | for (NetworkClient *c = clients; c != nullptr; c = c->GetNext()) |
| 272 | { |
| 273 | if (c->HandlesProtocol(protocol)) |
| 274 | { |
| 275 | client = true; |
| 276 | break; |
| 277 | } |
| 278 | } |
| 279 | # endif |
| 280 | |
| 281 | NetworkInterface * const iface = interfaces[interface]; |
| 282 | const GCodeResult ret = iface->DisableProtocol(protocol, reply, !client); |
| 283 | |
| 284 | if (ret == GCodeResult::ok) |
| 285 | { |
| 286 | # if HAS_RESPONDERS |
| 287 | if (!client) |
| 288 | { |
| 289 | TerminateResponders(iface, protocol); |
| 290 | } |
| 291 | |
| 292 | switch (protocol) |
| 293 | { |
| 294 | # if SUPPORT_HTTP |
| 295 | case HttpProtocol: |
| 296 | HttpResponder::DisableInterface(iface); // free up output buffers etc. |
| 297 | break; |
| 298 | # endif |
| 299 | |
| 300 | # if SUPPORT_FTP |
| 301 | case FtpProtocol: |
| 302 | // TODO the following isn't quite right, because we shouldn't free up output buffers if another network interface is still serving this protocol. |
| 303 | FtpResponder::Disable(); |
| 304 | break; |
| 305 | # endif |
| 306 | |
| 307 | # if SUPPORT_TELNET |
| 308 | case TelnetProtocol: |
| 309 | // TODO the following isn't quite right, because we shouldn't free up output buffers if another network interface is still serving this protocol. |
| 310 | TelnetResponder::Disable(); |
| 311 | break; |
| 312 | # endif |
| 313 | |
| 314 | # if SUPPORT_MULTICAST_DISCOVERY |
| 315 | // TODO the following isn't quite right, because we shouldn't free up output buffers if another network interface is still serving this protocol. |
| 316 | case MulticastDiscoveryProtocol: |
| 317 | break; |
| 318 | # endif |
nothing calls this directly
no test coverage detected