#include "isl_sm.h"
/* usb version 1 packet */
static char             islsm_data_packet1[86] = {	//0x00, 0x02, 0x02, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x01, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x00,
	0x00, 0x14, 0x0a, 0x06,
	0x02, 0x00, 0x1f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x00, 0x1f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x00, 0x1f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x00, 0x1f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x1f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};

/* usb version 2 packet */
static char             islsm_data_packet2[86] =
    { 0x01, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x00,
	0x00, 0x14, 0x0a, 0x06,
	0x02, 0x00, 0x03, 0x00, 0x07, 0x00, 0x5e, 0x00, 0x02, 0x00, 0x07,
	0x00,
	0x0f, 0x00, 0x2f, 0x00,
	0x03, 0x00, 0x0f, 0x00, 0xff, 0x03, 0x2b, 0x00, 0x07, 0x00, 0x0f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x78, 0x05
};

/* pci packet. 5a values are "don't care" values. */
static char             islsm_data_packet3[88] =
    { 0x01, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x00,
	0x00, 0x14, 0x0a, 0x06,
	0x02, 0x5a, 0x03, 0x00, 0x07, 0x00, 0x2f, 0x00, 0x02, 0x5a, 0x07,
	0x00,
	0x0f, 0x00, 0x5e, 0x00,
	0x03, 0x5a, 0x0f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x07, 0x5a, 0x0f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

/* ap mode, my device */
/*
0x01 0x80 0x4a 0x00 0x00 0x00 0x00 0x00 0x03 0x00 0x00 0x00 0x00 0x14 0x0a 0x06
0x02 0x5a 0x03 0x00 0x07 0x00 0x2f 0x00 0x02 0x5a 0x07 0x00 0x0f 0x00 0x5e 0x00
0x03 0x5a 0x0f 0x00 0xff 0x03 0x00 0x00 0x07 0x5a 0x0f 0x00 0xff 0x03 0x00 0x00
0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a
0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a 0x5a
0x00 0x00 0x00 0x00 0x00 0x00
*/

/* My device, client mode */
static char             islsm_data_UNK1[88]  __attribute__ ((unused)) =
    { 0x01, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x00,
	0x00, 0x14, 0x0a, 0x06,
	0x02, 0x5a, 0x03, 0x00, 0x07, 0x00, 0x2f, 0x00, 0x02, 0x5a, 0x07,
	0x00,
	0x0f, 0x00, 0x5e, 0x00,
	0x03, 0x5a, 0x0f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x07, 0x5a, 0x0f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

/* from david */
static char             islsm_data_UNK1_2[88]  __attribute__ ((unused)) =
    { 0x01, 0x80, 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
	0x00,
	0x00, 0x14, 0x0a, 0x06,
	0x02, 0x01, 0x03, 0x00, 0x07, 0x00, 0x2f, 0x00, 0x02, 0x00, 0x07,
	0x00,
	0x0f, 0x00, 0x5e, 0x00,
	0x03, 0x00, 0x0f, 0x00, 0xff, 0x03, 0x00, 0x00, 0x07, 0x00, 0x0f,
	0x00,
	0xff, 0x03, 0x00, 0x00,
	0x00, 0x16, 0x0e, 0x35, 0xbd, 0x34, 0xda, 0x56, 0x01, 0x4e, 0xb3,
	0xe5,
	0x50, 0x10, 0x29, 0xe0,
	0xa9, 0x91, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

/*
May 11 11:50:42 niobium kernel: frag :  01 80 08 00 00 00 00 00 0d 00 00 00 03 00 03 00 03 00 00 00
May 11 11:50:42 niobium kernel: driver_time time 0x396b6b6a us
May 11 11:50:42 niobium kernel: prism_interconnect_message_query(1, 1, 52, 20200, c75c47b8)
*/

/* Which mode was david on ? hostap mode ? */
static char             islsm_data_UNK2_2[52]  __attribute__ ((unused)) = {
	0x01, 0x80, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x50,
	0xbf, 0xa8, 0xa4, 0xe6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
	0x00,
	0x01, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x47, 0x02,
	0x00,
	0x20, 0x06, 0x03, 0x00,
	0x00, 0x00, 0x3f, 0xc7,
};

/* end */

/* client mode, my device. Try to understand AP mode, my device. See how
 * it fares. */
static char             islsm_data_UNK2[52]  __attribute__ ((unused)) = {
	0x01, 0x80, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x04,
	0xe2, 0x63, 0x97, 0x34, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
	0x00,
	0x01, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x47, 0x02,
	0x00,
	0x20, 0x06, 0x01, 0x00,
	0x00, 0x00, 0xc5, 0xf7,
};

/* ap mode, my device */
static char             islsm_data_UNK2_3[52]  __attribute__ ((unused)) = {
	0x01, 0x80, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00,
	0x00, 0x00, 0x00, 0x04,
	0xe2, 0x63, 0x97, 0x34, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
	0x00,
	0x01, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x47, 0x02,
	0x00,
	0x20, 0x06, 0x01, 0x00,
	0x00, 0x00, 0xc5, 0xf7,
};

/* client mode, my device */
static char             islsm_data_UNK3[]  __attribute__ ((unused)) = {
	0x01, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
	0x00,
	0x02, 0x00, 0x78, 0x00,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x5a, 0x5a, 0x5a, 0x5a, 0x6c, 0x09, 0xf5, 0x03, 0x10, 0x00, 0x00,
	0x00,
	0x06, 0x01, 0x08, 0x38,
	0x38, 0x38, 0x38, 0x38, 0x57, 0x75, 0x8b, 0x99, 0xa5, 0xb1, 0xbd,
	0x5a,
	0x4f, 0x40, 0x69, 0x77,
	0x83, 0x8f, 0x9b, 0x5a, 0x47, 0x18, 0x54, 0x62, 0x6e, 0x7a, 0x86,
	0x5a,
	0x3b, 0xea, 0x3e, 0x4c,
	0x58, 0x64, 0x70, 0x5a, 0x2f, 0xcb, 0x2b, 0x39, 0x45, 0x51, 0x5d,
	0x5a,
	0x23, 0xb5, 0x19, 0x27,
	0x33, 0x3f, 0x4b, 0x5a, 0x17, 0xa5, 0x07, 0x15, 0x21, 0x2d, 0x39,
	0x5a,
	0x00, 0x94, 0x00, 0x00,
	0x00, 0x0b, 0x17, 0x5a, 0x4d, 0x48, 0x44, 0x39, 0x7c, 0x00, 0x69,
	0xfe,
};

static char             islsm_data_UNK4[]  __attribute__ ((unused)) = {
	0x01, 0x80, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
	0x00,
	0x02, 0x00, 0x78, 0x00,
	0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a,
	0x5a,
	0x5a, 0x5a, 0x5a, 0x5a,
	0x5a, 0x5a, 0x5a, 0x5a, 0x71, 0x09, 0xf4, 0x03, 0x10, 0x00, 0x00,
	0x00,
	0x06, 0x01, 0x08, 0x48,
	0x48, 0x48, 0x43, 0x38, 0x57, 0x76, 0x8b, 0x99, 0xa5, 0xb1, 0xbd,
	0x5a,
	0x4f, 0x42, 0x69, 0x77,
	0x83, 0x8f, 0x9b, 0x5a, 0x47, 0x19, 0x54, 0x62, 0x6e, 0x7a, 0x86,
	0x5a,
	0x3b, 0xeb, 0x3e, 0x4c,
	0x58, 0x64, 0x70, 0x5a, 0x2f, 0xcb, 0x2b, 0x39, 0x45, 0x51, 0x5d,
	0x5a,
	0x23, 0xb5, 0x19, 0x27,
	0x33, 0x3f, 0x4b, 0x5a, 0x17, 0xa6, 0x07, 0x15, 0x21, 0x2d, 0x39,
	0x5a,
	0x00, 0x94, 0x00, 0x00,
	0x00, 0x0b, 0x17, 0x5a, 0x4d, 0x48, 0x43, 0x38, 0x7c, 0x00, 0x69,
	0xfe,
};

struct magicpkt {
	int                     len;
	char                   *data;
};

static struct magicpkt  magicpkt_table[3] = {
	[ISLSM_DEVICE_USB_VER1] {.len = sizeof (islsm_data_packet1),.data =
				 islsm_data_packet1}
	,
	[ISLSM_DEVICE_USB_VER2] {.len = sizeof (islsm_data_packet2),.data =
				 islsm_data_packet2}
	,
	[ISLSM_DEVICE_PCI_VER1] {.len = sizeof (islsm_data_packet3),.data =
				 islsm_data_packet3}
	,
};
