libcyberradio  22.01.24
DataPort Class Reference

10GigE data port class for the NDR810. More...

#include <DataPort.h>

Inheritance diagram for DataPort:
DataPort Configurable Debuggable

Public Member Functions

 DataPort (int index=0, ::LibCyberRadio::Driver::RadioHandler *parent=NULL, bool debug=false, const std::string &sourceIP="0.0.0.0")
 Constructs a DataPort object. More...
 
virtual ~DataPort ()
 Destroys a DataPort object.
 
 DataPort (const DataPort &other)
 Copies a DataPort object. More...
 
virtual DataPortoperator= (const DataPort &other)
 Assignment operator for DataPort objects. More...
 
virtual bool setConfiguration (ConfigurationDict &cfg)
 Sets the configuration dictionary for this object. More...
 
virtual void queryConfiguration ()
 Tells the object to create its configuration dictionary.
 
virtual int getNumDestEntries () const
 Gets the number of destination IP table entries. More...
 
virtual BasicIntList getDestEntryIndexRange () const
 Gets the list of destination IP table entry indices. More...
 
virtual std::string getSourceIP () const
 Gets the source IP address. More...
 
virtual bool setSourceIP (const std::string &ipAddr)
 Sets the source IP address. More...
 
virtual std::string getDestMACAddress (int dipIndex) const
 Gets the MAC address for a given entry in the destination IP table. More...
 
virtual std::string getDestIPAddress (int dipIndex) const
 Gets the IP address for a given entry in the destination IP table. More...
 
virtual unsigned int getDestSourcePort (int dipIndex) const
 Gets the source UDP port number for a given entry in the destination IP table. More...
 
virtual unsigned int getDestDestPort (int dipIndex) const
 Gets the destination UDP port number for a given entry in the destination IP table. More...
 
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. More...
 
virtual bool setDestMACAddress (int dipIndex, const std::string &macAddr)
 Sets the MAC address for a given entry in the destination IP table. More...
 
virtual bool setDestIPAddress (int dipIndex, const std::string &ipAddr)
 Sets the IP address for a given entry in the destination IP table. More...
 
virtual bool setDestSourcePort (int dipIndex, unsigned int sourcePort)
 Sets the source UDP port number for a given entry in the destination IP table. More...
 
virtual bool setDestDestPort (int dipIndex, unsigned int destPort)
 Sets the destination UDP port number for a given entry in the destination IP table. More...
 
virtual bool enableErrors (bool enabled=true)
 Enables errors on the data port. More...
 
virtual bool disableErrors ()
 Disables errors on the data port. More...
 
virtual bool enableFlowControl (bool enabled=true)
 Enables flow control on the data port. More...
 
virtual bool disableFlowControl ()
 Disables flow control on the data port. More...
 
virtual std::string getName () const
 Gets the name of the configurable object. More...
 
virtual void setName (const std::string &name)
 Sets the name of the configurable object. More...
 
virtual ConfigurationDict getConfiguration () const
 Gets the configuration dictionary for this object. More...
 
virtual ConfigString getConfigurationValue (const std::string &key) const
 Gets a named configuration value as a string. More...
 
virtual bool getConfigurationValueAsBool (const std::string &key) const
 Gets a named configuration value as a Boolean. More...
 
virtual int getConfigurationValueAsInt (const std::string &key) const
 Gets a named configuration value as an integer value. More...
 
virtual unsigned int getConfigurationValueAsUInt (const std::string &key) const
 Gets a named configuration value as an unsigned integer value. More...
 
virtual double getConfigurationValueAsDbl (const std::string &key) const
 Gets a named configuration value as a double value. More...
 
virtual bool setConfigurationValue (const std::string &key, const std::string &value)
 Sets a named configuration value to a string. More...
 
virtual bool setConfigurationValueToBool (const std::string &key, const bool value)
 Sets a named configuration value to a Boolean. More...
 
virtual bool setConfigurationValueToInt (const std::string &key, const int value)
 Sets a named configuration value to an integer value. More...
 
virtual bool setConfigurationValueToUInt (const std::string &key, const unsigned int value)
 Sets a named configuration value to an unsigned integer value. More...
 
virtual bool setConfigurationValueToDbl (const std::string &key, const double value)
 Sets a named configuration value to a double value. More...
 
virtual void setDebugName (const std::string &debug_name)
 Sets the debug name for this object. More...
 
virtual void setDebugFile (FILE *debug_fp)
 Sets the debug file pointer for this object. More...
 
virtual void setDebugTimeFormat (const std::string &debug_timefmt)
 Sets the debug time format for this object. More...
 
virtual int debug (const char *format,...)
 Outputs debug information. More...
 
virtual const char * debugBool (bool x)
 Gets a debug output string for a Boolean value. More...
 
virtual bool isDebug () const
 Gets whether this object produces debug output. More...
 
virtual std::string getDebugName () const
 Gets the debug name for this object. More...
 
virtual std::string rawString (const std::string &data)
 Gets a "raw" string representation of a given data string. More...
 

Protected Member Functions

virtual void initConfigurationDict ()
 Initializes the configuration dictionary, defining the allowed keys.
 
virtual void updateConfigurationDict ()
 Updates the configuration dictionary from object settings.
 
virtual bool executeSourceIPQuery (int index, std::string &ipAddr)
 Executes the source IP query command. More...
 
virtual bool executeSourceIPCommand (int index, std::string &ipAddr)
 Executes the source IP set command. More...
 
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. More...
 
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. More...
 
virtual bool executeErrorEnabledQuery (int index, bool &enabled)
 Executes the error enabled query. More...
 
virtual bool executeErrorEnabledCommand (int index, bool &enabled)
 Executes the error enabled command. More...
 
virtual bool executeFlowControlEnabledQuery (int index, bool &enabled)
 Executes the flow control enabled query. More...
 
virtual bool executeFlowControlEnabledCommand (int index, bool &enabled)
 Executes the flow control enabled command. More...
 
virtual ConfigurationDict normalizedConfigurationDict (const ConfigurationDict &cfg)
 Normalizes an incoming configuration dictionary. More...
 
virtual std::string normalizedBool (const std::string &val)
 Normalizes a Boolean string value. More...
 
virtual void dumpConfiguration ()
 Dumps this object's configuration dictionary to debug output.
 

Detailed Description

10GigE data port class for the NDR810.

Configuration dictionary items:

  • "sourceIP": Source IP address [string]
  • "errors": Whether errors are enabled [Boolean/integer/string]
  • "flowControl": Whether flow control is enabled [Boolean/integer/string]

Definition at line 44 of file DataPort.h.

Constructor & Destructor Documentation

◆ DataPort() [1/2]

DataPort ( int  index = 0,
::LibCyberRadio::Driver::RadioHandler parent = NULL,
bool  debug = false,
const std::string &  sourceIP = "0.0.0.0" 
)

Constructs a DataPort object.

Parameters
indexThe index number of this object.
parentA pointer to the RadioHandler object that "owns" this object.
debugWhether the object supports debug output.
sourceIPSource IP address.

Definition at line 24 of file DataPort.cpp.

◆ DataPort() [2/2]

DataPort ( const DataPort other)

Copies a DataPort object.

Parameters
otherThe DataPort object to copy.

Definition at line 44 of file DataPort.cpp.

Member Function Documentation

◆ debug()

int debug ( const char *  format,
  ... 
)
virtualinherited

Outputs debug information.

This method follows the same semantics as printf(). Output is preceded by a timestamp and the name of the object, if provided.

Parameters
formatThe printf()-style format string.
...Comma-separated list of arguments to print. Note that these need to be arguments that can be supported natively through printf().
Returns
The number of characters outputted.

Definition at line 95 of file Debuggable.cpp.

◆ debugBool()

const char * debugBool ( bool  x)
virtualinherited

Gets a debug output string for a Boolean value.

Parameters
xBoolean value
Returns
A constant string, either "true" or "false".

Definition at line 126 of file Debuggable.cpp.

◆ disableErrors()

bool disableErrors ( )
virtualinherited

Disables errors on the data port.

Returns
True if successful, false otherwise.

Definition at line 276 of file DataPort.cpp.

◆ disableFlowControl()

bool disableFlowControl ( )
virtualinherited

Disables flow control on the data port.

Returns
True if successful, false otherwise.

Definition at line 297 of file DataPort.cpp.

◆ enableErrors()

bool enableErrors ( bool  enabled = true)
virtualinherited

Enables errors on the data port.

Parameters
enabledWhether or not errors should be enabled.
Returns
True if successful, false otherwise.

Definition at line 260 of file DataPort.cpp.

◆ enableFlowControl()

bool enableFlowControl ( bool  enabled = true)
virtualinherited

Enables flow control on the data port.

Parameters
enabledWhether or not errors should be enabled.
Returns
True if successful, false otherwise.

Definition at line 281 of file DataPort.cpp.

◆ executeDestIPCommand()

bool executeDestIPCommand ( int  index,
int  dipIndex,
std::string &  ipAddr,
std::string &  macAddr,
unsigned int &  sourcePort,
unsigned int &  destPort 
)
protectedvirtualinherited

Executes the destination IP set command.

Parameters
indexData port index.
dipIndexDIP table entry index.
ipAddrDestination IP address.
macAddrDestination MAC address.
sourcePortSource UDP port.
destPortDestination UDP port.
Returns
True if the command succeeded, false otherwise.

Reimplemented in DataPort.

Definition at line 418 of file DataPort.cpp.

◆ executeDestIPQuery()

bool executeDestIPQuery ( int  index,
int  dipIndex,
std::string &  ipAddr,
std::string &  macAddr,
unsigned int &  sourcePort,
unsigned int &  destPort 
)
protectedvirtualinherited

Executes the destination IP query command.

Note
The return value from this method only indicates if the command succeeded or failed. This method uses reference parameters to return the results of the query.
Parameters
indexData port index.
dipIndexDIP table entry index.
ipAddrDestination IP address (return).
macAddrDestination MAC address (return).
sourcePortSource UDP port (return).
destPortDestination UDP port (return).
Returns
True if the command succeeded, false otherwise.

Reimplemented in DataPort.

Definition at line 367 of file DataPort.cpp.

◆ executeErrorEnabledCommand()

bool executeErrorEnabledCommand ( int  index,
bool &  enabled 
)
protectedvirtualinherited

Executes the error enabled command.

Parameters
indexData port index.
enabledError enabled.
Returns
True if the command succeeded, false otherwise.

Definition at line 470 of file DataPort.cpp.

◆ executeErrorEnabledQuery()

bool executeErrorEnabledQuery ( int  index,
bool &  enabled 
)
protectedvirtualinherited

Executes the error enabled query.

Parameters
indexData port index.
enabledError enabled [output].
Returns
True if the command succeeded, false otherwise.

Definition at line 446 of file DataPort.cpp.

◆ executeFlowControlEnabledCommand()

bool executeFlowControlEnabledCommand ( int  index,
bool &  enabled 
)
protectedvirtualinherited

Executes the flow control enabled command.

Parameters
indexData port index.
enabledFlow control enabled.
Returns
True if the command succeeded, false otherwise.

Definition at line 513 of file DataPort.cpp.

◆ executeFlowControlEnabledQuery()

bool executeFlowControlEnabledQuery ( int  index,
bool &  enabled 
)
protectedvirtualinherited

Executes the flow control enabled query.

Parameters
indexData port index.
enabledFlow control enabled [output].
Returns
True if the command succeeded, false otherwise.

Definition at line 489 of file DataPort.cpp.

◆ executeSourceIPCommand()

bool executeSourceIPCommand ( int  index,
std::string &  ipAddr 
)
protectedvirtualinherited

Executes the source IP set command.

Parameters
indexData port index.
ipAddrSource IP address (return).
Returns
True if the command succeeded, false otherwise.

Reimplemented in DataPort.

Definition at line 348 of file DataPort.cpp.

◆ executeSourceIPQuery()

bool executeSourceIPQuery ( int  index,
std::string &  ipAddr 
)
protectedvirtualinherited

Executes the source IP query command.

Note
The return value from this method only indicates if the command succeeded or failed. This method uses reference parameters to return the results of the query.
Parameters
indexData port index.
ipAddrSource IP address (return).
Returns
True if the command succeeded, false otherwise.

Reimplemented in DataPort.

Definition at line 325 of file DataPort.cpp.

◆ getConfiguration()

ConfigurationDict getConfiguration ( ) const
virtualinherited

Gets the configuration dictionary for this object.

Returns
The configuration dictionary.

Definition at line 93 of file Configurable.cpp.

◆ getConfigurationValue()

ConfigString getConfigurationValue ( const std::string &  key) const
virtualinherited

Gets a named configuration value as a string.

Parameters
keyThe key string in the configuration dictionary.
Returns
The value represented by this key. Returns an empty string if the key is not in the configuration dictionary.

Definition at line 98 of file Configurable.cpp.

◆ getConfigurationValueAsBool()

bool getConfigurationValueAsBool ( const std::string &  key) const
virtualinherited

Gets a named configuration value as a Boolean.

Parameters
keyThe key string in the configuration dictionary.
Returns
The Boolean value represented by this key. Returns false if the key is not in the configuration dictionary, or cannot be represented as a Boolean.

Definition at line 109 of file Configurable.cpp.

◆ getConfigurationValueAsDbl()

double getConfigurationValueAsDbl ( const std::string &  key) const
virtualinherited

Gets a named configuration value as a double value.

Parameters
keyThe key string in the configuration dictionary.
Returns
The double value represented by this key. Returns 0.0 if the key is not in the configuration dictionary, or if the value cannot be represented as a double.

Definition at line 148 of file Configurable.cpp.

◆ getConfigurationValueAsInt()

int getConfigurationValueAsInt ( const std::string &  key) const
virtualinherited

Gets a named configuration value as an integer value.

Parameters
keyThe key string in the configuration dictionary.
Returns
The integer value represented by this key. Returns 0 if the key is not in the configuration dictionary, or if the value cannot be represented as an integer.

Definition at line 122 of file Configurable.cpp.

◆ getConfigurationValueAsUInt()

unsigned int getConfigurationValueAsUInt ( const std::string &  key) const
virtualinherited

Gets a named configuration value as an unsigned integer value.

Parameters
keyThe key string in the configuration dictionary.
Returns
The integer value represented by this key. Returns 0 if the key is not in the configuration dictionary, or if the value cannot be represented as an integer.

Definition at line 135 of file Configurable.cpp.

◆ getDebugName()

std::string getDebugName ( ) const
virtualinherited

Gets the debug name for this object.

Returns
The debug name, as a string.

Definition at line 138 of file Debuggable.cpp.

◆ getDestDestPort()

unsigned int getDestDestPort ( int  dipIndex) const
virtualinherited

Gets the destination UDP port number for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
Returns
The port number.

Definition at line 193 of file DataPort.cpp.

◆ getDestEntryIndexRange()

BasicIntList getDestEntryIndexRange ( ) const
virtualinherited

Gets the list of destination IP table entry indices.

Returns
The list of indices.

Definition at line 136 of file DataPort.cpp.

◆ getDestIPAddress()

std::string getDestIPAddress ( int  dipIndex) const
virtualinherited

Gets the IP address for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
Returns
The IP address.

Definition at line 177 of file DataPort.cpp.

◆ getDestMACAddress()

std::string getDestMACAddress ( int  dipIndex) const
virtualinherited

Gets the MAC address for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
Returns
The MAC address.

Definition at line 169 of file DataPort.cpp.

◆ getDestSourcePort()

unsigned int getDestSourcePort ( int  dipIndex) const
virtualinherited

Gets the source UDP port number for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
Returns
The port number.

Definition at line 185 of file DataPort.cpp.

◆ getName()

std::string getName ( ) const
virtualinherited

Gets the name of the configurable object.

Returns
The name, as a string.

Definition at line 83 of file Configurable.cpp.

◆ getNumDestEntries()

int getNumDestEntries ( ) const
virtualinherited

Gets the number of destination IP table entries.

Returns
The number of entries, as an integer.

Definition at line 131 of file DataPort.cpp.

◆ getSourceIP()

std::string getSourceIP ( ) const
virtualinherited

Gets the source IP address.

Returns
The source IP address.

Definition at line 148 of file DataPort.cpp.

◆ isDebug()

bool isDebug ( ) const
virtualinherited

Gets whether this object produces debug output.

Returns
True if producing debug, false otherwise.

Definition at line 133 of file Debuggable.cpp.

◆ normalizedBool()

std::string normalizedBool ( const std::string &  val)
protectedvirtualinherited

Normalizes a Boolean string value.

Returns
The "normalized" string value.

Definition at line 241 of file Configurable.cpp.

◆ normalizedConfigurationDict()

ConfigurationDict normalizedConfigurationDict ( const ConfigurationDict cfg)
protectedvirtualinherited

Normalizes an incoming configuration dictionary.

"Normalizing" a configuration dictionary replaces certain strings representing Boolean values ("yes", "on", "true", "no", "off", and "false", case is irrelevant) with standard values ("0" and "1").

Note
The default behavior of this method normalizes every string in the configuration dictionary. Override this method if certain configuration items need to be protected from normalization.
Returns
The new configuration dictionary.

Definition at line 232 of file Configurable.cpp.

◆ operator=()

DataPort & operator= ( const DataPort other)
virtual

Assignment operator for DataPort objects.

Parameters
otherThe DataPort object to copy.
Returns
A reference to the assigned object.

Definition at line 49 of file DataPort.cpp.

◆ rawString()

std::string rawString ( const std::string &  data)
virtualinherited

Gets a "raw" string representation of a given data string.

"Raw" string representations mimic Python string representations. Whitespace characters are denoted by backslash representations ("\\r", "\\n", "\\t", "\\v", "\\f"), while other non-printable characters are represented with hex representation ("\\x00", etc.)

Parameters
dataData string
Returns
The data's "raw" representation.

Definition at line 143 of file Debuggable.cpp.

◆ setConfiguration()

bool setConfiguration ( ConfigurationDict cfg)
virtualinherited

Sets the configuration dictionary for this object.

Parameters
cfgThe configuration dictionary.
Returns
True if successful, false otherwise.

Reimplemented from Configurable.

Definition at line 84 of file DataPort.cpp.

◆ setConfigurationValue()

bool setConfigurationValue ( const std::string &  key,
const std::string &  value 
)
virtualinherited

Sets a named configuration value to a string.

Note
The default behavior of this method is to normalize the incoming value.
Parameters
keyThe key string in the configuration dictionary.
valueThe new value.
Returns
True if the key was set, false otherwise. Returns false if the key is not in the configuration dictionary.

Definition at line 177 of file Configurable.cpp.

◆ setConfigurationValueToBool()

bool setConfigurationValueToBool ( const std::string &  key,
const bool  value 
)
virtualinherited

Sets a named configuration value to a Boolean.

Parameters
keyThe key string in the configuration dictionary.
valueThe new value.
Returns
True if the key was set, false otherwise. Returns false if the key is not in the configuration dictionary.

Definition at line 193 of file Configurable.cpp.

◆ setConfigurationValueToDbl()

bool setConfigurationValueToDbl ( const std::string &  key,
const double  value 
)
virtualinherited

Sets a named configuration value to a double value.

Parameters
keyThe key string in the configuration dictionary.
valueThe new value.
Returns
True if the key was set, false otherwise. Returns false if the key is not in the configuration dictionary.

Definition at line 211 of file Configurable.cpp.

◆ setConfigurationValueToInt()

bool setConfigurationValueToInt ( const std::string &  key,
const int  value 
)
virtualinherited

Sets a named configuration value to an integer value.

Parameters
keyThe key string in the configuration dictionary.
valueThe new value.
Returns
True if the key was set, false otherwise. Returns false if the key is not in the configuration dictionary.

Definition at line 199 of file Configurable.cpp.

◆ setConfigurationValueToUInt()

bool setConfigurationValueToUInt ( const std::string &  key,
const unsigned int  value 
)
virtualinherited

Sets a named configuration value to an unsigned integer value.

Parameters
keyThe key string in the configuration dictionary.
valueThe new value.
Returns
True if the key was set, false otherwise. Returns false if the key is not in the configuration dictionary.

Definition at line 205 of file Configurable.cpp.

◆ setDebugFile()

void setDebugFile ( FILE *  debug_fp)
virtualinherited

Sets the debug file pointer for this object.

Parameters
debug_fpFile to send debug output to.

Definition at line 81 of file Debuggable.cpp.

◆ setDebugName()

void setDebugName ( const std::string &  debug_name)
virtualinherited

Sets the debug name for this object.

Use this method to set unique debug names for objects of the same class for easy differentiation.

Parameters
debug_nameName for identifying this object in debug output.

Definition at line 74 of file Debuggable.cpp.

◆ setDebugTimeFormat()

void setDebugTimeFormat ( const std::string &  debug_timefmt)
virtualinherited

Sets the debug time format for this object.

Parameters
debug_timefmtFormat string for displaying timestamp, as compatible with strftime(). If this is an empty string, don't display a timestamp.

Definition at line 88 of file Debuggable.cpp.

◆ setDestDestPort()

bool setDestDestPort ( int  dipIndex,
unsigned int  destPort 
)
virtualinherited

Sets the destination UDP port number for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
destPortThe destination UDP port number.
Returns
True if successful, false otherwise.

Definition at line 251 of file DataPort.cpp.

◆ setDestInfo()

bool setDestInfo ( int  dipIndex,
const std::string &  ipAddr,
const std::string &  macAddr,
unsigned int  sourcePort,
unsigned int  destPort 
)
virtualinherited

Sets the destination table information for a given entry in the DIP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
ipAddrThe IP address.
macAddrThe MAC address.
sourcePortThe source UDP port number.
destPortThe destination UDP port number.
Returns
True if successful, false otherwise.

Definition at line 201 of file DataPort.cpp.

◆ setDestIPAddress()

bool setDestIPAddress ( int  dipIndex,
const std::string &  ipAddr 
)
virtualinherited

Sets the IP address for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
ipAddrThe new IP address.
Returns
True if successful, false otherwise.

Definition at line 233 of file DataPort.cpp.

◆ setDestMACAddress()

bool setDestMACAddress ( int  dipIndex,
const std::string &  macAddr 
)
virtualinherited

Sets the MAC address for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
macAddrThe new MAC address.
Returns
True if successful, false otherwise.

Definition at line 224 of file DataPort.cpp.

◆ setDestSourcePort()

bool setDestSourcePort ( int  dipIndex,
unsigned int  sourcePort 
)
virtualinherited

Sets the source UDP port number for a given entry in the destination IP table.

Parameters
dipIndexIndex number for the entry in the DIP table.
sourcePortThe source UDP port number.
Returns
True if successful, false otherwise.

Definition at line 242 of file DataPort.cpp.

◆ setName()

void setName ( const std::string &  name)
virtualinherited

Sets the name of the configurable object.

Parameters
nameThe new name.

Definition at line 88 of file Configurable.cpp.

◆ setSourceIP()

bool setSourceIP ( const std::string &  ipAddr)
virtualinherited

Sets the source IP address.

Parameters
ipAddrThe new source IP address.
Returns
True if successful, false otherwise.

Definition at line 153 of file DataPort.cpp.


The documentation for this class was generated from the following files: