|
@@ -50,6 +50,8 @@ std::string pcap_processor::merge_pcaps(const std::string pcap_path) {
|
|
|
std::string::size_type h = new_filepath.rfind('.', new_filepath.length());
|
|
|
if (h != std::string::npos) {
|
|
|
new_filepath.replace(h, newExt.length(), newExt);
|
|
|
+ } else {
|
|
|
+ new_filepath.append(newExt);
|
|
|
}
|
|
|
|
|
|
FileSniffer sniffer_base(filePath);
|
|
@@ -65,15 +67,21 @@ std::string pcap_processor::merge_pcaps(const std::string pcap_path) {
|
|
|
for (; iterator_base != sniffer_base.end();) {
|
|
|
auto tstmp_base = (iterator_base->timestamp().seconds()) + (iterator_base->timestamp().microseconds()*1e-6);
|
|
|
auto tstmp_attack = (iterator_attack->timestamp().seconds()) + (iterator_attack->timestamp().microseconds()*1e-6);
|
|
|
-
|
|
|
if (!all_attack_pkts_processed && tstmp_attack <= tstmp_base) {
|
|
|
- writer.write(*iterator_attack);
|
|
|
+ try {
|
|
|
+ writer.write(*iterator_attack);
|
|
|
+ } catch (serialization_error) {
|
|
|
+ std::cout << "Could not serialize attack packet with timestamp " << tstmp_attack << std::endl;
|
|
|
+ }
|
|
|
iterator_attack++;
|
|
|
-
|
|
|
if (iterator_attack == sniffer_attack.end())
|
|
|
all_attack_pkts_processed = true;
|
|
|
} else {
|
|
|
- writer.write(*iterator_base);
|
|
|
+ try {
|
|
|
+ writer.write(*iterator_base);
|
|
|
+ } catch (serialization_error) {
|
|
|
+ std::cout << "Could not serialize base packet with timestamp " << tstmp_attack << std::endl;
|
|
|
+ }
|
|
|
iterator_base++;
|
|
|
}
|
|
|
}
|
|
@@ -81,9 +89,13 @@ std::string pcap_processor::merge_pcaps(const std::string pcap_path) {
|
|
|
|
|
|
|
|
|
for (; iterator_attack != sniffer_attack.end(); iterator_attack++) {
|
|
|
- writer.write(*iterator_attack);
|
|
|
+ try {
|
|
|
+ writer.write(*iterator_attack);
|
|
|
+ } catch (serialization_error) {
|
|
|
+ auto tstmp_attack = (iterator_attack->timestamp().seconds()) + (iterator_attack->timestamp().microseconds()*1e-6);
|
|
|
+ std::cout << "Could not serialize attack packet with timestamp " << tstmp_attack << std::endl;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
return new_filepath;
|
|
|
}
|
|
|
|
|
@@ -229,10 +241,11 @@ bool inline pcap_processor::file_exists(const std::string &filePath) {
|
|
|
* Comment in if executable should be build & run
|
|
|
* Comment out if library should be build
|
|
|
*/
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -244,11 +257,12 @@ bool inline pcap_processor::file_exists(const std::string &filePath) {
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
* Comment out if executable should be build & run
|