Documentation ¶
Index ¶
- Constants
- Variables
- func FindComID(d drive.DriveIntf, d0 *Level0Discovery) (ComID, ProtocolLevel, error)
- func HandleComIDRequest(d drive.DriveIntf, comID ComID, req ComIDRequest) ([]byte, error)
- func IsComIDValid(d drive.DriveIntf, comID ComID) (bool, error)
- func NewPlainCommunication(d drive.DriveIntf, hp HostProperties, tp TPerProperties) *plainCom
- func StackReset(d drive.DriveIntf, comID ComID) error
- type ComID
- type ComIDRequest
- type CommunicationIntf
- type ControlSession
- type ControlSessionOpt
- type Core
- type DiskInfo
- type HostProperties
- type Level0Discovery
- type ProtocolLevel
- type Session
- type SessionOpt
- type TPerProperties
Constants ¶
const ( DefaultMaxComPacketSize uint = 1024 * 1024 DefaultReceiveRetries = 100 DefaultReceiveInterval = 10 * time.Millisecond )
Variables ¶
var ( ErrTooLargeComPacket = errors.New("encountered a too large ComPacket") ErrTooLargePacket = errors.New("encountered a too large Packet") )
var ( ErrTPerSyncNotSupported = errors.New("synchronous operation not supported by TPer") ErrTPerBufferMgmtNotSupported = errors.New("TPer supports buffer management, but that is not implemented in this library") ErrInvalidPropertiesResponse = errors.New("response was not the expected Properties call format") ErrInvalidStartSessionResponse = errors.New("response was not the expected SyncSession format") ErrPropertiesCallFailed = errors.New("the properties call returned non-zero") ErrSessionAlreadyClosed = errors.New("the session has been closed by us") )
var ( // Table 168: "Communications Initial Assumptions" InitialTPerProperties = TPerProperties{ MaxSubpackets: 1, MaxPacketSize: 1004, MaxPackets: 1, MaxComPacketSize: 1024, MaxIndTokenSize: 968, MaxAggTokenSize: 968, MaxMethods: 1, ContinuedTokens: false, SequenceNumbers: false, AckNak: false, Asynchronous: false, } // Increased to match that one of the highest standard we support InitialHostProperties = HostProperties{ MaxSubpackets: 1, MaxPacketSize: 2028, MaxPackets: 1, MaxComPacketSize: 2048, MaxIndTokenSize: 1992, MaxAggTokenSize: 1992, MaxMethods: 1, ContinuedTokens: false, SequenceNumbers: false, AckNak: false, Asynchronous: false, } )
Functions ¶
func FindComID ¶
func FindComID(d drive.DriveIntf, d0 *Level0Discovery) (ComID, ProtocolLevel, error)
FindComID checks data of Level0Discovery for the particular SSC and reads the standard ComID of requests a ComID if no standard is set.
func HandleComIDRequest ¶
func IsComIDValid ¶
Validate a ComID.
func NewPlainCommunication ¶
func NewPlainCommunication(d drive.DriveIntf, hp HostProperties, tp TPerProperties) *plainCom
Low-level communication used to send/receive packets to a TPer or SP.
Implements Subpacket-Packet-ComPacket packet format.
Types ¶
type ComIDRequest ¶
type ComIDRequest [4]byte
var ( ComIDRequestVerifyComIDValid ComIDRequest = [4]byte{0x00, 0x00, 0x00, 0x01} ComIDRequestStackReset ComIDRequest = [4]byte{0x00, 0x00, 0x00, 0x02} ErrNotSupported = errors.New("device does not support TCG Storage Core") )
type CommunicationIntf ¶
type CommunicationIntf interface { Send(ses *Session, data []byte) error Receive(ses *Session) ([]byte, error) }
NOTE: This is almost io.ReadWriter, but not quite - I couldn't figure out a good interface use that wouldn't result in a lot of extra copying.
type ControlSession ¶
type ControlSession struct { Session HostProperties HostProperties TPerProperties TPerProperties MaxComPacketSizeOverride uint }
func NewControlSession ¶
func NewControlSession(d drive.DriveIntf, d0 *Level0Discovery, opts ...ControlSessionOpt) (*ControlSession, error)
Initiate a new control session with a ComID.
func (*ControlSession) Close ¶
func (cs *ControlSession) Close() error
func (*ControlSession) NewSession ¶
func (cs *ControlSession) NewSession(spid uid.SPID, opts ...SessionOpt) (*Session, error)
Initiate a new session with a Security Provider
The session will be a read-write by default, but can be changed by passing a SessionOpt from WithReadOnly() as argument. The session HSN will be random unless passed with WithHSN(x).
type ControlSessionOpt ¶
type ControlSessionOpt func(s *ControlSession)
func WithComID ¶
func WithComID(c ComID) ControlSessionOpt
func WithMaxComPacketSize ¶
func WithMaxComPacketSize(size uint) ControlSessionOpt
func WithReceiveTimeout ¶
func WithReceiveTimeout(retries int, interval time.Duration) ControlSessionOpt
type Core ¶
Core holds the device interface to access IFSend/IFReceive functions as well as disk information obtained by the Identify and Discovery functions. This struct shall be use to interface the library
type DiskInfo ¶
type DiskInfo struct { *Level0Discovery *drive.Identity }
diskInfo holds information obtained by Discovery0 and Identify functions.
type HostProperties ¶
type Level0Discovery ¶
type Level0Discovery struct { MajorVersion int MinorVersion int Vendor [32]byte TPer *feature.TPer Locking *feature.Locking Geometry *feature.Geometry SecureMsg *feature.SecureMsg Enterprise *feature.Enterprise OpalV1 *feature.OpalV1 SingleUser *feature.SingleUser DataStore *feature.DataStore OpalV2 *feature.OpalV2 Opalite *feature.Opalite PyriteV1 *feature.PyriteV1 PyriteV2 *feature.PyriteV2 RubyV1 *feature.RubyV1 LockingLBA *feature.LockingLBA BlockSID *feature.BlockSID NamespaceLocking *feature.NamespaceLocking DataRemoval *feature.DataRemoval NamespaceGeometry *feature.NamespaceGeometry SeagatePorts *feature.SeagatePorts UnknownFeatures []uint16 }
Level0Discovery structure as described in TCG Storage Architecture Core Spec v2.01 rev 1.00 (missing data length field, which is only required for parsing)
type ProtocolLevel ¶
type ProtocolLevel uint
const ( ProtocolLevelUnknown ProtocolLevel = 0 ProtocolLevelEnterprise ProtocolLevel = 1 ProtocolLevelCore ProtocolLevel = 2 )
func (*ProtocolLevel) String ¶
func (p *ProtocolLevel) String() string
type Session ¶
type Session struct { ControlSession *ControlSession MethodFlags method.MethodFlag ProtocolLevel ProtocolLevel ComID ComID TSN, HSN int // See "3.2.3.3.1.2 SeqNumber" SeqLastXmit int SeqLastAcked int SeqNextExpected int ReadOnly bool // Ignored for Control Sessions ReceiveRetries int ReceiveInterval time.Duration // contains filtered or unexported fields }
func (*Session) ExecuteMethod ¶
type SessionOpt ¶
type SessionOpt func(s *Session)
func WithHSN ¶
func WithHSN(hsn int) SessionOpt
func WithReadOnly ¶
func WithReadOnly() SessionOpt
type TPerProperties ¶
type TPerProperties struct { MaxMethods uint MaxSubpackets uint MaxPacketSize uint MaxPackets uint MaxComPacketSize uint MaxResponseComPacketSize *uint MaxSessions *uint MaxReadSessions *uint MaxIndTokenSize uint MaxAggTokenSize uint MaxAuthentications *uint MaxTransactionLimit *uint DefSessionTimeout *uint MaxSessionTimeout *uint MinSessionTimeout *uint DefTransTimeout *uint MaxTransTimeout *uint MinTransTimeout *uint MaxComIDTime *uint ContinuedTokens bool SequenceNumbers bool AckNak bool Asynchronous bool }