2017-05-19 20:28:49 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:23 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2015-11-02 19:12:19 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : DiscStructureCapabilities.cs
|
2016-07-28 18:13:49 +01:00
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
2015-11-02 19:12:19 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// Component : Device structures decoders.
|
2015-11-02 19:12:19 +00:00
|
|
|
//
|
|
|
|
|
// --[ Description ] ----------------------------------------------------------
|
|
|
|
|
//
|
2018-12-29 15:26:00 +00:00
|
|
|
// Decodes SCSI DISC STRUCTURE structures.
|
2015-11-02 19:12:19 +00:00
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
2015-11-02 19:12:19 +00:00
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
2015-11-02 19:12:19 +00:00
|
|
|
//
|
2016-07-28 18:13:49 +01:00
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
2015-11-02 19:12:19 +00:00
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2022-12-03 16:07:08 +00:00
|
|
|
// Copyright © 2011-2023 Natalia Portillo
|
2015-11-02 19:12:19 +00:00
|
|
|
// ****************************************************************************/
|
2016-07-28 18:13:49 +01:00
|
|
|
|
2015-11-02 19:12:19 +00:00
|
|
|
using System.Collections.Generic;
|
2017-12-22 02:04:18 +00:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2015-11-02 19:12:19 +00:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
namespace Aaru.Decoders.SCSI;
|
|
|
|
|
|
2023-10-03 23:09:28 +01:00
|
|
|
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBeInternal")]
|
|
|
|
|
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "NotAccessedField.Global")]
|
2023-10-05 01:05:20 +01:00
|
|
|
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
|
|
|
|
[SuppressMessage("ReSharper", "UnusedType.Global")]
|
2022-03-06 13:29:37 +00:00
|
|
|
public static class DiscStructureCapabilities
|
2015-11-02 19:12:19 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
public static Capability[] Decode(byte[] response)
|
2015-11-02 19:12:19 +00:00
|
|
|
{
|
2023-10-03 23:09:28 +01:00
|
|
|
var len = (ushort)((response[0] << 8) + response[1]);
|
2015-11-02 19:12:19 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
if(len + 2 != response.Length)
|
|
|
|
|
return null;
|
2015-11-02 19:12:19 +00:00
|
|
|
|
2022-11-15 15:58:41 +00:00
|
|
|
List<Capability> caps = new();
|
2015-11-02 19:12:19 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
uint offset = 4;
|
2015-11-02 19:12:19 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
while(offset < response.Length)
|
|
|
|
|
{
|
|
|
|
|
var cap = new Capability
|
2015-11-02 19:12:19 +00:00
|
|
|
{
|
2022-03-06 13:29:37 +00:00
|
|
|
FormatCode = response[offset],
|
|
|
|
|
SDS = (response[offset + 1] & 0x80) == 0x80,
|
|
|
|
|
RDS = (response[offset + 1] & 0x40) == 0x40
|
|
|
|
|
};
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
caps.Add(cap);
|
|
|
|
|
offset += 4;
|
2015-11-02 19:12:19 +00:00
|
|
|
}
|
2019-11-25 00:54:38 +00:00
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
return caps.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-03 23:09:28 +01:00
|
|
|
#region Nested type: Capability
|
|
|
|
|
|
2022-03-06 13:29:37 +00:00
|
|
|
public struct Capability
|
|
|
|
|
{
|
|
|
|
|
/// <summary>READ/SEND DISC STRUCTURE format code</summary>
|
|
|
|
|
public byte FormatCode;
|
|
|
|
|
/// <summary>Supported in SEND DISC STRUCTURE</summary>
|
|
|
|
|
public bool SDS;
|
|
|
|
|
/// <summary>Supported in READ DISC STRUCTURE</summary>
|
|
|
|
|
public bool RDS;
|
2015-11-02 19:12:19 +00:00
|
|
|
}
|
2023-10-03 23:09:28 +01:00
|
|
|
|
|
|
|
|
#endregion
|
2017-12-19 20:33:03 +00:00
|
|
|
}
|