date: 2016-09-11/21:30
This commit is contained in:
@@ -90,6 +90,10 @@ type ISCSICommand struct {
|
||||
Status byte
|
||||
SCSIResponse byte
|
||||
|
||||
// R2T
|
||||
R2TSN uint32
|
||||
DesiredLength uint32
|
||||
|
||||
// Data-In/Out
|
||||
HasStatus bool
|
||||
DataSN uint32
|
||||
@@ -112,6 +116,8 @@ func (cmd *ISCSICommand) Bytes() []byte {
|
||||
return cmd.noopInBytes()
|
||||
case OpSCSITaskResp:
|
||||
return cmd.scsiTMFRespBytes()
|
||||
case OpReady:
|
||||
return cmd.r2tRespBytes()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -139,7 +145,7 @@ func (m *ISCSICommand) String() string {
|
||||
s = append(s, fmt.Sprintf("Next Stage = %v", m.NSG))
|
||||
s = append(s, fmt.Sprintf("Status Class = %d", m.StatusClass))
|
||||
s = append(s, fmt.Sprintf("Status Detail = %d", m.StatusDetail))
|
||||
case OpSCSICmd:
|
||||
case OpSCSICmd, OpSCSIOut:
|
||||
s = append(s, fmt.Sprintf("LUN = %d", m.LUN))
|
||||
s = append(s, fmt.Sprintf("ExpectedDataLen = %d", m.ExpectedDataLen))
|
||||
s = append(s, fmt.Sprintf("CmdSN = %d", m.CmdSN))
|
||||
@@ -397,3 +403,33 @@ func (m *ISCSICommand) scsiTMFRespBytes() []byte {
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
func (m *ISCSICommand) r2tRespBytes() []byte {
|
||||
// rfc7143 11.8
|
||||
buf := &bytes.Buffer{}
|
||||
buf.WriteByte(byte(OpReady))
|
||||
var b byte
|
||||
if m.Final {
|
||||
b |= 0x80
|
||||
}
|
||||
buf.WriteByte(b)
|
||||
buf.WriteByte(0x00)
|
||||
buf.WriteByte(0x00)
|
||||
|
||||
// Skip through to byte 16
|
||||
for i := 0; i < 3*4; i++ {
|
||||
buf.WriteByte(0x00)
|
||||
}
|
||||
buf.Write(util.MarshalUint64(uint64(m.TaskTag))[4:])
|
||||
for i := 0; i < 4; i++ {
|
||||
buf.WriteByte(0x00)
|
||||
}
|
||||
buf.Write(util.MarshalUint64(uint64(m.StatSN))[4:])
|
||||
buf.Write(util.MarshalUint64(uint64(m.ExpCmdSN))[4:])
|
||||
buf.Write(util.MarshalUint64(uint64(m.MaxCmdSN))[4:])
|
||||
buf.Write(util.MarshalUint64(uint64(m.R2TSN))[4:])
|
||||
buf.Write(util.MarshalUint64(uint64(m.BufferOffset))[4:])
|
||||
buf.Write(util.MarshalUint64(uint64(m.DesiredLength))[4:])
|
||||
|
||||
return buf.Bytes()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user