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") )
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";
227 if ( (_parent != NULL) && (_parent->
isConnected()) )
229 std::ostringstream oss;
230 oss <<
"SIP?" <<
"\n";
249 if ( (_parent != NULL) && (_parent->
isConnected()) )
251 std::ostringstream oss;
268 if ( (_parent != NULL) && (_parent->
isConnected()) )
270 std::ostringstream oss;
271 oss <<
"DIP?" <<
"\n";
290 if ( (_parent != NULL) && (_parent->
isConnected()) )
292 std::ostringstream oss;
309 if ( (_parent != NULL) && (_parent->
isConnected()) )
311 std::ostringstream oss;
312 oss <<
"TDMAC?" <<
"\n";
331 if ( (_parent != NULL) && (_parent->
isConnected()) )
333 std::ostringstream oss;
virtual std::string getSourceIP() const
Gets the source IP address.
virtual bool executeDestMACQuery(std::string &macAddr)
Executes the destination MAC query command.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
virtual bool setDestMACAddress(const std::string &macAddr)
Sets the destination MAC address.
virtual bool hasKey(const std::string &key) const
Determines if the dictionary has the given key.
virtual SimpleIpSetup & operator=(const SimpleIpSetup &other)
Assignment operator for SimpleIpSetup objects.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual bool isConnected() const
Gets whether or not the handler is connected.
virtual bool setSourceIP(const std::string &ipAddr)
Sets the source IP address.
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.
virtual bool executeDestIPCommand(std::string &ipAddr)
Executes the destination IP set command.
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.
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.
Generic radio handler class.
virtual int debug(const char *format,...)
Outputs debug information.
BASIC_LIST_CONTAINER< std::string > BasicStringList
Type representing a list of strings.
virtual std::string getDestIPAddress() const
Gets the destination IP address.
virtual std::string getDestMACAddress() const
Gets the destination MAC address.
virtual std::string getSourceMAC() const
Gets the source MAC address.
Defines functionality for LibCyberRadio applications.
virtual bool executeDestIPQuery(std::string &ipAddr)
Executes the destination IP query command.
A configuration dictionary.
virtual bool executeSourceMACQuery(std::string &macAddr)
Executes the source MAC query command.
virtual void updateConfigurationDict()
Updates the configuration dictionary from object settings.
virtual std::string getLastCommandErrorInfo() const
Gets the error message from the last command attempted.
Simple IP setup class for radios without 10GigE data ports.
virtual Configurable & operator=(const Configurable &other)
Assignment operator for Configurable objects.
virtual bool executeSourceIPCommand(std::string &ipAddr)
Executes the source IP set command.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
virtual bool executeDestMACCommand(std::string &macAddr)
Executes the destination MAC set command.
virtual BasicStringList sendCommand(const std::string &cmdString, double timeout=-1)
Sends a command to the radio.
virtual void queryConfiguration()
Tells the object to create its configuration dictionary.
Base configurable object class.
virtual bool setConfigurationValue(const std::string &key, const std::string &value)
Sets a named configuration value to a string.
virtual bool setDestIPAddress(const std::string &ipAddr)
Sets the destination IP address.
virtual ~SimpleIpSetup()
Destroys a SimpleIpSetup object.
virtual bool executeSourceIPQuery(std::string &ipAddr)
Executes the source IP query command.