2021-09-24 06:48:48 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2021-09-24 06:48:48 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
2023-10-15 06:38:15 +00:00
|
|
|
// Copyright (C) 2021-2023 Uwe Seimet
|
2021-09-24 06:48:48 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-11-04 07:22:32 +00:00
|
|
|
#include "devices/device_factory.h"
|
|
|
|
#include "devices/primary_device.h"
|
2023-10-30 12:32:45 +00:00
|
|
|
#include "shared/piscsi_util.h"
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "generated/piscsi_interface.pb.h"
|
2021-09-24 06:48:48 +00:00
|
|
|
#include <string>
|
2023-10-15 06:38:15 +00:00
|
|
|
#include <span>
|
2023-10-30 12:32:45 +00:00
|
|
|
#include <set>
|
2021-09-24 06:48:48 +00:00
|
|
|
|
2022-10-04 15:23:42 +00:00
|
|
|
using namespace std;
|
2023-10-15 06:38:15 +00:00
|
|
|
using namespace filesystem;
|
2022-12-05 17:58:23 +00:00
|
|
|
using namespace piscsi_interface;
|
2021-09-24 06:48:48 +00:00
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
class PiscsiResponse
|
2021-09-24 06:48:48 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2023-11-15 06:36:07 +00:00
|
|
|
PiscsiResponse() { }
|
2022-12-05 17:58:23 +00:00
|
|
|
~PiscsiResponse() = default;
|
2022-10-04 15:23:42 +00:00
|
|
|
|
|
|
|
bool GetImageFile(PbImageFile&, const string&, const string&) const;
|
2023-10-15 06:38:15 +00:00
|
|
|
void GetImageFilesInfo(PbImageFilesInfo&, const string&, const string&, const string&, int) const;
|
|
|
|
void GetReservedIds(PbReservedIdsInfo&, const unordered_set<int>&) const;
|
2022-11-04 07:22:32 +00:00
|
|
|
void GetDevices(const unordered_set<shared_ptr<PrimaryDevice>>&, PbServerInfo&, const string&) const;
|
|
|
|
void GetDevicesInfo(const unordered_set<shared_ptr<PrimaryDevice>>&, PbResult&, const PbCommand&, const string&) const;
|
2023-10-15 06:38:15 +00:00
|
|
|
void GetDeviceTypesInfo(PbDeviceTypesInfo&) const;
|
|
|
|
void GetVersionInfo(PbVersionInfo&) const;
|
2023-10-30 12:32:45 +00:00
|
|
|
void GetServerInfo(PbServerInfo&, const PbCommand&, const unordered_set<shared_ptr<PrimaryDevice>>&,
|
|
|
|
const unordered_set<int>&, const string&, int) const;
|
2023-10-15 06:38:15 +00:00
|
|
|
void GetNetworkInterfacesInfo(PbNetworkInterfacesInfo&) const;
|
|
|
|
void GetMappingInfo(PbMappingInfo&) const;
|
|
|
|
void GetLogLevelInfo(PbLogLevelInfo&) const;
|
2023-10-30 12:32:45 +00:00
|
|
|
void GetStatisticsInfo(PbStatisticsInfo&, const unordered_set<shared_ptr<PrimaryDevice>>&) const;
|
2023-10-15 06:38:15 +00:00
|
|
|
void GetOperationInfo(PbOperationInfo&, int) const;
|
2021-09-24 06:48:48 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
inline static const vector<string> EMPTY_VECTOR;
|
2021-09-24 06:48:48 +00:00
|
|
|
|
2023-11-14 14:32:46 +00:00
|
|
|
[[no_unique_address]] const DeviceFactory device_factory;
|
2021-09-24 06:48:48 +00:00
|
|
|
|
2023-11-14 14:32:46 +00:00
|
|
|
void GetDeviceProperties(shared_ptr<Device>, PbDeviceProperties&) const;
|
|
|
|
void GetDevice(shared_ptr<Device>, PbDevice&, const string&) const;
|
2022-10-04 15:23:42 +00:00
|
|
|
void GetDeviceTypeProperties(PbDeviceTypesInfo&, PbDeviceType) const;
|
2023-10-15 06:38:15 +00:00
|
|
|
void GetAvailableImages(PbImageFilesInfo&, const string&, const string&, const string&, int) const;
|
|
|
|
void GetAvailableImages(PbServerInfo&, const string&, const string&, const string&, int) const;
|
|
|
|
PbOperationMetaData *CreateOperation(PbOperationInfo&, const PbOperation&, const string&) const;
|
|
|
|
void AddOperationParameter(PbOperationMetaData&, const string&, const string&,
|
|
|
|
const string& = "", bool = false, const vector<string>& = EMPTY_VECTOR) const;
|
2022-11-04 07:22:32 +00:00
|
|
|
set<id_set> MatchDevices(const unordered_set<shared_ptr<PrimaryDevice>>&, PbResult&, const PbCommand&) const;
|
2022-10-04 15:23:42 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
static bool ValidateImageFile(const path&);
|
|
|
|
|
|
|
|
static bool FilterMatches(const string&, string_view);
|
2023-10-30 12:32:45 +00:00
|
|
|
|
|
|
|
static bool HasOperation(const set<string, less<>>&, PbOperation);
|
2021-09-24 06:48:48 +00:00
|
|
|
};
|