openflow: doxygen fixes

This commit is contained in:
Tommaso Pecorella
2022-01-08 23:28:21 -06:00
parent d5dff3a6c5
commit fcd6678a01
3 changed files with 100 additions and 31 deletions

View File

@@ -111,6 +111,7 @@ class OpenFlowSwitchNetDevice;
namespace ofi {
/**
* \ingroup openflow
* \brief Port and its metadata.
*
* We need to store port metadata, because OpenFlow dictates that there
@@ -134,16 +135,27 @@ struct Port
uint32_t config; ///< Some subset of OFPPC_* flags.
uint32_t state; ///< Some subset of OFPPS_* flags.
Ptr<NetDevice> netdev;
unsigned long long int rx_packets, tx_packets;
unsigned long long int rx_bytes, tx_bytes;
unsigned long long int tx_dropped;
unsigned long long int mpls_ttl0_dropped;
Ptr<NetDevice> netdev; ///< NetDevice pointer
unsigned long long int rx_packets; //!< Counter of Rx packets
unsigned long long int tx_packets; //!< Counter of Tx packets
unsigned long long int rx_bytes; //!< Counter of Rx bytes
unsigned long long int tx_bytes; //!< Counter of Tx bytes
unsigned long long int tx_dropped; //!< Counter of Tx dropped packets
unsigned long long int mpls_ttl0_dropped; //!< Counter of packets dropped due to MPLS TTL
};
/**
* \ingroup openflow
* OpenFlow statistics
*/
class Stats
{
public:
/**
* Constructor
* \param _type OpenFlow stats type.
* \param body_len Stat body length.
*/
Stats (ofp_stats_types _type, size_t body_len);
/**
@@ -180,15 +192,16 @@ public:
*/
struct FlowStatsState
{
int table_idx;
sw_table_position position;
ofp_flow_stats_request rq;
time_t now;
int table_idx; //!< Table index
sw_table_position position; //!< Table position
ofp_flow_stats_request rq; //!< Stats requests
time_t now; //!< Actual time
ofpbuf *buffer;
ofpbuf *buffer; //!< Buffer
};
/**
* \ingroup openflow
* \brief State of the PortStats request/reply.
*/
struct PortStatsState
@@ -197,27 +210,52 @@ public:
uint32_t *ports; ///< Array of ports in network byte order
};
ofp_stats_types type;
ofp_stats_types type; //!< Status type
private:
/**
* Dumps the stats description
* \param [in] state The state.
* \param [out] buffer Output buffer.
* \return zero on success
*/
int DescStatsDump (void *state, ofpbuf *buffer);
/**
* @{
* Initialize the stats.
* \param body Body member of the struct ofp_stats_request.
* \param body_len Length of the body member.
* \param state State information.
* \return 0 if successful, otherwise a negative error code.
*/
int FlowStatsInit (const void *body, int body_len, void **state);
int (*FlowDumpCallback)(sw_flow *flow, void *state);
int FlowStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, FlowStatsState *s, ofpbuf *buffer);
int AggregateStatsInit (const void *body, int body_len, void **state);
int (*AggregateDumpCallback)(sw_flow *flow, void *state);
int AggregateStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, ofp_aggregate_stats_request *s, ofpbuf *buffer);
int TableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *buffer);
int PortStatsInit (const void *body, int body_len, void **state);
int PortStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, PortStatsState *s, ofpbuf *buffer);
/** @} */
/// Flow dump callback functor
int (*FlowDumpCallback)(sw_flow *flow, void *state);
/// Aggregate dump callback functor
int (*AggregateDumpCallback)(sw_flow *flow, void *state);
/**
* @{
* Dump the stats.
* \param dp OpenFlow NetDevice.
* \param state State.
* \param [out] buffer output buffer.
* \return 0 if successful
*/
int FlowStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, FlowStatsState *state, ofpbuf *buffer);
int AggregateStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, ofp_aggregate_stats_request *state, ofpbuf *buffer);
int TableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *buffer);
int PortStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, PortStatsState *state, ofpbuf *buffer);
int PortTableStatsDump (Ptr<OpenFlowSwitchNetDevice> dp, void *state, ofpbuf *buffer);
/** @} */
};
/**
* \ingroup openflow
* \brief Class for handling flow table actions.
*/
struct Action
@@ -251,6 +289,7 @@ struct Action
};
/**
* \ingroup openflow
* \brief Class for handling virtual port table actions.
*/
struct VPortAction
@@ -283,6 +322,7 @@ struct VPortAction
};
/**
* \ingroup openflow
* \brief Class for handling Ericsson Vendor-defined actions.
*/
struct EricssonAction
@@ -314,6 +354,7 @@ struct EricssonAction
};
/**
* \ingroup openflow
* \brief Callback for a stats dump request.
*/
struct StatsDumpCallback
@@ -326,6 +367,7 @@ struct StatsDumpCallback
};
/**
* \ingroup openflow
* \brief Packet Metadata, allows us to track the packet's metadata as it passes through the switch.
*/
struct SwitchPacketMetadata
@@ -338,6 +380,7 @@ struct SwitchPacketMetadata
};
/**
* \ingroup openflow
* \brief An interface for a Controller of OpenFlowSwitchNetDevices
*
* Follows the OpenFlow specification for a controller.
@@ -424,11 +467,13 @@ protected:
*/
uint8_t GetPacketType (ofpbuf* buffer);
/// OpenFlowSwitchNetDevice container type
typedef std::set<Ptr<OpenFlowSwitchNetDevice> > Switches_t;
Switches_t m_switches; ///< The collection of switches registered to this controller.
};
/**
* \ingroup openflow
* Demonstration of a Drop controller. When a connected switch
* passes it a packet the switch doesn't recognize, the controller
* configures the switch to make a flow that drops alike packets.
@@ -446,6 +491,7 @@ public:
};
/**
* \ingroup openflow
* Demonstration of a Learning controller. When a connected switch
* passes it a packet the switch doesn't recognize, the controller
* delves into its learned states and figures out if we know what
@@ -469,11 +515,13 @@ public:
void ReceiveFromSwitch (Ptr<OpenFlowSwitchNetDevice> swtch, ofpbuf* buffer);
protected:
/// Learned state
struct LearnedState
{
uint32_t port; ///< Learned port.
};
Time m_expirationTime; ///< Time it takes for learned MAC state entry/created flow to expire.
/// Learned state type
typedef std::map<Mac48Address, LearnedState> LearnState_t;
LearnState_t m_learnState; ///< Learned state data.
};

View File

@@ -79,6 +79,13 @@ namespace ns3 {
* call.
*/
/**
* \ingroup openflow
* \ingroup tests
* \defgroup openflow-tests OpenFlow module tests
*/
/**
* \ingroup openflow
* \brief A net device that switches multiple LAN segments via an OpenFlow-compatible flow table
@@ -136,7 +143,7 @@ public:
*
* \param switchPort The port to add.
* \return 0 if everything's ok, otherwise an error number.
* \sa #EXFULL
* Possible error numbers: EXFULL
*/
int AddSwitchPort (Ptr<NetDevice> switchPort);
@@ -148,7 +155,7 @@ public:
* don't have an understood use [perhaps it may have to do with
* MPLS integration].
*
* \sa #EINVAL
* Possible error numbers: EINVAL
*
* \param ovpm The data for adding a virtual port.
* \return 0 if everything's ok, otherwise an error number.
@@ -258,7 +265,7 @@ protected:
* \param protocol The protocol defining the Packet.
* \param src The source address of the Packet.
* \param dst The destination address of the Packet.
* \param PacketType Type of the packet.
* \param packetType Type of the packet.
*/
void ReceiveFromDevice (Ptr<NetDevice> netdev, Ptr<const Packet> packet, uint16_t protocol, const Address& src, const Address& dst, PacketType packetType);
@@ -278,7 +285,7 @@ private:
/**
* Add a flow.
*
* \sa #ENOMEM, #ENOBUFS, #ESRCH
* Possible error numbers: ENOMEM, ENOBUFS, ESRCH
*
* \param ofm The flow data to add.
* \return 0 if everything's ok, otherwise an error number.
@@ -307,6 +314,7 @@ private:
* Sends a copy of the Packet over the provided output port
*
* \param packet_uid Packet UID; used to fetch the packet and its metadata.
* \param out_port Output port.
*/
void OutputPacket (uint32_t packet_uid, int out_port);
@@ -477,15 +485,16 @@ private:
int ReceivePacketOut (const void *msg);
int ReceiveFlow (const void *msg);
int ReceivePortMod (const void *msg);
int ReceiveStatsRequest (const void *oh);
int ReceiveEchoRequest (const void *oh);
int ReceiveEchoReply (const void *oh);
int ReceiveStatsRequest (const void *msg);
int ReceiveEchoRequest (const void *msg);
int ReceiveEchoReply (const void *msg);
int ReceiveVPortMod (const void *msg);
int ReceiveVPortTableFeaturesRequest (const void *msg);
/**@}*/
/// Callbacks
/// Rx Callback
NetDevice::ReceiveCallback m_rxCallback;
/// Promiscuopus Rx Callback
NetDevice::PromiscReceiveCallback m_promiscRxCallback;
Mac48Address m_address; ///< Address of this device.
@@ -494,9 +503,11 @@ private:
uint32_t m_ifIndex; ///< Interface Index
uint16_t m_mtu; ///< Maximum Transmission Unit
/// PacketData type
typedef std::map<uint32_t,ofi::SwitchPacketMetadata> PacketData_t;
PacketData_t m_packetData; ///< Packet data
/// Switch's port type
typedef std::vector<ofi::Port> Ports_t;
Ports_t m_ports; ///< Switch's ports

View File

@@ -29,7 +29,12 @@
// to use the using directive to access the ns3 namespace directly
using namespace ns3;
// This is an example TestCase.
/**
* \ingroup openflow-tests
*
* \brief OpenFlow Test
*/
class SwitchFlowTableTestCase : public TestCase
{
public:
@@ -46,7 +51,7 @@ public:
private:
virtual void DoRun (void);
sw_chain* m_chain;
sw_chain* m_chain; //!< OpenFlow service function chain
};
void
@@ -173,6 +178,11 @@ SwitchFlowTableTestCase::DoRun (void)
NS_TEST_ASSERT_MSG_EQ (chain_lookup (m_chain, &key), 0, "Key provided shouldn't match the flow but it does.");
}
/**
* \ingroup openflow-tests
*
* \brief OpenFlow TestSuite
*/
class SwitchTestSuite : public TestSuite
{
public:
@@ -184,6 +194,6 @@ SwitchTestSuite::SwitchTestSuite () : TestSuite ("openflow", UNIT)
AddTestCase (new SwitchFlowTableTestCase, TestCase::QUICK);
}
// Do not forget to allocate an instance of this TestSuite
/// Do not forget to allocate an instance of this TestSuite
static SwitchTestSuite switchTestSuite;