summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-11-28 11:25:32 +0200
committerimarom <imarom@cisco.com>2016-11-28 11:25:32 +0200
commit537f5831c4400dea7fa15032c4cd6bd2fae86bb1 (patch)
tree10d3b4e158c0a0c3b6019b78a99660c0fbb18d97 /src/common
parentd0c838e0abd0b39df54547623b2fa87fcc8aa807 (diff)
RX features - self code review
Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/common')
-rwxr-xr-xsrc/common/captureFile.h5
-rwxr-xr-xsrc/common/erf.cpp6
-rwxr-xr-xsrc/common/erf.h7
-rwxr-xr-xsrc/common/pcap.cpp6
-rwxr-xr-xsrc/common/pcap.h7
5 files changed, 28 insertions, 3 deletions
diff --git a/src/common/captureFile.h b/src/common/captureFile.h
index fefa62bd..d87e57b6 100755
--- a/src/common/captureFile.h
+++ b/src/common/captureFile.h
@@ -227,9 +227,10 @@ class CFileWriterBase {
public:
- virtual ~CFileWriterBase(){};
- virtual bool Create(char * name) = 0;
+ virtual ~CFileWriterBase(){};
+ virtual bool Create(char * name) = 0;
virtual bool write_packet(CCapPktRaw * lpPacket)=0;
+ virtual void flush_to_disk() = 0;
};
diff --git a/src/common/erf.cpp b/src/common/erf.cpp
index 76945b01..f872a281 100755
--- a/src/common/erf.cpp
+++ b/src/common/erf.cpp
@@ -280,7 +280,11 @@ bool CErfFileWriter::write_packet(CCapPktRaw * lpPacket){
return true;
}
-
+void CErfFileWriter::flush_to_disk() {
+ if (m_fd) {
+ fflush(m_fd);
+ }
+}
bool CPcapFileWriter::Create(char *file_name){
m_fd=CAP_FOPEN_64(file_name,"wb");
diff --git a/src/common/erf.h b/src/common/erf.h
index e1b83e46..bec94872 100755
--- a/src/common/erf.h
+++ b/src/common/erf.h
@@ -224,6 +224,13 @@ public:
virtual bool Create(char *file_name);
void Delete();
virtual bool write_packet(CCapPktRaw * lpPacket);
+
+ /**
+ * flush all packets to disk
+ *
+ */
+ void flush_to_disk();
+
private:
FILE *m_fd;
int m_cnt;
diff --git a/src/common/pcap.cpp b/src/common/pcap.cpp
index 8e9bf0ac..f5eb3c41 100755
--- a/src/common/pcap.cpp
+++ b/src/common/pcap.cpp
@@ -228,6 +228,12 @@ bool LibPCapWriter::Create(char * name)
return init();
}
+void LibPCapWriter::flush_to_disk() {
+ if (m_is_open) {
+ fflush(m_file_handler);
+ }
+}
+
/**
*
* Write the libpcap header.
diff --git a/src/common/pcap.h b/src/common/pcap.h
index c9139e4c..265ea17b 100755
--- a/src/common/pcap.h
+++ b/src/common/pcap.h
@@ -143,6 +143,13 @@ public:
*/
void Close();
+ /**
+ * flush all packets to disk
+ *
+ * @author imarom (11/24/2016)
+ */
+ void flush_to_disk();
+
private:
bool init();