main.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. #include "pcap_processor.h"
  2. #include <pybind11/pybind11.h>
  3. #include <pybind11/embed.h>
  4. namespace py = pybind11;
  5. int main(int argc, char *argv[]){
  6. if (argc > 4) {
  7. // get user arguments
  8. std::string pcap_path = argv[1];
  9. std::string extra_tests = argv[2];
  10. std::string resource_path = argv[3];
  11. std::string db_path = argv[4];
  12. py::float_ elem = *reinterpret_cast<double*>(argv[5]);
  13. // init other needed vars
  14. py::scoped_interpreter guard{};
  15. bool del = true;
  16. py::list intervals;
  17. intervals.append(elem);
  18. // execute pcap processor
  19. pcap_processor pp(pcap_path, extra_tests, resource_path, db_path);
  20. pp.collect_statistics(intervals);
  21. pp.write_to_database(db_path, intervals, del);
  22. return 0;
  23. } else {
  24. // display error and example execution
  25. std::cerr << "Error with argument parsing." << std::endl;
  26. std::cerr << "example execution inside ID2T-toolkit dir (all arg paths should be absolute):" << std::endl;
  27. std::cerr << "$ code_boost/src/build/main <path_to_pcap_file> <extra_tests> <path_to_id2t_resource_dir> <path_to_db_file> <interval_length>" << std::endl;
  28. }
  29. }