diff options
-rw-r--r-- | anytun.cpp | 4 | ||||
-rw-r--r-- | buffer.cpp | 9 | ||||
-rw-r--r-- | buffer.h | 3 |
3 files changed, 10 insertions, 6 deletions
@@ -107,7 +107,7 @@ void encryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn, void* p) cLog.msg(Log::PRIO_NOTICE) << "Send Package: seq: " << conn.seq_nr_; cLog.msg(Log::PRIO_NOTICE) << "sID: " << param->opt.getSenderId(); - cLog.msg(Log::PRIO_NOTICE) << "Package dump: " << pack.getBuf(); + cLog.msg(Log::PRIO_NOTICE) << "Package dump: " << pack.getHexDump(); c.cypher(pack, conn.seq_nr_, param->opt.getSenderId()); } @@ -132,7 +132,7 @@ bool decryptPacket(Packet & pack, Cypher & c, ConnectionParam & conn) cLog.msg(Log::PRIO_NOTICE) << "Received Package: seq: " << seq; cLog.msg(Log::PRIO_NOTICE) << "sID: " << sid; - cLog.msg(Log::PRIO_NOTICE) << "Package dump: " << pack.getBuf(); + cLog.msg(Log::PRIO_NOTICE) << "Package dump: " << pack.getHexDump(); return true; } @@ -180,17 +180,20 @@ Buffer::operator u_int8_t*() // just for write/read tun return buf_; } -void Buffer::printHexDump() const +std::string Buffer::getHexDump() const { char text[10]; + std::string ret = ""; for( u_int32_t index = 0; index < length_; index++ ) { std::sprintf(text, "%#4x", buf_[index]); - std::cout << text << " "; + ret += text; + ret += ""; if( ((index+1) % 10) == 0 ) - std::cout << std::endl; + ret += '\n'; } + return ret; } Buffer Buffer::operator^(const Buffer &xor_by) const @@ -32,6 +32,7 @@ #define _BUFFER_H_ #include "datatypes.h" +#include <string> class TunDevice; class UDPPacketSource; @@ -58,7 +59,7 @@ public: u_int8_t* getBuf(); u_int8_t& operator[](u_int32_t index); u_int8_t operator[](u_int32_t index) const; - void printHexDump() const; + std::string getHexDump() const; operator u_int8_t*(); // just for write/read tun and packetSource protected: |