2022-10-08 17:26:04 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// SCSI Target Emulator RaSCSI Reloaded
|
|
|
|
// for Raspberry Pi
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Uwe Seimet
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "rascsi_interface.pb.h"
|
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace rascsi_interface;
|
|
|
|
|
|
|
|
class RasctlParser
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
RasctlParser() = default;
|
|
|
|
~RasctlParser() = default;
|
|
|
|
|
|
|
|
PbOperation ParseOperation(const string&) const;
|
|
|
|
PbDeviceType ParseType(const string&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
unordered_map<int, PbOperation> operations = {
|
|
|
|
{ '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 }
|
|
|
|
};
|
|
|
|
|
|
|
|
unordered_map<int, PbDeviceType> device_types = {
|
|
|
|
{ 'b', SCBR },
|
|
|
|
{ 'c', SCCD },
|
|
|
|
{ 'd', SCDP },
|
|
|
|
{ 'h', SCHD },
|
|
|
|
{ 'l', SCLP },
|
|
|
|
{ 'm', SCMO },
|
|
|
|
{ 'r', SCRM },
|
|
|
|
{ 's', SCHS }
|
|
|
|
};
|
|
|
|
};
|