11 #include "LibCyberRadio/Driver/NDR551/DataPort.h" 12 #include "LibCyberRadio/Driver/RadioHandler.h" 13 #include <boost/format.hpp> 28 const std::string& sourceIP) :
38 this->
debug(
"[NDR551::DataPort] index - %d\n", index);
54 ::LibCyberRadio::Driver::DataPort::operator=(other);
64 _config[
"sourceIP"] = _sourceIP;
65 _config[
"sourcePort"] = _sourcePort;
66 _config[
"sourceMac"] = _sourceMacAddr;
72 command[
"cmd"] =
"qcfge10g";
74 command[
"params"] = Json::objectValue;
75 command[
"params"][
"link"] = _index;
76 Json::FastWriter fastWriter;
77 std::string output = fastWriter.write(command);
80 Json::Value returnVal;
81 std::string t = rsp.at(0);
82 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
83 _sourceIP = boost::lexical_cast<std::string>(returnVal[
"result"][
"ip"].asString());
84 _sourceMacAddr = boost::lexical_cast<std::string>(returnVal[
"result"][
"mac"].asString());
85 _sourcePort = boost::lexical_cast<uint16_t>(returnVal[
"result"][
"port"].asUInt());
86 for(
int i = _dipEntryIndexBase; i < _numDipEntries; i++ )
101 command[
"cmd"] =
"qcfge10g";
103 command[
"params"] = Json::objectValue;
104 command[
"params"][
"link"] = index;
105 Json::FastWriter fastWriter;
106 std::string output = fastWriter.write(command);
109 Json::Value returnVal;
110 std::string t = rsp.at(0);
111 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
112 ret = returnVal[
"success"].asBool();
114 ipAddr = boost::lexical_cast<std::string>(returnVal[
"result"][
"ip"].asString());
125 command[
"cmd"] =
"cfge10g";
127 command[
"params"] = Json::objectValue;
128 command[
"params"][
"link"] = index;
129 command[
"params"][
"ip"] = ipAddr.c_str();
130 Json::FastWriter fastWriter;
131 std::string output = fastWriter.write(command);
134 Json::Value returnVal;
135 std::string t = rsp.at(0);
136 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
137 ret = returnVal[
"success"].asBool();
144 std::string& macAddr,
145 unsigned int& sourcePort,
146 unsigned int& destPort)
153 if ( (_parent != NULL) && (_parent->
isConnected()) &&
154 ( _macAddresses.find(dipIndex) != _macAddresses.end()) )
158 command[
"cmd"] =
"qe10g";
160 command[
"params"] = Json::objectValue;
161 command[
"params"][
"link"] = index;
162 command[
"params"][
"dest"] = dipIndex;
163 Json::FastWriter fastWriter;
164 std::string output = fastWriter.write(command);
167 Json::Value returnVal;
168 std::string t = rsp.at(0);
169 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
170 ret = returnVal[
"success"].asBool();
173 ipAddr = boost::lexical_cast<std::string>(returnVal[
"result"][
"ip"].asString());
174 macAddr = boost::lexical_cast<std::string>(returnVal[
"result"][
"mac"].asString());
177 destPort = boost::lexical_cast<uint16_t>(returnVal[
"result"][
"port"].asUInt());
185 std::string& macAddr,
186 unsigned int& sourcePort,
187 unsigned int& destPort)
192 command[
"cmd"] =
"e10g";
194 command[
"params"] = Json::objectValue;
195 command[
"params"][
"link"] = index;
196 command[
"params"][
"dest"] = dipIndex;
197 command[
"params"][
"ip"] = ipAddr.c_str();
198 command[
"params"][
"port"] = destPort;
199 command[
"params"][
"mac"] = macAddr.c_str();
200 command[
"params"][
"arp"] =
false;
201 Json::FastWriter fastWriter;
202 std::string output = fastWriter.write(command);
205 Json::Value returnVal;
206 std::string t = rsp.at(0);
207 bool parsingSuccessful = reader.parse( t.c_str(), returnVal );
208 ret = returnVal[
"success"].asBool();
void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual bool isConnected() const
Gets whether or not the handler is connected.
void queryConfiguration()
Updates the configuration dictionary from object settings.
virtual void updateConfigurationDict()
Updates the configuration dictionary from object settings.
DataPort(int index=0, ::LibCyberRadio::Driver::RadioHandler *parent=NULL, bool debug=false, const std::string &sourceIP="0.0.0.0")
Constructs a DataPort object.
virtual DataPort & operator=(const DataPort &other)
Assignment operator for DataPort objects.
bool executeDestIPCommand(int index, int dipIndex, std::string &ipAddr, std::string &macAddr, unsigned int &sourcePort, unsigned int &destPort)
Executes the destination IP set command.
bool executeDestIPQuery(int index, int dipIndex, std::string &ipAddr, std::string &macAddr, unsigned int &sourcePort, unsigned int &destPort)
Executes the destination IP query command.
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.
Defines functionality for LibCyberRadio applications.
virtual ~DataPort()
Destroys a DataPort object.
virtual BasicStringList sendCommand(const std::string &cmdString, double timeout=-1)
Sends a command to the radio.
bool executeSourceIPCommand(int index, std::string &ipAddr)
Executes the source IP set command.
bool executeSourceIPQuery(int index, std::string &ipAddr)
Executes the source IP query command.
virtual uint32_t getMessageId(void)
Get a json Message ID.