Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Duet/Webserver.cpp')
-rw-r--r--src/Duet/Webserver.cpp63
1 files changed, 23 insertions, 40 deletions
diff --git a/src/Duet/Webserver.cpp b/src/Duet/Webserver.cpp
index 20c8c1e2..d21fd99b 100644
--- a/src/Duet/Webserver.cpp
+++ b/src/Duet/Webserver.cpp
@@ -150,26 +150,17 @@ void Webserver::Spin()
// Take care of different protocol types here
ProtocolInterpreter *interpreter;
const uint16_t localPort = currentTransaction->GetLocalPort();
- switch (localPort)
+ if (localPort == Network::GetHttpPort())
{
- case FTP_PORT: /* FTP */
- interpreter = ftpInterpreter;
- break;
-
- case TELNET_PORT: /* Telnet */
- interpreter = telnetInterpreter;
- break;
-
- default: /* HTTP and FTP data */
- if (localPort == network->GetHttpPort())
- {
- interpreter = httpInterpreter;
- }
- else
- {
- interpreter = ftpInterpreter;
- }
- break;
+ interpreter = httpInterpreter;
+ }
+ else if (localPort == Network::GetTelnetPort())
+ {
+ interpreter = telnetInterpreter;
+ }
+ else
+ {
+ interpreter = ftpInterpreter;
}
// See if we have to print some debug info
@@ -345,28 +336,20 @@ void Webserver::ConnectionLost(Connection conn)
// Inform protocol handlers that this connection has been lost
const uint16_t localPort = Network::GetLocalPort(conn);
ProtocolInterpreter *interpreter;
- switch (localPort)
+ if (localPort == Network::GetHttpPort())
+ {
+ interpreter = httpInterpreter;
+ }
+ else if (localPort == Network::GetFtpPort() || localPort == network->GetDataPort())
{
- case FTP_PORT: /* FTP */
interpreter = ftpInterpreter;
- break;
-
- case TELNET_PORT: /* Telnet */
+ }
+ else if (localPort == Network::GetTelnetPort())
+ {
interpreter = telnetInterpreter;
- break;
-
- default: /* HTTP and FTP data */
- if (localPort == network->GetHttpPort())
- {
- interpreter = httpInterpreter;
- break;
- }
- else if (localPort == network->GetDataPort())
- {
- interpreter = ftpInterpreter;
- break;
- }
-
+ }
+ else
+ {
platform->MessageF(GENERIC_MESSAGE, "Error: Webserver should handle disconnect event at local port %d, but no handler was found!\n", localPort);
return;
}
@@ -1956,7 +1939,7 @@ void Webserver::FtpInterpreter::ConnectionEstablished()
// Is this a new connection on the data port?
NetworkTransaction *transaction = webserver->currentTransaction;
- if (transaction->GetLocalPort() != FTP_PORT)
+ if (transaction->GetLocalPort() != Network::GetFtpPort())
{
if (state == waitingForPasvPort)
{
@@ -1995,7 +1978,7 @@ void Webserver::FtpInterpreter::ConnectionLost(Connection conn)
{
connectedClients--;
- if (Network::GetLocalPort(conn) != FTP_PORT)
+ if (Network::GetLocalPort(conn) != Network::GetFtpPort())
{
// Did everything work out? Usually this is only called for uploads
if (network->AcquireFTPTransaction())