libcyberradio 22.01.24
DataPort.h
1/***************************************************************************
2 * \file DataPort.h
3 * \brief Defines the basic 10GigE data port interface for an
4 * NDR-class radio.
5 * \author DA
6 * \author NH
7 * \author MN
8 * \copyright (c) 2017 CyberRadio Solutions, Inc. All rights reserved.
9 *
10 ***************************************************************************/
11
12#ifndef INCLUDED_LIBCYBERRADIO_DRIVER_DATAPORT_H
13#define INCLUDED_LIBCYBERRADIO_DRIVER_DATAPORT_H
14
15#include "LibCyberRadio/Driver/Configurable.h"
16#include "LibCyberRadio/Common/BasicDict.h"
17#include "LibCyberRadio/Common/BasicList.h"
18#include <string>
19
20
24namespace LibCyberRadio
25{
29 namespace Driver
30 {
31 // Forward declaration for RadioHandler object
32 class RadioHandler;
33
45 class DataPort : public Configurable
46 {
47 public:
59 DataPort(const std::string& name = "DATAPORT",
60 int index = 0,
61 RadioHandler* parent = NULL,
62 bool debug = false,
63 const std::string& sourceIP = "0.0.0.0",
64 int numDataPortDipEntries = 0,
65 int dataPortDipEntryIndexBase = 0);
69 virtual ~DataPort();
74 DataPort(const DataPort& other);
80 virtual DataPort& operator=(const DataPort& other);
81 // Configurable interface
88 virtual bool setConfiguration(ConfigurationDict& cfg);
92 virtual void queryConfiguration();
93 // DataPort extensions
98 virtual int getNumDestEntries() const;
103 virtual BasicIntList getDestEntryIndexRange() const;
108 virtual std::string getSourceIP() const;
114 virtual bool setSourceIP(const std::string& ipAddr);
121 virtual std::string getDestMACAddress(int dipIndex) const;
128 virtual std::string getDestIPAddress(int dipIndex) const;
135 virtual unsigned int getDestSourcePort(int dipIndex) const;
142 virtual unsigned int getDestDestPort(int dipIndex) const;
153 virtual bool setDestInfo(int dipIndex,
154 const std::string& ipAddr,
155 const std::string& macAddr,
156 unsigned int sourcePort,
157 unsigned int destPort);
165 virtual bool setDestMACAddress(int dipIndex, const std::string& macAddr);
173 virtual bool setDestIPAddress(int dipIndex, const std::string& ipAddr);
181 virtual bool setDestSourcePort(int dipIndex, unsigned int sourcePort);
189 virtual bool setDestDestPort(int dipIndex, unsigned int destPort);
195 virtual bool enableErrors(bool enabled = true);
200 virtual bool disableErrors();
206 virtual bool enableFlowControl(bool enabled = true);
211 virtual bool disableFlowControl();
212
213 protected:
214 // Configurable interface
219 virtual void initConfigurationDict();
223 virtual void updateConfigurationDict();
224 // DataPort extensions
234 virtual bool executeSourceIPQuery(int index, std::string& ipAddr);
241 virtual bool executeSourceIPCommand(int index, std::string& ipAddr);
255 virtual bool executeDestIPQuery(int index,
256 int dipIndex,
257 std::string& ipAddr,
258 std::string& macAddr,
259 unsigned int& sourcePort,
260 unsigned int& destPort);
271 virtual bool executeDestIPCommand(int index,
272 int dipIndex,
273 std::string& ipAddr,
274 std::string& macAddr,
275 unsigned int& sourcePort,
276 unsigned int& destPort);
283 virtual bool executeErrorEnabledQuery(int index, bool& enabled);
290 virtual bool executeErrorEnabledCommand(int index, bool& enabled);
297 virtual bool executeFlowControlEnabledQuery(int index, bool& enabled);
304 virtual bool executeFlowControlEnabledCommand(int index, bool& enabled);
305
306 protected:
307 // Index number of the data port
308 int _index;
309 // Parent radio handler object
310 RadioHandler* _parent;
311 // Source IP address
312 std::string _sourceIP;
313 // Number of DIP table entries
314 int _numDipEntries;
315 // DIP entry index base
316 int _dipEntryIndexBase;
317 // Whether errors are enabled or not
318 bool _errorsEnabled;
319 // Whether flow control is enabled or not
320 bool _flowControlEnabled;
321 // Dict of MAC addresses, keyed by DIP table index
322 BasicIntStringDict _macAddresses;
323 // Dict of IP addresses, keyed by DIP table index
324 BasicIntStringDict _ipAddresses;
325 // Dict of source UDP port numbers, keyed by DIP table index
326 BasicIntUIntDict _sourcePorts;
327 // Dict of destination UDP port numbers, keyed by DIP table index
328 BasicIntUIntDict _destPorts;
329
330
331 }; /* class DataPort */
332
336 typedef BASIC_DICT_CONTAINER<int, DataPort*> DataPortDict;
337
338 } /* namespace Driver */
339
340} /* namespace LibCyberRadio */
341
342#endif /* INCLUDED_LIBCYBERRADIO_DRIVER_DATAPORT_H0 */
virtual int debug(const char *format,...)
Outputs debug information.
Configurable(const std::string &name="<unknown>", bool debug=false)
Constructs a Configurable object.
A configuration dictionary.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
Definition DataPort.cpp:84
virtual bool executeFlowControlEnabledCommand(int index, bool &enabled)
Executes the flow control enabled command.
Definition DataPort.cpp:513
virtual bool executeErrorEnabledQuery(int index, bool &enabled)
Executes the error enabled query.
Definition DataPort.cpp:446
virtual int getNumDestEntries() const
Gets the number of destination IP table entries.
Definition DataPort.cpp:131
virtual bool executeDestIPCommand(int index, int dipIndex, std::string &ipAddr, std::string &macAddr, unsigned int &sourcePort, unsigned int &destPort)
Executes the destination IP set command.
Definition DataPort.cpp:418
virtual bool executeDestIPQuery(int index, int dipIndex, std::string &ipAddr, std::string &macAddr, unsigned int &sourcePort, unsigned int &destPort)
Executes the destination IP query command.
Definition DataPort.cpp:367
virtual BasicIntList getDestEntryIndexRange() const
Gets the list of destination IP table entry indices.
Definition DataPort.cpp:136
virtual bool setDestInfo(int dipIndex, const std::string &ipAddr, const std::string &macAddr, unsigned int sourcePort, unsigned int destPort)
Sets the destination table information for a given entry in the DIP table.
Definition DataPort.cpp:201
virtual bool setSourceIP(const std::string &ipAddr)
Sets the source IP address.
Definition DataPort.cpp:153
DataPort(const std::string &name="DATAPORT", int index=0, RadioHandler *parent=NULL, bool debug=false, const std::string &sourceIP="0.0.0.0", int numDataPortDipEntries=0, int dataPortDipEntryIndexBase=0)
Constructs a DataPort object.
Definition DataPort.cpp:25
virtual bool setDestMACAddress(int dipIndex, const std::string &macAddr)
Sets the MAC address for a given entry in the destination IP table.
Definition DataPort.cpp:224
virtual DataPort & operator=(const DataPort &other)
Assignment operator for DataPort objects.
Definition DataPort.cpp:64
virtual std::string getSourceIP() const
Gets the source IP address.
Definition DataPort.cpp:148
virtual std::string getDestIPAddress(int dipIndex) const
Gets the IP address for a given entry in the destination IP table.
Definition DataPort.cpp:177
virtual std::string getDestMACAddress(int dipIndex) const
Gets the MAC address for a given entry in the destination IP table.
Definition DataPort.cpp:169
virtual ~DataPort()
Destroys a DataPort object.
Definition DataPort.cpp:44
virtual unsigned int getDestSourcePort(int dipIndex) const
Gets the source UDP port number for a given entry in the destination IP table.
Definition DataPort.cpp:185
virtual bool executeSourceIPCommand(int index, std::string &ipAddr)
Executes the source IP set command.
Definition DataPort.cpp:348
virtual bool disableErrors()
Disables errors on the data port.
Definition DataPort.cpp:276
virtual void queryConfiguration()
Tells the object to create its configuration dictionary.
Definition DataPort.cpp:107
virtual void updateConfigurationDict()
Updates the configuration dictionary from object settings.
Definition DataPort.cpp:312
virtual bool setDestIPAddress(int dipIndex, const std::string &ipAddr)
Sets the IP address for a given entry in the destination IP table.
Definition DataPort.cpp:233
virtual bool enableErrors(bool enabled=true)
Enables errors on the data port.
Definition DataPort.cpp:260
virtual bool executeSourceIPQuery(int index, std::string &ipAddr)
Executes the source IP query command.
Definition DataPort.cpp:325
virtual bool executeErrorEnabledCommand(int index, bool &enabled)
Executes the error enabled command.
Definition DataPort.cpp:470
virtual bool setDestDestPort(int dipIndex, unsigned int destPort)
Sets the destination UDP port number for a given entry in the destination IP table.
Definition DataPort.cpp:251
virtual bool disableFlowControl()
Disables flow control on the data port.
Definition DataPort.cpp:297
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
Definition DataPort.cpp:302
virtual bool enableFlowControl(bool enabled=true)
Enables flow control on the data port.
Definition DataPort.cpp:281
virtual bool setDestSourcePort(int dipIndex, unsigned int sourcePort)
Sets the source UDP port number for a given entry in the destination IP table.
Definition DataPort.cpp:242
virtual unsigned int getDestDestPort(int dipIndex) const
Gets the destination UDP port number for a given entry in the destination IP table.
Definition DataPort.cpp:193
virtual bool executeFlowControlEnabledQuery(int index, bool &enabled)
Executes the flow control enabled query.
Definition DataPort.cpp:489
Generic radio handler class.
Provides programming elements for driving CRS NDR-class radios.
BASIC_DICT_CONTAINER< int, DataPort * > DataPortDict
A dictionary of data ports, keyed by index.
Definition DataPort.h:336
Defines functionality for LibCyberRadio applications.
Definition App.h:24
BASIC_LIST_CONTAINER< int > BasicIntList
Type representing a list of integers.
Definition BasicList.h:27
BASIC_DICT_CONTAINER< int, std::string > BasicIntStringDict
Type representing a dictionary of strings, keyed by integer values.
Definition BasicDict.h:31
BASIC_DICT_CONTAINER< int, unsigned int > BasicIntUIntDict
Type representing a dictionary of unsigned integers, keyed by integer values.
Definition BasicDict.h:35