61 #include <json/json.h>
63 #include <jsoncpp/json/json.h>
76 std::vector<std::string> substrings;
78 std::istringstream ss(
s);
79 while (std::getline(ss, part, delimiter))
80 substrings.push_back(part);
97 std::vector<std::string> scandatatypes_hex;
98 scandatatypes_hex.reserve(scandatatypes.size());
99 for(
int type_cnt = 0; type_cnt < scandatatypes.size(); type_cnt++)
101 const std::string & scandatatype = scandatatypes[type_cnt];
102 std::stringstream hex_stream;
103 for(
int char_cnt = 0; char_cnt < scandatatype.size(); char_cnt++)
107 hex_stream << std::setfill(
'0') << std::setw(2) << std::hex << (int)(scandatatype[char_cnt] & 0xFF);
109 scandatatypes_hex.push_back(hex_stream.str());
119 Json::Reader json_reader;
120 Json::Value json_root;
124 for (Json::Value::ArrayIndex json_idx = 0; json_idx != json_root.size(); json_idx++)
126 if(json_root[json_idx].isMember(
"_source") && json_root[json_idx][
"_source"].isMember(
"layers") && json_root[json_idx][
"_source"][
"layers"].isMember(
"tcp"))
128 Json::Value & json_tcp = json_root[json_idx][
"_source"][
"layers"][
"tcp"];
130 if(json_tcp.isMember(
"Timestamps") && json_tcp[
"Timestamps"].isMember(
"tcp.time_relative"))
131 tcp_timestamp = json_tcp[
"Timestamps"][
"tcp.time_relative"].asString();
132 if(json_tcp.isMember(
"tcp.payload"))
135 bool type_check_passed = scandatatypes.empty();
136 for(
int type_cnt = 0; type_check_passed ==
false && type_cnt < scandatatypes_hex.size(); type_cnt++)
138 if(
tcp_payload.find(scandatatypes_hex[type_cnt]) != std::string::npos)
139 type_check_passed =
true;
141 if(!type_check_passed)
143 if(tcp_timestamp.size() > 0 &&
tcp_payload.size() > 4)
146 double msg_timestamp = std::stod(tcp_timestamp) + start_time;
147 std::vector<uint8_t> msg_payload;
151 while (std::getline(payload_stream, hexval,
':'))
153 msg_payload.push_back(std::stoul(hexval, 0, 16) & 0xFF);
164 catch(
const std::exception& e)
166 ROS_WARN_STREAM(
"## WARNING sick_scan_xd::PcapngJsonParser::parseJsonfile: exception \"" << e.what() <<
"\" in file \"" <<
json_filename <<
"\".");
167 std::cerr << e.what() <<
'\n';