diff --git a/src/raspberrypi/devices/ctapdriver.cpp b/src/raspberrypi/devices/ctapdriver.cpp index ce978a4f..2cbe44fc 100644 --- a/src/raspberrypi/devices/ctapdriver.cpp +++ b/src/raspberrypi/devices/ctapdriver.cpp @@ -38,12 +38,17 @@ using namespace std; // Constructor // //--------------------------------------------------------------------------- -CTapDriver::CTapDriver(const string& interfaces) +CTapDriver::CTapDriver(const list& params) { - stringstream s(!interfaces.empty() ? interfaces : DEFAULT_INTERFACES); - string interface; - while (getline(s, interface, ',')) { - this->interfaces.push_back(interface); + if (!params.empty()) { + interfaces = params; + } + else { + stringstream s(DEFAULT_INTERFACES); + string interface; + while (getline(s, interface, ',')) { + interfaces.push_back(interface); + } } // Initialization diff --git a/src/raspberrypi/devices/ctapdriver.h b/src/raspberrypi/devices/ctapdriver.h index 1d4f4c6f..37d480c4 100644 --- a/src/raspberrypi/devices/ctapdriver.h +++ b/src/raspberrypi/devices/ctapdriver.h @@ -17,13 +17,15 @@ #include #include "filepath.h" -#include +#include #include #ifndef ETH_FRAME_LEN #define ETH_FRAME_LEN 1514 #endif +using namespace std; + //=========================================================================== // // Linux Tap Driver @@ -32,7 +34,7 @@ class CTapDriver { public: - CTapDriver(const std::string&); + CTapDriver(const list&); ~CTapDriver() {}; bool Init(); @@ -57,7 +59,7 @@ private: pcap_t *m_pcap; pcap_dumper_t *m_pcap_dumper; - // Prioritized comma-separated list of interfaces to create the bridge for - std::vector interfaces; + // Prioritized list of interfaces to create the bridge for + list interfaces; }; diff --git a/src/raspberrypi/devices/device.h b/src/raspberrypi/devices/device.h index 06abeac6..9ff8cdf3 100644 --- a/src/raspberrypi/devices/device.h +++ b/src/raspberrypi/devices/device.h @@ -9,6 +9,7 @@ #pragma once +#include #include using namespace std; @@ -92,7 +93,7 @@ public: virtual ~Device() {}; // Override for device specific initializations, to be called after all device properties have been set - virtual bool Init(const string&) { return true; }; + virtual bool Init(const list&) { return true; }; virtual bool Dispatch(SCSIDEV *) = 0; diff --git a/src/raspberrypi/devices/scsi_daynaport.cpp b/src/raspberrypi/devices/scsi_daynaport.cpp index 535986c0..0626a920 100644 --- a/src/raspberrypi/devices/scsi_daynaport.cpp +++ b/src/raspberrypi/devices/scsi_daynaport.cpp @@ -85,11 +85,11 @@ bool SCSIDaynaPort::Dispatch(SCSIDEV *controller) return Disk::Dispatch(controller); } -bool SCSIDaynaPort::Init(const string& interfaces) +bool SCSIDaynaPort::Init(const list& params) { #ifdef __linux__ // TAP Driver Generation - m_tap = new CTapDriver(interfaces); + m_tap = new CTapDriver(params); m_bTapEnable = m_tap->Init(); if(!m_bTapEnable){ LOGERROR("Unable to open the TAP interface"); diff --git a/src/raspberrypi/devices/scsi_daynaport.h b/src/raspberrypi/devices/scsi_daynaport.h index d96b9c2f..2c405d8e 100644 --- a/src/raspberrypi/devices/scsi_daynaport.h +++ b/src/raspberrypi/devices/scsi_daynaport.h @@ -31,6 +31,7 @@ #include "os.h" #include "disk.h" #include "ctapdriver.h" +#include #include #include #include "../rascsi.h" @@ -60,7 +61,7 @@ public: SCSIDaynaPort(); ~SCSIDaynaPort(); - bool Init(const string&) override; + bool Init(const list&) override; void Open(const Filepath& path) override; // Commands diff --git a/src/raspberrypi/devices/scsi_host_bridge.cpp b/src/raspberrypi/devices/scsi_host_bridge.cpp index 54f039ca..fa67909c 100644 --- a/src/raspberrypi/devices/scsi_host_bridge.cpp +++ b/src/raspberrypi/devices/scsi_host_bridge.cpp @@ -75,11 +75,11 @@ SCSIBR::~SCSIBR() } } -bool SCSIBR::Init(const string& interfaces) +bool SCSIBR::Init(const list& params) { #ifdef __linux__ // TAP Driver Generation - tap = new CTapDriver(interfaces); + tap = new CTapDriver(params); m_bTapEnable = tap->Init(); // Generate MAC Address diff --git a/src/raspberrypi/devices/scsi_host_bridge.h b/src/raspberrypi/devices/scsi_host_bridge.h index 2a3866a0..7a30907d 100644 --- a/src/raspberrypi/devices/scsi_host_bridge.h +++ b/src/raspberrypi/devices/scsi_host_bridge.h @@ -19,6 +19,7 @@ #include "os.h" #include "disk.h" +#include #include #include "../rascsi.h" @@ -50,7 +51,7 @@ public: SCSIBR(); ~SCSIBR(); - bool Init(const string&) override; + bool Init(const list&) override; bool Dispatch(SCSIDEV *) override; // Commands diff --git a/src/raspberrypi/rascsi.cpp b/src/raspberrypi/rascsi.cpp index f311289b..27bd19f8 100644 --- a/src/raspberrypi/rascsi.cpp +++ b/src/raspberrypi/rascsi.cpp @@ -822,7 +822,8 @@ bool Attach(int fd, const PbDeviceDefinition& pb_device, Device *map[], bool dry return true; } - if (!device->Init(pb_device.params_size() > 0 ? pb_device.params().Get(0) : "")) { + const list params = { pb_device.params().begin(), pb_device.params().end() }; + if (!device->Init(params)) { error << "Initialization of " << device->GetType() << " device, ID " << id << ", unit " << unit << " failed"; delete device;