mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 08:29:59 +00:00
Updated parameter handling
This commit is contained in:
parent
e628bf9632
commit
35302addd5
@ -38,12 +38,17 @@ using namespace std;
|
||||
// Constructor
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
CTapDriver::CTapDriver(const string& interfaces)
|
||||
CTapDriver::CTapDriver(const list<string>& params)
|
||||
{
|
||||
stringstream s(!interfaces.empty() ? interfaces : DEFAULT_INTERFACES);
|
||||
if (!params.empty()) {
|
||||
interfaces = params;
|
||||
}
|
||||
else {
|
||||
stringstream s(DEFAULT_INTERFACES);
|
||||
string interface;
|
||||
while (getline(s, interface, ',')) {
|
||||
this->interfaces.push_back(interface);
|
||||
interfaces.push_back(interface);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialization
|
||||
|
@ -17,13 +17,15 @@
|
||||
|
||||
#include <pcap/pcap.h>
|
||||
#include "filepath.h"
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#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<string>&);
|
||||
~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<std::string> interfaces;
|
||||
// Prioritized list of interfaces to create the bridge for
|
||||
list<string> interfaces;
|
||||
};
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
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<string>&) { return true; };
|
||||
|
||||
virtual bool Dispatch(SCSIDEV *) = 0;
|
||||
|
||||
|
@ -85,11 +85,11 @@ bool SCSIDaynaPort::Dispatch(SCSIDEV *controller)
|
||||
return Disk::Dispatch(controller);
|
||||
}
|
||||
|
||||
bool SCSIDaynaPort::Init(const string& interfaces)
|
||||
bool SCSIDaynaPort::Init(const list<string>& 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");
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "os.h"
|
||||
#include "disk.h"
|
||||
#include "ctapdriver.h"
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "../rascsi.h"
|
||||
@ -60,7 +61,7 @@ public:
|
||||
SCSIDaynaPort();
|
||||
~SCSIDaynaPort();
|
||||
|
||||
bool Init(const string&) override;
|
||||
bool Init(const list<string>&) override;
|
||||
void Open(const Filepath& path) override;
|
||||
|
||||
// Commands
|
||||
|
@ -75,11 +75,11 @@ SCSIBR::~SCSIBR()
|
||||
}
|
||||
}
|
||||
|
||||
bool SCSIBR::Init(const string& interfaces)
|
||||
bool SCSIBR::Init(const list<string>& params)
|
||||
{
|
||||
#ifdef __linux__
|
||||
// TAP Driver Generation
|
||||
tap = new CTapDriver(interfaces);
|
||||
tap = new CTapDriver(params);
|
||||
m_bTapEnable = tap->Init();
|
||||
|
||||
// Generate MAC Address
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "os.h"
|
||||
#include "disk.h"
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include "../rascsi.h"
|
||||
|
||||
@ -50,7 +51,7 @@ public:
|
||||
SCSIBR();
|
||||
~SCSIBR();
|
||||
|
||||
bool Init(const string&) override;
|
||||
bool Init(const list<string>&) override;
|
||||
bool Dispatch(SCSIDEV *) override;
|
||||
|
||||
// Commands
|
||||
|
@ -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<string> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user