12#include "LibCyberRadio/Driver/SimpleIpSetup.h"
13#include "LibCyberRadio/Driver/RadioHandler.h"
14#include "LibCyberRadio/Common/Pythonesque.h"
15#include <boost/lexical_cast.hpp>
28 const std::string& sourceIP,
29 const std::string& destIP,
30 const std::string& destMAC) :
34 _sourceMAC(
"00:00:00:00:00:00"),
47 _parent(other._parent),
48 _sourceIP(other._sourceIP),
49 _sourceMAC(other._sourceMAC),
50 _destIP(other._destIP),
51 _destMAC(other._destMAC)
60 _parent = other._parent;
61 _sourceIP = other._sourceIP;
62 _sourceMAC = other._sourceMAC;
63 _destIP = other._destIP;
64 _destMAC = other._destMAC;
71 this->
debug(
"[SimpleIpSetup::setConfiguration] Called\n");
76 if ( cfg.
hasKey(
"sourceIP") && _config.hasKey(
"sourceIP") )
80 if ( cfg.
hasKey(
"destIP") && _config.hasKey(
"destIP") )
84 if ( cfg.
hasKey(
"destMAC") && _config.hasKey(
"destMAC") )
88 this->
debug(
"[SimpleIpSetup::setConfiguration] Returning\n");
94 this->
debug(
"[SimpleIpSetup::queryConfiguration] Called\n");
96 if ( _config.hasKey(
"sourceIP") )
98 if ( _config.hasKey(
"sourceMAC") )
100 if ( _config.hasKey(
"destIP") )
102 if ( _config.hasKey(
"destMAC") )
105 this->
debug(
"[SimpleIpSetup::queryConfiguration] Returning\n");
121 if ( _config.hasKey(
"sourceIP") )
123 std::string adjSourceIP = ipAddr;
127 _sourceIP = adjSourceIP;
147 if ( _config.hasKey(
"destMAC") )
149 std::string adjDestMAC = macAddr;
153 _destMAC = adjDestMAC;
163 if ( _config.hasKey(
"destIP") )
165 std::string adjDestIP = ipAddr;
180 _config[
"sourceIP"] = _sourceIP;
181 _config[
"sourceMAC"] = _sourceMAC;
182 _config[
"destIP"] = _destIP;
183 _config[
"destMAC"] = _destMAC;
189 this->
debug(
"[SimpleIpSetup::updateConfigurationDict] Called\n");
190 if ( _config.hasKey(
"sourceIP") )
192 if ( _config.hasKey(
"sourceMAC") )
194 if ( _config.hasKey(
"destIP") )
196 if ( _config.hasKey(
"destMAC") )
198 this->
debug(
"[SimpleIpSetup::updateConfigurationDict] Returning\n");
205 if ( (_parent != NULL) && (_parent->isConnected()) )
207 std::ostringstream oss;
208 oss <<
"#MAC?" <<
"\n";
210 if ( _parent->getLastCommandErrorInfo() ==
"" )
227 if ( (_parent != NULL) && (_parent->isConnected()) )
229 std::ostringstream oss;
230 oss <<
"SIP?" <<
"\n";
232 if ( _parent->getLastCommandErrorInfo() ==
"" )
249 if ( (_parent != NULL) && (_parent->isConnected()) )
251 std::ostringstream oss;
256 if ( _parent->getLastCommandErrorInfo() ==
"" )
268 if ( (_parent != NULL) && (_parent->isConnected()) )
270 std::ostringstream oss;
271 oss <<
"DIP?" <<
"\n";
273 if ( _parent->getLastCommandErrorInfo() ==
"" )
290 if ( (_parent != NULL) && (_parent->isConnected()) )
292 std::ostringstream oss;
297 if ( _parent->getLastCommandErrorInfo() ==
"" )
309 if ( (_parent != NULL) && (_parent->isConnected()) )
311 std::ostringstream oss;
312 oss <<
"TDMAC?" <<
"\n";
314 if ( _parent->getLastCommandErrorInfo() ==
"" )
331 if ( (_parent != NULL) && (_parent->isConnected()) )
333 std::ostringstream oss;
338 if ( _parent->getLastCommandErrorInfo() ==
"" )
virtual int debug(const char *format,...)
Outputs debug information.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
virtual Configurable & operator=(const Configurable &other)
Assignment operator for Configurable objects.
virtual bool setConfigurationValue(const std::string &key, const std::string &value)
Sets a named configuration value to a string.
Configurable(const std::string &name="<unknown>", bool debug=false)
Constructs a Configurable object.
A configuration dictionary.
virtual bool hasKey(const std::string &key) const
Determines if the dictionary has the given key.
Generic radio handler class.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
virtual SimpleIpSetup & operator=(const SimpleIpSetup &other)
Assignment operator for SimpleIpSetup objects.
SimpleIpSetup(const std::string &name="SIMPLEIPSETUP", RadioHandler *parent=NULL, bool debug=false, const std::string &sourceIP="0.0.0.0", const std::string &destIP="0.0.0.0", const std::string &destMAC="00:00:00:00:00:00")
Constructs a SimpleIpSetup object.
virtual bool executeDestMACQuery(std::string &macAddr)
Executes the destination MAC query command.
virtual bool setSourceIP(const std::string &ipAddr)
Sets the source IP address.
virtual std::string getSourceIP() const
Gets the source IP address.
virtual bool setDestIPAddress(const std::string &ipAddr)
Sets the destination IP address.
virtual bool executeDestMACCommand(std::string &macAddr)
Executes the destination MAC set command.
virtual std::string getSourceMAC() const
Gets the source MAC address.
virtual void queryConfiguration()
Tells the object to create its configuration dictionary.
virtual std::string getDestMACAddress() const
Gets the destination MAC address.
virtual std::string getDestIPAddress() const
Gets the destination IP address.
virtual bool executeSourceMACQuery(std::string &macAddr)
Executes the source MAC query command.
virtual bool executeDestIPQuery(std::string &ipAddr)
Executes the destination IP query command.
virtual void updateConfigurationDict()
Updates the configuration dictionary from object settings.
virtual bool executeSourceIPCommand(std::string &ipAddr)
Executes the source IP set command.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual bool setDestMACAddress(const std::string &macAddr)
Sets the destination MAC address.
virtual bool executeSourceIPQuery(std::string &ipAddr)
Executes the source IP query command.
virtual ~SimpleIpSetup()
Destroys a SimpleIpSetup object.
virtual bool executeDestIPCommand(std::string &ipAddr)
Executes the destination IP set command.
static BasicStringList Split(const std::string &str, const std::string &sep, int maxsplit=INT_MAX)
Splits the given string into a list of string tokens.
static std::string Replace(const std::string &str, const std::string &oldstr, const std::string &newstr, int count=INT_MAX)
Replaces occurrences of one substring with another within the given string.
Provides programming elements for driving CRS NDR-class radios.
Defines functionality for LibCyberRadio applications.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.