summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buffer.cpp14
-rw-r--r--buffer.h5
2 files changed, 8 insertions, 11 deletions
diff --git a/buffer.cpp b/buffer.cpp
index 808f639..6d16467 100644
--- a/buffer.cpp
+++ b/buffer.cpp
@@ -30,8 +30,8 @@
#include <stdexcept>
#include <string>
-#include <iostream>
#include <cstdio>
+#include <iostream>
#include "datatypes.h"
#include "buffer.h"
@@ -165,15 +165,13 @@ Buffer::operator u_int8_t*() // just for write/read tun
return buf_;
}
-std::ostream& operator<<(std::ostream& output, const Buffer &src)
+void Buffer::printHexDump() const
{
- char buf[10];
+ char text[10];
- for( u_int32_t index = 0; index < src.getLength(); index++ )
+ for( u_int32_t index = 0; index < length_; index++ )
{
- std::sprintf(buf, "%#x", src[index]);
- output << buf << " ";
+ std::sprintf(text, "%#x", buf_[index]);
+ std::cout << text << " ";
}
-
- return output;
}
diff --git a/buffer.h b/buffer.h
index fc9d78b..0506e98 100644
--- a/buffer.h
+++ b/buffer.h
@@ -33,8 +33,6 @@
#include "datatypes.h"
-#include <ostream>
-
class TunDevice;
class UDPPacketSource;
@@ -54,7 +52,7 @@ public:
u_int8_t* getBuf();
u_int8_t& operator[](u_int32_t index);
u_int8_t operator[](u_int32_t index) const;
- friend std::ostream& operator<<(std::ostream& output, const Buffer &src);
+ void printHexDump() const;
protected:
operator u_int8_t*(); // just for write/read tun and packetSource
@@ -65,6 +63,7 @@ protected:
u_int8_t *buf_;
u_int32_t length_;
+
};
#endif