From 941536313ad21db2e91b63b79a8ba99e68aa8971 Mon Sep 17 00:00:00 2001 From: Eduardo Almeida Date: Fri, 14 Jul 2023 14:17:47 +0000 Subject: [PATCH] openflow: Move ReceivePortMod() to fix (erroneous) Doxygen warning --- .../model/openflow-switch-net-device.cc | 86 +++++++++---------- .../model/openflow-switch-net-device.h | 2 +- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/openflow/model/openflow-switch-net-device.cc b/src/openflow/model/openflow-switch-net-device.cc index 594a7bf87..822c3fa86 100644 --- a/src/openflow/model/openflow-switch-net-device.cc +++ b/src/openflow/model/openflow-switch-net-device.cc @@ -1165,6 +1165,49 @@ OpenFlowSwitchNetDevice::RunThroughVPortTable(uint32_t packet_uid, int port, uin return 0; } +int +OpenFlowSwitchNetDevice::ReceivePortMod(const void* msg) +{ + ofp_port_mod* opm = (ofp_port_mod*)msg; + + int port = opm->port_no; // ntohs(opm->port_no); + if (port < DP_MAX_PORTS) + { + ofi::Port& p = m_ports[port]; + + // Make sure the port id hasn't changed since this was sent + Mac48Address hw_addr = Mac48Address(); + hw_addr.CopyFrom(opm->hw_addr); + if (p.netdev->GetAddress() != hw_addr) + { + return 0; + } + + if (opm->mask) + { + uint32_t config_mask = ntohl(opm->mask); + p.config &= ~config_mask; + p.config |= ntohl(opm->config) & config_mask; + } + + if (opm->mask & htonl(OFPPC_PORT_DOWN)) + { + if ((opm->config & htonl(OFPPC_PORT_DOWN)) && (p.config & OFPPC_PORT_DOWN) == 0) + { + p.config |= OFPPC_PORT_DOWN; + /// \todo Possibly disable the Port's Net Device via the appropriate interface. + } + else if ((opm->config & htonl(OFPPC_PORT_DOWN)) == 0 && (p.config & OFPPC_PORT_DOWN)) + { + p.config &= ~OFPPC_PORT_DOWN; + /// \todo Possibly enable the Port's Net Device via the appropriate interface. + } + } + } + + return 0; +} + int OpenFlowSwitchNetDevice::ReceiveFeaturesRequest(const void* msg) { @@ -1252,49 +1295,6 @@ OpenFlowSwitchNetDevice::ReceivePacketOut(const void* msg) return 0; } -int -OpenFlowSwitchNetDevice::ReceivePortMod(const void* msg) -{ - ofp_port_mod* opm = (ofp_port_mod*)msg; - - int port = opm->port_no; // ntohs(opm->port_no); - if (port < DP_MAX_PORTS) - { - ofi::Port& p = m_ports[port]; - - // Make sure the port id hasn't changed since this was sent - Mac48Address hw_addr = Mac48Address(); - hw_addr.CopyFrom(opm->hw_addr); - if (p.netdev->GetAddress() != hw_addr) - { - return 0; - } - - if (opm->mask) - { - uint32_t config_mask = ntohl(opm->mask); - p.config &= ~config_mask; - p.config |= ntohl(opm->config) & config_mask; - } - - if (opm->mask & htonl(OFPPC_PORT_DOWN)) - { - if ((opm->config & htonl(OFPPC_PORT_DOWN)) && (p.config & OFPPC_PORT_DOWN) == 0) - { - p.config |= OFPPC_PORT_DOWN; - /// \todo Possibly disable the Port's Net Device via the appropriate interface. - } - else if ((opm->config & htonl(OFPPC_PORT_DOWN)) == 0 && (p.config & OFPPC_PORT_DOWN)) - { - p.config &= ~OFPPC_PORT_DOWN; - /// \todo Possibly enable the Port's Net Device via the appropriate interface. - } - } - } - - return 0; -} - // add or remove a virtual port table entry int OpenFlowSwitchNetDevice::ReceiveVPortMod(const void* msg) diff --git a/src/openflow/model/openflow-switch-net-device.h b/src/openflow/model/openflow-switch-net-device.h index 05265608d..632c96e4b 100644 --- a/src/openflow/model/openflow-switch-net-device.h +++ b/src/openflow/model/openflow-switch-net-device.h @@ -503,12 +503,12 @@ class OpenFlowSwitchNetDevice : public NetDevice * \param msg The OpenFlow message received. * \return 0 if everything's ok, otherwise an error number. */ + int ReceivePortMod(const void* msg); int ReceiveFeaturesRequest(const void* msg); int ReceiveGetConfigRequest(const void* msg); int ReceiveSetConfig(const void* msg); int ReceivePacketOut(const void* msg); int ReceiveFlow(const void* msg); - int ReceivePortMod(const void* msg); int ReceiveStatsRequest(const void* msg); int ReceiveEchoRequest(const void* msg); int ReceiveEchoReply(const void* msg);