2022-10-08 17:26:04 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
2022-12-05 17:58:23 +00:00
|
|
|
// SCSI Target Emulator PiSCSI
|
2022-10-08 17:26:04 +00:00
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
#include "generated/piscsi_interface.pb.h"
|
2022-10-08 17:26:04 +00:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
using namespace std;
|
2022-12-05 17:58:23 +00:00
|
|
|
using namespace piscsi_interface;
|
2022-10-08 17:26:04 +00:00
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
class ScsictlParser
|
2022-10-08 17:26:04 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2022-12-05 17:58:23 +00:00
|
|
|
ScsictlParser() = default;
|
|
|
|
~ScsictlParser() = default;
|
2022-10-08 17:26:04 +00:00
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
PbOperation ParseOperation(string_view) const;
|
2022-10-08 17:26:04 +00:00
|
|
|
PbDeviceType ParseType(const string&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
const unordered_map<int, PbOperation> operations = {
|
2022-10-08 17:26:04 +00:00
|
|
|
{ 'a', ATTACH },
|
|
|
|
{ 'd', DETACH },
|
|
|
|
{ 'e', EJECT },
|
2022-10-27 14:31:32 +00:00
|
|
|
{ 'i', INSERT },
|
2022-10-08 17:26:04 +00:00
|
|
|
{ 'p', PROTECT },
|
2022-10-27 14:31:32 +00:00
|
|
|
{ 's', DEVICES_INFO },
|
2022-10-08 17:26:04 +00:00
|
|
|
{ 'u', UNPROTECT }
|
|
|
|
};
|
|
|
|
|
2023-10-15 06:38:15 +00:00
|
|
|
const unordered_map<int, PbDeviceType> device_types = {
|
2022-10-08 17:26:04 +00:00
|
|
|
{ 'b', SCBR },
|
|
|
|
{ 'c', SCCD },
|
|
|
|
{ 'd', SCDP },
|
|
|
|
{ 'h', SCHD },
|
|
|
|
{ 'l', SCLP },
|
|
|
|
{ 'm', SCMO },
|
|
|
|
{ 'r', SCRM },
|
|
|
|
{ 's', SCHS }
|
|
|
|
};
|
|
|
|
};
|