diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-12-10 18:03:11 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-12-10 18:03:11 +0300 |
commit | b7daa1866c654eefe9d1427fd5d2c68b476d7cd7 (patch) | |
tree | c9ca30e6f07acd55061236c820469e794111fb14 /src/Networking | |
parent | d4342a41d2972c20892c793f2ce015e6eafc70ed (diff) |
Added more noexcept specifiers
Diffstat (limited to 'src/Networking')
-rw-r--r-- | src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp | 20 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/GMAC/ethernet_sam.h | 20 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/GMAC/same70_gmac.cpp | 36 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/GMAC/same70_gmac.h | 18 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h | 5 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/LwipEthernetInterface.cpp | 58 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/LwipEthernetInterface.h | 70 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/LwipSocket.cpp | 38 | ||||
-rw-r--r-- | src/Networking/LwipEthernet/LwipSocket.h | 44 |
9 files changed, 156 insertions, 153 deletions
diff --git a/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp b/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp index e706a153..d4301e93 100644 --- a/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp +++ b/src/Networking/LwipEthernet/GMAC/ethernet_sam.cpp @@ -89,14 +89,14 @@ static timers_info_t gs_timers_table[] = { #endif }; -extern uint32_t millis(); +extern uint32_t millis() noexcept; } // end extern "C" /** * \brief Process timing functions. */ -void ethernet_timers_update(void) +void ethernet_timers_update(void) noexcept { static uint32_t ul_last_time; uint32_t ul_cur_time, ul_time_diff, ul_idx_timer; @@ -127,7 +127,7 @@ void ethernet_timers_update(void) //************************************************************************************************************ // This sets the static IP configuration on-the-fly -void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) +void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept { ip4_addr_t x_ip_addr, x_net_mask, x_gateway; x_ip_addr.addr = ipAddress.GetV4LittleEndian(); @@ -143,7 +143,7 @@ void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddres /** \brief Initialize the Ethernet subsystem. * */ -void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) +void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept { ip4_addr_t x_ip_addr, x_net_mask, x_gateway; x_ip_addr.addr = ipAddress.GetV4LittleEndian(); @@ -169,7 +169,7 @@ void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) /** \brief Configure the Ethernet subsystem. Should be called after init_ethernet() * */ -void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname) +void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname) noexcept { ethernetif_set_mac_address(macAddress); @@ -181,7 +181,7 @@ void ethernet_configure_interface(const uint8_t macAddress[], const char *hostna /* \brief Perform ethernet auto-negotiation and establish link. Returns true when ready * */ -bool ethernet_establish_link(void) +bool ethernet_establish_link() noexcept { if (ethernetif_establish_link()) { @@ -194,7 +194,7 @@ bool ethernet_establish_link(void) /* \brief Is the link still up? Also updates the interface status if the link has gone down * */ -bool ethernet_link_established(void) +bool ethernet_link_established() noexcept { if (!ethernetif_link_established()) { @@ -210,7 +210,7 @@ bool ethernet_link_established(void) * * \return Returns true if data has been processed. */ -void ethernet_task(void) +void ethernet_task() noexcept { #if !LWIP_GMAC_TASK /* Run polling tasks */ @@ -229,7 +229,7 @@ void ethernet_task(void) * * \param callback The callback to be called when a new packet is ready */ -void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) +void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept { ethernetif_set_rx_callback(callback); } @@ -238,7 +238,7 @@ void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) /* * \brief Returns the current IP address */ -void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay) +void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay) noexcept { ipAddress.SetV4LittleEndian(gs_net_if.ip_addr.addr); netMask.SetV4LittleEndian(gs_net_if.netmask.addr); diff --git a/src/Networking/LwipEthernet/GMAC/ethernet_sam.h b/src/Networking/LwipEthernet/GMAC/ethernet_sam.h index 06516e19..c1948803 100644 --- a/src/Networking/LwipEthernet/GMAC/ethernet_sam.h +++ b/src/Networking/LwipEthernet/GMAC/ethernet_sam.h @@ -52,35 +52,35 @@ #include "lwip/netif.h" // Perform low-level initialisation of the network interface -void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay); +void init_ethernet(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept; // Terminate Ethernet and stop any interrupts, tasks etc. Used when shutting down the whole system. -inline void ethernet_terminate() { ethernetif_terminate(); } +inline void ethernet_terminate() noexcept { ethernetif_terminate(); } // Configure the ethernet interface -void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname); +void ethernet_configure_interface(const uint8_t macAddress[], const char *hostname) noexcept; // Perform ethernet auto-negotiation and establish link. Returns true when ready -bool ethernet_establish_link(void); +bool ethernet_establish_link() noexcept; // Is the link still up? Also updates the interface status if the link has gone down -bool ethernet_link_established(void); +bool ethernet_link_established() noexcept; // Update IPv4 configuration on demand -void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay); +void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay) noexcept; // Must be called periodically to keep the LwIP timers running -void ethernet_timers_update(void); +void ethernet_timers_update() noexcept; // Reads all stored network packets and processes them -void ethernet_task(void); +void ethernet_task() noexcept; #if !LWIP_GMAC_TASK // Set the RX callback for incoming network packets -void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback); +void ethernet_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept; #endif // Returns the network interface's current IPv4 address -void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay); +void ethernet_get_ipaddress(IPAddress& ipAddress, IPAddress& netMask, IPAddress& gateWay) noexcept; #endif /* ETHERNET_SAM_H_INCLUDED */ diff --git a/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp b/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp index 863f4018..2565fe79 100644 --- a/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp +++ b/src/Networking/LwipEthernet/GMAC/same70_gmac.cpp @@ -176,7 +176,7 @@ static gmac_dev_tx_cb_t gmac_rx_cb = nullptr; /** * \brief GMAC interrupt handler. */ -void GMAC_Handler(void) +extern "C" void GMAC_Handler() noexcept { #if LWIP_GMAC_TASK /* Get interrupt status. */ @@ -214,7 +214,7 @@ void GMAC_Handler(void) * \param p_gmac_dev Pointer to driver data structure. * \param startAt The index to start populating from */ -static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t startAt) +static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t startAt) noexcept { uint32_t ul_index = startAt; @@ -278,7 +278,7 @@ static void gmac_rx_populate_queue(struct gmac_device *p_gmac_dev, uint32_t star * * \param ps_gmac_dev Pointer to driver data structure. */ -static void gmac_rx_init(struct gmac_device *ps_gmac_dev) +static void gmac_rx_init(struct gmac_device *ps_gmac_dev) noexcept { uint32_t ul_index = 0; @@ -308,7 +308,7 @@ static void gmac_rx_init(struct gmac_device *ps_gmac_dev) * * \param ps_gmac_dev Pointer to driver data structure. */ -static void gmac_tx_init(struct gmac_device *ps_gmac_dev) +static void gmac_tx_init(struct gmac_device *ps_gmac_dev) noexcept { uint32_t ul_index; @@ -334,7 +334,7 @@ static void gmac_tx_init(struct gmac_device *ps_gmac_dev) * * \param netif the lwIP network interface structure for this ethernetif. */ -static void gmac_low_level_init(struct netif *netif) +static void gmac_low_level_init(struct netif *netif) noexcept { #if 0 // chrishamm volatile uint32_t ul_delay; @@ -402,7 +402,7 @@ static void gmac_low_level_init(struct netif *netif) * \return ERR_OK if the packet could be sent. * an err_t value if the packet couldn't be sent. */ -static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p) +static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p) noexcept { gmac_device *const ps_gmac_dev = static_cast<gmac_device *>(p_netif->state); @@ -482,7 +482,7 @@ static err_t gmac_low_level_output(netif *p_netif, struct pbuf *p) * \return a pbuf filled with the received packet (including MAC header). * 0 on memory error. */ -static pbuf *gmac_low_level_input(struct netif *netif) +static pbuf *gmac_low_level_input(struct netif *netif) noexcept { gmac_device *ps_gmac_dev = static_cast<gmac_device *>(netif->state); @@ -565,7 +565,7 @@ static pbuf *gmac_low_level_input(struct netif *netif) * * \param pvParameters A pointer to the gmac_device instance. */ -extern "C" [[noreturn]] void gmac_task(void *pvParameters) +extern "C" [[noreturn]] void gmac_task(void *pvParameters) noexcept { gmac_device * const ps_gmac_dev = static_cast<gmac_device*>(pvParameters); netif * const p_netif = ps_gmac_dev->netif; @@ -593,7 +593,7 @@ extern "C" [[noreturn]] void gmac_task(void *pvParameters) * * \param netif the lwIP network interface structure for this ethernetif. */ -bool ethernetif_input(struct netif *netif) +bool ethernetif_input(struct netif *netif) noexcept { struct eth_hdr *ethhdr; struct pbuf *p; @@ -642,7 +642,7 @@ bool ethernetif_input(struct netif *netif) * ERR_MEM if private data couldn't be allocated. * any other err_t on error. */ -err_t ethernetif_init(struct netif *netif) +err_t ethernetif_init(struct netif *netif) noexcept { LWIP_ASSERT("netif != NULL", (netif != NULL)); @@ -683,7 +683,7 @@ err_t ethernetif_init(struct netif *netif) return ERR_OK; } -void ethernetif_hardware_init(void) +void ethernetif_hardware_init() noexcept { /* Enable GMAC clock. */ pmc_enable_periph_clk(ID_GMAC); @@ -767,7 +767,7 @@ void ethernetif_hardware_init(void) NVIC_EnableIRQ(GMAC_IRQn); } -bool ethernetif_establish_link(void) +bool ethernetif_establish_link() noexcept { /* Auto Negotiate, work in RMII mode. */ uint8_t result = ethernet_phy_auto_negotiate(GMAC, BOARD_GMAC_PHY_ADDR); @@ -790,7 +790,7 @@ bool ethernetif_establish_link(void) } // Ask the PHY if the link is still up -bool ethernetif_link_established(void) +bool ethernetif_link_established() noexcept { gmac_enable_management(GMAC, true); @@ -810,13 +810,13 @@ bool ethernetif_link_established(void) } #if !LWIP_GMAC_TASK -void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback) +void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept { gmac_rx_cb = callback; } #endif -void ethernetif_set_mac_address(const uint8_t macAddress[]) +void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept { // This function must be called once before low_level_init(), because that is where the // MAC address of the netif is assigned @@ -827,7 +827,7 @@ void ethernetif_set_mac_address(const uint8_t macAddress[]) } // This is called when we shut down -void ethernetif_terminate() +void ethernetif_terminate() noexcept { NVIC_DisableIRQ(GMAC_IRQn); #if LWIP_GMAC_TASK @@ -835,9 +835,9 @@ void ethernetif_terminate() #endif } -extern "C" u32_t millis(); +extern "C" u32_t millis() noexcept; -extern "C" u32_t sys_now(void) +extern "C" u32_t sys_now() noexcept { return millis(); } diff --git a/src/Networking/LwipEthernet/GMAC/same70_gmac.h b/src/Networking/LwipEthernet/GMAC/same70_gmac.h index 6d494faf..8d6bd595 100644 --- a/src/Networking/LwipEthernet/GMAC/same70_gmac.h +++ b/src/Networking/LwipEthernet/GMAC/same70_gmac.h @@ -57,24 +57,24 @@ extern "C" { #ifdef __cplusplus } -err_t ethernetif_init(struct netif *netif); // called by LwIP to initialise the interface +err_t ethernetif_init(struct netif *netif) noexcept; // called by LwIP to initialise the interface -void ethernetif_terminate(); // called when we shut down +void ethernetif_terminate() noexcept; // called when we shut down -bool ethernetif_input(struct netif *netif); // checks for a new packet and returns true if one was processed +bool ethernetif_input(struct netif *netif) noexcept; // checks for a new packet and returns true if one was processed -void ethernetif_hardware_init(void); // initialises the low-level hardware interface +void ethernetif_hardware_init() noexcept; // initialises the low-level hardware interface -bool ethernetif_establish_link(void); // attempts to establish link and returns true on success +bool ethernetif_establish_link() noexcept; // attempts to establish link and returns true on success -bool ethernetif_link_established(void); // asks the PHY if the link is still up +bool ethernetif_link_established() noexcept; // asks the PHY if the link is still up #if !LWIP_GMAC_TASK -typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status); // copied from gmac_raw.h -void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback); +typedef void (*gmac_dev_tx_cb_t) (uint32_t ul_status) noexcept; // copied from gmac_raw.h +void ethernetif_set_rx_callback(gmac_dev_tx_cb_t callback) noexcept; #endif -void ethernetif_set_mac_address(const uint8_t macAddress[]); +void ethernetif_set_mac_address(const uint8_t macAddress[]) noexcept; #endif diff --git a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h index 3bfa245f..89e44449 100644 --- a/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h +++ b/src/Networking/LwipEthernet/Lwip/src/include/lwip/sys.h @@ -40,7 +40,10 @@ #include <Lwip/src/include/lwip/opt.h> #ifdef __cplusplus +# define NOEXCEPT noexcept extern "C" { +#else +# define NOEXCEPT #endif #if NO_SYS @@ -340,7 +343,7 @@ u32_t sys_jiffies(void); * Returns the current time in milliseconds, * may be the same as sys_jiffies or at least based on it. */ -u32_t sys_now(void); +u32_t sys_now(void) NOEXCEPT; /* Critical Region Protection */ /* These functions must be implemented in the sys_arch.c file. diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp index 79378030..88c42a90 100644 --- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp +++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp @@ -134,7 +134,7 @@ extern "C" /*-----------------------------------------------------------------------------------*/ -LwipEthernetInterface::LwipEthernetInterface(Platform& p) : platform(p), closeDataPort(false), state(NetworkState::disabled), +LwipEthernetInterface::LwipEthernetInterface(Platform& p) noexcept : platform(p), closeDataPort(false), state(NetworkState::disabled), activated(false), initialised(false), usingDhcp(false) { ethernetInterface = this; @@ -175,7 +175,7 @@ DEFINE_GET_OBJECT_MODEL_TABLE(LwipEthernetInterface) #endif -void LwipEthernetInterface::Init() +void LwipEthernetInterface::Init() noexcept { interfaceMutex.Create("LwipIface"); //TODO we don't yet use this mutex anywhere! @@ -193,7 +193,7 @@ void LwipEthernetInterface::Init() memcpy(macAddress, platform.GetDefaultMacAddress(), sizeof(macAddress)); } -GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) +GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept { if (secure != 0 && secure != -1) { @@ -229,7 +229,7 @@ GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int return GCodeResult::error; } -GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply) +GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept { if (protocol < NumProtocols) { @@ -246,7 +246,7 @@ GCodeResult LwipEthernetInterface::DisableProtocol(NetworkProtocol protocol, con return GCodeResult::error; } -void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) +void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) noexcept { if (listeningPcbs[protocol] == nullptr) { @@ -278,7 +278,7 @@ void LwipEthernetInterface::StartProtocol(NetworkProtocol protocol) } } -void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol) +void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol) noexcept { #if 0 // chrishamm: Also see Network::Stop for (NetworkResponder* r = responders; r != nullptr; r = r->GetNext()) @@ -317,7 +317,7 @@ void LwipEthernetInterface::ShutdownProtocol(NetworkProtocol protocol) } // Report the protocols and ports in use -GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const +GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const noexcept { reply.Clear(); for (size_t i = 0; i < NumProtocols; ++i) @@ -327,7 +327,7 @@ GCodeResult LwipEthernetInterface::ReportProtocols(const StringRef& reply) const return GCodeResult::ok; } -void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const +void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const noexcept { if (protocolEnabled[protocol]) { @@ -341,7 +341,7 @@ void LwipEthernetInterface::ReportOneProtocol(NetworkProtocol protocol, const St // This is called at the end of config.g processing. // Start the network if it was enabled -void LwipEthernetInterface::Activate() +void LwipEthernetInterface::Activate() noexcept { if (!activated) { @@ -357,14 +357,14 @@ void LwipEthernetInterface::Activate() } } -void LwipEthernetInterface::Exit() +void LwipEthernetInterface::Exit() noexcept { Stop(); ethernet_terminate(); } // Get the network state into the reply buffer, returning true if there is some sort of error -GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply) +GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply) noexcept { ethernet_get_ipaddress(ipAddress, netmask, gateway); const int enableState = EnableState(); @@ -375,7 +375,7 @@ GCodeResult LwipEthernetInterface::GetNetworkState(const StringRef& reply) } // Start up the network -void LwipEthernetInterface::Start() +void LwipEthernetInterface::Start() noexcept { #if defined(DUET3) digitalWrite(PhyResetPin, true); // bring the Ethernet Phy out of reset @@ -412,7 +412,7 @@ void LwipEthernetInterface::Start() } // Stop the network -void LwipEthernetInterface::Stop() +void LwipEthernetInterface::Stop() noexcept { if (state != NetworkState::disabled) { @@ -430,7 +430,7 @@ void LwipEthernetInterface::Stop() } // Main spin loop. If 'full' is true then we are being called from the main spin loop. If false then we are being called during HSMCI idle time. -void LwipEthernetInterface::Spin() +void LwipEthernetInterface::Spin() noexcept { #if LWIP_GMAC_TASK MutexLocker lock(lwipMutex); @@ -542,7 +542,7 @@ void LwipEthernetInterface::Spin() #endif } -void LwipEthernetInterface::Interrupt() +void LwipEthernetInterface::Interrupt() noexcept { #if !LWIP_GMAC_TASK if (initialised && LockLWIP()) @@ -553,7 +553,7 @@ void LwipEthernetInterface::Interrupt() #endif } -void LwipEthernetInterface::Diagnostics(MessageType mtype) +void LwipEthernetInterface::Diagnostics(MessageType mtype) noexcept { platform.Message(mtype, "- Ethernet -\n"); platform.MessageF(mtype, "State: %d\n", (int)state); @@ -575,7 +575,7 @@ void LwipEthernetInterface::Diagnostics(MessageType mtype) } // Enable or disable the network. For Ethernet the ssid parameter is not used. -GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) +GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept { if (!activated) { @@ -598,12 +598,12 @@ GCodeResult LwipEthernetInterface::EnableInterface(int mode, const StringRef& ss return GCodeResult::ok; } -int LwipEthernetInterface::EnableState() const +int LwipEthernetInterface::EnableState() const noexcept { return (state == NetworkState::disabled) ? 0 : 1; } -bool LwipEthernetInterface::InNetworkStack() const +bool LwipEthernetInterface::InNetworkStack() const noexcept { #if LWIP_GMAC_TASK return false; @@ -612,7 +612,7 @@ bool LwipEthernetInterface::InNetworkStack() const #endif } -bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb) +bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb) noexcept { for (LwipSocket *s : sockets) { @@ -627,12 +627,12 @@ bool LwipEthernetInterface::ConnectionEstablished(tcp_pcb *pcb) return false; } -IPAddress LwipEthernetInterface::GetIPAddress() const +IPAddress LwipEthernetInterface::GetIPAddress() const noexcept { return ipAddress; } -void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) +void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) noexcept { if (state == NetworkState::obtainingIP || state == NetworkState::active) { @@ -668,7 +668,7 @@ void LwipEthernetInterface::SetIPAddress(IPAddress p_ipAddress, IPAddress p_netm } } -void LwipEthernetInterface::UpdateHostname(const char *hostname) +void LwipEthernetInterface::UpdateHostname(const char *hostname) noexcept { if (initialised) { @@ -677,12 +677,12 @@ void LwipEthernetInterface::UpdateHostname(const char *hostname) } } -void LwipEthernetInterface::SetMacAddress(const uint8_t mac[]) +void LwipEthernetInterface::SetMacAddress(const uint8_t mac[]) noexcept { memcpy(macAddress, mac, sizeof(macAddress)); } -void LwipEthernetInterface::OpenDataPort(Port port) +void LwipEthernetInterface::OpenDataPort(Port port) noexcept { if (listeningPcbs[NumProtocols] != nullptr) { @@ -699,7 +699,7 @@ void LwipEthernetInterface::OpenDataPort(Port port) } // Close FTP data port and purge associated resources -void LwipEthernetInterface::TerminateDataPort() +void LwipEthernetInterface::TerminateDataPort() noexcept { if (closeDataPort || !sockets[FtpDataSocketNumber]->IsClosing()) { @@ -720,7 +720,7 @@ void LwipEthernetInterface::TerminateDataPort() } } -void LwipEthernetInterface::InitSockets() +void LwipEthernetInterface::InitSockets() noexcept { for (size_t i = 0; i < NumProtocols; ++i) { @@ -732,7 +732,7 @@ void LwipEthernetInterface::InitSockets() nextSocketToPoll = 0; } -void LwipEthernetInterface::TerminateSockets() +void LwipEthernetInterface::TerminateSockets() noexcept { for (LwipSocket *socket : sockets) { @@ -748,7 +748,7 @@ void GetServiceTxtEntries(struct mdns_service *service, void *txt_userdata) } } -void LwipEthernetInterface::RebuildMdnsServices() +void LwipEthernetInterface::RebuildMdnsServices() noexcept { mdns_resp_remove_netif(&gs_net_if); mdns_resp_add_netif(&gs_net_if, reprap.GetNetwork().GetHostname(), MdnsTtl); diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.h b/src/Networking/LwipEthernet/LwipEthernetInterface.h index 94ec30e0..3a4a6f42 100644 --- a/src/Networking/LwipEthernet/LwipEthernetInterface.h +++ b/src/Networking/LwipEthernet/LwipEthernetInterface.h @@ -28,36 +28,36 @@ struct tcp_pcb; class LwipEthernetInterface : public NetworkInterface { public: - LwipEthernetInterface(Platform& p); - - void Init() override; - void Activate() override; - void Exit() override; - void Spin() override; - void Interrupt() override; - void Diagnostics(MessageType mtype) override; - - GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) override; // enable or disable the network - GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) override; - GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) override; - GCodeResult ReportProtocols(const StringRef& reply) const override; - - GCodeResult GetNetworkState(const StringRef& reply) override; - int EnableState() const override; - bool InNetworkStack() const override; - bool IsWiFiInterface() const override { return false; } - - void UpdateHostname(const char *hostname) override; - IPAddress GetIPAddress() const override; - void SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) override; - void SetMacAddress(const uint8_t mac[]) override; - const uint8_t *GetMacAddress() const override { return macAddress; } + LwipEthernetInterface(Platform& p) noexcept; + + void Init() noexcept override; + void Activate() noexcept override; + void Exit() noexcept override; + void Spin() noexcept override; + void Interrupt() noexcept override; + void Diagnostics(MessageType mtype) noexcept override; + + GCodeResult EnableInterface(int mode, const StringRef& ssid, const StringRef& reply) noexcept override; // enable or disable the network + GCodeResult EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept override; + GCodeResult DisableProtocol(NetworkProtocol protocol, const StringRef& reply) noexcept override; + GCodeResult ReportProtocols(const StringRef& reply) const noexcept override; + + GCodeResult GetNetworkState(const StringRef& reply) noexcept override; + int EnableState() const noexcept override; + bool InNetworkStack() const noexcept override; + bool IsWiFiInterface() const noexcept override { return false; } + + void UpdateHostname(const char *hostname) noexcept override; + IPAddress GetIPAddress() const noexcept override; + void SetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, IPAddress p_gateway) noexcept override; + void SetMacAddress(const uint8_t mac[]) noexcept override; + const uint8_t *GetMacAddress() const noexcept override { return macAddress; } // LwIP interfaces - bool ConnectionEstablished(tcp_pcb *pcb); + bool ConnectionEstablished(tcp_pcb *pcb) noexcept; - void OpenDataPort(Port port) override; - void TerminateDataPort() override; + void OpenDataPort(Port port) noexcept override; + void TerminateDataPort() noexcept override; protected: DECLARE_OBJECT_MODEL @@ -73,20 +73,20 @@ private: active // network running }; - void Start(); - void Stop(); - void InitSockets(); - void TerminateSockets(); + void Start() noexcept; + void Stop() noexcept; + void InitSockets() noexcept; + void TerminateSockets() noexcept; - void RebuildMdnsServices(); + void RebuildMdnsServices() noexcept; - void StartProtocol(NetworkProtocol protocol) + void StartProtocol(NetworkProtocol protocol) noexcept pre(protocol < NumProtocols); - void ShutdownProtocol(NetworkProtocol protocol) + void ShutdownProtocol(NetworkProtocol protocol) noexcept pre(protocol < NumProtocols); - void ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const + void ReportOneProtocol(NetworkProtocol protocol, const StringRef& reply) const noexcept pre(protocol < NumProtocols); Platform& platform; diff --git a/src/Networking/LwipEthernet/LwipSocket.cpp b/src/Networking/LwipEthernet/LwipSocket.cpp index 69d7bab5..52c5288c 100644 --- a/src/Networking/LwipEthernet/LwipSocket.cpp +++ b/src/Networking/LwipEthernet/LwipSocket.cpp @@ -77,13 +77,13 @@ extern void UnlockLWIP(); // LwipSocket class -LwipSocket::LwipSocket(NetworkInterface *iface) : Socket(iface), connectionPcb(nullptr), +LwipSocket::LwipSocket(NetworkInterface *iface) noexcept : Socket(iface), connectionPcb(nullptr), receivedData(nullptr), state(SocketState::disabled) { ReInit(); } -bool LwipSocket::AcceptConnection(tcp_pcb *pcb) +bool LwipSocket::AcceptConnection(tcp_pcb *pcb) noexcept { if (state == SocketState::listening && pcb->local_port == localPort) { @@ -104,7 +104,7 @@ bool LwipSocket::AcceptConnection(tcp_pcb *pcb) return false; } -void LwipSocket::DataReceived(pbuf *data) +void LwipSocket::DataReceived(pbuf *data) noexcept { if (state != SocketState::closing) { @@ -125,7 +125,7 @@ void LwipSocket::DataReceived(pbuf *data) } } -void LwipSocket::DataSent(size_t numBytes) +void LwipSocket::DataSent(size_t numBytes) noexcept { if (numBytes <= unAcked) { @@ -144,7 +144,7 @@ void LwipSocket::DataSent(size_t numBytes) } } -void LwipSocket::ConnectionClosedGracefully() +void LwipSocket::ConnectionClosedGracefully() noexcept { if (connectionPcb != nullptr) { @@ -166,7 +166,7 @@ void LwipSocket::ConnectionClosedGracefully() } } -void LwipSocket::ConnectionError(err_t err) +void LwipSocket::ConnectionError(err_t err) noexcept { DiscardReceivedData(); connectionPcb = nullptr; @@ -179,7 +179,7 @@ void LwipSocket::ConnectionError(err_t err) } // Initialise a TCP socket -void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p) +void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p) noexcept { UNUSED(skt); localPort = serverPort; @@ -189,13 +189,13 @@ void LwipSocket::Init(SocketNumber skt, Port serverPort, NetworkProtocol p) ReInit(); } -void LwipSocket::TerminateAndDisable() +void LwipSocket::TerminateAndDisable() noexcept { Terminate(); state = SocketState::disabled; } -void LwipSocket::ReInit() +void LwipSocket::ReInit() noexcept { DiscardReceivedData(); whenConnected = whenWritten = whenClosed = 0; @@ -204,7 +204,7 @@ void LwipSocket::ReInit() } // Close a connection when the last packet has been sent -void LwipSocket::Close() +void LwipSocket::Close() noexcept { if (state != SocketState::disabled && state != SocketState::listening) { @@ -223,7 +223,7 @@ void LwipSocket::Close() } // Terminate a connection immediately -void LwipSocket::Terminate() +void LwipSocket::Terminate() noexcept { if (state != SocketState::disabled) { @@ -246,19 +246,19 @@ void LwipSocket::Terminate() } // Return true if there is or may soon be more data to read -bool LwipSocket::CanRead() const +bool LwipSocket::CanRead() const noexcept { return (state == SocketState::connected) || (state == SocketState::clientDisconnecting && receivedData != nullptr); } -bool LwipSocket::CanSend() const +bool LwipSocket::CanSend() const noexcept { return (state == SocketState::connected); } // Read 1 character from the receive buffers, returning true if successful -bool LwipSocket::ReadChar(char& c) +bool LwipSocket::ReadChar(char& c) noexcept { if (receivedData != nullptr) { @@ -292,7 +292,7 @@ bool LwipSocket::ReadChar(char& c) } // Return a pointer to data in a buffer and a length available -bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len) +bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len) noexcept { if (receivedData != nullptr) { @@ -306,7 +306,7 @@ bool LwipSocket::ReadBuffer(const uint8_t *&buffer, size_t &len) } // Flag some data as taken from the receive buffers. We never take data from more than one buffer at a time. -void LwipSocket::Taken(size_t len) +void LwipSocket::Taken(size_t len) noexcept { if (receivedData != nullptr) { @@ -333,7 +333,7 @@ void LwipSocket::Taken(size_t len) } // Poll a socket to see if it needs to be serviced -void LwipSocket::Poll() +void LwipSocket::Poll() noexcept { switch (state) { @@ -399,7 +399,7 @@ void LwipSocket::Poll() } // Discard any received data for this transaction -void LwipSocket::DiscardReceivedData() +void LwipSocket::DiscardReceivedData() noexcept { if (receivedData != nullptr) { @@ -410,7 +410,7 @@ void LwipSocket::DiscardReceivedData() } // Send the data, returning the length buffered -size_t LwipSocket::Send(const uint8_t *data, size_t length) +size_t LwipSocket::Send(const uint8_t *data, size_t length) noexcept { #if LWIP_GMAC_TASK MutexLocker lock(lwipMutex); diff --git a/src/Networking/LwipEthernet/LwipSocket.h b/src/Networking/LwipEthernet/LwipSocket.h index 5f9b1f0f..f2e9ef85 100644 --- a/src/Networking/LwipEthernet/LwipSocket.h +++ b/src/Networking/LwipEthernet/LwipSocket.h @@ -21,30 +21,30 @@ struct pbuf; class LwipSocket : public Socket { public: - LwipSocket(NetworkInterface *iface); - int GetState() const { return (int)state; } // for debugging + LwipSocket(NetworkInterface *iface) noexcept; + int GetState() const noexcept { return (int)state; } // for debugging // LwIP interfaces - bool AcceptConnection(tcp_pcb *pcb); - void DataReceived(pbuf *data); - void DataSent(size_t numBytes); - void ConnectionClosedGracefully(); - void ConnectionError(err_t err); + bool AcceptConnection(tcp_pcb *pcb) noexcept; + void DataReceived(pbuf *data) noexcept; + void DataSent(size_t numBytes) noexcept; + void ConnectionClosedGracefully() noexcept; + void ConnectionError(err_t err) noexcept; // Inherited members of the Socket class - void Init(SocketNumber s, Port serverPort, NetworkProtocol p); - void TerminateAndDisable() override; - void Poll() override; - void Close() override; - bool IsClosing() const { return (state == SocketState::closing); } - void Terminate() override; - bool ReadChar(char& c) override; - bool ReadBuffer(const uint8_t *&buffer, size_t &len) override; - void Taken(size_t len) override; - bool CanRead() const override; - bool CanSend() const override; - size_t Send(const uint8_t *data, size_t length) override; - void Send() override { } + void Init(SocketNumber s, Port serverPort, NetworkProtocol p) noexcept; + void TerminateAndDisable() noexcept override; + void Poll() noexcept override; + void Close() noexcept override; + bool IsClosing() const noexcept { return (state == SocketState::closing); } + void Terminate() noexcept override; + bool ReadChar(char& c) noexcept override; + bool ReadBuffer(const uint8_t *&buffer, size_t &len) noexcept override; + void Taken(size_t len) noexcept override; + bool CanRead() const noexcept override; + bool CanSend() const noexcept override; + size_t Send(const uint8_t *data, size_t length) noexcept override; + void Send() noexcept override { } private: enum class SocketState : uint8_t @@ -58,8 +58,8 @@ private: aborted }; - void ReInit(); - void DiscardReceivedData(); + void ReInit() noexcept; + void DiscardReceivedData() noexcept; uint32_t whenConnected; uint32_t whenWritten; |