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

📄 unplug_test.c

📁 blue tooth 核心协议栈在linux上的实现
💻 C
📖 第 1 页 / 共 3 页
字号:
#define __NO_VERSION__ /* don't define kernel_version in module.h */#ifdef __KERNEL__#include <linux/malloc.h>#include <linux/bluetooth/hci.h>#include <linux/bluetooth/l2cap_con.h>#include <linux/bluetooth/sdp.h>#include <linux/bluetooth/tcs.h>#include <linux/bluetooth/test.h>#include <linux/bluetooth/rfcomm.h>#include <linux/bluetooth/btcommon.h>#else#include <string.h>#include "include/hci.h"#include "include/l2cap_con.h"#include "include/sdp.h"#include "include/tcs.h"#include "include/test.h"#include "include/rfcomm.h"#include "include/btcommon.h"#endifextern rfcomm_con rfcomm_con_list[7];extern rpn_values rpn_val;extern tcs_con tcs[1];extern sdp_con sdp_con_list[7];extern l2cap_con *testcon; /* is set in test.c */extern s32 emulate_pending; /* is set in test.c */extern s32 test_inmtu;extern s32 dont_send_config_req;extern s32 use_multiple_conf_params;extern s32 disable_testpsm;s32 test_role;/* ======================================================================== */ /* Unplug Test Cases 1-13 *//* [Test-01] Service search request for UUID 0x1103 (DialUp Profile) */unsigned char q1_1[] = {0x02, 0x77, 0x77, 0x00, 0x08,		      0x35, 0x03, 0x19, 0x11, 0x03, 0x00, 0xff, 0x00};/* Service attribute request for Rec Hdl 00010000 * Attr :  ProtDescrList  */unsigned char q1_2[] = {0x04, 0x77, 0x77, 0x00, 0x0c,			0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35, 0x03,			0x09, 0x00, 0x04, 0x00};/*  [Test-02] Service browsing.  *  Service Search Attribute Req for UUID 1002 (Public  *  Browse Group) Attr : ServiceName  */unsigned char q2[] = {0x06, 0x77, 0x77, 0x00, 0x0d,		      0x35, 0x03, 0x19, 0x10, 0x02, 0x00, 0xff, 0x35,		      0x03, 0x09, 0x01, 0x00, 0x00};/* [Test-3]  * Continued query with limiting MaximumAttrByteCount */unsigned char q3_1[] = {0x06, 0x77, 0x77, 0x00, 0x0f,			0x35, 0x03, 0x19, 0x11, 0x05, 0x00, 0x45, 0x35,			0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00};/* The continued request */unsigned char q3_2[] = {0x06, 0x88, 0x88, 0x00, 0x13,			0x35, 0x03, 0x19, 0x11, 0x05, 0x00, 0x45, 0x35,			0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x01, 0x00};/* [Test-04]  * Search for non-existing service  */unsigned char q4[] = {0x02, 0x88, 0x88, 0x00, 0x08,		      0x35, 0x03, 0x19, 0x12, 0x35, 0x00, 0xff, 0x00};unsigned char q5[] = {0x04, 0x88, 0x88, 0x00, 0x0c,		      0x12, 0x34, 0x56, 0x78, 0x00, 0xff, 0x35, 0x03,		      0x09, 0x00, 0x06, 0x00};unsigned char q6[] = {0x06, 0x88, 0x88, 0x00, 0x0d,		      0x35, 0x03, 0x19, 0x11, 0x11, 0x00, 0xff, 0x35, 0x03,		      0x09, 0xab, 0xcd, 0x00};unsigned char q7[] = {0x04, 0x88, 0x88, 0x00, 0x50,		      0x00, 0x01, 0x00, 0x02, 0x00, 0xff, 0x35, 0x03, 0x09,		      0x00, 0x09, 0x00};unsigned char q8[] = {0x06, 0x88, 0x88, 0x00, 0x0d,		      0x35, 0x03, 0x09, 0x11, 0x11, 0x00, 0xff, 0x35, 0x03,		      0x09, 0x00, 0x09, 0x00};unsigned char q9[] = {0x06, 0x88, 0x88, 0x00, 0x13,		      0x35, 0x09, 0x19, 0x11, 0x05, 0x19, 0x00, 0x03, 0x19,		      0x01, 0x00, 0x00, 0xff, 0x35, 0x03, 0x09, 0x00, 0x04,		      0x00};unsigned char q10[] = {0x02, 0x88, 0x88, 0x00, 0x08,		       0x35, 0x03, 0x19, 0x00, 0x03, 0x00, 0x02, 0x00};unsigned char q11[] = {0x04, 0x88, 0x88, 0x00, 0x12,		       0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35, 0x09, 0x09,		       0x00, 0x06, 0x09, 0x00, 0x11, 0x09, 0x01, 0x00, 0x00};/* ======================================================================== */ unsigned char sdp_data_52111[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				   0x35, 0x03, 0x19, 0x00, 0x01, 0x00, 0xff,				   0x00 };unsigned char sdp_data_52113_1[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				     0x35, 0x03, 0x19, 0x00, 0x01, 0x00, 0x01,				     0x00 };unsigned char sdp_data_52113_2[] = { 0x02, 0x77, 0x77, 0x00, 0x09,				     0x35, 0x03, 0x19, 0x00, 0x01, 0x00, 0x01,				     0x01, 0x00 };unsigned char sdp_data_52114[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				   0x35, 0x03, 0x19, 0x12, 0x34, 0x00, 0xff,				   0x00 };unsigned char sdp_data_52121[] = { 0x02, 0x77, 0x77, 0x00, 0x0a,				   0x35, 0x03, 0x19, 0x00, 0x01, 0x00, 0xff,				   0x00 };unsigned char sdp_data_52122[] = { 0x02, 0x77, 0x77, 0x00, 0x06,				   0x19, 0x00, 0x01, 0x00, 0xff, 0x00 };  unsigned char sdp_data_53111[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				   0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_53113_1[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				     0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x35,				     0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_53113_2[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				     0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x35,				     0x03, 0x09, 0x00, 0x01, 0x01 };unsigned char sdp_data_53114[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				   0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_53115[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				   0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x04, 0x00 };unsigned char sdp_data_53118[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				   0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x05, 0x00 };unsigned char sdp_data_531110[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				    0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				    0x03, 0x09, 0x00, 0x08, 0x00 };unsigned char sdp_data_531117[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				    0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				    0x03, 0x09, 0x00, 0x09, 0x00 };unsigned char sdp_data_531120[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				    0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				    0x03, 0x09, 0x01, 0xff, 0x00 };unsigned char sdp_data_53121[] = { 0x04, 0x88, 0x88, 0x00, 0x0c,				   0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_53122[] = { 0x04, 0x88, 0x88, 0x00, 0x0a,				   0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x09,				   0x00, 0x01, 0x00 };unsigned char sdp_data_53123[] = { 0x04, 0x88, 0x88, 0x00, 0x0a,				   0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x35,				   0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_54111[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				   0x35, 0x03, 0x19, 0x12, 0x34, 0x00, 0xff,				   0x35, 0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_54112[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				   0x35, 0x03, 0x19, 0x00, 0x01, 0x00, 0xff,				   0x35, 0x03, 0x09, 0x01, 0xff, 0x00 };unsigned char sdp_data_54113[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				   0x35, 0x03, 0x19, 0x12, 0x34, 0x00, 0xff,				   0x35, 0x03, 0x09, 0x01, 0xff, 0x00 };unsigned char sdp_data_54114[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				   0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				   0x35, 0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_54116_1[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				     0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0x06,				     0x35, 0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_54116_2[] = { 0x06, 0x88, 0x88, 0x00, 0x0e,				     0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0x06,				     0x35, 0x03, 0x09, 0x00, 0x01, 0x01, 0x00 };unsigned char sdp_data_541110[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				    0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				    0x35, 0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_541111[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				    0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				    0x35, 0x03, 0x09, 0x00, 0x04, 0x00 };unsigned char sdp_data_541112[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				    0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				    0x35, 0x03, 0x09, 0x00, 0x05, 0x00 };unsigned char sdp_data_541120[] = { 0x06, 0x88, 0x88, 0x00, 0x0d,				    0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				    0x35, 0x03, 0x09, 0x00, 0x09, 0x00 };unsigned char sdp_data_54121[] = { 0x06, 0x88, 0x88, 0x00, 0x0b,				   0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				   0x09, 0x00, 0x09, 0x00 };unsigned char sdp_data_54122[] = { 0x06, 0x88, 0x88, 0x00, 0x0f,				   0x35, 0x03, 0x19, 0x10, 0x00, 0x00, 0xff,				   0x35, 0x03, 0x09, 0x00, 0x01, 0x00 };unsigned char sdp_data_55111_1[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				     0x35, 0x03, 0x19, 0x10, 0x02, 0x00, 0xff,				     0x00 };unsigned char sdp_data_55111_2[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_3[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x00, 0x10, 0x00, 0x00, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_4[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x00, 0x10, 0xff, 0xff, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_5[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x00, 0x11, 0xff, 0xff, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_6[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x01, 0x00, 0xff, 0xff, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_7[] = { 0x04, 0x88, 0x88, 0x00, 0x0e,				     0x01, 0x01, 0xff, 0xff, 0x00, 0xff, 0x35,				     0x05, 0x0a, 0x00, 0x00, 0xff, 0xff, 0x00 };unsigned char sdp_data_55111_8[] = { 0x02, 0x77, 0x77, 0x00, 0x08,				     0x35, 0x03, 0x19, 0x10, 0x01, 0x00, 0xff,				     0x00 };unsigned char sdp_data_55112_1[] = { 0x06, 0x88, 0x88, 0x00, 0x0f,				     0x35, 0x03, 0x19, 0x10, 0x02, 0x00, 0xff,				     0x35, 0x05, 0x0a, 0x00, 0x00, 0xff, 0xff,				     0x00 };unsigned char sdp_data_55112_2[] = { 0x06, 0x88, 0x88, 0x00, 0x0f,				     0x35, 0x03, 0x19, 0x10, 0x01, 0x00, 0xff,				     0x35, 0x05, 0x0a, 0x00, 0x00, 0xff, 0xff,				     0x00 };extern u8 testdata[];static u8 test_is_initialized = 0;static voidunplug_test_init(void){	/* initializes temp data */	s32 i;	printk("Initializing Unplug Test\n");	/* group data into 0xff chunks */	for (i = 0; i < UPTEST_DATA_LEN; i++) {		*(testdata+i) = (u8) i%0x100;	}	test_is_initialized = 1;}#define SERVER 0#define CLIENT 1static s32 test_server(void){	printk("Now we are test server (device A)\n");	test_role = SERVER;	return 0;}static s32 test_client(void){	printk("Now we are test client (device B)\n");	test_role = CLIENT;	return 0;}/*  * FIXME - do complete test 'scripts' that runs through all the test * on one section  *//*  * L2CAP stuff  *//* * Test case 1 : Opening of a Connection-Oriented Channel,  * * (see bttest.c, issue command 'test_conn <bd addr> <psm>') *//* * Test case : Data transfer via Open L2CAP Channel (L2CAP Test 2) *//* * Test case : Data transfer via Open L2CAP Channel (L2CAP Test 3) */static s32 test_2_2_1(void){	/* client sends 10 bytes */	printk("test_2_2_1, client sends 10 bytes\n"); 	return test_send_data(testcon, testdata, 10);}static s32 test_2_2_2(void){	/* client sends 350 bytes */	printk("test_2_2_2, client sends 350 bytes\n"); 	return test_send_data(testcon, testdata, 350);}static s32 test_2_2_3(void){	/* client sends 672 bytes */	printk("test_2_2_3, client sends 672 bytes\n"); 	return test_send_data(testcon, testdata, 672);}static s32 test_2_2_4(void){	/* server sends 10 bytes */	printk("test_2_2_4, server sends 10 bytes\n"); 	return test_send_data(testcon, testdata, 10);}static s32 test_2_2_5(void){	/* server sends 350 bytes */	printk("test_2_2_5, server sends 350 bytes\n"); 	return test_send_data(testcon, testdata, 350);}static s32 test_2_2_6(void){	/* server sends 672 bytes */	printk("test_2_2_6, server sends 672 bytes\n"); 	return test_send_data(testcon, testdata, 672);}static s32 test_2_3(void){	printk("test_2_3, disconnect\n");	return test_disconnect_req(testcon);} /* * Test case : Echo * Device A Initiator (L2CAP Test 4) * *//*  upt t 241 *//* * Test case : Re-Configuration, using assymetric MTU:s and * Data Transferred (L2CAP Test 5) */#define OPTION_MTU1 4096#define OPTION_MTU2 8192static s32 test_2_5_1(void){	s32 retval = 0;	printk("[Client] Sending config req for mtu = %d\n", OPTION_MTU1);	if ((retval = l2ca_config_req(testcon, OPTION_MTU1, NULL, 0, 0)) < 0) {		D_ERR("l2ca_connect_cfm : Configuration request failed\n");	}	return retval;}static s32 test_2_5_2(void){	printk("[Server] Set our in_mtu to :%d\n", OPTION_MTU2);	test_inmtu = OPTION_MTU2;	return 0;}static s32 test_2_5_3(void){	s32 retval = 0;	printk("[Client] Sending config req for mtu = %d\n", OPTION_MTU2);	if ((retval = l2ca_config_req(testcon, OPTION_MTU2, NULL, 0xffff, 0)) < 0) {		D_ERR("l2ca_connect_cfm : Configuration request failed\n");	}	return retval;}static s32 test_2_5_4(void){	printk("[Server] Set our in_mtu to :%d\n", OPTION_MTU1);	test_inmtu = OPTION_MTU1;	return 0;}static s32 test_2_5_5(void){	/* Client sends 8192 bytes of data */	printk("Sends 8192 bytes\n");	return test_send_data(testcon, testdata, 8192);}static s32 test_2_5_6(void){	printk("Sending 4096 bytes\n");	/* Server sends 4096 bytes of data */	return test_send_data(testcon, testdata, 4096);}/* * Test case : Connection reject on psm 0x4561 */static s32 test_2_6_1(void){	printk("Now disabling test psm\n");	disable_testpsm = 1;	return 0;}/* * Test case : Echo (server) (L2CAP Test 7) * handled automatically in l2cap */ /* * Test case : Connection Request Rejected (L2CAP Test 8, 9) * (see btd.c, issue 'test_con <bd> 4561' ) */static s32 test_2_7_2(void){	printk("Emulating authorization pending...\n");	emulate_pending = 1;	return 0;}static s32 test_2_8_1(void){	printk("Client sends 350 bytes on testcon 1\n");	return test_send_data(testcon, testdata, 350);}static s32 test_2_8_2(void){	printk("Server sends 350 bytes on testcon 1\n");	return test_send_data(testcon, testdata, 350);}static s32 test_2_8_3(void){	printk("Client sends 350 bytes on testcon 2\n");	return test_send_data(testcon2, testdata, 350);}static s32 test_2_8_4(void){	printk("Server sends 350 bytes on testcon 2\n");	return test_send_data(testcon2, testdata, 350);}static s32 test_2_9_1(void){	s32 retval = 0;	printk("Now testing timeout in reconfigure state\n");	printk("Client tries to reconfigure mtu 4096\n");	if ((retval = l2ca_config_req(testcon, 4096, NULL, 0xffff, 0)) < 0){		D_ERR("test_connect_cfm : Configuration request failed\n");	}	return retval;}static s32 test_2_9_2(void){	printk("Server won't send a config req back...\n");	dont_send_config_req = 1;	return 0;}static s32 test_2_10(void){	/* set to use mutiple config parameters */	printk("Using multiple config parameters\n");	use_multiple_conf_params = 1;	return 0;}#if 0typedef struct flow {	u8 type; /* = 0x3 or 0x4 ??? */	u8 len; /* = 22 (0x16) */	u8 flags; /* default 0 */	u8 service; /* default 0x01 (best effort) */	u32 token_rate;	u32 bucket_size; /* bytes */	u32 peak; /* bps */	u32 latency; /* ms */ 	u32 delay; /* ms */} flow;#endif

⌨️ 快捷键说明

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