func (t *Target) handleVPD(s *Session, m, resp *packet.Message) { lun := int(m.LUN) alloc := int(packet.ParseUint(m.CDB[3:5])) vpd, err := t.LUNs[lun].VitalProductData(m.CDB[2]) if err != nil { resp.Status = 0x02 resp.SCSIResponse = 0x01 return } resp.RawData = vpd if len(vpd) >= alloc { resp.RawData = resp.RawData[:alloc] } }
func setError(resp *packet.Message, serr SCSIError) { buf := &bytes.Buffer{} data := serr.Bytes() buf.Write(packet.MarshalUint64(uint64(len(data)))[6:]) buf.Write(data) resp.RawData = buf.Bytes() }
// Send sends a message to the initiator on the appropriate connection. func (s *Session) Send(m *packet.Message) error { m.ISID = s.isid m.TSIH = s.tsih return s.conn.Send(m) }