#include "mcdp.h"

/**
 * Copyright (C) 2001-2006 Tino Reichardt
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License Version 2, as
 * published by the Free Software Foundation.
 *
 * This program 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/* INQUIRY COMMAND (6)
 *
 * 0 = op code (0x12)
 * 1 = reserved
 * 2 = reserved
 * 3 = reserved
 * 4 = allocation len
 * 5 = reserved
 */

#define INQUIRY_SIZE 36 /* 8 + vendor(8) + model(16) + revision(4) */

void scmd_inquiry(void)
{
	scmd_ready(6, INQUIRY_SIZE);
#if DEBUG_CDB
	if (!stralloc_copys(&cdb.name, "INQUIRY COMMAND (6)")) die_nomem();
#endif

	/* send inquiry command */
	cdb.cmd.s[0]=0x12;
	cdb.cmd.s[4]=INQUIRY_SIZE;
	cdb.flags=D_READ;

	if (cd->cmd(&cdb) == -1) {
		die_msg(111,"scmd_inquiry() failed!");
	}

	/* copy info to our struct */
	byte_copy(cd->vendor, 8, cdb.buf.s+8);
	byte_copy(cd->model, 16, cdb.buf.s+8+8);
	byte_copy(cd->rev,    4, cdb.buf.s+8+8+16);
	set(cd->updates, U_DEVICE);

	return;
}

