⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unplug_test.c

📁 blue tooth 核心协议栈在linux上的实现
💻 C
📖 第 1 页 / 共 3 页
字号:
static s32 test_2_13_1(void){	s32 retval = 0;	flow qos;	init_flow(&qos);	qos.bucket_size = 0x16;	qos.flags = 0;	qos.service = 0x2;	printk("Client sending QOS options\n");	if ((retval = l2ca_config_req(testcon, 0, &qos, 0, 0)) < 0) {		D_ERR("test_connect_cfm : Configuration request failed\n");	}	return retval;}static s32 test_2_13_5(void){	printk("test_2_13_5, client sending 672 bytes\n"); 	return test_send_data(testcon, testdata, 672);	}static s32 test_2_13_6(void){	printk("test_2_13_6, server sending 672 bytes\n"); 	return test_send_data(testcon, testdata, 672);	}/* * SDP Stuff */s32 do_sdp_test(int n){	unsigned char *q;	int q_len;	printk(__FUNCTION__" -- %d\n", n);	switch(n) {			case 101: q = q1_1; break;	case 102: q = q1_2; break;	case 2:  q = q2; break;	case 301: q = q3_1; break;	case 302: q = q3_2; break;	case 4:  q = q4; break;	case 5:  q = q5; break;	case 6:  q = q6; break;	case 7:  q = q7; break;	case 8:  q = q8; break;	case 9:  q = q9; break;	case 10: q = q10; break;	case 11: q = q11; break;	default: printk("Unknown SDP test.\n");		return -1;	}	q_len = q[4] + 5; /* assumes less than 255 bytes long pdu:s */		/* Now send the request */  	return sdp_send_data(&sdp_con_list[0], q, q_len);}static s32 sdp_test_52111(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_52111, sdp_data_52111[4] + 5);}static s32 sdp_test_52113(void){	static int t = 0;	s32 retval = 0;		if (!t) {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_52113_1, sdp_data_52113_1[4] + 5);		t = 1;	} else {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_52113_2, sdp_data_52113_2[4] + 5);		t = 0;	}	return retval;}static s32 sdp_test_52114(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_52114, sdp_data_52114[4] + 5);}static s32 sdp_test_52121(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_52121, sdp_data_52121[4] + 5);}static s32 sdp_test_52122(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_52122, sdp_data_52122[4] + 5);}static s32 sdp_test_53111(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53111, sdp_data_53111[4] + 5);}static s32 sdp_test_53113(void){	static int t = 0;	s32 retval;		if (!t) {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_53113_1, sdp_data_53113_2[4] + 5);		t = 1;	} else {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_53113_2, sdp_data_53113_2[4] + 5);		t = 0;	}	return retval;}static s32 sdp_test_53114(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53114, sdp_data_53114[4] + 5);}static s32 sdp_test_53115(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53115, sdp_data_53115[4] + 5);}static s32 sdp_test_53118(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53118, sdp_data_53118[4] + 5);}static s32 sdp_test_531110(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_531110, sdp_data_531110[4] + 5);}static s32 sdp_test_531117(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_531117, sdp_data_531117[4] + 5);}static s32 sdp_test_531120(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_531120, sdp_data_531120[4] + 5);}static s32 sdp_test_53121(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53121, sdp_data_53121[4] + 5);}static s32 sdp_test_53122(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53122, sdp_data_53122[4] + 5);}static s32 sdp_test_53123(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_53123, sdp_data_53123[4] + 5);}static s32 sdp_test_54111(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54111, sdp_data_54111[4] + 5);}static s32 sdp_test_54112(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54112, sdp_data_54112[4] + 5);}static s32 sdp_test_54113(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54113, sdp_data_54113[4] + 5);}static s32 sdp_test_54114(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54114, sdp_data_54114[4] + 5);}static s32 sdp_test_54116(void){	static int t = 0;	s32 retval;	if (!t) {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_54116_1, sdp_data_54116_1[4] + 5);		t = 1;	} else {		retval = sdp_send_data(&sdp_con_list[0], sdp_data_54116_2, sdp_data_54116_2[4] + 5);		t = 0;	} 	return retval;}static s32 sdp_test_541110(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_541110, sdp_data_541110[4] + 5);}static s32 sdp_test_541111(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_541111, sdp_data_541111[4] + 5);}static s32 sdp_test_541112(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_541112, sdp_data_541112[4] + 5);}static s32 sdp_test_541120(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_541120, sdp_data_541120[4] + 5);}static s32 sdp_test_54121(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54121, sdp_data_54121[4] + 5);}static s32 sdp_test_54122(void){	return sdp_send_data(&sdp_con_list[0], sdp_data_54122, sdp_data_54122[4] + 5);}static s32 sdp_test_55111(void){	static int t = 0;	s32 retval = 0;		switch (t) {	case 0:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_1, sdp_data_55111_1[4] + 5);		t = 1;		break;	case 1:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_2, sdp_data_55111_2[4] + 5);		t = 2;//		break;	case 2:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_3, sdp_data_55111_3[4] + 5);		t = 3;//		break;	case 3:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_4, sdp_data_55111_4[4] + 5);		t = 4;//		break;	case 4:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_5, sdp_data_55111_5[4] + 5);		t = 5;//		break;	case 5:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_6, sdp_data_55111_6[4] + 5);		t = 6;//		break;	case 6:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_7, sdp_data_55111_7[4] + 5);		t = 7;//		break;	case 7:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55111_8, sdp_data_55111_8[4] + 5);		t = 0;		break;  	} 	return retval;}static s32 sdp_test_55112(void){	static int t = 0;	s32 retval = 0;	switch (t) {	case 0:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55112_1, sdp_data_55112_1[4] + 5);		t = 1;		break;	case 1:		retval = sdp_send_data(&sdp_con_list[0], sdp_data_55112_2, sdp_data_55112_2[4] + 5);		t = 0;		break;	}	return retval;}/* * Serial Port Profile Stuff */static s32 spp_test_52211(void){	static int t = 0;	s32 retval = 0;  	unsigned char sdp_query[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				      0x35, 0x03, 0x19, 0x11, 0x01, 0x00, 0xff,				      0x35, 0x03, 0x09, 0x00, 0x04, 0x00 };	switch (t) {	case 0:		retval = sdp_send_data(&sdp_con_list[0], sdp_query, sdp_query[4] + 5);		t++;		break;	case 1:		printk(__FUNCTION__": Establish RFCOMM on channel 0\n");		t++;		break;	case 2:		printk(__FUNCTION__": Establish RFCOMM on channel 2\n");		t = 0;		break;	}	return retval;}static s32 spp_test_52311(void){	static int t = 0;	s32 retval = 0;		switch (t) {	case 0:		retval = hci_sniff_mode(rfcomm_con_list[0].l2cap->hci_hdl, 0xff, 0xf0, 0x10, 0x05);		t = 1;		break;	case 1:		retval = hci_exit_sniff_mode(rfcomm_con_list[0].l2cap->hci_hdl);		t = 0;		break;	}	return retval;}static s32 spp_test_52312(void){	static int t = 0;	s32 retval = 0;	switch (t) {	case 0:		retval = hci_park_mode(rfcomm_con_list[0].l2cap->hci_hdl, 0xfff, 0xf0);		t = 1;		break;	case 1:		retval = hci_exit_park_mode(rfcomm_con_list[0].l2cap->hci_hdl);		t = 0;		break;	}	return retval;}static s32 spp_test_52313(void){	return hci_hold_mode(rfcomm_con_list[0].l2cap->hci_hdl, 0xfff, 0xf0);}static s32 spp_test_52314(void){	printk(__FUNCTION__": Do test 52211, then do a M/S switch\n");	return 0;}static s32 spp_test_53112(void){	/* Establish a L2CAP channel in PSM 3 (RFCOMM), before doing this test */	return rfcomm_sabm_msg(&rfcomm_con_list[0], 0);}static s32 spp_test_53211(void){	/* This test has to be done rigth after test 53112 */	return rfcomm_disc_msg(&rfcomm_con_list[0], 0);}static s32 spp_test_53312(void){	/* Establish a L2CAP channel in PSM 3 (RFCOMM), and establish DLCI 0	   before doing this test */	return rfcomm_sabm_msg(&rfcomm_con_list[0], 2);}static s32 spp_test_53411(void){	/* Establish a L2CAP channel in PSM 3 (RFCOMM), and establish DLCI 0	   and 2 before doing this test */	/* Here the BAP should send the disc command so we just have to wait	   for that, rf_disc should probably work in the BAP */	return 0;}static s32 spp_test_53412(void){	/* This test has to be done rigth after test 53116 */	return rfcomm_disc_msg(&rfcomm_con_list[0], 2);}static s32 spp_test_53511(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	/* Send data from the BAp with the rf_send command */  	return rfcomm_msc_msg(&rfcomm_con_list[0], 0x85 ,MCC_CMD, 2);}static s32 spp_test_53611(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */  	/* Then send data from the BAP with the rf_send command */	return 0;}static s32 spp_test_53711(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	unsigned char data[] = {0,1,2,3,4,5,6,7,9};	/* We send a test messages of ten bytes size */	return rfcomm_test_msg(&rfcomm_con_list[0], data, 10, MCC_CMD);}static s32 spp_test_53811(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	s32 retval = 0;	static int t = 0;	switch (t) {	case 0:		retval = rfcomm_fcoff_msg(&rfcomm_con_list[0], MCC_CMD);		printk(__FUNCTION__": Flow is set to OFF\n");		t++;		break;	case 1:		retval = rfcomm_fcon_msg(&rfcomm_con_list[0], MCC_CMD);		printk(__FUNCTION__": Flow is set to ON\n");		t = 0;		break;	}	return retval;}static s32 spp_test_53911(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	return rfcomm_rls_msg(&rfcomm_con_list[0], MCC_CMD, 2, 0x05);}static s32 spp_test_531011(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	static int t = 0;	s32 retval = 0;	switch (t) {	case 0:		retval = rfcomm_pn_msg(&rfcomm_con_list[0], 2, 0, 1000);		t++;		break;	case 1:		retval = rfcomm_pn_msg(&rfcomm_con_list[0], 2, 0, 667);		break;	}	return retval;}static s32 spp_test_531111(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	return rfcomm_rpn_msg(&rfcomm_con_list[0], MCC_CMD, 4, 0);}static s32 spp_test_531112(void){	/* Do test 52211 before to establish RFCOMM, DLCI 1 and 2. You also	   have to verify so both sides have sent a MSC command with flow on */	return rfcomm_rpn_msg(&rfcomm_con_list[0], MCC_CMD, 4, 1);}static s32 spp_test_55111(void){	/* Establish a L2CAP channel on PSM 1 (SDP) before doing this test */	unsigned char sdp_query[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				      0x35, 0x03, 0x19, 0x00, 0x03, 0x00, 0xff, 0x00 };	return sdp_send_data(&sdp_con_list[0], sdp_query, sdp_query[4] + 5);}static s32 spp_test_55112(void){	/* Establish a L2CAP channel on PSM 1 (SDP) before doing this test */	unsigned char sdp_query[] = { 0x04, 0x88, 0x88, 0x00, 0x12,				      0x01, 0x00, 0xff, 0xff, 0x00, 0xff, 0x35, 0x09,				      0x09, 0x00, 0x01, 0x09, 0x00, 0x04, 0x09, 0x01,				      0x00, 0x00 };	return sdp_send_data(&sdp_con_list[0], sdp_query, sdp_query[4] + 5);}static s32 spp_test_55113(void){	/* Establish a L2CAP channel on PSM 1 (SDP) before doing this test */	unsigned char sdp_query[] = { 0x06, 0x88, 0x88, 0x00, 0x13,				      0x35, 0x03, 0x19, 0x12, 0x34, 0x00, 0xff, 0x35,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -