Open hesingh opened 5 years ago
The following code changes to SAI-P4-BM/p4-switch/behavioral-model have fixed the build. I wonder why these changes do not exist in this repo's behavioral-model?
diff --git a/include/bm/bm_apps/packet_pipe.h b/include/bm/bm_apps/packet_pipe.h
index 0478b29..c8ed181 100644
--- a/include/bm/bm_apps/packet_pipe.h
+++ b/include/bm/bm_apps/packet_pipe.h
@@ -25,6 +25,7 @@
#include <thread>
#include <mutex>
#include <memory>
+#include <functional>
namespace bm_apps {
@@ -33,8 +34,8 @@ class PacketInjectImp;
class PacketInject {
public:
// the library owns the memory, make a copy if you need before returning
- typedef std::function<void(int port_num, const char *buffer, int len,
- void *cookie)> PacketReceiveCb;
+ using PacketReceiveCb = std::function<void(int port_num, const char *buffer,
+ int len, void *cookie)>;
explicit PacketInject(const std::string &addr);
diff --git a/include/bm/bm_sim/packet_handler.h b/include/bm/bm_sim/packet_handler.h
index 53ae69e..6d5825e 100644
--- a/include/bm/bm_sim/packet_handler.h
+++ b/include/bm/bm_sim/packet_handler.h
@@ -16,12 +16,14 @@
#ifndef BM_BM_SIM_PACKET_HANDLER_H_
#define BM_BM_SIM_PACKET_HANDLER_H_
+#include <functional>
+
namespace bm {
class PacketDispatcherIface {
public:
- typedef std::function<void(int port_num, const char *buffer,
- int len, void* cookie)> PacketHandler;
+ using PacketHandler = std::function<void(int port_num, const char *buffer,
+ int len, void* cookie)>;
enum class ReturnCode {
SUCCESS,
UNSUPPORTED,
diff --git a/src/bm_sim/pcap_file.cpp b/src/bm_sim/pcap_file.cpp
index 6c682c5..4b646eb 100644
--- a/src/bm_sim/pcap_file.cpp
+++ b/src/bm_sim/pcap_file.cpp
@@ -150,9 +150,12 @@ PcapFileIn::current() const {
}
case State::Opened:
pcap_fatal_error("Must call moveNext() before calling current()");
+ break;
case State::AtEnd:
pcap_fatal_error("Cannot read past end-of-file");
+ break;
case State::Uninitialized:
+ /* fallthrough */
default:
pcap_fatal_error("Unexpected state");
}
@@ -192,9 +195,9 @@ PcapFilesReader::scan() {
}
int earliest_index = -1;
- const struct timeval *earliest_time;
+ const struct timeval *earliest_time = nullptr;
- for (unsigned i=0; i < files.size(); i++) {
+ for (unsigned int i = 0; i < files.size(); i++) {
auto file = files.at(i).get();
if (file->atEOF()) continue;
@@ -211,7 +214,7 @@ PcapFilesReader::scan() {
}
}
- assert(earliest_index >= 0);
+ assert(earliest_index >= 0 && earliest_time != nullptr);
struct timeval delay;
BMLOG_DEBUG("Pcap reader: first packet to send {}",
diff --git a/third_party/spdlog/bm/spdlog/spdlog.h b/third_party/spdlog/bm/spdlog/spdlog.h
index aef0406..5596ecd 100644
--- a/third_party/spdlog/bm/spdlog/spdlog.h
+++ b/third_party/spdlog/bm/spdlog/spdlog.h
@@ -32,6 +32,8 @@
#include "common.h"
#include "logger.h"
+#include <functional>
+
namespace spdlog
{
// Return an existing logger or nullptr if a logger with such name doesn't exist.
Hi,
I've changed README with the --recursive flag. Can you send these other changes in a PR so it will be easier to review? by the way, I've lately managed to install this repo successfully on a clean ubuntu 16.04 machine
Regarding P4_16, as you understand this repo is not actively maintained at the moment, some of the work to do so was done, but currently we postponed working on this project.
Thanks, Yonatan
I am using Ubuntu 18.04. I already have behavioral-model working on my machine since its used by p4c. Thus, the machine has all dependencies that the behavioral-model needs. But, still, using the behavioral-model in sai-p4-bm, I run into build problems.
p4-switch/sai-p4-target/main.cpp p4-switch/sai-p4-target/primitives.cpp p4-switch/sai-p4-target/simple_switch.cpp /p4-switch/sai-p4-target/simple_switch.h
I had to change simple_switch.h to fix the compilation 'override' error.
I also had to comment out code in simple_switch.cpp to fix its compilation.
See log below.