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/Networking/LwipEthernet/LwipEthernetInterface.cpp')
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.cpp41
1 files changed, 32 insertions, 9 deletions
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
index 9f35a201..443a09f7 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
@@ -20,6 +20,10 @@
#include <Networking/HttpResponder.h>
#include <Networking/FtpResponder.h>
#include <Networking/TelnetResponder.h>
+#if SUPPORT_MULTICAST_DISCOVERY
+# include <Networking/MulticastDiscovery/MulticastResponder.h>
+#endif
+
#include <General/IP4String.h>
#include <Version.h> // version is reported by MDNS
#include "GMAC/ethernet_sam.h"
@@ -46,7 +50,14 @@ extern "C"
extern struct netif gs_net_if;
}
-const char * const MdnsServiceStrings[NumProtocols] = { "_http", "_ftp", "_telnet" };
+const char * const MdnsServiceStrings[NumProtocols] =
+{
+ "_http", "_ftp", "_telnet",
+#if SUPPORT_MULTICAST_DISCOVERY
+ "_duet_discovery"
+#endif
+};
+
const char * const MdnsTxtRecords[2] = { "product=" FIRMWARE_NAME, "version=" VERSION };
const unsigned int MdnsTtl = 10 * 60; // same value as on the Duet 0.6/0.8.5
@@ -142,9 +153,9 @@ void LwipEthernetInterface::Init() noexcept
lwipMutex.Create("LwipCore");
// Clear the PCBs
- for (size_t i = 0; i < NumTcpPorts; ++i)
+ for (tcp_pcb*& pcb : listeningPcbs)
{
- listeningPcbs[i] = nullptr;
+ pcb = nullptr;
}
macAddress = platform.GetDefaultMacAddress();
@@ -178,6 +189,7 @@ GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int
RebuildMdnsServices();
}
}
+
ReportOneProtocol(protocol, reply);
return GCodeResult::ok;
}
@@ -205,7 +217,11 @@ GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, con
void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) noexcept
{
- if (listeningPcbs[protocol] == nullptr)
+ if ( listeningPcbs[protocol] == nullptr
+#if SUPPORT_MULTICAST_DISCOVERY
+ && protocol != MulticastDiscoveryProtocol
+#endif
+ )
{
tcp_pcb *pcb = tcp_new();
if (pcb == nullptr)
@@ -245,6 +261,12 @@ void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) noexcept
sockets[TelnetSocketNumber]->Init(TelnetSocketNumber, portNumbers[protocol], protocol);
break;
+#if SUPPORT_MULTICAST_DISCOVERY
+ case MulticastDiscoveryProtocol:
+ MulticastResponder::Start(portNumbers[protocol]);
+ break;
+#endif
+
default:
break;
}
@@ -270,6 +292,12 @@ void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol) noexcept
sockets[TelnetSocketNumber]->TerminateAndDisable();
break;
+#if SUPPORT_MULTICAST_DISCOVERY
+ case MulticastDiscoveryProtocol:
+ MulticastResponder::Stop();
+ break;
+#endif
+
default:
break;
}
@@ -547,11 +575,6 @@ bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb) noexcept
return false;
}
-IPAddress LwipEthernetInterface::GetIPAddress() const noexcept
-{
- return ipAddress;
-}
-
void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) noexcept
{
if (GetState() == NetworkState::obtainingIP || GetState() == NetworkState::active)