?? unplug_test.c
字號:
/* * unplug_test.c -- Test cases for the UnPlugFests * * Copyright (C) 2000, 2001 Axis Communications AB * * Author: Mats Friden <mats.friden@axis.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * Exceptionally, Axis Communications AB grants discretionary and * conditional permissions for additional use of the text contained * in the company's release of the AXIS OpenBT Stack under the * provisions set forth hereunder. * * Provided that, if you use the AXIS OpenBT Stack with other files, * that do not implement functionality as specified in the Bluetooth * System specification, to produce an executable, this does not by * itself cause the resulting executable to be covered by the GNU * General Public License. Your use of that executable is in no way * restricted on account of using the AXIS OpenBT Stack code with it. * * This exception does not however invalidate any other reasons why * the executable file might be covered by the provisions of the GNU * General Public License. * * $Id: unplug_test.c,v 1.3 2001/07/31 19:28:55 pkj Exp $ * */#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){
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -