Commit e9610929 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1239] DHCPv4 echo server implemented.

parent be3e7b88
......@@ -50,9 +50,12 @@ Dhcpv4Srv::run() {
boost::shared_ptr<Pkt4> query; // client's message
boost::shared_ptr<Pkt4> rsp; // server's response
#if 1
// uncomment this once ticket 1239 is merged.
query = IfaceMgr::instance().receive4();
#if ECHO_SERVER
query->repack();
IfaceMgr::instance().send(query);
continue;
#endif
if (query) {
......
......@@ -156,6 +156,14 @@ Pkt4::unpack() {
return (true);
}
void Pkt4::repack() {
cout << "Convering RX packet to TX packet: " << bufferIn_.getLength() << " bytes." << endl;
vector<uint8_t> buf;
bufferIn_.readVector(buf, bufferIn_.getLength());
bufferOut_.writeData(&buf[0], bufferIn_.getLength());
}
std::string
Pkt4::toText() {
stringstream tmp;
......
......@@ -78,6 +78,14 @@ public:
bool
unpack();
/// @brief Copies content of input buffer to output buffer.
///
/// This is mostly a diagnostic function. It is being used for sending
/// received packet. Received packet is stored in bufferIn_, but
/// transmitted data is stored in bufferOut_. If we want to send packet
/// that we just received, a copy between those two buffers is necessary.
void repack();
/// @brief Returns text representation of the packet.
///
/// This function is useful mainly for debugging.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment