mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-21 23:29:39 +00:00
Updated parameter handling
This commit is contained in:
parent
e628bf9632
commit
35302addd5
@ -38,12 +38,17 @@ using namespace std;
|
|||||||
// Constructor
|
// 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;
|
string interface;
|
||||||
while (getline(s, interface, ',')) {
|
while (getline(s, interface, ',')) {
|
||||||
this->interfaces.push_back(interface);
|
interfaces.push_back(interface);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -17,13 +17,15 @@
|
|||||||
|
|
||||||
#include <pcap/pcap.h>
|
#include <pcap/pcap.h>
|
||||||
#include "filepath.h"
|
#include "filepath.h"
|
||||||
#include <vector>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef ETH_FRAME_LEN
|
#ifndef ETH_FRAME_LEN
|
||||||
#define ETH_FRAME_LEN 1514
|
#define ETH_FRAME_LEN 1514
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
//
|
//
|
||||||
// Linux Tap Driver
|
// Linux Tap Driver
|
||||||
@ -32,7 +34,7 @@
|
|||||||
class CTapDriver
|
class CTapDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CTapDriver(const std::string&);
|
CTapDriver(const list<string>&);
|
||||||
~CTapDriver() {};
|
~CTapDriver() {};
|
||||||
|
|
||||||
bool Init();
|
bool Init();
|
||||||
@ -57,7 +59,7 @@ private:
|
|||||||
pcap_t *m_pcap;
|
pcap_t *m_pcap;
|
||||||
pcap_dumper_t *m_pcap_dumper;
|
pcap_dumper_t *m_pcap_dumper;
|
||||||
|
|
||||||
// Prioritized comma-separated list of interfaces to create the bridge for
|
// Prioritized list of interfaces to create the bridge for
|
||||||
std::vector<std::string> interfaces;
|
list<string> interfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -92,7 +93,7 @@ public:
|
|||||||
virtual ~Device() {};
|
virtual ~Device() {};
|
||||||
|
|
||||||
// Override for device specific initializations, to be called after all device properties have been set
|
// 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;
|
virtual bool Dispatch(SCSIDEV *) = 0;
|
||||||
|
|
||||||
|
@ -85,11 +85,11 @@ bool SCSIDaynaPort::Dispatch(SCSIDEV *controller)
|
|||||||
return Disk::Dispatch(controller);
|
return Disk::Dispatch(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCSIDaynaPort::Init(const string& interfaces)
|
bool SCSIDaynaPort::Init(const list<string>& params)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// TAP Driver Generation
|
// TAP Driver Generation
|
||||||
m_tap = new CTapDriver(interfaces);
|
m_tap = new CTapDriver(params);
|
||||||
m_bTapEnable = m_tap->Init();
|
m_bTapEnable = m_tap->Init();
|
||||||
if(!m_bTapEnable){
|
if(!m_bTapEnable){
|
||||||
LOGERROR("Unable to open the TAP interface");
|
LOGERROR("Unable to open the TAP interface");
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
#include "ctapdriver.h"
|
#include "ctapdriver.h"
|
||||||
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../rascsi.h"
|
#include "../rascsi.h"
|
||||||
@ -60,7 +61,7 @@ public:
|
|||||||
SCSIDaynaPort();
|
SCSIDaynaPort();
|
||||||
~SCSIDaynaPort();
|
~SCSIDaynaPort();
|
||||||
|
|
||||||
bool Init(const string&) override;
|
bool Init(const list<string>&) override;
|
||||||
void Open(const Filepath& path) override;
|
void Open(const Filepath& path) override;
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
@ -75,11 +75,11 @@ SCSIBR::~SCSIBR()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SCSIBR::Init(const string& interfaces)
|
bool SCSIBR::Init(const list<string>& params)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
// TAP Driver Generation
|
// TAP Driver Generation
|
||||||
tap = new CTapDriver(interfaces);
|
tap = new CTapDriver(params);
|
||||||
m_bTapEnable = tap->Init();
|
m_bTapEnable = tap->Init();
|
||||||
|
|
||||||
// Generate MAC Address
|
// Generate MAC Address
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "disk.h"
|
#include "disk.h"
|
||||||
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../rascsi.h"
|
#include "../rascsi.h"
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ public:
|
|||||||
SCSIBR();
|
SCSIBR();
|
||||||
~SCSIBR();
|
~SCSIBR();
|
||||||
|
|
||||||
bool Init(const string&) override;
|
bool Init(const list<string>&) override;
|
||||||
bool Dispatch(SCSIDEV *) override;
|
bool Dispatch(SCSIDEV *) override;
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
@ -822,7 +822,8 @@ bool Attach(int fd, const PbDeviceDefinition& pb_device, Device *map[], bool dry
|
|||||||
return true;
|
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";
|
error << "Initialization of " << device->GetType() << " device, ID " << id << ", unit " << unit << " failed";
|
||||||
|
|
||||||
delete device;
|
delete device;
|
||||||
|
Loading…
Reference in New Issue
Block a user