mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-10 02:29:33 +00:00
Merge 3223f2ad64
into a6a8cadf21
This commit is contained in:
commit
89531b5fc3
|
@ -29,8 +29,9 @@ using namespace std;
|
||||||
using namespace piscsi_util;
|
using namespace piscsi_util;
|
||||||
using namespace network_util;
|
using namespace network_util;
|
||||||
|
|
||||||
const string CTapDriver::BRIDGE_NAME = "piscsi_bridge";
|
// const string CTapDriver::BRIDGE_NAME = "piscsi_bridge";
|
||||||
|
|
||||||
|
#if 0
|
||||||
static string br_setif(int br_socket_fd, const string& bridgename, const string& ifname, bool add) {
|
static string br_setif(int br_socket_fd, const string& bridgename, const string& ifname, bool add) {
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
return "if_nametoindex: Linux is required";
|
return "if_nametoindex: Linux is required";
|
||||||
|
@ -47,6 +48,7 @@ static string br_setif(int br_socket_fd, const string& bridgename, const string&
|
||||||
return "";
|
return "";
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
string ip_link(int fd, const char* ifname, bool up) {
|
string ip_link(int fd, const char* ifname, bool up) {
|
||||||
#ifndef __linux__
|
#ifndef __linux__
|
||||||
|
@ -113,6 +115,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0);
|
||||||
if (br_socket_fd < 0) {
|
if (br_socket_fd < 0) {
|
||||||
LogErrno("Can't open bridge socket");
|
LogErrno("Can't open bridge socket");
|
||||||
|
@ -121,15 +124,17 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
close(ip_fd);
|
close(ip_fd);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
auto cleanUp = [&] (const string& error) {
|
auto cleanUp = [&] (const string& error) {
|
||||||
LogErrno(error);
|
LogErrno(error);
|
||||||
close(m_hTAP);
|
close(m_hTAP);
|
||||||
close(ip_fd);
|
close(ip_fd);
|
||||||
close(br_socket_fd);
|
// close(br_socket_fd);
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if 0
|
||||||
// Check if the bridge has already been created
|
// Check if the bridge has already been created
|
||||||
// TODO Find an alternative to accessing a file, there is most likely a system call/ioctl
|
// TODO Find an alternative to accessing a file, there is most likely a system call/ioctl
|
||||||
if (access(string("/sys/class/net/" + BRIDGE_NAME).c_str(), F_OK)) {
|
if (access(string("/sys/class/net/" + BRIDGE_NAME).c_str(), F_OK)) {
|
||||||
|
@ -162,6 +167,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
else {
|
else {
|
||||||
spdlog::info(BRIDGE_NAME + " is already available");
|
spdlog::info(BRIDGE_NAME + " is already available");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
spdlog::trace(">ip link set piscsi0 up");
|
spdlog::trace(">ip link set piscsi0 up");
|
||||||
|
|
||||||
|
@ -169,11 +175,13 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
return cleanUp(error);
|
return cleanUp(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
spdlog::trace(">brctl addif " + BRIDGE_NAME + " piscsi0");
|
spdlog::trace(">brctl addif " + BRIDGE_NAME + " piscsi0");
|
||||||
|
|
||||||
if (const string error = br_setif(br_socket_fd, BRIDGE_NAME, "piscsi0", true); !error.empty()) {
|
if (const string error = br_setif(br_socket_fd, BRIDGE_NAME, "piscsi0", true); !error.empty()) {
|
||||||
return cleanUp(error);
|
return cleanUp(error);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
spdlog::trace("Getting the MAC address");
|
spdlog::trace("Getting the MAC address");
|
||||||
|
|
||||||
|
@ -186,7 +194,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
memcpy(m_MacAddr.data(), ifr.ifr_hwaddr.sa_data, m_MacAddr.size());
|
memcpy(m_MacAddr.data(), ifr.ifr_hwaddr.sa_data, m_MacAddr.size());
|
||||||
|
|
||||||
close(ip_fd);
|
close(ip_fd);
|
||||||
close(br_socket_fd);
|
// close(br_socket_fd);
|
||||||
|
|
||||||
spdlog::info("Tap device " + string(ifr.ifr_name) + " created");
|
spdlog::info("Tap device " + string(ifr.ifr_name) + " created");
|
||||||
|
|
||||||
|
@ -197,6 +205,7 @@ bool CTapDriver::Init(const param_map& const_params)
|
||||||
void CTapDriver::CleanUp() const
|
void CTapDriver::CleanUp() const
|
||||||
{
|
{
|
||||||
if (m_hTAP != -1) {
|
if (m_hTAP != -1) {
|
||||||
|
#if 0
|
||||||
if (const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0); br_socket_fd < 0) {
|
if (const int br_socket_fd = socket(AF_LOCAL, SOCK_STREAM, 0); br_socket_fd < 0) {
|
||||||
LogErrno("Can't open bridge socket");
|
LogErrno("Can't open bridge socket");
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,6 +216,7 @@ void CTapDriver::CleanUp() const
|
||||||
}
|
}
|
||||||
close(br_socket_fd);
|
close(br_socket_fd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Release TAP device
|
// Release TAP device
|
||||||
close(m_hTAP);
|
close(m_hTAP);
|
||||||
|
@ -243,6 +253,7 @@ pair<string, string> CTapDriver::ExtractAddressAndMask(const string& s)
|
||||||
return { address, netmask };
|
return { address, netmask };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
|
string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -261,7 +272,9 @@ string CTapDriver::SetUpEth0(int socket_fd, const string& bridge_interface)
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
string CTapDriver::SetUpNonEth0(int socket_fd, int ip_fd, const string& s)
|
string CTapDriver::SetUpNonEth0(int socket_fd, int ip_fd, const string& s)
|
||||||
{
|
{
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -301,6 +314,7 @@ string CTapDriver::SetUpNonEth0(int socket_fd, int ip_fd, const string& s)
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
string CTapDriver::IpLink(bool enable) const
|
string CTapDriver::IpLink(bool enable) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,7 @@ using namespace std;
|
||||||
|
|
||||||
class CTapDriver
|
class CTapDriver
|
||||||
{
|
{
|
||||||
static const string BRIDGE_NAME;
|
// static const string BRIDGE_NAME;
|
||||||
|
|
||||||
const inline static string DEFAULT_IP = "10.10.20.1/24"; //NOSONAR This hardcoded IP address is safe
|
const inline static string DEFAULT_IP = "10.10.20.1/24"; //NOSONAR This hardcoded IP address is safe
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static string SetUpEth0(int, const string&);
|
//static string SetUpEth0(int, const string&);
|
||||||
static string SetUpNonEth0(int, int, const string&);
|
static string SetUpNonEth0(int, int, const string&);
|
||||||
static pair<string, string> ExtractAddressAndMask(const string&);
|
static pair<string, string> ExtractAddressAndMask(const string&);
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,12 @@ bool SCSIDaynaPort::Init(const param_map& params)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void SCSIDaynaPort::CleanUp()
|
void SCSIDaynaPort::CleanUp()
|
||||||
{
|
{
|
||||||
tap.CleanUp();
|
tap.CleanUp();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vector<uint8_t> SCSIDaynaPort::InquiryInternal() const
|
vector<uint8_t> SCSIDaynaPort::InquiryInternal() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
~SCSIDaynaPort() override = default;
|
~SCSIDaynaPort() override = default;
|
||||||
|
|
||||||
bool Init(const param_map&) override;
|
bool Init(const param_map&) override;
|
||||||
void CleanUp() override;
|
// void CleanUp() override;
|
||||||
|
|
||||||
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
||||||
|
|
||||||
|
|
|
@ -67,10 +67,12 @@ bool SCSIBR::Init(const param_map& params)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
void SCSIBR::CleanUp()
|
void SCSIBR::CleanUp()
|
||||||
{
|
{
|
||||||
tap.CleanUp();
|
tap.CleanUp();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
vector<uint8_t> SCSIBR::InquiryInternal() const
|
vector<uint8_t> SCSIBR::InquiryInternal() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
~SCSIBR() override = default;
|
~SCSIBR() override = default;
|
||||||
|
|
||||||
bool Init(const param_map&) override;
|
bool Init(const param_map&) override;
|
||||||
void CleanUp() override;
|
// void CleanUp() override;
|
||||||
|
|
||||||
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
param_map GetDefaultParams() const override { return tap.GetDefaultParams(); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user