You can subscribe to this list here.
2001 |
Jan
|
Feb
(44) |
Mar
(202) |
Apr
(134) |
May
(89) |
Jun
(94) |
Jul
(58) |
Aug
(58) |
Sep
(56) |
Oct
(75) |
Nov
(26) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(24) |
Feb
(30) |
Mar
(15) |
Apr
(49) |
May
(12) |
Jun
(6) |
Jul
(11) |
Aug
(20) |
Sep
(19) |
Oct
(3) |
Nov
(13) |
Dec
(1) |
2003 |
Jan
(7) |
Feb
(4) |
Mar
(7) |
Apr
(5) |
May
(6) |
Jun
(3) |
Jul
(1) |
Aug
(1) |
Sep
|
Oct
(2) |
Nov
(51) |
Dec
(1) |
2004 |
Jan
(11) |
Feb
(5) |
Mar
|
Apr
(5) |
May
(2) |
Jun
|
Jul
(21) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Peter K. <pk...@us...> - 2001-03-27 19:32:30
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.154 1.155=20=20=20=20=20=20=20=20=20=20=20 l2cap.c 1.93 1.94=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Improved LED blink. The diff of the modified file(s): --- bluetooth.c 2001/03/20 15:29:49 1.154 +++ bluetooth.c 2001/03/27 19:32:27 1.155 @@ -162,11 +162,18 @@ =20 #ifdef __CRIS__ #define BT_FLASH_LED_TIME (HZ/50) /* 20 ms */ +#define BT_FLASH_LED_PAUSE (HZ/100) /* 10 ms */ + +#define NO_BLUETOOTH_ACTIVITY 0 +#define BLUETOOTH_ACTIVITY 1 =20 static struct timer_list bt_clear_led_timer; -static int bt_led_clear_time; +static int bt_led_next_time; +static int bt_led_active; static void bt_clear_led(unsigned long dummy); +static void bt_set_leds(int active); #endif + static void bt_flash_led(void); =20 #ifdef CONFIG_BLUETOOTH_USE_INBUFFER @@ -1835,20 +1842,48 @@ static void bt_clear_led(unsigned long dummy) { - if (jiffies > bt_led_clear_time) - LED_ACTIVE_SET(0); + if (bt_led_active && jiffies > bt_led_next_time) { + bt_set_leds(NO_BLUETOOTH_ACTIVITY); + + /* Set the earliest time we may set the LED */ + bt_led_next_time =3D jiffies + BT_FLASH_LED_PAUSE; + bt_led_active =3D 0; + } + bt_clear_led_timer.expires =3D jiffies + HZ/10; add_timer(&bt_clear_led_timer); } =20 -void bt_flash_led(void) +static void +bt_flash_led(void) { - LED_ACTIVE_SET(1); - bt_led_clear_time =3D jiffies + BT_FLASH_LED_TIME;=20 + if (!bt_led_active && jiffies > bt_led_next_time) { + bt_set_leds(BLUETOOTH_ACTIVITY); + + /* Set the earliest time we may clear the LED */ + bt_led_next_time =3D jiffies + BT_FLASH_LED_TIME; + bt_led_active =3D 1; + } +} + +static void +bt_set_leds(int active) +{ + extern int bt_connections; + int light_leds =3D ((!bt_connections && active =3D=3D BLUETOOTH_ACTIVITY)= || + (bt_connections && active =3D=3D NO_BLUETOOTH_ACTIVITY)); + + if (light_leds) { + LED_ACTIVE_SET(LED_GREEN); + } + else { + LED_ACTIVE_SET(LED_OFF); + } } =20 #else -void bt_flash_led(void) +static void +bt_flash_led(void) { /* blink blink :) */ } --- l2cap.c 2001/03/12 16:09:37 1.93 +++ l2cap.c 2001/03/27 19:32:28 1.94 @@ -253,6 +253,10 @@ =20 /****************** GLOBAL VARIABLE DECLARATION SECTION ******************= ***/ =20 +#ifdef __CRIS__ +int bt_connections =3D 0; +#endif + /****************** LOCAL VARIABLE DECLARATION SECTION *******************= ***/ =20 static l2cap_layer l2capmain; /* Main structure */ @@ -275,6 +279,10 @@ init_con_list(); l2cap->cid_count =3D MIN_CID; /* Moved from init_con_list */ =20=20=20=20=20=20=20=20=20 +#ifdef __CRIS__ + bt_connections =3D 0; +#endif + /* Set all upper layers to default */ =20 l2cap_protocol_default(&default_protocol); @@ -361,6 +369,11 @@ =20 free_list(); remove_all_upper(); + +#ifdef __CRIS__ + bt_connections =3D 0; +#endif + /*ALWAYS SUCCESS*/ return 0; } @@ -1315,6 +1328,10 @@ con->hci_hdl =3D con_hdl; con->link_up =3D TRUE; =20 +#ifdef __CRIS__ + bt_connections++; +#endif +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 /* Check if a ping is to be sent */ if (con->ping_sent) { D_STATE("baseband up, now send ping\n"); @@ -1427,7 +1444,13 @@ /* flush old buffers waiting to be sent on this handle */ btmem_flushhandle((u16)con_hdl); //btmem_reset(); - return; + +#ifdef __CRIS__ + if (bt_connections > 0) + bt_connections--; + else + D_ERR(__FUNCTION__ ": bt_connections =3D=3D 0\n"); +#endif } =20 /* FIXME - lp_qos_violation_ind() */ |
From: Peter K. <pk...@us...> - 2001-03-27 19:31:13
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sdp.c 1.69 1.70=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Space -> tab. |
From: Peter K. <pk...@us...> - 2001-03-27 18:12:49
|
The following file was modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.25 1.26=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Handle failed memory allocations. * Fixed a couple of memory leaks. * Fixed too small allocations in get_start(). The diff of the modified file(s): --- sdp_server.c 2001/03/26 16:06:45 1.25 +++ sdp_server.c 2001/03/27 18:12:47 1.26 @@ -204,6 +204,12 @@ return tmp; } =20 +int +is_err(void) +{ + return parse_err !=3D 0; +} + void start_xml_parser(XML_Parser p, int fd) { @@ -238,6 +244,11 @@ fprintf(stderr, "len:%d\n",len); break; } + + if (is_err()) + { + break; + } } while (len); } =20 @@ -464,6 +475,12 @@ s_hdl->hdl_list_max +=3D 16; tmp =3D realloc(s_hdl->hdl_list, s_hdl->hdl_list_max * sizeof *s_h= dl->hdl_list); D_MEM("---> realloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl->hd= l_list_max * sizeof *s_hdl->hdl_list, tmp); + if (!tmp) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + s_hdl->hdl_list_max -=3D 16; + return; + } =20 s_hdl->hdl_list =3D tmp; } @@ -510,6 +527,13 @@ s_hdl.hdl_list_max =3D 16; s_hdl.hdl_list =3D malloc(s_hdl.hdl_list_max * sizeof *s_hdl.hdl_list); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl.hdl_list_m= ax * sizeof *s_hdl.hdl_list, s_hdl.hdl_list); + if (!s_hdl.hdl_list) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, s_hdl.uuid); + free(s_hdl.uuid); + return NULL; + } =20 p =3D XML_ParserCreate(NULL); XML_SetElementHandler(p, get_more_rec_hdl_start, get_more_rec_hdl_end); @@ -519,15 +543,33 @@ start_xml_parser(p, fd); XML_ParserFree(p); =20 + D_MEM("<--- free%d 0x%8p", --malloc_dbg, s_hdl.uuid); + free(s_hdl.uuid); + + if (is_err()) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, s_hdl.hdl_list); + free(s_hdl.hdl_list); + return NULL; + } + if (s_hdl.hdl_list_len >=3D s_hdl.hdl_list_max) { - s_hdl.hdl_list_max =3D s_hdl.hdl_list_len + 1; + s_hdl.hdl_list_max++; =20 tmp =3D realloc(s_hdl.hdl_list, s_hdl.hdl_list_max * sizeof *s_hdl.hdl= _list); D_MEM("---> realloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl.hdl_lis= t_max * sizeof *s_hdl.hdl_list, tmp); + if (!tmp) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, s_hdl.hdl_list); + free(s_hdl.hdl_list); + return NULL; + } =20 s_hdl.hdl_list =3D tmp; } + s_hdl.hdl_list[s_hdl.hdl_list_len++] =3D NO_REC_HDL; =20 return s_hdl.hdl_list; @@ -544,6 +586,11 @@ /* FIXME: But for now 256 bytes will do */ return_sequence =3D malloc(256); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, return_seque= nce); + if (!return_sequence) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + return NULL; + } =20 D_ATTR("A range of attributes was requested 0x%04x - 0x%04x", (attr_id_code >> 16), (attr_id_code & 0xffff)); @@ -551,6 +598,13 @@ /* Lists all attributes registerd in the database */ attr_lst =3D get_all_attributes(fd); =20=20=20 + if (!attr_lst) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, return_sequence); + free(return_sequence); + return NULL; + } +=20=20 return_sequence[pos++] =3D DES_HDR; return_sequence[pos++] =3D 0; =20=20=20 @@ -576,6 +630,12 @@ D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } + else if (is_err()) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, return_sequence); + free(return_sequence); + return NULL; + } i++; } =20=20=20 @@ -587,6 +647,7 @@ =20=20=20 if (return_sequence[1] =3D=3D 0) { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, return_sequence); free(return_sequence); return NULL; } @@ -667,10 +728,26 @@ start_xml_parser(p, fd); XML_ParserFree(p); =20 + if (is_err()) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); + free(search_struct.attribute_name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class); + free(search_struct.service_class); + + return NULL; + } + if (search_struct.attrlist_index =3D=3D 0) { D_ATTR("Didn't find the attribute values for the attribute %s", search_struct.attribute_name); + + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); + free(search_struct.attribute_name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class); + free(search_struct.service_class); + return NULL; } =20=20=20 @@ -679,7 +756,17 @@ =20 return_sequence =3D malloc(len + 2); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, len + 2, return_s= equence); + if (!return_sequence) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); + free(search_struct.attribute_name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class); + free(search_struct.service_class); =20=20=20 + return NULL; + } +=20=20 return_sequence[0] =3D 0x35; return_sequence[1] =3D len; char2hex(char_tmp, return_sequence + 2); @@ -907,9 +994,10 @@ {=20=20=20=20 if (set_value !=3D -1) { - fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D = NULL\n"); + fprintf(stderr, __FUNCTION__ ": Error more than one attribute =3D=3D= NULL\n"); return NULL; } + S_FNC("Looking for attribute"); set_value =3D ATTR; } @@ -918,9 +1006,10 @@ { if (set_value !=3D -1) { - fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D = NULL\n"); + fprintf(stderr, __FUNCTION__ ": Error more than one attribute =3D=3D= NULL\n"); return NULL; } + S_FNC("Looking for value"); set_value =3D VAL; } @@ -932,16 +1021,15 @@ { case TAG: return search_hdl.search_name; - break; + case ATTR: return search_hdl.search_attr; - break; + case VAL: return search_hdl.search_val; - break; + default: return NULL; - break; } =20=20=20 #undef TAG @@ -967,10 +1055,13 @@ if (strcmp(attr[i + 1], search_hdl->search_val) =3D=3D 0) { S_FNC("Found %s", attr[i]); - m_size =3D strlen(attr[i] + 1); + m_size =3D strlen(attr[i]) + 1; search_hdl->search_attr =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, s= earch_hdl->search_attr); + if (search_hdl->search_attr) + { strcpy(search_hdl->search_attr, attr[i]); + } return; } } @@ -986,10 +1077,13 @@ if (strcmp(attr[i], search_hdl->search_attr) =3D=3D 0) { S_FNC("Found %s", attr[i + 1]); - m_size =3D strlen(attr[i + 1] + 1); + m_size =3D strlen(attr[i + 1]) + 1; search_hdl->search_val =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, s= earch_hdl->search_val); + if (search_hdl->search_val) + { strcpy(search_hdl->search_val, attr[i + 1]); + } return; } } @@ -1005,7 +1099,10 @@ m_size =3D strlen(el) + 1; search_hdl->search_name =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, sea= rch_hdl->search_name); + if (search_hdl->search_name) + { strcpy(search_hdl->search_name, el); + } return; } } @@ -1039,18 +1136,13 @@ =20 attr_lst =3D (unsigned int*)search_hdl.search_val; =20 - for (i =3D 1; i <=3D attr_lst[0]; i++) - { - D_ATTR("Before free Attribute %d: 0x%04x", i , attr_lst[i]); - } - XML_ParserFree(p); =20=20=20 /* If we didn't find the service class we return here */ - if (search_hdl.search_val =3D=3D NULL) + if (!attr_lst) { D_ATTR("Didn't find anything"); - return 0; + return NULL; } =20 for (i =3D 1; i <=3D attr_lst[0]; i++) @@ -1070,6 +1162,8 @@ =20=20=20 if (strncmp(el, search_hdl->search_name, strlen(search_hdl->search_name)= ) =3D=3D0) { + unsigned int *attributes; + S_FNC("Found %s", el); attr_cnt =3D XML_GetSpecifiedAttributeCount((XML_Parser*) data); /* Since attr_cnt is the count of both the attibutes and the attribute @@ -1079,15 +1173,23 @@ S_FNC("%d attributes found", attr_cnt); /* Allocate space for all the attribute UUIDs plus the attribute count in the search_output pointer, */ - m_size =3D attr_cnt * 4 + 4; + m_size =3D (attr_cnt + 1) * sizeof *attributes; search_hdl->search_val =3D malloc(m_size); - D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, search_= hdl->search_val); - memcpy(search_hdl->search_val, &attr_cnt, 4); + attributes =3D (unsigned int *)search_hdl->search_val; + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, attribu= tes); + + if (!attributes) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + return; + } + + *attributes++ =3D (unsigned int)attr_cnt; for (i =3D 0; attr[i]; i +=3D 2) { unsigned int tmp =3D strtoul(attr[i + 1], NULL, 16);=20 =20 - memcpy(search_hdl->search_val + 4 +(i * 2), &tmp ,4); + *attributes++ =3D tmp; S_FNC("Attribute %d found", tmp); }=20 } @@ -1148,6 +1250,8 @@ =20=20=20 rec_hdl =3D get_record_handle(db_hdl->service_class_list[0], xml_fd); =20 + D_REC("Got Record handle: 0x%08x", rec_hdl); + if (rec_hdl !=3D NO_REC_HDL) { rec_hdl_cnt++; @@ -1155,11 +1259,17 @@ =20 rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd); =20=20=20 - D_REC("Got Record handle: 0x%08x", rec_hdl); + if (is_err()) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); + free(rec_hdl_list); + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()); + return; + } +=20=20 if (rec_hdl_list) { - i =3D 0; - while (rec_hdl_list[i] !=3D NO_REC_HDL) + for (i =3D 0; rec_hdl_list[i] !=3D NO_REC_HDL; i++) { D_REC("Got Record handle: 0x%08x", rec_hdl_list[i]); if (rec_hdl =3D=3D rec_hdl_list[i]) @@ -1167,7 +1277,6 @@ rec_hdl_cnt--; rec_hdl =3D NO_REC_HDL; } - i++; } rec_hdl_cnt +=3D i; } @@ -1208,6 +1317,12 @@ =20 rsp_pkt_len =3D set_cont_state_search(rsp_pkt, rsp_pkt_len, db_hdl->max_= rec_cnt); =20 + if (is_err()) + { + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()); + return; + } +=20=20 write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 } =20 @@ -1235,6 +1350,7 @@ { tmp_ptr =3D get_attribute_list(xml_fd, db_hdl->rec_hdl, db_hdl->attr= _list[i]); } + if (tmp_ptr) { memcpy(rsp_pkt + rsp_pkt_len, tmp_ptr + 2, tmp_ptr[1]); @@ -1243,17 +1359,12 @@ D_MEM("<--- free %d 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } - else - { - int err =3D get_err(); - - if (err) + else if (is_err()) { - send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, err); + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()= ); return; } } - } =20 /* Set the attribute byte count to packet length minus sdp pdu header si= ze minus attribute byte count field length, minus continuation field len= gth*/ @@ -1269,6 +1380,12 @@ =20 rsp_pkt_len =3D set_cont_state_attr(rsp_pkt, rsp_pkt_len,db_hdl->max_att= r_byte_cnt); =20 + if (is_err()) + { + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()); + return; + } +=20=20 write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 } =20 @@ -1288,6 +1405,14 @@ =20=20=20 rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd); =20=20=20 + if (is_err()) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); + free(rec_hdl_list); + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()); + return; + } +=20=20 rec_hdl_cnt =3D 0; if (rec_hdl_list) { @@ -1314,6 +1439,9 @@ rsp_pkt_len +=3D 2; =20 if (!rec_hdl_cnt) { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); + free(rec_hdl_list); + rec_hdl_cnt =3D 1; rec_hdl_list =3D &rec_hdl; } @@ -1342,6 +1470,16 @@ D_MEM("<--- free%d tmp_ptr 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } + else if (is_err()) + { + if (rec_hdl_list !=3D &rec_hdl) + { + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); + free(rec_hdl_list); + } + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err= ()); + return; + } } if (tmp_len > 2)=20 { @@ -1372,6 +1510,12 @@ =20=20=20 rsp_pkt_len =3D set_cont_state_attr(rsp_pkt, rsp_pkt_len,db_hdl->max_att= r_byte_cnt); =20=20=20 + if (is_err()) + { + send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, get_err()); + return; + } +=20=20 /* FIXME: Add features to handle continuation state packets */ write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 } @@ -1405,6 +1549,12 @@ cont_state_buf =3D malloc(sizeof(cont_state_struct) + cnt_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cnt_len, cont_state_buf); =20 + if (!cont_state_buf) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + return 0; + } +=20=20=20=20 cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE]; D_MISC("PDU: 0x%02x", cont_state_buf->pdu); =20=20=20=20=20 @@ -1456,6 +1606,12 @@ cont_state_buf =3D malloc(sizeof(cont_state_struct) + cont_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cont_len , cont_state_buf); =20 + if (!cont_state_buf) + { + set_err(SDP_INSUFFICIENT_RESOURCES); + return 0; + } +=20=20=20=20 cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE]; D_MISC("PDU: 0x%02x", cont_state_buf->pdu); =20 @@ -1501,6 +1657,11 @@ =20 send_buf =3D malloc(send_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, send_= buf); + if (!send_buf) + { + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCES); + return; + } =20 set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_HD= R_SIZE); =20 @@ -1519,12 +1680,12 @@ /* Send the whole buffer */ write2stack(sdp_con_id, send_buf, send_len); =20 + D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf); + free(send_buf); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, cont_state_buf); free(cont_state_buf); cont_state_buf =3D NULL; - - D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf); - free(send_buf); } else { @@ -1546,9 +1707,7 @@ if (!cont_state_buf) { send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_CONTINUATION_STATE); } - else - { - if (max_attr_cnt >=3D cont_state_buf->len) + else if (max_attr_cnt >=3D cont_state_buf->len) { /* Allocate space for the SDP header, the attribute byte count field, the attributes and the continuation state field */ @@ -1556,6 +1715,11 @@ =20 send_buf =3D malloc(send_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, sen= d_buf); + if (!send_buf) + { + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCES); + return; + } =20 set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); =20 @@ -1570,12 +1734,12 @@ /* Send the whole buffer */ write2stack(sdp_con_id, send_buf, send_len); =20 + D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf); + free(send_buf); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, cont_state_buf); free(cont_state_buf); cont_state_buf =3D NULL; - - D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf); - free(send_buf); } else { @@ -1584,6 +1748,5 @@ /* FIXME: Have to implement this too... */ =20 send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_SDP_VERSION); - } } } |
From: Peter K. <pk...@us...> - 2001-03-26 16:06:47
|
The following file was modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.24 1.25=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use strtoul() to extract unsigned values. The diff of the modified file(s): --- sdp_server.c 2001/03/26 15:52:26 1.24 +++ sdp_server.c 2001/03/26 16:06:45 1.25 @@ -291,23 +291,24 @@ position so we can fill in the length field later */=20=20=20=20= =20=20 if (strncmp(value_string + value_string_pos, S_DES_HDR, strlen(S_DES= _HDR)) =3D=3D 0) { - int j; + unsigned int pos; + unsigned int j; =20 - i =3D (int) strtol(value_string + value_string_pos + strlen(S_DES_= HDR), + pos =3D strtoul(value_string + value_string_pos + strlen(S_DES_HDR= ), NULL, 16); =20 /* Now we found a data element sequence header inside another data element sequence */ - if (des_pos[i]) + if (des_pos[pos]) { - sprintf(c_des_len[i], "%02x", des_len[i]); - D_MISC("c_des_len[%d]: %s", i, c_des_len[i]); - strncpy(des_pos[i], c_des_len[i], 2); - D_MISC("des_pos[%d]: %s", i, des_pos[i]); + sprintf(c_des_len[pos], "%02x", des_len[pos]); + D_MISC("c_des_len[%d]: %s", pos, c_des_len[pos]); + strncpy(des_pos[pos], c_des_len[pos], 2); + D_MISC("des_pos[%d]: %s", pos, des_pos[pos]); } - des_pos[i] =3D tmp_list + tmp_len - 2; - des_len[i] =3D 0; - for (j =3D i; j > 0; j--) + des_pos[pos] =3D tmp_list + tmp_len - 2; + des_len[pos] =3D 0; + for (j =3D pos; j > 0; j--) { des_len[0] +=3D (strlen(value_string + value_string_pos) - 2) / = 2; } @@ -420,7 +421,7 @@ if (service_class_id !=3D NULL) { D_RHDL("Found %s", service_class_id); - record_handle =3D (unsigned int) strtol(service_class_id, NULL, 16); + record_handle =3D strtoul(service_class_id, NULL, 16); D_RHDL("Record handle converted to int 0x%08x", record_handle); D_MEM("<--- free%d 0x%8p", --malloc_dbg, service_class_id); free(service_class_id); @@ -438,7 +439,7 @@ if (attr[0] && strcmp(attr[0], "ServiceRecordHandle") =3D=3D 0) { S_FNC("Found Record Handle %s", attr[1]); - s_hdl->tmp_hdl =3D (unsigned int)strtol(attr[1], NULL, 16); + s_hdl->tmp_hdl =3D strtoul(attr[1], NULL, 16); S_FNC("Found Record Handle 0x%08x", s_hdl->tmp_hdl); } if ((s_hdl->tmp_hdl) && (strcmp(el, s_hdl->uuid) =3D=3D 0)) |
From: Peter K. <pk...@us...> - 2001-03-26 15:52:28
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.23 1.24=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.h 1.9 1.10=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * hdl_list_len and hdl_list_max (formerly block_len) now counts the number of entries in the hdl_list in the rec_hdl_search_struct. * Use realloc() instead of malloc() + memcpy() to add space to the hdl_list in the rec_hdl_search_struct. The diff of the modified file(s): --- sdp_server.c 2001/03/26 14:02:09 1.23 +++ sdp_server.c 2001/03/26 15:52:26 1.24 @@ -287,7 +287,7 @@ strcpy(tmp_list + tmp_len, value_string + value_string_pos + 2); tmp_len +=3D strlen(value_string + value_string_pos) - 2; =20 - /* If we found a data element sequens header we need to remember that + /* If we found a data element sequence header we need to remember th= at position so we can fill in the length field later */=20=20=20=20= =20=20 if (strncmp(value_string + value_string_pos, S_DES_HDR, strlen(S_DES= _HDR)) =3D=3D 0) { @@ -296,8 +296,8 @@ i =3D (int) strtol(value_string + value_string_pos + strlen(S_DES_= HDR), NULL, 16); =20 - /* Now we found a data element sequens header inside another - data element sequense */ + /* Now we found a data element sequence header inside another + data element sequence */ if (des_pos[i]) { sprintf(c_des_len[i], "%02x", des_len[i]); @@ -444,7 +444,7 @@ if ((s_hdl->tmp_hdl) && (strcmp(el, s_hdl->uuid) =3D=3D 0)) { if ((s_hdl->hdl_list_len > 0) && - (s_hdl->tmp_hdl =3D=3D s_hdl->hdl_list[(s_hdl->hdl_list_len / U32_= SIZE) - 1])) + (s_hdl->tmp_hdl =3D=3D s_hdl->hdl_list[s_hdl->hdl_list_len - 1])) { S_FNC("%s is present in record handle 0x%08x, but already found", s_hdl->uuid, s_hdl->tmp_hdl); @@ -458,23 +458,16 @@ necessary allocate new space for both the old and the new record handles */ =20 - if (s_hdl->hdl_list_len >=3D s_hdl->block_len) + if (s_hdl->hdl_list_len >=3D s_hdl->hdl_list_max) { - tmp =3D s_hdl->hdl_list; - s_hdl->block_len =3D s_hdl->hdl_list_len + s_hdl->block_len * 2; - s_hdl->hdl_list =3D malloc(s_hdl->block_len); - D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, s_hdl->bloc= k_len, s_hdl->hdl_list); + s_hdl->hdl_list_max +=3D 16; + tmp =3D realloc(s_hdl->hdl_list, s_hdl->hdl_list_max * sizeof *s_h= dl->hdl_list); + D_MEM("---> realloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl->hd= l_list_max * sizeof *s_hdl->hdl_list, tmp); =20 - memcpy(s_hdl->hdl_list, tmp, s_hdl->hdl_list_len); - if (tmp) - { - D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp); - free(tmp); - } + s_hdl->hdl_list =3D tmp; } =20=20=20=20=20 - s_hdl->hdl_list[s_hdl->hdl_list_len/sizeof(unsigned int)] =3D s_hdl-= >tmp_hdl; - s_hdl->hdl_list_len +=3D sizeof(unsigned int); + s_hdl->hdl_list[s_hdl->hdl_list_len++] =3D s_hdl->tmp_hdl; } } } @@ -490,7 +483,6 @@ rec_hdl_search_struct s_hdl; char tmp_ch[12]; unsigned int *tmp; - unsigned int tmp_len; =20=20=20 XML_Parser p; =20 @@ -514,8 +506,9 @@ } =20 s_hdl.hdl_list_len =3D 0; - s_hdl.block_len =3D 16 * sizeof(unsigned int); - s_hdl.hdl_list =3D malloc(s_hdl.block_len); + s_hdl.hdl_list_max =3D 16; + s_hdl.hdl_list =3D malloc(s_hdl.hdl_list_max * sizeof *s_hdl.hdl_list); + D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl.hdl_list_m= ax * sizeof *s_hdl.hdl_list, s_hdl.hdl_list); =20=20=20 p =3D XML_ParserCreate(NULL); XML_SetElementHandler(p, get_more_rec_hdl_start, get_more_rec_hdl_end); @@ -525,24 +518,16 @@ start_xml_parser(p, fd); XML_ParserFree(p); =20 - if (s_hdl.hdl_list_len >=3D s_hdl.block_len) + if (s_hdl.hdl_list_len >=3D s_hdl.hdl_list_max) { - tmp =3D s_hdl.hdl_list; - tmp_len =3D s_hdl.hdl_list_len + sizeof(unsigned int); - s_hdl.block_len +=3D 1; + s_hdl.hdl_list_max =3D s_hdl.hdl_list_len + 1; =20=20=20=20=20 - s_hdl.hdl_list =3D malloc(tmp_len); - D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, tmp_len, s_hdl.= hdl_list); + tmp =3D realloc(s_hdl.hdl_list, s_hdl.hdl_list_max * sizeof *s_hdl.hdl= _list); + D_MEM("---> realloc%d %ld bytes at 0x%8p", malloc_dbg++, s_hdl.hdl_lis= t_max * sizeof *s_hdl.hdl_list, tmp); =20=20=20=20=20 - memcpy(s_hdl.hdl_list, tmp, s_hdl.hdl_list_len); - if (tmp) - { - D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp); - free(tmp); - } + s_hdl.hdl_list =3D tmp; } - s_hdl.hdl_list[s_hdl.hdl_list_len / sizeof(unsigned int)] =3D NO_REC_HDL; - s_hdl.hdl_list_len +=3D sizeof(unsigned int); + s_hdl.hdl_list[s_hdl.hdl_list_len++] =3D NO_REC_HDL; =20=20=20 return s_hdl.hdl_list; } @@ -559,7 +544,6 @@ return_sequence =3D malloc(256); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, return_seque= nce); =20=20=20 -=20=20 D_ATTR("A range of attributes was requested 0x%04x - 0x%04x", (attr_id_code >> 16), (attr_id_code & 0xffff)); =20 @@ -774,7 +758,7 @@ } } } - /* This is when we found a data element sequense, we here browses + /* This is when we found a data element sequence, we here browses through all the attributes in the sequence and copies them into our list */ else if (search_struct->attr2get > 0) @@ -1276,7 +1260,7 @@ rsp_pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(rsp_pkt_len - SDP_HDR_SIZE - 2= ); =20 /* The length of the attribute list is the length of the attribute byte - count minus the size of the data element sequens header */ + count minus the size of the data element sequence header */ rsp_pkt[des_len_pos] =3D rsp_pkt_len - SDP_HDR_SIZE - 2 - 2; =20=20=20 set_sdp_hdr(rsp_pkt, SDP_SERVICEATTR_RSP, db_hdl->db.trans_id, --- sdp_server.h 2001/03/26 12:25:24 1.9 +++ sdp_server.h 2001/03/26 15:52:26 1.10 @@ -73,8 +73,6 @@ =20 #define NO_REC_HDL 1 =20 -#define U32_SIZE sizeof(unsigned int) - #define SDP_ERROR_RSP 1 #define SDP_SERVICESEARCH_REQ 2 #define SDP_SERVICESEARCH_RSP 3 @@ -90,7 +88,7 @@ char *uuid; unsigned int tmp_hdl; unsigned int hdl_list_len; - unsigned int block_len; + unsigned int hdl_list_max; unsigned int *hdl_list; } rec_hdl_search_struct; =20 |
From: Mattias A. <mat...@us...> - 2001-03-26 15:37:35
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_ipa.h 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added error codes The diff of the modified file(s): --- bt_ipa.h 2001/03/21 18:35:20 1.2 +++ bt_ipa.h 2001/03/26 15:37:33 1.3 @@ -66,6 +66,10 @@ #define IPA_STATUSSUCCESS 0 #define IPA_STATUSFAILED 1 =20 +/* Error codes */ +#define ERR_WRONGSTATE 2 +#define ERR_REQUESTFAILED 3 + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ /* IPA Client struct */ =20 |
From: Mattias A. <mat...@us...> - 2001-03-26 15:35:47
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bttest.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added options to inquiry added ping The diff of the modified file(s): --- bttest.c 2001/03/21 19:03:09 1.3 +++ bttest.c 2001/03/26 15:35:44 1.4 @@ -80,11 +80,12 @@ { "\nMenu", "------------------------", - " inq (inquiry scan)", + " inq <max nbr resp> <inq time>", " rf_conn <xx:xx:xx:xx:xx:xx> <srv ch> <line>", " rf_send <nbr bytes> <nbr repeats> <line>",=20 " rf_disc <line>", " rf_wait <line>", /* waits for a connection on that line */ + " ping <xx:xx:xx:xx:xx:xx>", " setbd <xx:xx:xx:xx:xx:xx>", /* only ericsson HW */ " readbd", /* read module bd address */ " reset", /* reset board */ @@ -107,7 +108,6 @@ " test_conn <xx:xx:xx:xx:xx:xx> <psm>", /* l2cap test using PSM psm */ " test_disc", /* disconnect all (both) test connections */ " test_case_reject <xx:xx:xx:xx:xx:xx>",=20 - " ping <xx:xx:xx:xx:xx:xx>", " getinfo <xx:xx:xx:xx:xx:xx> <type>", " ", " bb_conn <xx:xx:xx:xx:xx:xx>", /* connect only baseband */ @@ -219,10 +219,9 @@ bt_waitconnection(bt_cfd, line); printf("Connect on line %d\n", line); } - else if (strncmp(buf, "inq", 3) =3D=3D 0) + else if (sscanf(buf, "inq %d %d", &tmp[0], &tmp[1]) =3D=3D 2) { - /* fixme<2> use real params */ - bt_inquiry(bt_cfd, 10, 10); + bt_inquiry(bt_cfd, tmp[0], tmp[1]); } else if (sscanf(buf, "rf_send %d %d %d", &i, &repeat, &line) =3D=3D 3) { @@ -299,25 +298,29 @@ { bt_showstatus(); } -/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ -/* FIXME !!! -- make this work for both kernel / usermode stack */ -/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ - - -#ifdef BT_USERSTACK else if (sscanf(buf, "ping %x:%x:%x:%x:%x:%x", - &bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5]) =3D=3D 6) + &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) { + unsigned char bd[6]; +=20=20=20=20 for (i =3D 0; i < 6; i++) { - tmp_bd[i] =3D (unsigned char)bd[i]; + bd[i] =3D (unsigned char)tmp[i]; } =20=20 printf("Pinging bd : %02X:%02X:%02X:%02X:%02X:%02X\n", - tmp_bd[0], tmp_bd[1], tmp_bd[2], - tmp_bd[3], tmp_bd[4], tmp_bd[5]); - l2ca_ping(tmp_bd); + bd[0], bd[1], bd[2], + bd[3], bd[4], bd[5]); + + bt_ping(bt_cfd, bd, NULL, 0); } + +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ +/* FIXME !!! -- make this work for both kernel / usermode stack */ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ + + +#ifdef BT_USERSTACK else if (sscanf(buf, "getinfo %x:%x:%x:%x:%x:%x %x", &bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5],=20 &tmp[0]) =3D=3D 7) |
From: Mattias A. <mat...@us...> - 2001-03-26 15:33:14
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- bt_if.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 bt_if.h 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: added bt_ping (sends l2cap echo requests) The diff of the modified file(s): --- bt_if.c 2001/03/21 17:26:44 1.3 +++ bt_if.c 2001/03/26 15:33:13 1.4 @@ -62,7 +62,6 @@ #include "bt_misc.h" #include "bt_conf.h" =20 - int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len) { unsigned char buf[261]; @@ -76,7 +75,7 @@ #ifndef BT_USERSTACK=20 if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0) { - perror("ecs_testctrl"); + perror("bt_send_raw_hci"); } #else printf("not yet for usermode stack...\n"); @@ -85,6 +84,35 @@ return 0; } =20 +int bt_ping(int bt_cfd, unsigned char bd[6],=20 + unsigned char *data, unsigned short len) +{ + unsigned char buf[264]; + int ret_val; +=20=20 + printf("bt_ping\n"); + + memcpy(buf, bd, 6); + buf[6] =3D len>>8; + buf[7] =3D len&0xff; + memcpy(buf, data, len); + +#ifndef BT_USERSTACK=20 + if ((ret_val =3D ioctl(bt_cfd, BTPING, buf)) < 0) + { + printf("Error : %s\n", error_msg(ret_val)); + } + else + printf("Success!\n"); + +#else + printf("not yet for usermode stack...\n"); +#endif + return 0;=20=20 + +} + + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Functions common for kernel and usermode stack */ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ @@ -382,14 +410,14 @@ { int result; =20=20=20 - printf("bt_waitnewconnections\n"); + syslog(LOG_INFO, "bt_waitnewconnections\n"); #ifndef BT_USERSTACK if ((result =3D ioctl(bt_fd, BTWAITNEWCONNECTIONS)) < 0) { perror("bt_waitnewconnections"); exit(1); } - printf("bt_waitnewconnections : got a connection !\n"); + printf("bt_waitnewconnections : found a connection !\n"); return; #else /* fixme<1>*/ --- bt_if.h 2001/03/21 17:29:55 1.2 +++ bt_if.h 2001/03/26 15:33:13 1.3 @@ -191,6 +191,9 @@ /* | len 1 byte | 4 bytes hci header | data (max 256) | */ #define HCISENDRAWDATA _IOW(BT_IOC_MAGIC, 0x72, unsigned char[261]) =20 +/* | BD(6) | len(2) | data(max 256) |*/ +#define BTPING _IOW(BT_IOC_MAGIC, 0x73, unsigned char[264]) + /* Used to calculate opcode for HCI commands using raw interface */ #define OPCODE_MSB(ocf, ogf) ((ocf) & 0xff) #define OPCODE_LSB(ocf, ogf) (((ocf) >> 8) | (((ogf) & 0x3f) << 2)) @@ -263,6 +266,9 @@ */ =20 int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len); +int bt_ping(int bt_cfd, unsigned char bd[6],=20 + unsigned char *data, unsigned short len); + void bt_inquiry(int bt_cfd, int nbr_rsp, int t); int bt_set_baudrate(int bt_cfd, int spd); void bt_set_bd_addr(int bt_cfd, unsigned char *bd); |
From: Mattias A. <mat...@us...> - 2001-03-26 15:30:37
|
The following file was modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- btd.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: btd now retries if IPA server is not responding forgot to set peer state to PPP_CONFDONE after successfully received ipa pa= rs added state checks when parsing ipa responses added ipa error return values fixed typos The diff of the modified file(s): --- btd.c 2001/03/21 20:48:04 1.5 +++ btd.c 2001/03/26 15:30:36 1.6 @@ -360,25 +360,26 @@ default: { /* Got data on some fd */ - int i;=20=20=20=20=20=20=20=20 + int i, retval; =20=20 +#ifdef USE_IPASSIGN=20 for (i=3D0; i < result; i++)=20 { -#ifdef USE_IPASSIGN /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { msg =3D (struct ipa_msg*) ipa_buf; /* Got response from IPA, if ok then start pppd or modem emul = */ ipa_read(ipa_fd, msg); - parse_ipa_response(msg); + if ((retval =3D parse_ipa_response(msg)) < 0) + { + /* FIXME -- we got an error. Reset peer ? */ + syslog(LOG_INFO, "Got IPA error %d", retval); } -#else - /* Got data on a line */ - printf("Other data (?)\n"); -#endif=09=20=20 }=20 } +#endif + } break; }=20=20=20=20 } /* while */ @@ -749,12 +750,27 @@ =20=20=20 #ifdef USE_IPASSIGN /* Look for IPA server */ + ipa_fd =3D -1; + i =3D 1; + while (ipa_fd < 0)=20 + {=20=20 ipa_fd =3D open_socket(IPASERVER, CLIENT); if (ipa_fd < 0) { - printf("Found no IPA server\n"); + syslog(LOG_INFO, "Found no IPA server"); + + if (i > 8) + {=20=20 exit(1);=20 } + else + { + syslog(LOG_INFO, "Retrying in %d sec", i); + sleep(i); + i*=3D2; + }=20=20=20=20=20=20 + }=20 + }=20 #endif =20=20=20 if (modem_emul =3D=3D 1) @@ -854,13 +870,23 @@ case IPARSP_STATUS: { ipa_status *rsp =3D (struct ipa_status*)(msg->msg); - D(syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 + D(syslog(LOG_INFO, "parse_ipa_response : got status %d on line\n",= =20 rsp->status, rsp->id)); =20=20=20=20=20=20=20=20=20 + /* Check state */ + if (STATE(rsp->id) !=3D WAITING_RETURN_PPPCONF) + { + syslog(LOG_INFO, "parse_ipa_response : wrong state"); + return -ERR_WRONGSTATE; + } + /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) + { syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"= ,=20 rsp->id); + return -IPA_STATUSFAILED; + }=20=20=20=20=20=20 else D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", = rsp->id)); =20 @@ -869,32 +895,33 @@ =20 STATE(rsp->id) =3D NOCONNECTION; =20 - return rsp->status; + return 0; } =20=20=20=20=20 case IPARSP_PEERSETTINGS: { ipa_response* rsp =3D (struct ipa_response*)(msg->msg); - D(syslog(LOG_INFO, "ipa_parse_msg : got client settings\n")); + D(syslog(LOG_INFO, "parse_ipa_response : got client settings\n")); =20=20=20=20=20=20=20 + /* Check state */ + if (STATE(rsp->id) !=3D WAITING_PPPCONF) + { + syslog(LOG_INFO, "parse_ipa_response : wrong state"); + return -ERR_WRONGSTATE; + } + /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) { /* error */ printf("parse_ipa_response : failed to get client settings\n"); - return rsp->status; + return -ERR_REQUESTFAILED; } =20 /* Store ipa settings in peer struct */ memcpy(PEER(rsp->id).ipset, &rsp->set, msg->len); =20 - /* Now proceed to next state */ - if (PEER(rsp->id).state =3D=3D WAITING_PPPCONF) - { PEER(rsp->id).state =3D PPPCONF_DONE; - }=20=20=20=20=20=20 - else - syslog(LOG_INFO, "Warning : Wrong state on line %d, should have been WAIT= ING_PPPCONF", rsp->id); =20 /* Build options and start ppp */ build_pppdopts(rsp->id, (char**)pppd_options); @@ -903,6 +930,7 @@ }=20 =20=20=20=20=20 default : + syslog(LOG_INFO, "Error : Unknown message type"); break; } return 0; |
From: Ulf H. <ul...@us...> - 2001-03-26 14:58:28
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- hci.c 1.133 1.134=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Chenged the return parameters for the HCI event READ_STORED_LINK_KEY. It now also returns both the current number of stored link keys and the total capacity (storage space for link keys) The diff of the modified file(s): --- hci.c 2001/03/21 11:53:09 1.133 +++ hci.c 2001/03/26 14:58:26 1.134 @@ -1051,7 +1051,8 @@ result_param =3D - r_val[0]; } else { D_CMD(__FUNCTION__", READ_STORED_LINK_KEY Success\n"); - result_param =3D CHAR2INT16(r_val[4], r_val[3]); + result_param =3D CHAR2INT32(r_val[4], r_val[3], + r_val[2], r_val[= 1]); } D_CMD(__FUNCTION__", Max number of Linkkeys: %d\n", CHAR2INT16(r_val[2], r_val[1])); |
From: Peter K. <pk...@us...> - 2001-03-26 14:02:11
|
The following file was modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.22 1.23=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * char2hex() now takes the result buffer as argument. * get_values() uses a static buffer for its result. * Removed two unnecessary malloc()'s and a memcpy() due to the two changes above.=20 The diff of the modified file(s): --- sdp_server.c 2001/03/26 13:48:28 1.22 +++ sdp_server.c 2001/03/26 14:02:09 1.23 @@ -119,7 +119,7 @@ #endif =20 void start_xml_parser(XML_Parser p, int fd); -unsigned char* char2hex(char *char_data); +void char2hex(const char *char_data, unsigned char* buf); char* get_values(char *value_string, int value_string_len, int fd); void set_sdp_hdr(unsigned char *hdr, unsigned char pkt_type, unsigned short trans_id, unsigned short len); @@ -241,32 +241,25 @@ } while (len); } =20 -unsigned char* -char2hex(char *char_data) +void +char2hex(const char *char_data, unsigned char* buf) { - int i =3D 0, m_size; + int i; int tmp; - unsigned char *hex_data; - - m_size =3D strlen(char_data) / 2;=20 - hex_data =3D malloc(m_size); - D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, m_size, hex_data= ); =20 /* FIXME, How will this work when using big endian ? */ for (i =3D 0; i < strlen(char_data) / 2; i++) { sscanf(char_data + i * 2, "%02x", &tmp); - hex_data[i] =3D (unsigned char)(tmp & 0xff); + buf[i] =3D (unsigned char)(tmp & 0xff); } -=20=20 - return hex_data; } =20 char* get_values(char *value_string, int value_string_len, int fd) { int value_string_pos =3D 0; - char *tmp_list; + static char tmp_list[256]; char tmp_len =3D 0; char *des_pos[DES_HDR_DEPTH]; /* des stands for Data Elemet Sequence */ int des_len[DES_HDR_DEPTH]; @@ -285,9 +278,6 @@ des_pos[i] =3D NULL; } =20=20=20 - tmp_list =3D malloc(256); - D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, tmp_list); - /* While we have not reached the end of the string */ while (value_string_pos < value_string_len) { @@ -647,7 +637,6 @@ XML_Parser p; char *return_sequence =3D NULL; char *char_tmp =3D NULL; - unsigned char *hex_tmp =3D NULL; char tmp[12]; int len; sdp_attribute_search search_struct; @@ -703,19 +692,13 @@ char_tmp =3D get_values(search_struct.attrlist, search_struct.attrlist_i= ndex, fd); len =3D strlen(char_tmp) / 2; =20 - hex_tmp =3D char2hex(char_tmp); - return_sequence =3D malloc(len + 2); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, len + 2, return_s= equence); =20=20=20 return_sequence[0] =3D 0x35; return_sequence[1] =3D len; - memcpy(return_sequence + 2, hex_tmp, len); + char2hex(char_tmp, return_sequence + 2); =20=20=20 - D_MEM("<--- free%d 0x%8p", --malloc_dbg, char_tmp); - free(char_tmp); - D_MEM("<--- free%d 0x%8p", --malloc_dbg, hex_tmp); - free(hex_tmp); D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); free(search_struct.attribute_name); D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class); |
From: Peter K. <pk...@us...> - 2001-03-26 13:48:44
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.16 1.17=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.c 1.21 1.22=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Replaced -=3D 1 and +=3D 1 with -- and ++, and some other minor clean-up. The diff of the modified file(s): --- sdp_parser.c 2001/03/26 12:25:24 1.16 +++ sdp_parser.c 2001/03/26 13:48:28 1.17 @@ -304,7 +304,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Found UUID16 0x%04x", service_search_uuid[i]);=20 - i +=3D 1; + i++; tmp_pos +=3D 3; cur_pos +=3D 3; } @@ -314,7 +314,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Found UUID32 0x%08x", service_search_uuid[i]);=20 - i +=3D 1; + i++; tmp_pos +=3D 5; cur_pos +=3D 3; } @@ -324,7 +324,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Got Service class 0x%08x", service_search_uuid[i]); - i +=3D 1; + i++; tmp_pos +=3D 17; cur_pos +=3D 15; } @@ -341,10 +341,8 @@ max_rec_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]); D_MISC("max_rec_cnt: %d", max_rec_cnt); cur_pos +=3D 2; - - cont_state_len =3D data[cur_pos]; - cur_pos +=3D 1; =20=20=20 + cont_state_len =3D data[cur_pos++]; =20 if (len < cur_pos) { @@ -451,7 +449,7 @@ attr_list[attr_list_pos] =3D CHAR2INT32(data[cur_pos], data[cur_pos = + 1], data[cur_pos + 2], data[cur_pos + 3]); D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]= );=20 cur_pos +=3D 4; - attr_list_pos +=3D 1; + attr_list_pos++; } else { @@ -461,13 +459,13 @@ attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16; D_MISC("Found single attributes: 0x%04x", attr_list[attr_list_pos]);= =20 cur_pos +=3D 2; - attr_list_pos +=3D 1; + attr_list_pos++; } des_len -=3D (*new_pos + tmp_len); } =20 - cont_state_len =3D data[cur_pos]; - cur_pos +=3D 1 + cont_state_len; + cont_state_len =3D data[cur_pos++]; + cur_pos +=3D cont_state_len; =20 if (len < cur_pos) { @@ -568,7 +566,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Got Service class 0x%04x", service_search_uuid[i]); - i +=3D 1; + i++; tmp_pos +=3D 3; cur_pos +=3D 3; } @@ -578,7 +576,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Got Service class 0x%08x", service_search_uuid[i]); - i +=3D 1; + i++; tmp_pos +=3D 5; cur_pos +=3D 3; } @@ -588,7 +586,7 @@ service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); D_MISC("Got Service class 0x%08x", service_search_uuid[i]); - i +=3D 1; + i++; tmp_pos +=3D 17; cur_pos +=3D 15; } @@ -636,7 +634,7 @@ data[cur_pos + 3]); D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]= );=20 cur_pos +=3D 4; - attr_list_pos +=3D 1; + attr_list_pos++; } else { @@ -647,13 +645,13 @@ D_MISC("Found single attributes: 0x%04x", (attr_list[attr_list_pos]) & 0xffff);=20 cur_pos +=3D 2; - attr_list_pos +=3D 1; + attr_list_pos++; } des_len -=3D (*new_pos + tmp_len); } =20 - cont_state_len =3D data[cur_pos]; - cur_pos +=3D 1 + cont_state_len; + cont_state_len =3D data[cur_pos++]; + cur_pos +=3D cont_state_len; =20 if (len < cur_pos) { --- sdp_server.c 2001/03/26 12:58:25 1.21 +++ sdp_server.c 2001/03/26 13:48:28 1.22 @@ -198,8 +198,8 @@ int get_err(void) { - int tmp; - tmp =3D parse_err; + int tmp =3D parse_err; + parse_err =3D 0; return tmp; } @@ -208,13 +208,12 @@ start_xml_parser(XML_Parser p, int fd) { void *buf; + int len; =20 lseek(fd, 0, SEEK_SET); =20=20=20=20=20=20=20 - for (;;) + do { - int len; - buf =3D XML_GetBuffer(p, BUFFSIZE); if (buf =3D=3D NULL) { @@ -238,10 +237,8 @@ XML_ErrorString(XML_GetErrorCode(p))); fprintf(stderr, "len:%d\n",len); break; - } - if (len =3D=3D 0) - break; } + } while (len); } =20 unsigned char* @@ -579,9 +576,8 @@ /* Lists all attributes registerd in the database */ attr_lst =3D get_all_attributes(fd); =20=20=20 - return_sequence[0] =3D DES_HDR; - return_sequence[1] =3D 0; - pos +=3D 2; + return_sequence[pos++] =3D DES_HDR; + return_sequence[pos++] =3D 0; =20=20=20 /* Find the first attribute in the range */ while ((i < attr_lst[0]) && (attr_lst[i] < (attr_id_code >> 16))) @@ -743,7 +739,7 @@ if (strcmp(el, search_struct->service_class) =3D=3D 0) { S_FNC("Found service class %s", el); - search_struct->service_class_found +=3D 1; + search_struct->service_class_found++; } if (search_struct->service_class_found) { @@ -800,7 +796,7 @@ list */ else if (search_struct->attr2get > 0) { - search_struct->attr2get -=3D 1; + search_struct->attr2get--; =20 if (attr[0] && attr[1] && (strcmp(attr[0], "type") =3D=3D 0) && (strcmp(attr[1], "DES") = =3D=3D 0)) @@ -840,7 +836,7 @@ if (strcmp(el, search_hdl->service_class) =3D=3D 0) { S_FNC("Found %s", el); - search_hdl->service_class_found -=3D 1; + search_hdl->service_class_found--; } /* If we have found the attribute name end tag, there are no more attrib= utes to find */ @@ -869,17 +865,19 @@ int i =3D 0; =20 if (len <=3D 0) + { return; + } =20=20=20 - while (i < len) + while (i < len && !FIRST_VALID_CHAR(s[i])) { - if (FIRST_VALID_CHAR(s[i])) - break; i++; } =20 if (i =3D=3D len) + { return; + } =20 if ((search_hdl->service_class_found) && (search_hdl->attribute_name_fou= nd)) { @@ -901,11 +899,10 @@ sprintf(search_hdl->attrlist + search_hdl->attrlist_index, "%01x%01x" , s[i] / 16, s[i] % 16); search_hdl->attrlist_index +=3D 2; - search_hdl->des_len[0] +=3D1; + search_hdl->des_len[0]++; } =20=20=20=20=20 - strncpy(search_hdl->attrlist + search_hdl->attrlist_index, "\0", 1); - search_hdl->attrlist_index +=3D 1; + search_hdl->attrlist[search_hdl->attrlist_index++] =3D '\0'; } } =20 @@ -1120,8 +1117,8 @@ memcpy(search_hdl->search_val, &attr_cnt, 4); for (i =3D 0; attr[i]; i +=3D 2) { - unsigned int tmp; - tmp =3D (unsigned int)strtol(attr[i + 1], NULL, 16);=20 + unsigned int tmp =3D strtoul(attr[i + 1], NULL, 16);=20 + memcpy(search_hdl->search_val + 4 +(i * 2), &tmp ,4); S_FNC("Attribute %d found", tmp); }=20 @@ -1185,7 +1182,7 @@ =20 if (rec_hdl !=3D NO_REC_HDL) { - rec_hdl_cnt +=3D 1; + rec_hdl_cnt++; } =20 rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd); @@ -1199,7 +1196,7 @@ D_REC("Got Record handle: 0x%08x", rec_hdl_list[i]); if (rec_hdl =3D=3D rec_hdl_list[i]) { - rec_hdl_cnt -=3D 1; + rec_hdl_cnt--; rec_hdl =3D NO_REC_HDL; } i++; @@ -1210,33 +1207,29 @@ rsp_pkt_len =3D SDP_HDR_SIZE;=20=20 =20=20=20 /* Set the total service record count */ - rsp_pkt[rsp_pkt_len] =3D SHORT2CHAR_MS(rec_hdl_cnt); - rsp_pkt[rsp_pkt_len + 1] =3D SHORT2CHAR_LS(rec_hdl_cnt); - rsp_pkt_len +=3D 2; + rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_MS(rec_hdl_cnt); + rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_LS(rec_hdl_cnt); =20=20=20 /* Set the current service record count */ - rsp_pkt[rsp_pkt_len] =3D SHORT2CHAR_MS(rec_hdl_cnt); - rsp_pkt[rsp_pkt_len + 1] =3D SHORT2CHAR_LS(rec_hdl_cnt); - rsp_pkt_len +=3D 2; + rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_MS(rec_hdl_cnt); + rsp_pkt[rsp_pkt_len++] =3D SHORT2CHAR_LS(rec_hdl_cnt); =20=20=20 if (rec_hdl !=3D NO_REC_HDL) { - rsp_pkt[rsp_pkt_len] =3D (rec_hdl >> 24) & 0xff; - rsp_pkt[rsp_pkt_len + 1] =3D (rec_hdl >> 16) & 0xff; - rsp_pkt[rsp_pkt_len + 2] =3D (rec_hdl >> 8) & 0xff; - rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl & 0xff; - rsp_pkt_len +=3D 4; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 24) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 16) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl >> 8) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D rec_hdl & 0xff; } =20 if (rec_hdl_list) { for (i =3D 0; rec_hdl_list[i] !=3D NO_REC_HDL; i++) { - rsp_pkt[rsp_pkt_len] =3D (rec_hdl_list[i] >> 24) & 0xff; - rsp_pkt[rsp_pkt_len + 1] =3D (rec_hdl_list[i] >> 16) & 0xff; - rsp_pkt[rsp_pkt_len + 2] =3D (rec_hdl_list[i] >> 8) & 0xff; - rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl_list[i] & 0xff; - rsp_pkt_len +=3D 4; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 24) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 16) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D (rec_hdl_list[i] >> 8) & 0xff; + rsp_pkt[rsp_pkt_len++] =3D rec_hdl_list[i] & 0xff; } D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); free(rec_hdl_list); @@ -1260,9 +1253,9 @@ /* Skip the sdp header and the attribute byte count field */ rsp_pkt_len =3D SDP_HDR_SIZE + 2; =20 - rsp_pkt[rsp_pkt_len] =3D DES_HDR; - des_len_pos =3D rsp_pkt_len + 1; - rsp_pkt_len +=3D 2; + rsp_pkt[rsp_pkt_len++] =3D DES_HDR; + des_len_pos =3D rsp_pkt_len; + rsp_pkt_len++; =20=20=20 for (i =3D 0; i < db_hdl->attr_cnt; i++) { @@ -1348,9 +1341,9 @@ /* Skip the sdp header and the attribute byte count field */ rsp_pkt_len =3D SDP_HDR_SIZE + 2; =20 - rsp_pkt[rsp_pkt_len] =3D DES_HDR_2B; - des_len_pos =3D rsp_pkt_len + 1; - rsp_pkt_len +=3D 3; + rsp_pkt[rsp_pkt_len++] =3D DES_HDR_2B; + des_len_pos =3D rsp_pkt_len; + rsp_pkt_len +=3D 2; =20 if (!rec_hdl_cnt) { rec_hdl_cnt =3D 1; @@ -1421,7 +1414,7 @@ int cur_rec_cnt; int cnt_len; =20 - cur_rec_cnt =3D CHAR2INT16(pkt[7], pkt[8]); + cur_rec_cnt =3D CHAR2INT16(pkt[SDP_HDR_SIZE+2], pkt[SDP_HDR_SIZE+3]); =20 if (cur_rec_cnt > max_rec_cnt) { @@ -1444,23 +1437,20 @@ cont_state_buf =3D malloc(sizeof(cont_state_struct) + cnt_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cnt_len, cont_state_buf); =20 - cont_state_buf->pdu =3D pkt[0]; - D_MISC("PDU: 0x%02x", pkt[0]); + cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE]; + D_MISC("PDU: 0x%02x", cont_state_buf->pdu); =20=20=20=20=20 cont_state_buf->len =3D cnt_len; memcpy(cont_state_buf->data, pkt + len, cnt_len); =20=20=20=20=20 len =3D SDP_HDR_SIZE + 2 + 2 + (max_rec_cnt * 4); =20 - pkt[len] =3D 1; - len +=3D 1; - pkt[len] =3D 0; - len +=3D 1; + pkt[len++] =3D 1; + pkt[len++] =3D 0; } else { - pkt[len] =3D 0; - len +=3D 1; + pkt[len++] =3D 0; } =20=20=20 /* Change the length field */ @@ -1498,8 +1488,8 @@ cont_state_buf =3D malloc(sizeof(cont_state_struct) + cont_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cont_len , cont_state_buf); =20 - cont_state_buf->pdu =3D pkt[0]; - D_MISC("PDU: 0x%02x", pkt[0]); + cont_state_buf->pdu =3D pkt[SDP_HDR_TYPE]; + D_MISC("PDU: 0x%02x", cont_state_buf->pdu); =20 cont_state_buf->len =3D cont_len; memcpy(cont_state_buf->data, pkt + len, cont_len); @@ -1507,16 +1497,13 @@ pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(max_attr_len); pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(max_attr_len); =20=20=20=20=20 - pkt[len] =3D 1; - len +=3D 1; - pkt[len] =3D 0; - len +=3D 1; + pkt[len++] =3D 1; + pkt[len++] =3D 0; } else { S_FNC("No continuation State set"); - pkt[len] =3D 0; - len +=3D 1; + pkt[len++] =3D 0; } =20=20=20 /* Change the length field */ @@ -1538,9 +1525,7 @@ if (!cont_state_buf) { send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_CONTINUATION_STATE); } - else - { - if ((max_rec_cnt * 4) >=3D cont_state_buf->len) + else if ((max_rec_cnt * 4) >=3D cont_state_buf->len) { /* Allocate space for the SDP header, the attribute byte count field, the attributes and the continuation state field */ @@ -1582,7 +1567,6 @@ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_SDP_VERSION); } } -} =20 void send_cont_state_attr_rsp(int len, unsigned char *info, int max_attr_cnt, |
From: Peter K. <pk...@us...> - 2001-03-26 12:58:27
|
The following file was modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.20 1.21=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Removed unnecessary casts when calling malloc(). The diff of the modified file(s): --- sdp_server.c 2001/03/26 12:25:24 1.20 +++ sdp_server.c 2001/03/26 12:58:25 1.21 @@ -252,7 +252,7 @@ unsigned char *hex_data; =20 m_size =3D strlen(char_data) / 2;=20 - hex_data =3D (char*) malloc(m_size); + hex_data =3D malloc(m_size); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, m_size, hex_data= ); =20 /* FIXME, How will this work when using big endian ? */ @@ -288,7 +288,7 @@ des_pos[i] =3D NULL; } =20=20=20 - tmp_list =3D (char*) malloc(256); + tmp_list =3D malloc(256); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, tmp_list); =20 /* While we have not reached the end of the string */ @@ -475,7 +475,7 @@ { tmp =3D s_hdl->hdl_list; s_hdl->block_len =3D s_hdl->hdl_list_len + s_hdl->block_len * 2; - s_hdl->hdl_list =3D (unsigned int*) malloc(s_hdl->block_len); + s_hdl->hdl_list =3D malloc(s_hdl->block_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, s_hdl->bloc= k_len, s_hdl->hdl_list); =20 memcpy(s_hdl->hdl_list, tmp, s_hdl->hdl_list_len); @@ -528,7 +528,7 @@ =20 s_hdl.hdl_list_len =3D 0; s_hdl.block_len =3D 16 * sizeof(unsigned int); - s_hdl.hdl_list =3D (unsigned int*) malloc(s_hdl.block_len); + s_hdl.hdl_list =3D malloc(s_hdl.block_len); =20=20=20 p =3D XML_ParserCreate(NULL); XML_SetElementHandler(p, get_more_rec_hdl_start, get_more_rec_hdl_end); @@ -544,7 +544,7 @@ tmp_len =3D s_hdl.hdl_list_len + sizeof(unsigned int); s_hdl.block_len +=3D 1; =20=20=20=20=20 - s_hdl.hdl_list =3D (unsigned int*) malloc(tmp_len); + s_hdl.hdl_list =3D malloc(tmp_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, tmp_len, s_hdl.= hdl_list); =20=20=20=20=20 memcpy(s_hdl.hdl_list, tmp, s_hdl.hdl_list_len); @@ -569,7 +569,7 @@ char *return_sequence; =20 /* FIXME: But for now 256 bytes will do */ - return_sequence =3D (char*) malloc(256); + return_sequence =3D malloc(256); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, return_seque= nce); =20=20=20 =20=20=20 @@ -709,7 +709,7 @@ =20 hex_tmp =3D char2hex(char_tmp); =20 - return_sequence =3D (char*) malloc(len + 2); + return_sequence =3D malloc(len + 2); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, len + 2, return_s= equence); =20=20=20 return_sequence[0] =3D 0x35; @@ -1003,7 +1003,7 @@ { S_FNC("Found %s", attr[i]); m_size =3D strlen(attr[i] + 1); - search_hdl->search_attr =3D (char*) malloc(m_size); + search_hdl->search_attr =3D malloc(m_size); D_MEM("---> malloc%d % d bytes at 0x%8p", malloc_dbg++, m_size, = search_hdl->search_attr); strcpy(search_hdl->search_attr, attr[i]); return; @@ -1022,7 +1022,7 @@ { S_FNC("Found %s", attr[i + 1]); m_size =3D strlen(attr[i + 1] + 1); - search_hdl->search_val =3D (char*) malloc(m_size); + search_hdl->search_val =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, s= earch_hdl->search_val); strcpy(search_hdl->search_val, attr[i + 1]); return; @@ -1038,7 +1038,7 @@ (strcmp(search_hdl->search_val, attr[i + 1]) =3D=3D 0)) { m_size =3D strlen(el) + 1; - search_hdl->search_name =3D (char*) malloc(m_size); + search_hdl->search_name =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, sea= rch_hdl->search_name); strcpy(search_hdl->search_name, el); return; @@ -1115,7 +1115,7 @@ /* Allocate space for all the attribute UUIDs plus the attribute count in the search_output pointer, */ m_size =3D attr_cnt * 4 + 4; - search_hdl->search_val =3D (char*) malloc(m_size); + search_hdl->search_val =3D malloc(m_size); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, search_= hdl->search_val); memcpy(search_hdl->search_val, &attr_cnt, 4); for (i =3D 0; attr[i]; i +=3D 2) @@ -1441,7 +1441,7 @@ bytes */ len -=3D cnt_len; =20=20=20=20=20 - cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc= t) + cnt_len); + cont_state_buf =3D malloc(sizeof(cont_state_struct) + cnt_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cnt_len, cont_state_buf); =20 cont_state_buf->pdu =3D pkt[0]; @@ -1495,7 +1495,7 @@ bytes */ len -=3D cont_len; =20=20=20=20 - cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc= t) + cont_len); + cont_state_buf =3D malloc(sizeof(cont_state_struct) + cont_len); D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cont_len , cont_state_buf); =20 cont_state_buf->pdu =3D pkt[0]; @@ -1546,7 +1546,7 @@ the attributes and the continuation state field */ send_len =3D SDP_HDR_SIZE + 2 + 2 + cont_state_buf->len + 1; =20 - send_buf =3D (unsigned char*) malloc(send_len); + send_buf =3D malloc(send_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, sen= d_buf); =20 set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); @@ -1602,7 +1602,7 @@ the attributes and the continuation state field */ send_len =3D SDP_HDR_SIZE + 2 + cont_state_buf->len + 1; =20 - send_buf =3D (unsigned char*) malloc(send_len); + send_buf =3D malloc(send_len); D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, sen= d_buf); =20 set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); |
From: Peter K. <pk...@us...> - 2001-03-26 12:25:26
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.15 1.16=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.h 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use defines for the SDP header fields. The diff of the modified file(s): --- sdp_parser.c 2001/03/26 11:28:41 1.15 +++ sdp_parser.c 2001/03/26 12:25:24 1.16 @@ -172,9 +172,10 @@ sdp_con_id =3D db_hdl->sdp_con_id; pkt_len =3D db_hdl->len; =20 - id =3D data[0]; - trans_id =3D CHAR2INT16(data[1], data[2]); - par_len =3D CHAR2INT16(data[3], data[4]); + id =3D data[SDP_HDR_TYPE]; + trans_id =3D CHAR2INT16(data[SDP_HDR_TRANS_ID_MS], data[SDP_HDR_TRANS_ID= _LS]); + par_len =3D CHAR2INT16(data[SDP_HDR_LENGTH_MS], data[SDP_HDR_LENGTH_LS]); + data +=3D SDP_HDR_SIZE; =20 if (par_len > (len - SDP_HDR_SIZE)) { @@ -189,7 +190,7 @@ switch (id) { case SDP_ERROR_RSP: - switch (CHAR2INT16(data[5], data[6])) + switch (CHAR2INT16(data[0], data[1])) { case SDP_INVALID_SDP_VERSION: D_ERR("Got Invalid/unsupported SDP version"); @@ -211,39 +212,39 @@ break; default: D_ERR("Error code 0x%04x is not specified", - CHAR2INT16(data[5], data[6])); + CHAR2INT16(data[0], data[1])); break; } break; =20 case SDP_SERVICESEARCH_REQ: D_REC("SDP_SERVICESEARCH_REQ %d bytes", par_len); - process_service_search_req(sdp_con_id, data + 5, par_len, trans_id); + process_service_search_req(sdp_con_id, data, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICESEARCH_RSP: D_REC("SDP_SERVICESEARCH_RSP"); - process_service_search_rsp(sdp_con_id, data + 5); + process_service_search_rsp(sdp_con_id, data); break; =20=20=20=20=20 case SDP_SERVICEATTR_REQ: D_REC("SDP_SERVICEATTR_REQ"); - process_service_attr_req(sdp_con_id, data + 5, par_len, trans_id); + process_service_attr_req(sdp_con_id, data, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICEATTR_RSP: D_REC("SDP_SERVICEATTR_RSP"); - process_service_attr_rsp(sdp_con_id, data + 5); + process_service_attr_rsp(sdp_con_id, data); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_REQ: D_REC("SDP_SERVICESEARCHATTR_REQ"); - process_service_search_attr_req(sdp_con_id, data + 5, par_len, trans_i= d); + process_service_search_attr_req(sdp_con_id, data, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_RSP: D_REC("SDP_SERVICESEARCHATTR_RSP"); - process_service_search_attr_rsp(sdp_con_id, data + 5); + process_service_search_attr_rsp(sdp_con_id, data); break; =20=20=20=20=20 default: --- sdp_server.c 2001/03/26 11:28:41 1.19 +++ sdp_server.c 2001/03/26 12:25:24 1.20 @@ -390,11 +390,11 @@ void set_sdp_hdr(unsigned char *hdr, unsigned char pkt_type, unsigned short trans_id, unsigned short len) { - hdr[0] =3D pkt_type; - hdr[1] =3D SHORT2CHAR_MS(trans_id); - hdr[2] =3D SHORT2CHAR_LS(trans_id); - hdr[3] =3D SHORT2CHAR_MS(len); - hdr[4] =3D SHORT2CHAR_LS(len); + hdr[SDP_HDR_TYPE] =3D pkt_type; + hdr[SDP_HDR_TRANS_ID_MS] =3D SHORT2CHAR_MS(trans_id); + hdr[SDP_HDR_TRANS_ID_LS] =3D SHORT2CHAR_LS(trans_id); + hdr[SDP_HDR_LENGTH_MS] =3D SHORT2CHAR_MS(len); + hdr[SDP_HDR_LENGTH_LS] =3D SHORT2CHAR_LS(len); } =20 unsigned int @@ -1296,8 +1296,8 @@ =20 /* Set the attribute byte count to packet length minus sdp pdu header si= ze minus attribute byte count field length, minus continuation field len= gth*/ - rsp_pkt[5] =3D SHORT2CHAR_MS(rsp_pkt_len - SDP_HDR_SIZE - 2); - rsp_pkt[6] =3D SHORT2CHAR_LS(rsp_pkt_len - SDP_HDR_SIZE - 2); + rsp_pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(rsp_pkt_len - SDP_HDR_SIZE - 2= ); + rsp_pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(rsp_pkt_len - SDP_HDR_SIZE - 2= ); =20 /* The length of the attribute list is the length of the attribute byte count minus the size of the data element sequens header */ @@ -1397,8 +1397,8 @@ =20 /* Set the attribute byte count to packet length minus sdp pdu header si= ze minus attribute byte count field length */ - rsp_pkt[5] =3D SHORT2CHAR_MS(rsp_pkt_len - SDP_HDR_SIZE - 2); - rsp_pkt[6] =3D SHORT2CHAR_LS(rsp_pkt_len - SDP_HDR_SIZE - 2); + rsp_pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(rsp_pkt_len - SDP_HDR_SIZE - 2= ); + rsp_pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(rsp_pkt_len - SDP_HDR_SIZE - 2= ); =20 /* The length of the attribute list is the same as the packet length min= us the packet header length minus the attibute byte count filed minus the @@ -1428,11 +1428,11 @@ S_FNC("Setting cont state, cur_rec_cnt:%d, max_rec_cnt:%d", cur_rec_cnt, max_rec_cnt); =20 - pkt[5] =3D SHORT2CHAR_MS(max_rec_cnt); - pkt[6] =3D SHORT2CHAR_LS(max_rec_cnt); + pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(max_rec_cnt); + pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(max_rec_cnt); =20=20=20=20=20 - pkt[7] =3D SHORT2CHAR_MS(max_rec_cnt); - pkt[8] =3D SHORT2CHAR_LS(max_rec_cnt); + pkt[SDP_HDR_SIZE+2] =3D SHORT2CHAR_MS(max_rec_cnt); + pkt[SDP_HDR_SIZE+3] =3D SHORT2CHAR_LS(max_rec_cnt); =20=20=20=20=20 /* There are cnt_len byte too much to fit the data in one packet */ cnt_len =3D (cur_rec_cnt - max_rec_cnt) * 4; @@ -1464,8 +1464,8 @@ } =20=20=20 /* Change the length field */ - pkt[3] =3D SHORT2CHAR_MS(len - SDP_HDR_SIZE); - pkt[4] =3D SHORT2CHAR_LS(len - SDP_HDR_SIZE); + pkt[SDP_HDR_LENGTH_MS] =3D SHORT2CHAR_MS(len - SDP_HDR_SIZE); + pkt[SDP_HDR_LENGTH_LS] =3D SHORT2CHAR_LS(len - SDP_HDR_SIZE); =20 return len; } @@ -1478,7 +1478,7 @@ int cur_attr_cnt; int cont_len; =20=20=20 - cur_attr_cnt =3D CHAR2INT16(pkt[5], pkt[6]); + cur_attr_cnt =3D CHAR2INT16(pkt[SDP_HDR_SIZE], pkt[SDP_HDR_SIZE+1]); =20 S_FNC("len %d, max_attr_len %d, cur_attr_cnt %d", len, max_attr_len, cur= _attr_cnt); =20 @@ -1504,8 +1504,8 @@ cont_state_buf->len =3D cont_len; memcpy(cont_state_buf->data, pkt + len, cont_len); =20 - pkt[5] =3D SHORT2CHAR_MS(max_attr_len); - pkt[6] =3D SHORT2CHAR_LS(max_attr_len); + pkt[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(max_attr_len); + pkt[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(max_attr_len); =20=20=20=20=20 pkt[len] =3D 1; len +=3D 1; @@ -1522,8 +1522,8 @@ /* Change the length field */ =20 S_FNC("Changing length field"); - pkt[3] =3D SHORT2CHAR_MS(len- SDP_HDR_SIZE); - pkt[4] =3D SHORT2CHAR_LS(len -SDP_HDR_SIZE); + pkt[SDP_HDR_LENGTH_MS] =3D SHORT2CHAR_MS(len - SDP_HDR_SIZE); + pkt[SDP_HDR_LENGTH_LS] =3D SHORT2CHAR_LS(len - SDP_HDR_SIZE); =20 return len; } @@ -1552,12 +1552,12 @@ set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); =20 /* Set the attribute byte count field */ - send_buf[5] =3D SHORT2CHAR_MS(cont_state_buf->len / 4); - send_buf[6] =3D SHORT2CHAR_LS(cont_state_buf->len / 4); + send_buf[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(cont_state_buf->len / 4); + send_buf[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(cont_state_buf->len / 4); =20 /* Set the attribute byte count field */ - send_buf[7] =3D SHORT2CHAR_MS(cont_state_buf->len / 4); - send_buf[8] =3D SHORT2CHAR_LS(cont_state_buf->len / 4); + send_buf[SDP_HDR_SIZE+2] =3D SHORT2CHAR_MS(cont_state_buf->len / 4); + send_buf[SDP_HDR_SIZE+3] =3D SHORT2CHAR_LS(cont_state_buf->len / 4); =20 memcpy(send_buf + SDP_HDR_SIZE + 2 + 2, cont_state_buf->data, cont_s= tate_buf->len); =20 @@ -1608,8 +1608,8 @@ set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); =20 /* Set the attribute byte count field */ - send_buf[5] =3D SHORT2CHAR_MS(cont_state_buf->len); - send_buf[6] =3D SHORT2CHAR_LS(cont_state_buf->len); + send_buf[SDP_HDR_SIZE] =3D SHORT2CHAR_MS(cont_state_buf->len); + send_buf[SDP_HDR_SIZE+1] =3D SHORT2CHAR_LS(cont_state_buf->len); =20 memcpy(send_buf + SDP_HDR_SIZE + 2, cont_state_buf->data, cont_state= _buf->len); =20 --- sdp_server.h 2001/03/26 11:28:41 1.8 +++ sdp_server.h 2001/03/26 12:25:24 1.9 @@ -54,6 +54,11 @@ =20 #define BUFFSIZE 1024 =20 +#define SDP_HDR_TYPE 0 +#define SDP_HDR_TRANS_ID_MS 1 +#define SDP_HDR_TRANS_ID_LS 2 +#define SDP_HDR_LENGTH_MS 3 +#define SDP_HDR_LENGTH_LS 4 #define SDP_HDR_SIZE 5 =20 #define DES_HDR 0x35 |
From: Peter K. <pk...@us...> - 2001-03-26 11:28:45
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.14 1.15=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.c 1.18 1.19=20=20=20=20=20=20=20=20=20=20=20=20 sdp_server.h 1.7 1.8=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Cleaned up debugging. The diff of the modified file(s): --- sdp_parser.c 2001/03/23 16:19:36 1.14 +++ sdp_parser.c 2001/03/26 11:28:41 1.15 @@ -64,49 +64,49 @@ #define SDP_DEBUG_MISC 0 #define SDP_DEBUG_MEM 0 #define SDP_DEBUG_PROC 0 -#define SDP_PRINT_DATA 0 +#define SDP_DEBUG_PRINT_DATA 0 =20 #ifdef BTD_USERSTACK -#define syslog(x, fmt...) printf(fmt) +#define syslog(x, fmt...) do { fprintf(stderr, __FILE__ "::"); fprintf(std= err, fmt); fprintf(stderr, "\n"); } while (0) #endif =20 #if SDP_DEBUG_XMIT -#define D_XMIT(fmt...) syslog(LOG_DEBUG, fmt) +#define D_XMIT(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_XMIT(fmt...) #endif =20 #if SDP_DEBUG_REC -#define D_REC(fmt...) syslog(LOG_DEBUG, fmt) +#define D_REC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_REC(fmt...) #endif =20 #if SDP_DEBUG_MISC -#define D_MISC(fmt...) syslog(LOG_DEBUG, fmt) +#define D_MISC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_MISC(fmt...) #endif =20 #if SDP_DEBUG_MEM -#define D_MEM(fmt...) syslog(LOG_DEBUG, fmt) +#define D_MEM(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_MEM(fmt...) #endif =20 #if SDP_DEBUG_PROC -#define D_PROC(fmt...) syslog(LOG_DEBUG, fmt) +#define D_PROC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_PROC(fmt...) #endif =20 -#if SDP_PRINT_DATA -#define PRINTPKT(str, data, len) print_data(str, data, len) +#if SDP_DEBUG_PRINT_DATA +#define PRINT_DATA(str, data, len) print_data(str, data, len) #else -#define PRINTPKT(str, data, len) +#define PRINT_DATA(str, data, len) #endif =20 -#define D_ERR(fmt...) printf("ERROR :" fmt) +#define D_ERR(fmt...) do { fprintf(stderr, __FUNCTION__ ": ERROR: " fmt); = fprintf(stderr, "\n"); } while (0) =20 #define GET_TYPE(ch) (((ch) >> 3) & 0x1f) #define GET_SIZE(ch) ((ch) & 0x7) @@ -156,7 +156,6 @@ void=20 sdp_parse_data(unsigned char* data, unsigned int len) { -#define FNC "sdp_parse_data: " unsigned char id; unsigned short trans_id; unsigned short par_len; @@ -164,7 +163,7 @@ int sdp_con_id; data_struct *db_hdl; =20 - PRINTPKT(FNC, data, len);=20=20 + PRINT_DATA(__FUNCTION__, data, len); =20 db_hdl =3D (data_struct*)data; data +=3D sizeof *db_hdl; @@ -179,12 +178,13 @@ =20 if (par_len > (len - SDP_HDR_SIZE)) { - D_XMIT(FNC"Packet length does not match received data length par_len %= d, pkt_len %d\n", par_len, len); + D_XMIT("Packet length (%d) does not match received data length (%d)", + len - SDP_HDR_SIZE, par_len); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20 - D_REC(FNC"id:0x%x, trans_id:0x%x, par_len:%d\n", id, trans_id,par_len); + D_REC("id: 0x%x, trans_id: 0x%x, par_len: %d", id, trans_id, par_len); =20 switch (id) { @@ -192,73 +192,71 @@ switch (CHAR2INT16(data[5], data[6])) { case SDP_INVALID_SDP_VERSION: - D_ERR(FNC"Got Invalid/unsupported SDP version\n"); + D_ERR("Got Invalid/unsupported SDP version"); break; case SDP_INVALID_SERVICE_RECORD_HANDLE: - D_ERR(FNC"Got Invalid Service Record Handle\n"); + D_ERR("Got Invalid Service Record Handle"); break; case SDP_INVALID_REQUEST_SYNTAX: - D_ERR(FNC"Got Invalid Request Syntax\n"); + D_ERR("Got Invalid Request Syntax"); break; case SDP_INVALID_PDU_SIZE: - D_ERR(FNC"Got Invalid PDU Size\n"); + D_ERR("Got Invalid PDU Size"); break; case SDP_INVALID_CONTINUATION_STATE: - D_ERR(FNC"Got Invalid Continuation State\n"); + D_ERR("Got Invalid Continuation State"); break; case SDP_INSUFFICIENT_RESOURCES: - D_ERR(FNC"Got Insufficient Resources to satisfy Request\n"); + D_ERR("Got Insufficient Resources to satisfy Request"); break; default: - D_ERR(FNC" Error code 0x%04x is not specified\n", + D_ERR("Error code 0x%04x is not specified", CHAR2INT16(data[5], data[6])); break; } break; =20=09=09 case SDP_SERVICESEARCH_REQ: - D_REC(FNC"SDP_SERVICESEARCH_REQ %d bytes\n", par_len); + D_REC("SDP_SERVICESEARCH_REQ %d bytes", par_len); process_service_search_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICESEARCH_RSP: - D_REC(FNC"SDP_SERVICESEARCH_RSP\n"); + D_REC("SDP_SERVICESEARCH_RSP"); process_service_search_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICEATTR_REQ: - D_REC(FNC"SDP_SERVICEATTR_REQ\n"); + D_REC("SDP_SERVICEATTR_REQ"); process_service_attr_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICEATTR_RSP: - D_REC(FNC"SDP_SERVICEATTR_RSP\n"); + D_REC("SDP_SERVICEATTR_RSP"); process_service_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_REQ: - D_REC(FNC"SDP_SERVICESEARCHATTR_REQ\n"); + D_REC("SDP_SERVICESEARCHATTR_REQ"); process_service_search_attr_req(sdp_con_id, data + 5, par_len, trans_i= d); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_RSP: - D_REC(FNC"SDP_SERVICESEARCHATTR_RSP\n"); + D_REC("SDP_SERVICESEARCHATTR_RSP"); process_service_search_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 default: - D_REC(FNC"ERROR Invalid pdu type\n"); + D_REC("ERROR Invalid pdu type"); /* Send an error response with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } -#undef FNC } =20 void process_service_search_req(int sdp_con_id, unsigned char *data, unsigned s= hort len, unsigned int trans_id) { -#define FNC "process_service_search_req: " unsigned int service_search_uuid[12]; int service_search_uuid_cnt; unsigned char des_len; @@ -267,10 +265,10 @@ int new_pos[1]; int cont_state_len; =20=09 - D_REC(FNC"got %d bytes\n", len); + D_REC("Got %d bytes", len); if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE) { - D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); + D_REC("Incorrect packet: Data Element Sequence expected"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -278,11 +276,11 @@ =20 des_len =3D get_size(data + cur_pos, new_pos); cur_pos +=3D *new_pos; - D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos); + D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos); =20=09 if (des_len > (len - DES_HDR_LEN)) { - D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); + D_REC("Incorrect packet: Incorrect length field or whole packet was no= t received"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -294,9 +292,8 @@ { if (i >=3D 12) { - D_REC(FNC"More than 12 UUID in one request\n"); - /* Send an error msg with error code Invalid request - syntax */ + D_REC("More than 12 UUID in one request"); + /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } @@ -305,8 +302,7 @@ { service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Found UUID16 0x%04x\n", - service_search_uuid[i]);=20 + D_MISC("Found UUID16 0x%04x", service_search_uuid[i]);=20 i +=3D 1; tmp_pos +=3D 3; cur_pos +=3D 3; @@ -316,8 +312,7 @@ cur_pos +=3D 2; service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Found UUID32 0x%08x\n", - service_search_uuid[i]);=20 + D_MISC("Found UUID32 0x%08x", service_search_uuid[i]);=20 i +=3D 1; tmp_pos +=3D 5; cur_pos +=3D 3; @@ -327,16 +322,15 @@ cur_pos +=3D 2; service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]); + D_MISC("Got Service class 0x%08x", service_search_uuid[i]); i +=3D 1; tmp_pos +=3D 17; cur_pos +=3D 15; } else { - D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); - /* Send an error msg with error code Invalid request - syntax */ + D_REC("Unknown UUID size 0x%02x", data[cur_pos]); + /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } @@ -344,7 +338,7 @@ service_search_uuid_cnt =3D i; =20 max_rec_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]); - D_MISC(FNC"max_rec_cnt: %d\n", max_rec_cnt); + D_MISC("max_rec_cnt: %d", max_rec_cnt); cur_pos +=3D 2; =20 cont_state_len =3D data[cur_pos]; @@ -353,13 +347,13 @@ =20 if (len < cur_pos) { - D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) shorter than actual packet length (%d)", len= , cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { - D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) longer than actual packet length (%d)", len,= cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } @@ -368,7 +362,7 @@ { cur_pos +=3D data[cur_pos]; =20=20=20=20=20 - D_MISC(FNC"Sending continuationstate packet\n"); + D_MISC("Sending continuationstate packet"); send_cont_state_search_rsp(cont_state_len, data + cur_pos, max_rec_cnt, sdp_con_id, trans_id); } @@ -388,13 +382,11 @@ /* Here we ask the database for the requested attributes */ handle_query(&db_hdl.db); } -#undef FNC } =20 void=20 process_service_attr_req(int sdp_con_id, unsigned char *data, unsigned sho= rt len, int trans_id) { -#define FNC "process_service_attr_req: " service_attr_struct *db_hdl; =20=09 int tmp_len, cur_pos =3D 0; @@ -409,21 +401,21 @@ =20=20=20 int new_pos[1]; =20 - D_REC(FNC"got %d bytes\n", len); + D_REC("Got %d bytes", len); =20 rec_hdl =3D CHAR2INT32(data[cur_pos], data[cur_pos + 1], data[cur_pos + 2], data[cur_pos + 3]); =20 - D_MISC(FNC"rec_hdl: 0x%08x\n",rec_hdl); + D_MISC("rec_hdl: 0x%08x", rec_hdl); cur_pos +=3D 4; =20 max_attr_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]); - D_MISC(FNC"max_attr_cnt: %d\n",max_attr_cnt); + D_MISC("max_attr_cnt: %d", max_attr_cnt); cur_pos +=3D 2; =20 if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE) { - D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); + D_REC("Incorrect packet: Data Element Sequence expected"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -431,11 +423,11 @@ =20 des_len =3D get_size(data + cur_pos, new_pos); cur_pos +=3D *new_pos; - D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos); + D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos); =20=09 if (des_len > (len - DES_HDR_LEN)) { - D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); + D_REC("Incorrect packet: Incorrect length field or whole packet was no= t received"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -448,7 +440,7 @@ { /* Get the length of the data element */ tmp_len =3D get_size(data + cur_pos, new_pos); - D_MISC(FNC"tmp_len: %d, new_pos: %d\n", tmp_len, *new_pos); + D_MISC("tmp_len: %d, new_pos: %d", tmp_len, *new_pos); /* Move the data pointer past the length field to the start of the data element */ cur_pos +=3D *new_pos; @@ -456,8 +448,7 @@ { /* Now we got a range of attributes */ attr_list[attr_list_pos] =3D CHAR2INT32(data[cur_pos], data[cur_pos = + 1], data[cur_pos + 2], data[cur_pos + 3]); - D_MISC(FNC"Found range of attributes: 0x%08x\n", - attr_list[attr_list_pos]);=20 + D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]= );=20 cur_pos +=3D 4; attr_list_pos +=3D 1; } @@ -467,8 +458,7 @@ attr_list[attr_list_pos] =3D CHAR2INT16(data[cur_pos], data[cur_pos = + 1]); /* We stor all attributes as ranges */ attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16; - D_MISC(FNC"Found single attributes: 0x%04x\n", - attr_list[attr_list_pos]);=20 + D_MISC("Found single attributes: 0x%04x", attr_list[attr_list_pos]);= =20 cur_pos +=3D 2; attr_list_pos +=3D 1;=09 } @@ -480,20 +470,20 @@ =20 if (len < cur_pos) { - D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) shorter than actual packet length (%d)", len= , cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { - D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) longer than actual packet length (%d)", len,= cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 if (cont_state_len) { - D_MISC(FNC"Sending continuationstate packet\n"); + D_MISC("Sending continuationstate packet"); send_cont_state_attr_rsp(cont_state_len, data + cur_pos, max_attr_cnt, sdp_con_id, trans_id); } @@ -502,12 +492,12 @@ len =3D sizeof(service_attr_struct) + attr_list_pos * sizeof *attr_lis= t; =20=09 if (!(db_hdl =3D malloc(len))) { - D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = len); + D_ERR("malloc failed to allocate %d bytes!", len); send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); return; } =20 - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, len, (int)db= _hdl); + D_MEM("---> malloc%d %d bytes at 0x%08x", malloc_dbg++, len, (int)db_h= dl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; db_hdl->db.trans_id =3D trans_id; @@ -522,19 +512,15 @@ =20 handle_query(&db_hdl->db); =20=20=20=20=20 - D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (int) db_hdl); + D_MEM("<--- free%d 0x%08x", --malloc_dbg, (int) db_hdl); free(db_hdl); } -=09 -#undef FNC } =20 void=20 process_service_search_attr_req(int sdp_con_id, unsigned char *data, unsig= ned short len,int trans_id) { -#define FNC "process_service_search_attr_req: " service_search_attr_struct *db_hdl; -=09 unsigned int service_search_uuid[12]; int service_search_uuid_cnt; unsigned char des_len; @@ -543,14 +529,12 @@ int new_pos[1]; unsigned int attr_list[256]; int attr_list_pos =3D 0; - unsigned char cont_state_len; - =20 - D_REC(FNC"got %d bytes\n", len); + D_REC("Got %d bytes", len); if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE) { - D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); + D_REC("Incorrect packet: Data Element Sequence expected"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -558,11 +542,11 @@ =20 des_len =3D get_size(data + cur_pos, new_pos); cur_pos +=3D *new_pos; - D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos); + D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos); =20=09 if (des_len > (len - DES_HDR_LEN)) { - D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); + D_REC("Incorrect packet: Incorrect length field or whole packet was no= t received"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -574,7 +558,7 @@ { if (i >=3D 12) { - D_REC(FNC"More than 12 UUID in one request\n"); + D_REC("More than 12 UUID in one request"); break; } =20=09=09 @@ -582,7 +566,7 @@ { service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Got Service class 0x%04x\n", service_search_uuid[i]); + D_MISC("Got Service class 0x%04x", service_search_uuid[i]); i +=3D 1; tmp_pos +=3D 3; cur_pos +=3D 3; @@ -592,7 +576,7 @@ cur_pos +=3D 2; service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]); + D_MISC("Got Service class 0x%08x", service_search_uuid[i]); i +=3D 1; tmp_pos +=3D 5; cur_pos +=3D 3; @@ -602,14 +586,14 @@ cur_pos +=3D 2; service_search_uuid[i] =3D CHAR2INT16(data[cur_pos + 1], data[cur_pos + 2]); - D_MISC(FNC"Got Service class 0x%08x\n", service_search_uuid[i]); + D_MISC("Got Service class 0x%08x", service_search_uuid[i]); i +=3D 1; tmp_pos +=3D 17; cur_pos +=3D 15; } else { - D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); + D_REC("Unknown UUID size 0x%02x", data[cur_pos]); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } @@ -617,12 +601,12 @@ service_search_uuid_cnt =3D i; =20 max_attr_cnt =3D CHAR2INT16(data[cur_pos], data[cur_pos + 1]); - D_MISC(FNC"max_attr_cnt: %d\n",max_attr_cnt); + D_MISC("max_attr_cnt: %d", max_attr_cnt); cur_pos +=3D 2; =20 if (GET_TYPE(data[cur_pos]) !=3D DES_TYPE) { - D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); + D_REC("Incorrect packet: Data Element Sequence expected"); /* Send an error msg with error code Invalid request syntax */ send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; @@ -630,8 +614,7 @@ =20 des_len =3D get_size(data + cur_pos, new_pos); cur_pos +=3D *new_pos; - D_MISC(FNC"des_len: %d, new_pos:%d\n",des_len, *new_pos); - + D_MISC("des_len: %d, new_pos: %d", des_len, *new_pos); =20 /* Now we parses the third parameter which is a data element list. i.e we have to go through the whole list and pick out one element at @@ -640,7 +623,7 @@ { /* Get the length of the data element */ tmp_len =3D get_size(data + cur_pos, new_pos); - D_MISC(FNC"tmp_len: %d, new_pos: %d\n", tmp_len, *new_pos); + D_MISC("tmp_len: %d, new_pos: %d", tmp_len, *new_pos); /* Move the data pointer past the length field to the start of the data element */ cur_pos +=3D *new_pos; @@ -650,8 +633,7 @@ attr_list[attr_list_pos] =3D CHAR2INT32(data[cur_pos], data[cur_pos = + 1], data[cur_pos + 2], data[cur_pos + 3]); - D_MISC(FNC"Found range of attributes: 0x%08x\n", - attr_list[attr_list_pos]);=20 + D_MISC("Found range of attributes: 0x%08x", attr_list[attr_list_pos]= );=20 cur_pos +=3D 4; attr_list_pos +=3D 1; } @@ -661,7 +643,7 @@ attr_list[attr_list_pos] =3D CHAR2INT16(data[cur_pos], data[cur_pos = + 1]); /* We stor all attributes as ranges */ attr_list[attr_list_pos] |=3D attr_list[attr_list_pos] << 16; - D_MISC(FNC"Found single attributes: 0x%04x\n", + D_MISC("Found single attributes: 0x%04x", (attr_list[attr_list_pos]) & 0xffff);=20 cur_pos +=3D 2; attr_list_pos +=3D 1;=09 @@ -674,20 +656,20 @@ =20 if (len < cur_pos) { - D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) shorter than actual packet length (%d)", len= , cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { - D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); + D_ERR("Packet length (%d) longer than actual packet length 8%d)", len,= cur_pos); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 if (cont_state_len) { - D_MISC(FNC"Sending continuationstate packet\n"); + D_MISC("Sending continuationstate packet"); send_cont_state_attr_rsp(cont_state_len, data + cur_pos, max_attr_cnt, sdp_con_id, trans_id); } @@ -696,12 +678,12 @@ tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * sizeo= f *attr_list; =20=09 if (!(db_hdl =3D malloc(tmp_len))) { - D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = tmp_len); + D_ERR("malloc failed to allocate %d bytes!", tmp_len); send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); return; } =20 - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, tmp_len, (in= t) db_hdl); + D_MEM("---> malloc%d %d bytes at 0x%08x", malloc_dbg++, tmp_len, (int)= db_hdl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; db_hdl->db.trans_id =3D trans_id; @@ -716,41 +698,29 @@ /* Here we ask the database for the requested attributes */ handle_query(&db_hdl->db); =20 - D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (int) db_hdl); + D_MEM("<--- free%d 0x%08x", --malloc_dbg, (int) db_hdl); free(db_hdl); } -=09=09 -#undef FNC=09 } =20 void process_service_search_rsp(int sdp_con_id, unsigned char *data) { -#define FNC "process_service_search_rsp: " -=09 -#undef FNC=09 } =20 void=20 process_service_attr_rsp(int sdp_con_id, unsigned char *data) { -#define FNC "process_service_attr_rsp: " -=09 -#undef FNC } =20 void process_service_search_attr_rsp(int sdp_con_id, unsigned char *data) { -#define FNC "process_service_search_attr_rsp: " -=09 -#undef FNC=09 } =20 void send_error_rsp(int sdp_con_id, unsigned short trans_id, unsigned short err= _code) { -#define FNC "send_error_rsp: " unsigned char sdp_data[7]; unsigned short pdu_len; =20 @@ -769,8 +739,6 @@ sdp_data[6] =3D err_code & 0xff; =20=09 write2stack(sdp_con_id, sdp_data, 7); - -#undef FNC } =20 /* "Support" functions used by the other functions in this file */ @@ -817,7 +785,7 @@ data_struct db_hdl; struct iovec vec[2]; =20 - D_XMIT("write2stack: writing %d bytes to sdp_con_id %d\n", len, sdp_con_= id); + D_XMIT("Writing %d bytes to sdp_con_id %d", len, sdp_con_id); =20=20=20 db_hdl.sdp_con_id =3D sdp_con_id; db_hdl.len =3D len; @@ -852,7 +820,7 @@ } else if (len =3D=3D 0) { - syslog(LOG_DEBUG, "No data was read\n"); + syslog(LOG_DEBUG, "No data was read"); } else { @@ -876,7 +844,7 @@ =20=20=20=20=20 select(FD_SETSIZE, &rfd, NULL, NULL, NULL); =20 - printf(__FUNCTION__", \n"); + printf(__FUNCTION__ "\n"); =20=20=20=20=20 if (FD_ISSET(clnt_fd, &rfd)) { @@ -906,7 +874,7 @@ int sdp_srv_sock; int sdp_clnt_sock; =20 - syslog(LOG_INFO, "Opening server socket %s\n", name); + syslog(LOG_INFO, "Opening server socket %s", name); =20 /* remove any old socket */ unlink(name); @@ -925,7 +893,7 @@ =20 while (1) { - syslog(LOG_INFO, "SDP Server listens...\n"); + syslog(LOG_INFO, "SDP Server listens..."); listen(sdp_srv_sock, 5); =20 client_len =3D sizeof(client_address); --- sdp_server.c 2001/03/25 09:50:02 1.18 +++ sdp_server.c 2001/03/26 11:28:41 1.19 @@ -51,68 +51,68 @@ #include "sdp_parser.h" =20 #ifdef BTD_USERSTACK -#define syslog(x, fmt...) printf(fmt) +#define syslog(x, fmt...) do { fprintf(stderr, __FILE__ "::"); fprintf(std= err, fmt); fprintf(stderr, "\n"); } while (0) #endif =20 /* Does printouts in all functions called by expat */ -#define DBG_SUBFNC 0 +#define SDP_DEBUG_SUBFNC 0 =20 /* Does debug printouts in functions related to incomming data from the sdp parts in the kernel */ -#define DBG_SDP_INCOMING 0 +#define SDP_DEBUG_INCOMING 0 =20 /* Other misc functions such as get_values, char2hex etc */ -#define DBG_MISC 0 +#define SDP_DEBUG_MISC 0 =20 /* Debug for the get attribute functions */ -#define DBG_GET_ATTRIBUTES 0 +#define SDP_DEBUG_GET_ATTRIBUTES 0 =20 /* Debug for the get record handle functions */ -#define DBG_GET_RECORD_HDL 0 +#define SDP_DEBUG_GET_RECORD_HDL 0 =20 /* Debug all malloc and free commands */ -#define DBG_MEM 0 +#define SDP_DEBUG_MEM 0 =20 /* Printouts data in hex format */ -#define DBG_PRINT_DATA 0 +#define SDP_DEBUG_PRINT_DATA 0 =20 -#if DBG_SUBFNC -#define S_FNC(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_SUBFNC +#define S_FNC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define S_FNC(fmt...) #endif =20 -#if DBG_SDP_INCOMING -#define D_REC(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_INCOMING +#define D_REC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_REC(fmt...) #endif =20 -#if DBG_MISC -#define D_MISC(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_MISC +#define D_MISC(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_MISC(fmt...) #endif =20 -#if DBG_GET_ATTRIBUTES -#define D_ATTR(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_GET_ATTRIBUTES +#define D_ATTR(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_ATTR(fmt...) #endif =20 -#if DBG_GET_RECORD_HDL -#define D_RHDL(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_GET_RECORD_HDL +#define D_RHDL(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_RHDL(fmt...) #endif =20 -#if DBG_MEM -#define D_MEM(fmt...) syslog(LOG_DEBUG, fmt) +#if SDP_DEBUG_MEM +#define D_MEM(fmt...) syslog(LOG_DEBUG, __FUNCTION__ ": " fmt) #else #define D_MEM(fmt...) #endif =20 -#if DBG_PRINT_DATA +#if SDP_DEBUG_PRINT_DATA #define PRINT_DATA(str, data, len) print_data(str, data, len) #else #define PRINT_DATA(str, data, len) @@ -160,36 +160,27 @@ extern cont_state_struct *cont_state_buf; =20 void=20 -print_data(const char *message, char *buf, int len) +print_data(const char *message, const unsigned char *buf, int len) {=20 - int t, offs; - char tmp[1024]; + int t, offs =3D 0; + char tmp[100]; =20=20=20 - sprintf(tmp, "\n %s (%d)", message, len); - offs =3D strlen(tmp); + syslog(LOG_DEBUG, "%s (%d):", message, len); =20=20=20 for (t =3D 0; t < len; t++)=20 { - if ((t % 16) =3D=3D 0) + offs +=3D sprintf(tmp + offs, " 0x%02x", (unsigned int)buf[t]); + if (!((t+1) % 8)) { - if ((offs + 2) > (1024 - 3)) - break; - - sprintf(tmp + offs , "\n "); - offs +=3D 2; + syslog(LOG_DEBUG, tmp); + offs =3D 0; } -=20=20=20=20 - if ((offs + 5) > (1024 - 3)) - break; -=20=20=20 - sprintf(tmp + offs, "0x%02x ", (unsigned char) buf[t]); - offs +=3D 5; -=20=20=20 } - sprintf(tmp + offs, "\n"); =20 - syslog(LOG_DEBUG, "%s", tmp); -=20=20 + if (offs) + { + syslog(LOG_DEBUG, tmp); + } } =20 void @@ -227,7 +218,7 @@ buf =3D XML_GetBuffer(p, BUFFSIZE); if (buf =3D=3D NULL) { - syslog(LOG_ERR, "start_xml_parser: couldn't get a free buffer\n"); + syslog(LOG_ERR, "start_xml_parser: couldn't get a free buffer"); break; } =20 @@ -262,7 +253,7 @@ =20 m_size =3D strlen(char_data) / 2;=20 hex_data =3D (char*) malloc(m_size); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int) = hex_data); + D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, m_size, hex_data= ); =20 /* FIXME, How will this work when using big endian ? */ for (i =3D 0; i < strlen(char_data) / 2; i++) @@ -277,7 +268,6 @@ char* get_values(char *value_string, int value_string_len, int fd) { -#define FNC "get_values: " int value_string_pos =3D 0; char *tmp_list; char tmp_len =3D 0; @@ -289,7 +279,7 @@ i =3D 0; while (i < value_string_len) { - D_MISC(FNC"%s \n",value_string + i); + D_MISC("%s", value_string + i); i +=3D strlen(value_string + i) + 1; } =20=20=20 @@ -299,8 +289,7 @@ } =20=20=20 tmp_list =3D (char*) malloc(256); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, 256, (int) tmp= _list); -=20=20 + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, tmp_list); =20=20=20 /* While we have not reached the end of the string */ while (value_string_pos < value_string_len) @@ -317,17 +306,17 @@ { int j; =20 - i =3D (int) strtol(value_string + value_string_pos + - strlen(S_DES_HDR), NULL, 16); + i =3D (int) strtol(value_string + value_string_pos + strlen(S_DES_= HDR), + NULL, 16); =20 /* Now we found a data element sequens header inside another data element sequense */ if (des_pos[i]) { sprintf(c_des_len[i], "%02x", des_len[i]); - D_MISC(FNC"c_des_len[%d]: %s\n", i, c_des_len[i]); + D_MISC("c_des_len[%d]: %s", i, c_des_len[i]); strncpy(des_pos[i], c_des_len[i], 2); - D_MISC(FNC"des_pos[%d]: %s\n", i, des_pos[i]); + D_MISC("des_pos[%d]: %s", i, des_pos[i]); } des_pos[i] =3D tmp_list + tmp_len - 2; des_len[i] =3D 0; @@ -353,8 +342,8 @@ =20=20=20=20=20=20=20 if (tmp_code =3D=3D NULL) { - D_MISC(FNC"Didn't find the hex code for: %s\n", value_string - + value_string_pos); + D_MISC("Didn't find the hex code for: %s", + value_string + value_string_pos); } else { @@ -368,12 +357,12 @@ des_len[1] +=3D tmp / 2; des_len[0] +=3D tmp / 2; =20 - D_MISC(FNC"des_len[1]: %d\n", des_len[1]); - D_MISC(FNC"Found %s\n", tmp_code); + D_MISC("des_len[1]: %d", des_len[1]); + D_MISC("Found %s", tmp_code); =20 /* since get_from_xml allocates space for the reurn paramterer we have to do free here */ - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp_code); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp_code); free(tmp_code); } } @@ -388,42 +377,34 @@ sprintf(c_des_len[i], "%02x", des_len[i]); strncpy(des_pos[i], c_des_len[i], 2); =20 - D_MISC(FNC"%s\n", des_pos[i]); - D_MISC(FNC"c_des_len[%d]: %s\n",i, c_des_len[i]); + D_MISC("%s", des_pos[i]); + D_MISC("c_des_len[%d]: %s",i, c_des_len[i]); } } =20 - D_MISC(FNC"return_list %s\n", tmp_list); + D_MISC("return_list %s", tmp_list); =20 return tmp_list; -#undef FNC } =20 void set_sdp_hdr(unsigned char *hdr, unsigned char pkt_type, unsigned short trans_id, unsigned short len) { -#define FCN "set_sdp_hdr: " - hdr[0] =3D pkt_type; hdr[1] =3D SHORT2CHAR_MS(trans_id); hdr[2] =3D SHORT2CHAR_LS(trans_id); hdr[3] =3D SHORT2CHAR_MS(len); hdr[4] =3D SHORT2CHAR_LS(len); -=09 -#undef FNC } =20 unsigned int get_record_handle(unsigned short service_class, int fd) { -#define FNC "get_record_handle: " -=20=20 int record_handle =3D NO_REC_HDL; char *service_class_name =3D NULL; char *service_class_id =3D NULL; char tmp[12]; =20 -=20=20 /* Before we can get the recordhandle we have to find the name of the service class, so we can search for it in the database. When we search the service class id, have to be converted to characters. All service @@ -435,7 +416,7 @@ /* If we didn't find the service class we return here */ if (service_class_name =3D=3D NULL) { - D_RHDL(FNC"Didn't find ServiceClass name for uuid 0x%04x\n",service_cl= ass); + D_RHDL("Didn't find ServiceClass name for uuid 0x%04x", service_class); return NO_REC_HDL; } =20=20=20 @@ -445,52 +426,48 @@ service_class_id =3D get_from_xml(fd, service_class_name, "ServiceRecordHandle", NULL); =20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) service_class_name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, service_class_name); free(service_class_name); =20=20=20 /* If we found the record handle we convert it to an unsigned int */ if (service_class_id !=3D NULL) { - D_RHDL(FNC"Found %s\n", service_class_id); + D_RHDL("Found %s", service_class_id); record_handle =3D (unsigned int) strtol(service_class_id, NULL, 16); - D_RHDL(FNC"Record handle converted to int 0x%08x\n", record_handle); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) service_class_id); + D_RHDL("Record handle converted to int 0x%08x", record_handle); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, service_class_id); free(service_class_id); } =20 return record_handle; -#undef FNC } =20 void get_more_rec_hdl_start(void *data, const char *el, const char **attr) { -#define FNC "get_more_rec_hdl_start: " - unsigned int *tmp; rec_hdl_search_struct *s_hdl =3D (rec_hdl_search_struct*) data; =20 if (attr[0] && strcmp(attr[0], "ServiceRecordHandle") =3D=3D 0) { -=20=20=20=20 - S_FNC(FNC"Found Record Handle %s\n", attr[1]); + S_FNC("Found Record Handle %s", attr[1]); s_hdl->tmp_hdl =3D (unsigned int)strtol(attr[1], NULL, 16); - S_FNC(FNC"Found Record Handle 0x%08x\n", s_hdl->tmp_hdl); + S_FNC("Found Record Handle 0x%08x", s_hdl->tmp_hdl); } if ((s_hdl->tmp_hdl) && (strcmp(el, s_hdl->uuid) =3D=3D 0)) { if ((s_hdl->hdl_list_len > 0) && (s_hdl->tmp_hdl =3D=3D s_hdl->hdl_list[(s_hdl->hdl_list_len / U32_SIZE) -= 1])) { - S_FNC(FNC"%s is present in record handle 0x%08x, but already found\n= ", + S_FNC("%s is present in record handle 0x%08x, but already found", s_hdl->uuid, s_hdl->tmp_hdl); } else { - S_FNC(FNC"%s is present in record handle 0x%08x\n", + S_FNC("%s is present in record handle 0x%08x", s_hdl->uuid, s_hdl->tmp_hdl); =20=20=20=20=20=20=20 - /* Store the poiter to the allready found record handles, and than if + /* Store the poiter to the allready found record handles, and then if necessary allocate new space for both the old and the new record handles */ =20=20=20=20=20=20=20 @@ -499,12 +476,12 @@ tmp =3D s_hdl->hdl_list; s_hdl->block_len =3D s_hdl->hdl_list_len + s_hdl->block_len * 2; s_hdl->hdl_list =3D (unsigned int*) malloc(s_hdl->block_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, s_hdl->block_le= n, (unsigned int) s_hdl->hdl_list); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, s_hdl->bloc= k_len, s_hdl->hdl_list); =20=09 memcpy(s_hdl->hdl_list, tmp, s_hdl->hdl_list_len); if (tmp) { - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp); free(tmp); } } @@ -513,8 +490,6 @@ s_hdl->hdl_list_len +=3D sizeof(unsigned int); } } -=20=20 -#undef FNC } =20 void @@ -525,8 +500,6 @@ unsigned int* get_more_rec_hdl(unsigned short service_class, int fd) { -#define FNC "get_more_rec_hdl: " - rec_hdl_search_struct s_hdl; char tmp_ch[12]; unsigned int *tmp; @@ -537,18 +510,18 @@ sprintf(tmp_ch, "0x%04x", service_class); s_hdl.uuid =3D get_from_xml(fd, "Protocols", NULL, tmp_ch);=20 =20=20=20=20=20 - /* If we didn't find the service class among the protocols we look in it + /* If we didn't find the service class among the protocols we look for it among the ServiceClasses */ if (s_hdl.uuid =3D=3D NULL) { - D_RHDL(FNC"Didn't find Protocol name for uuid 0x%04x among the protoco= ls\n" - ,service_class); + D_RHDL("Didn't find Protocol name for uuid 0x%04x among the protocols", + service_class); s_hdl.uuid =3D get_from_xml(fd, "ServiceClasses", NULL, tmp_ch);=20 =20 /* If we still didn't find the sevice class, we return NULL */ if (s_hdl.uuid =3D=3D NULL) { - D_RHDL(FNC"Didn't find Protocol name for uuid 0x%04x\n",service_clas= s); + D_RHDL("Didn't find Protocol name for uuid 0x%04x", service_class); return NULL; } } @@ -572,12 +545,12 @@ s_hdl.block_len +=3D 1; =20=20=20=20=20 s_hdl.hdl_list =3D (unsigned int*) malloc(tmp_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, tmp_len, (in= t) s_hdl.hdl_list); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, tmp_len, s_hdl.= hdl_list); =20=20=20=20=20 memcpy(s_hdl.hdl_list, tmp, s_hdl.hdl_list_len); if (tmp) { - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp); free(tmp); } } @@ -585,26 +558,22 @@ s_hdl.hdl_list_len +=3D sizeof(unsigned int); =20=20=20 return s_hdl.hdl_list; -=20=20 -#undef FNC } =20 char* get_attribute_range(int fd, unsigned int record_handle, unsigned int attr_id_code) { -#define FNC "get_attribute_range: " -=20=20 int *attr_lst, i =3D 1, pos =3D 0; char *tmp_ptr; char *return_sequence; =20 /* FIXME: But for now 256 bytes will do */ return_sequence =3D (char*) malloc(256); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, 256, (int) ret= urn_sequence); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, 256, return_seque= nce); =20=20=20 =20=20=20 - D_ATTR(FNC" A range of attributes was requested 0x%04x - 0x%04x\n", + D_ATTR("A range of attributes was requested 0x%04x - 0x%04x", (attr_id_code >> 16), (attr_id_code & 0xffff)); =20=20=20 /* Lists all attributes registerd in the database */ @@ -619,12 +588,12 @@ { i++; } - D_ATTR(FNC"attr_lst[0]: %d, attr_id_code: 0x%04x\n", + D_ATTR("attr_lst[0]: %d, attr_id_code: 0x%04x", attr_lst[0], attr_id_code); =20=20=20 while ((i < attr_lst[0]) && (attr_lst[i] <=3D (attr_id_code & 0xffff))) { - D_REC(FNC"attr_lst[%d]: 0x%04x\n", i, attr_lst[i]); + D_REC("attr_lst[%d]: 0x%04x", i, attr_lst[i]); /* we mask the attribute her so we don't by misstake send a range as input */ tmp_ptr =3D get_attribute_list(fd, record_handle, attr_lst[i] & 0xffff= ); @@ -633,17 +602,17 @@ { memcpy(return_sequence + pos, tmp_ptr + 2, tmp_ptr[1]); pos +=3D tmp_ptr[1]; - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) tmp_ptr); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } i++; } =20=20=20 return_sequence[1] =3D pos - 2; - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) attr_lst); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, attr_lst); free(attr_lst); =20 - PRINT_DATA(FNC"return_sequence\n", return_sequence, return_sequence[1] += 2); + PRINT_DATA(__FUNCTION__ ": return_sequence", return_sequence, return_seq= uence[1] + 2); =20=20=20 if (return_sequence[1] =3D=3D 0) { @@ -654,8 +623,6 @@ { return return_sequence; } -=20=20 -#undef FNC } =20 void init_attribute_search_struct(sdp_attribute_search *search_struct) @@ -679,7 +646,6 @@ get_attribute_list(int fd, unsigned int record_handle, unsigned short attr_id_code) { -#define FNC "get_attribute_list: " #define SEQ_LEN 256 =20 XML_Parser p; @@ -692,7 +658,7 @@ =20 init_attribute_search_struct(&search_struct); =20=20=20 - D_ATTR(FNC" Searching for attribute 0x%04x for record handle 0x%08x\n", + D_ATTR("Searching for attribute 0x%04x for record handle 0x%08x", attr_id_code, record_handle); =20=20=20 search_struct.attribute_id =3D attr_id_code; @@ -701,27 +667,26 @@ =20 if (search_struct.attribute_name =3D=3D NULL) { - fprintf(stderr, FNC"Didn't find service attribute id name for uuid 0x%= 04x\n", - attr_id_code); + fprintf(stderr, __FUNCTION__ ": Didn't find service attribute id name = for uuid 0x%04x\n", attr_id_code); return NULL; } =20=20=20 - D_ATTR(FNC"Found %s\n", search_struct.attribute_name); + D_ATTR("Found %s", search_struct.attribute_name); =20 sprintf(tmp, "0x%08x", record_handle); search_struct.service_class =3D get_from_xml(fd, NULL, "ServiceRecordHan= dle", tmp); =20=20=20 if (search_struct.service_class =3D=3D NULL) { - fprintf(stderr, FNC"Didn't find service class name for RecordHandle 0x= %08x\n", record_handle); + fprintf(stderr, __FUNCTION__ ": Didn't find service class name for Rec= ordHandle 0x%08x\n", record_handle); =20 set_err(SDP_INVALID_SERVICE_RECORD_HANDLE); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.attribu= te_name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); free(search_struct.attribute_name); return NULL; } =20=20=20 - D_ATTR(FNC"Found %s\n", search_struct.service_class); + D_ATTR("Found %s", search_struct.service_class); =20 p =3D XML_ParserCreate(NULL); XML_SetElementHandler(p, get_attribute_list_start, get_attribute_list_en= d); @@ -734,7 +699,7 @@ =20 if (search_struct.attrlist_index =3D=3D 0) { - D_ATTR(FNC" Didn't find the attribute values for the attribute %s\n", + D_ATTR("Didn't find the attribute values for the attribute %s", search_struct.attribute_name); return NULL; } @@ -745,32 +710,29 @@ hex_tmp =3D char2hex(char_tmp); =20 return_sequence =3D (char*) malloc(len + 2); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, len + 2, (int)= return_sequence); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, len + 2, return_s= equence); =20=20=20 return_sequence[0] =3D 0x35; return_sequence[1] =3D len; memcpy(return_sequence + 2, hex_tmp, len); =20=20=20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) char_tmp); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, char_tmp); free(char_tmp); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) hex_tmp); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, hex_tmp); free(hex_tmp); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.attribute= _name); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.attribute_name); free(search_struct.attribute_name); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.service_c= lass); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, search_struct.service_class); free(search_struct.service_class); =20 - PRINT_DATA(FNC"return value\n", return_sequence, len + 2); + PRINT_DATA(__FUNCTION__ ": return value", return_sequence, len + 2); =20 return return_sequence; -=20=20 -#undef FNC } =20 void get_attribute_list_start(void *data, const char *el, const char **attr) { -#define FNC "get_attribute_list_start: " int i; sdp_attribute_search *search_struct; =20 @@ -780,7 +742,7 @@ service_class_found parameter to TRUE */ if (strcmp(el, search_struct->service_class) =3D=3D 0) { - S_FNC(FNC"Found service class %s\n", el); + S_FNC("Found service class %s", el); search_struct->service_class_found +=3D 1; } if (search_struct->service_class_found) @@ -791,7 +753,7 @@ { search_struct->attribute_name_found =3D 1; =20=20=20=20=20=20=20 - S_FNC(FNC"Found attribute name %s\n", el); + S_FNC("Found attribute name %s", el); =20 /* We then inserts the attribute id code of the attribute type we ha= ve found */ @@ -806,15 +768,15 @@ if (strcmp(attr[i], "NbrOfEntities") =3D=3D 0) { search_struct->attr2get =3D atoi(attr[i + 1]); - S_FNC(FNC"attr2get: %d\n", atoi(attr[i + 1])); + S_FNC("attr2get: %d", atoi(attr[i + 1])); /* Set the data element sequence header */ strcpy(search_struct->attrlist + search_struct->attrlist_index, S_DES_H= DR0); search_struct->attrlist_index +=3D strlen(S_DES_HDR0) + 1; } /* Otherwise the wole attribute may be stored as a data element sequence */ - else if (attr[i] && attr[i + 1] && (strcmp(attr[i], "type") =3D=3D 0) - && (strcmp(attr[i + 1], "DES") =3D=3D 0)) + else if (attr[i] && attr[i + 1] && (strcmp(attr[i], "type") =3D=3D= 0) && + (strcmp(attr[i + 1], "DES") =3D=3D 0)) { /* Set the data element sequence header */ strcpy(search_struct->attrlist + search_struct->attrlist_index, S_DES_H= DR1); @@ -863,7 +825,6 @@ the function get_values */ } } -#undef FNC } =20 =20 @@ -878,13 +839,13 @@ can se whether it was the last end tag for the service class or not*/ if (strcmp(el, search_hdl->service_class) =3D=3D 0) { - S_FNC("get_attribute_list_end: Found %s\n", el); + S_FNC("Found %s", el); search_hdl->service_class_found -=3D 1; } /* If we have found the attribute name end tag, there are no more attrib= utes to find */ - else if ((strcmp(el, search_hdl->attribute_name) =3D=3D 0) - && (search_hdl->service_class_found)) + else if ((strcmp(el, search_hdl->attribute_name) =3D=3D 0) && + (search_hdl->service_class_found)) { search_hdl->attribute_name_found =3D 0; } @@ -904,7 +865,6 @@ void get_attribute_char_data(void *userData, const XML_Char *s, int len) { -#define FNC "get_attribute_char_data: " sdp_attribute_search *search_hdl =3D (sdp_attribute_search*) userData; int i =3D 0; =20 @@ -947,7 +907,6 @@ strncpy(search_hdl->attrlist + search_hdl->attrlist_index, "\0", 1); search_hdl->attrlist_index +=3D 1; } -#undef FNC } =20 /* This function search the xml file for the one of tag, attr or val that = is @@ -957,7 +916,6 @@ char* get_from_xml(int fd, char *tag, char *attr, unsigned char *val) { -#define FNC "get_from_xml: " #define TAG 0 #define ATTR 1 #define VAL 2 @@ -976,7 +934,7 @@ =20=20=20 if (!tag) { - S_FNC(FNC"Looking for tag\n"); + S_FNC("Looking for tag"); set_value =3D TAG; } =20 @@ -984,10 +942,10 @@ {=20=20=20=20 if (set_value !=3D -1) { - fprintf(stderr, FNC"Error more the one attribute =3D=3D NULL\n"); + fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D = NULL\n"); return NULL; } - S_FNC(FNC"Looking for attribute\n"); + S_FNC("Looking for attribute"); set_value =3D ATTR; } =20=20=20 @@ -995,10 +953,10 @@ { if (set_value !=3D -1) { - fprintf(stderr, FNC"Error more the one attribute =3D=3D NULL\n"); + fprintf(stderr, __FUNCTION__ ": Error more the one attribute =3D=3D = NULL\n"); return NULL; } - S_FNC(FNC"Looking for value\n"); + S_FNC("Looking for value"); set_value =3D VAL; } =20=20=20 @@ -1024,7 +982,6 @@ #undef TAG #undef ATTR #undef VAl -#undef FNC } =20 =20 @@ -1039,15 +996,15 @@ { if (strcmp(el, search_hdl->search_name) =3D=3D 0) { - S_FNC("get_start: Found %s\n", el); + S_FNC("Found %s", el); for (i =3D 0; attr[i]; i +=3D 2) { if (strcmp(attr[i + 1], search_hdl->search_val) =3D=3D 0) { - S_FNC("get_start: Found %s\n", attr[i]); + S_FNC("Found %s", attr[i]); m_size =3D strlen(attr[i] + 1); search_hdl->search_attr =3D (char*) malloc(m_size); - D_MEM("---> malloc%d % d bytes at 0x%08x\n", malloc_dbg++, m_size, (int= ) search_hdl->search_attr); + D_MEM("---> malloc%d % d bytes at 0x%8p", malloc_dbg++, m_size, = search_hdl->search_attr); strcpy(search_hdl->search_attr, attr[i]); return; } @@ -1058,15 +1015,15 @@ { if (strcmp(el, search_hdl->search_name) =3D=3D 0) { - S_FNC("get_start: Found %s\n", el); + S_FNC("Found %s", el); for (i =3D 0; attr[i]; i +=3D 2) { if (strcmp(attr[i], search_hdl->search_attr) =3D=3D 0) { - S_FNC("get_start: Found %s\n", attr[i + 1]); + S_FNC("Found %s", attr[i + 1]); m_size =3D strlen(attr[i + 1] + 1); search_hdl->search_val =3D (char*) malloc(m_size); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int)= search_hdl->search_val); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, s= earch_hdl->search_val); strcpy(search_hdl->search_val, attr[i + 1]); return; } @@ -1077,12 +1034,12 @@ { for (i =3D 0; attr[i]; i +=3D 2) { - if ((strcmp(search_hdl->search_attr, attr[i]) =3D=3D 0) - && (strcmp(search_hdl->search_val, attr[i + 1]) =3D=3D 0)) + if ((strcmp(search_hdl->search_attr, attr[i]) =3D=3D 0) && + (strcmp(search_hdl->search_val, attr[i + 1]) =3D=3D 0)) { m_size =3D strlen(el) + 1; search_hdl->search_name =3D (char*) malloc(m_size); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int) s= earch_hdl->search_name); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, sea= rch_hdl->search_name); strcpy(search_hdl->search_name, el); return; } @@ -1119,7 +1076,7 @@ =20 for (i =3D 1; i <=3D attr_lst[0]; i++) { - D_ATTR("Before free Attribute %d: 0x%04x\n", i , attr_lst[i]); + D_ATTR("Before free Attribute %d: 0x%04x", i , attr_lst[i]); } =20 XML_ParserFree(p); @@ -1127,13 +1084,13 @@ /* If we didn't find the service class we return here */ if (search_hdl.search_val =3D=3D NULL) { - D_ATTR("get_all_attributes: Didn't find anything\n"); + D_ATTR("Didn't find anything"); return 0; } =20 for (i =3D 1; i <=3D attr_lst[0]; i++) { - D_ATTR("Attribute %d: 0x%04x\n", i , attr_lst[i]); + D_ATTR("Attribute %d: 0x%04x", i , attr_lst[i]); } =20=20=20=20=20 return attr_lst; @@ -1148,25 +1105,25 @@ =20=20=20 if (strncmp(el, search_hdl->search_name, strlen(search_hdl->search_name)= ) =3D=3D0) { - S_FNC("get_all_start: Found %s\n", el); + S_FNC("Found %s", el); attr_cnt =3D XML_GetSpecifiedAttributeCount((XML_Parser*) data); /* Since attr_cnt is the count of both the attibutes and the attribute values, we have to divide it by 2 */ attr_cnt /=3D 2; =20=20=20=20=20 - S_FNC("get_all_start: %d attributes found\n", attr_cnt); + S_FNC("%d attributes found", attr_cnt); /* Allocate space for all the attribute UUIDs plus the attribute count in the search_output pointer, */ m_size =3D attr_cnt * 4 + 4; search_hdl->search_val =3D (char*) malloc(m_size); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, m_size, (int= )search_hdl->search_val); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, m_size, search_= hdl->search_val); memcpy(search_hdl->search_val, &attr_cnt, 4); for (i =3D 0; attr[i]; i +=3D 2) { unsigned int tmp; tmp =3D (unsigned int)strtol(attr[i + 1], NULL, 16);=20 memcpy(search_hdl->search_val + 4 +(i * 2), &tmp ,4); - S_FNC(__FUNCTION__", Attribute %d found \n", tmp); + S_FNC("Attribute %d found", tmp); }=20 } } @@ -1177,38 +1134,32 @@ =20 void browse_database() { - - } =20 void browse_database_start(void *data, const char *el, const char **attr) { -=09 } =20 void browse_database_end(void *data, const char *el) { - } =20 void handle_query(database_query_struct *db_hdl) { -#define FNC "handle_query: " - switch (db_hdl->pkt_type) { case SDP_SERVICESEARCH_REQ: - D_REC(FNC" Got SDP_SERVICESEARCH_REQ\n"); + D_REC("Got SDP_SERVICESEARCH_REQ"); handle_service_search_req((service_search_struct*) db_hdl); break; =20=20=20 case SDP_SERVICEATTR_REQ: - D_REC(FNC"Got SDP_SERVICEATTR_REQ\n"); + D_REC("Got SDP_SERVICEATTR_REQ"); handle_service_attr_req((service_attr_struct*) db_hdl); break; =20=20=20 case SDP_SERVICESEARCHATTR_REQ: - D_REC(FNC"Got SDP_SERVICESEARCHATTR_REQ\n"); + D_REC("Got SDP_SERVICESEARCHATTR_REQ"); handle_service_search_attr_req((service_search_attr_struct*) db_hdl); break; =20=20=20=20=20 @@ -1216,8 +1167,6 @@ fprintf(stderr, "Unrecognised packet 0x%02x\n", db_hdl->pkt_type); break; } - -#undef FNC } =20 /* FIXME: Add features to handle continuation states and multiple service @@ -1226,8 +1175,6 @@ void=20 handle_service_search_req(service_search_struct *db_hdl) { -#define FNC "handle_service_search_req: " - unsigned char rsp_pkt[256]; int rsp_pkt_len; unsigned int rec_hdl, rec_hdl_cnt =3D 0; @@ -1243,13 +1190,13 @@ =20 rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd); =20=20=20 - D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl); + D_REC("Got Record handle: 0x%08x", rec_hdl); if (rec_hdl_list) { i =3D 0; while (rec_hdl_list[i] !=3D NO_REC_HDL) { - D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl_list[i]); + D_REC("Got Record handle: 0x%08x", rec_hdl_list[i]); if (rec_hdl =3D=3D rec_hdl_list[i]) { rec_hdl_cnt -=3D 1; @@ -1291,7 +1238,7 @@ rsp_pkt[rsp_pkt_len + 3] =3D rec_hdl_list[i] & 0xff; rsp_pkt_len +=3D 4; } - D_MEM("<--- free%d 0x%08x\n", malloc_dbg--, (unsigned int)rec_hdl_list= ); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); free(rec_hdl_list); } =20=20=20 @@ -1301,14 +1248,11 @@ rsp_pkt_len =3D set_cont_state_search(rsp_pkt, rsp_pkt_len, db_hdl->max_= rec_cnt); =20 write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 -#undef FNC } =20 void=20 handle_service_attr_req(service_attr_struct *db_hdl) { -#define FNC "handle_service_attr_req: " - unsigned char rsp_pkt[256]; int rsp_pkt_len, i, des_len_pos; unsigned char *tmp_ptr; @@ -1335,7 +1279,7 @@ memcpy(rsp_pkt + rsp_pkt_len, tmp_ptr + 2, tmp_ptr[1]); rsp_pkt_len +=3D tmp_ptr[1] ; =20=20=20=20=20=20=20 - D_MEM("<--- free %d 0x%08x\n", malloc_dbg--, (int) tmp_ptr); + D_MEM("<--- free %d 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } else @@ -1365,13 +1309,11 @@ rsp_pkt_len =3D set_cont_state_attr(rsp_pkt, rsp_pkt_len,db_hdl->max_att= r_byte_cnt); =20 write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 -#undef FNC } =20 void=20 handle_service_search_attr_req(service_search_attr_struct *db_hdl) { -#define FNC "handle_service_search_attr_req: " unsigned char *tmp_ptr; unsigned int rec_hdl; unsigned int *rec_hdl_list; @@ -1381,7 +1323,7 @@ =20 rec_hdl =3D get_record_handle(db_hdl->service_class_list[0], xml_fd); =20 - D_REC(FNC"Got Record handle: 0x%08x\n", rec_hdl); + D_REC("Got Record handle: 0x%08x", rec_hdl); =20=20=20 rec_hdl_list =3D get_more_rec_hdl(db_hdl->service_class_list[0], xml_fd); =20=20=20 @@ -1392,12 +1334,12 @@ { if (rec_hdl_list[i] !=3D rec_hdl) { - D_REC(FNC"Got Record handle list %d: 0x%08x\n", i, rec_hdl_list[i]); + D_REC("Got Record handle list %d: 0x%08x", i, rec_hdl_list[i]); j++; } else { - D_REC(FNC"Dupplicated record handle %d: 0x%08x\n", i, rec_hdl_list[i]); + D_REC("Dupplicated record handle %d: 0x%08x", i, rec_hdl_list[i]); } } rec_hdl_cnt +=3D j; @@ -1430,13 +1372,13 @@ } if (tmp_ptr) { - printf(FNC"Copying %d bytes to rsp_pkt\n", tmp_ptr[1]); + printf(__FUNCTION__ ": Copying %d bytes to rsp_pkt\n", tmp_ptr[1]); memcpy(rsp_pkt + rsp_pkt_len + tmp_len, tmp_ptr + 2, tmp_ptr[1]); tmp_len +=3D tmp_ptr[1]; =20=20=20=20=20=20=20=20=20=20=20 - printf(FNC"list_len:%d\n", tmp_len); + printf(__FUNCTION__ ": list_len: %d\n", tmp_len); =20=20=20=20=20=20=20=20=20 - D_MEM("<--- free tmp_ptr 0x%08x\n",malloc_dbg--, (unsigned int) tm= p_ptr); + D_MEM("<--- free%d tmp_ptr 0x%8p", --malloc_dbg, tmp_ptr); free(tmp_ptr); } } @@ -1449,7 +1391,7 @@ } if (rec_hdl_list !=3D &rec_hdl) { - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) rec_hdl_list= ); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, rec_hdl_list); free(rec_hdl_list); } =20 @@ -1471,8 +1413,6 @@ =20=20=20 /* FIXME: Add features to handle continuation state packets */ write2stack(db_hdl->db.sdp_con_id, rsp_pkt, rsp_pkt_len);=20 -=20=20 -#undef FNC=09 } =20 int @@ -1485,7 +1425,7 @@ =20 if (cur_rec_cnt > max_rec_cnt) { - S_FNC(__FUNCTION__", Setting cont state, cur_rec_cnt:%d, max_rec_cnt:%= d\n", + S_FNC("Setting cont state, cur_rec_cnt:%d, max_rec_cnt:%d", cur_rec_cnt, max_rec_cnt); =20 pkt[5] =3D SHORT2CHAR_MS(max_rec_cnt); @@ -1494,7 +1434,7 @@ pkt[7] =3D SHORT2CHAR_MS(max_rec_cnt); pkt[8] =3D SHORT2CHAR_LS(max_rec_cnt); =20=20=20=20=20 - /* There are cnt_len byte to much to fit the data in one packet */ + /* There are cnt_len byte too much to fit the data in one packet */ cnt_len =3D (cur_rec_cnt - max_rec_cnt) * 4; =20=20=20=20=20 /* The packet can't be longer than this, excluding the continuation st= ate @@ -1502,10 +1442,10 @@ len -=3D cnt_len; =20=20=20=20=20 cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc= t) + cnt_len); - D_MEM("---> malloc%d %d bytes at %p\n", malloc_dbg++, sizeof(cont_stat= e_struct) + cnt_len, cont_state_buf); + D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cnt_len, cont_state_buf); =20 cont_state_buf->pdu =3D pkt[0]; - D_MISC("set_cont_state_attr: PDU:0x%02x\n", pkt[0]); + D_MISC("PDU: 0x%02x", pkt[0]); =20=20=20=20=20 cont_state_buf->len =3D cnt_len; memcpy(cont_state_buf->data, pkt + len, cnt_len); @@ -1540,25 +1480,27 @@ =20=20=20 cur_attr_cnt =3D CHAR2INT16(pkt[5], pkt[6]); =20 - S_FNC(__FUNCTION__", len %d, max_attr_len %d, cur_attr_cnt %d\n", len, m= ax_attr_len, cur_attr_cnt); + S_FNC("len %d, max_attr_len %d, cur_attr_cnt %d", len, max_attr_len, cur= _attr_cnt); =20 - PRINT_DATA("set_cont_state_attr", pkt, len); + PRINT_DATA(__FUNCTION__, pkt, len); =20 if (max_attr_len < cur_attr_cnt) { - S_FNC("set_cont_state_attr: max_attr_len:%d, cur_attr_cnt:%d and packe= t length:%d\n", max_attr_len, cur_attr_cnt, len); + S_FNC("max_attr_len:%d, cur_attr_cnt:%d and packet length:%d", max_att= r_len, cur_attr_cnt, len); =20=20=20=20=20 /* There are cont_len byte to much to fit the data in one packet */ cont_len =3D cur_attr_cnt - max_attr_len; + /* The packet can't be longer than this, excluding the continuation st= ate bytes */ len -=3D cont_len; =20=20=20=20 cont_state_buf =3D (cont_state_struct*) malloc(sizeof(cont_state_struc= t) + cont_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, sizeof(cont_= state_struct) + cont_len , (unsigned int)cont_state_buf); + D_MEM("---> malloc%d %ld bytes at 0x%8p", malloc_dbg++, sizeof(cont_st= ate_struct) + cont_len , cont_state_buf); =20 cont_state_buf->pdu =3D pkt[0]; - D_MISC("set_cont_state_attr: PDU:0x%02x\n", pkt[0]); + D_MISC("PDU: 0x%02x", pkt[0]); + cont_state_buf->len =3D cont_len; memcpy(cont_state_buf->data, pkt + len, cont_len); =20 @@ -1572,14 +1514,14 @@ } else { - S_FNC(__FUNCTION__", No continuation State set\n"); + S_FNC("No continuation State set"); pkt[len] =3D 0; len +=3D 1; } =20=20=20 /* Change the length field */ =20 - S_FNC(__FUNCTION__", Changing length field\n"); + S_FNC("Changing length field"); pkt[3] =3D SHORT2CHAR_MS(len- SDP_HDR_SIZE); pkt[4] =3D SHORT2CHAR_LS(len -SDP_HDR_SIZE); =20=20=20 @@ -1600,12 +1542,12 @@ { if ((max_rec_cnt * 4) >=3D cont_state_buf->len) { - /* Allocate space for the SDP header the attribute byte count field, - the attribytes and the continuation state field */ + /* Allocate space for the SDP header, the attribute byte count field, + the attributes and the continuation state field */ send_len =3D SDP_HDR_SIZE + 2 + 2 + cont_state_buf->len + 1; =20=20=20=20=20=20=20 send_buf =3D (unsigned char*) malloc(send_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++, send_len, = (unsigned int) send_buf); + D_MEM("---> malloc%d %d bytes at 0x%8p", malloc_dbg++, send_len, sen= d_buf); =20 set_sdp_hdr(send_buf, cont_state_buf->pdu, trans_id, send_len - SDP_= HDR_SIZE); =20 @@ -1624,13 +1566,12 @@ /* Send the whole buffer */ write2stack(sdp_con_id, send_buf, send_len); =20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) cont_state= _buf); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, cont_state_buf); free(cont_state_buf); cont_state_buf =3D NULL; =20=20=20=20=20=20=20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (unsigned int) send_buf); + D_MEM("<--- free%d 0x%8p", --malloc_dbg, send_buf); free(send_bu... [truncated message content] |
From: Peter K. <pk...@us...> - 2001-03-25 09:50:04
|
The following file was modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_server.c 1.17 1.18=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Use the defines for the error messages. The diff of the modified file(s): --- sdp_server.c 2001/02/27 15:32:14 1.17 +++ sdp_server.c 2001/03/25 09:50:02 1.18 @@ -715,7 +715,7 @@ { fprintf(stderr, FNC"Didn't find service class name for RecordHandle 0x= %08x\n", record_handle); =20 - set_err(2); + set_err(SDP_INVALID_SERVICE_RECORD_HANDLE); D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) search_struct.attribu= te_name); free(search_struct.attribute_name); return NULL; @@ -1340,8 +1340,8 @@ } else { - int err; - err =3D get_err(); + int err =3D get_err(); + if (err) { send_error_rsp(db_hdl->db.sdp_con_id, db_hdl->db.trans_id, err); @@ -1594,7 +1594,7 @@ int send_len; =20=20=20 if (!cont_state_buf) { - send_error_rsp(sdp_con_id, trans_id, 5); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_CONTINUATION_STATE); } else { @@ -1638,7 +1638,7 @@ =20 /* FIXME: Have to implement this too... */ =20 - send_error_rsp(sdp_con_id, trans_id, 1); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_SDP_VERSION); } } } @@ -1651,7 +1651,7 @@ int send_len; =20=20=20 if (!cont_state_buf) { - send_error_rsp(sdp_con_id, trans_id, 5); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_CONTINUATION_STATE); } else { @@ -1691,7 +1691,7 @@ =20 /* FIXME: Have to implement this too... */ =20 - send_error_rsp(sdp_con_id, trans_id, 1); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_SDP_VERSION); } } } |
From: Peter K. <pk...@us...> - 2001-03-25 09:32:05
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sdp.c 1.68 1.69=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Made it compile in user mode stack again. The diff of the modified file(s): --- sdp.c 2001/03/23 15:21:04 1.68 +++ sdp.c 2001/03/25 09:32:03 1.69 @@ -412,8 +412,11 @@ } }=20=20 =20 +#ifdef __KERNEL__ unsubscribe_bt_buf(db_write_tx_buf); + db_write_tx_buf =3D NULL; db_write_recv =3D 0; +#endif } =20 #ifdef __KERNEL__ |
From: Gordon M. <gm...@us...> - 2001-03-24 21:12:10
|
The following files were modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- Config.in 1.7.2.1 1.7.2.2=20=20=20=20=20=20=20=20=20 bluetooth.c 1.154.2.3 1.154.2.4=20=20=20=20=20=20=20 btmem.c 1.37 1.37.2.1=20=20=20=20=20=20=20=20 hci.c 1.132.2.3 1.132.2.4=20=20=20=20=20=20=20 sdp.c 1.67 1.67.2.1=20=20=20=20=20=20=20=20 The accompanying log: Merged from trunk The diff of the modified file(s): --- Config.in 2001/03/20 16:48:15 1.7.2.1 +++ Config.in 2001/03/24 21:11:38 1.7.2.2 @@ -15,7 +15,7 @@ bool ' Allow connectionless L2CAP' CONFIG_BLUETOOTH_L2CAP_CONNECTIONLESS bool ' Enable TCI' CONFIG_BLUETOOTH_USE_TCI bool ' HCI Inquiry' CONFIG_BLUETOOTH_HCI_INQUIRY - bool ' Kernel Thread' CONFIG_BLUETOOTH_KERNEL_THREAD + bool ' Enable M/S Switch' CONFIG_BLUETOOTH_ENABLE_MSSWITCH =20 choice ' Bluetooth hardware type' \ "None CONFIG_BLUETOOTH_NOINIT \ --- bluetooth.c 2001/03/24 19:37:17 1.154.2.3 +++ bluetooth.c 2001/03/24 21:11:38 1.154.2.4 @@ -735,8 +735,9 @@ inq_res)) < 0) goto end_inquiry; =20 - copy_to_user((s32*)arg, inq_res, sizeof(inquiry_results) + 6 *=20 - inq_res->nbr_of_units); + copy_to_user((s32*)arg, inq_res, sizeof(inquiry_results) + + 6 * inq_res->nbr_of_units); + end_inquiry: kfree(inq_res); return ret; --- btmem.c 2001/03/02 21:52:15 1.37 +++ btmem.c 2001/03/24 21:11:38 1.37.2.1 @@ -214,7 +214,6 @@ =20 bt_tx_buf* subscribe_bt_buf(s32 send_len) { -#define FNC "subscribe_bt_buf : " bt_tx_buf *tx; s32 buf_len; /* Total size of bt_tx_object */ u32 head_free; @@ -222,7 +221,7 @@ =20 cli(); buf_len =3D send_len + BT_TX_HDRSIZE;=20=20 - D_MEM(FNC"buf_len %d\n", buf_len); + D_MEM(__FUNCTION__ ": buf_len %d\n", buf_len); =20 /*=20=20 'Normal' case @@ -239,13 +238,11 @@ get_bt_buf(); =20 if (bt_buf.free > bt_buf.send) { -=20=20=20=20 tail_free =3D (bt_buf.tail - bt_buf.free); head_free =3D (bt_buf.send - bt_buf.head); =20 if (tail_free >=3D buf_len) { - - D_MEM(FNC"subscribe in tail at pos %d\n",=20 + D_MEM(__FUNCTION__ ": subscribe in tail at pos %d\n",=20 bt_buf.free - bt_buf.head); tx =3D (bt_tx_buf *)bt_buf.free; /* Don't touch send, only update free and count */ @@ -253,7 +250,6 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else if (head_free >=3D buf_len) {=20=20 - D_MEM("No room in tail, subscribe at head (WRAP!)\n"); tx =3D (bt_tx_buf *)bt_buf.head; =20=09=09=09 @@ -264,9 +260,8 @@ bt_buf.nbr_bufs++; bt_buf.count +=3D buf_len; } else { - - D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len); - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len); + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); =20 #if PANIC_AT_ERROR @@ -277,7 +272,6 @@ return NULL; } } else if (bt_buf.free <=3D bt_buf.send) { -=20=20=20=20 /* 'Wrap' case */ tail_free =3D (bt_buf.send - bt_buf.free); head_free =3D 0; /* head_free is not interesting since we cannot=20 @@ -286,7 +280,6 @@ buffer! (Fragmentation) */ =20=20=20=20=20 if (tail_free >=3D buf_len) { - D_MEM("Wrapped buffer, subscribe at free (pos %d)\n",=20 bt_buf.free - bt_buf.head); tx =3D (bt_tx_buf *)bt_buf.free; @@ -294,13 +287,12 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else if (!bt_buf.count) { - /* If buffer empty, reset buffer */=20=20=20=20=20=20=20=20=20=20 btmem_reset(); =20=09=09=09 if (buf_len > bt_buf.size) { - D_ERR(FNC"Cannot subscribe %d bytes !\n", send_len);=20 - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Cannot subscribe %d bytes !\n", send_len);=20 + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); btmem_get_status(NULL); sti(); @@ -314,9 +306,9 @@ bt_buf.count +=3D buf_len; bt_buf.nbr_bufs++; } else { - D_ERR(FNC"Cannot subscribe requested size (%d) !\n",=20 + D_ERR(__FUNCTION__ ": Cannot subscribe requested size (%d) !\n",=20 send_len); - D_ERR(FNC"Only %d available (non - fragmented)\n", + D_ERR(__FUNCTION__ ": Only %d available (non - fragmented)\n", buf_write_room()); btmem_get_status(NULL); #if PANIC_AT_ERROR @@ -333,7 +325,6 @@ =20 sti(); return tx; -#undef FNC } =20 /* Returns number of buffers */ @@ -343,7 +334,6 @@ return bt_buf.nbr_bufs; } =20 - /* Returns total number of bytes in buffer (fragmented) */ =20 s32 buf_byte_count() @@ -351,7 +341,6 @@ return bt_buf.count; } =20 - /* Returns unfragmented buffer space */=20 =20 #define BTMEM_EXTRASPACE BT_BUF_SIZE/10 /* always an extra 10 % marginal @@ -375,7 +364,6 @@ don't count a tossed tail ! */ space_left =3D (BT_BUF_SIZE -=20 (bt_buf.tail - bt_buf.toss_tail) - bt_buf.count); -=20=20 } =20 space_left -=3D (BT_TX_HDRSIZE+BTMEM_EXTRASPACE); @@ -412,8 +400,7 @@ =20 tx =3D (bt_tx_buf *)(bt_buf.send); =20 - if (tx->magic !=3D 0x4321) - { + if (tx->magic !=3D 0x4321) { D_ERR("get_bt_buf : wrong magic!\n"); #if PANIC_AT_ERROR panic("lets stop here...\n"); @@ -442,32 +429,32 @@ =20 void unsubscribe_bt_buf(bt_tx_buf *tx) { -#define FNC "unsubscribe_bt_buf : " s32 tail_free; /* for debug */ s32 head_free; =20=20=20 - D_MEM(FNC"%d bytes (not incl hdrs) at pos %d\n",=20 + if (!tx) + return; + + D_MEM(__FUNCTION__ ": %d bytes (not incl hdrs) at pos %d\n",=20 tx->subscr_len, (u8 *)tx - bt_buf.head); =20=20=20 /* Check that tx is valid for unssubscribe. We must process the=20 buffers in fifo order ! */ =20 cli(); - if (tx && (bt_buf.send =3D=3D (u8*)tx)) { - + if (bt_buf.send =3D=3D (u8*)tx) { if ((u8*)(tx->data + tx->subscr_len) <=3D bt_buf.tail) { -=20=20=20=20=20=20 /* don't touch free, only subscribe_bt_buf change free */ bt_buf.send +=3D (tx->subscr_len + BT_TX_HDRSIZE); bt_buf.count -=3D (tx->subscr_len + BT_TX_HDRSIZE); bt_buf.nbr_bufs--;=20=20=20=20=20=20 } else { - D_ERR(FNC"failed, out of boundary\n"); + D_ERR(__FUNCTION__ ": failed, out of boundary\n"); } } else if (bt_buf.count =3D=3D 0) - D_MEM(FNC"no data in buffer\n"); + D_MEM(__FUNCTION__ ": no data in buffer\n"); else { - D_ERR(FNC"invalid data segment!\n"); + D_ERR(__FUNCTION__ ": invalid data segment!\n"); #ifdef __KERNEL__ =20 D_ERR("pid : %d (tx:0x%x - send:0x%x=3D%d) send:%ld free:%ld\n", @@ -495,7 +482,7 @@ =20 /* Is also checked done in get_bt_buf */ if (bt_buf.send =3D=3D bt_buf.toss_tail) { - D_MEM(FNC"toss_tail, now send pos is 0\n"); + D_MEM(__FUNCTION__ ": toss_tail, now send pos is 0\n"); bt_buf.send =3D bt_buf.head; bt_buf.toss_tail =3D bt_buf.tail; =20 @@ -603,13 +590,11 @@ bt_tx_buf *tx; =20=20=20=20 for (i =3D 0; i < count; i++) { - if (cursize > buf_write_room()) return; =20=09=20=20=20=20=20 printk("storing %d bytes packets\n", cursize); while (buf_write_room() >=3D cursize) { -=09=20=20=20=20=20=20=20 if (!(tx =3D subscribe_bt_buf(cursize))) { return ; } --- hci.c 2001/03/21 23:23:25 1.132.2.3 +++ hci.c 2001/03/24 21:11:38 1.132.2.4 @@ -2189,7 +2189,7 @@ bytes2send =3D tx_buf->cur_len; } =20=09 - D_SND(__FUNCTION__", %d bytes \n", tx_buf->cur_len); + D_SND(__FUNCTION__", %d bytes \n", bytes2send); =20=09 /* while there is space in the hardware buffers and we have hci packets to send, we send them. After each sent packet --- sdp.c 2001/03/06 11:06:24 1.67 +++ sdp.c 2001/03/24 21:11:38 1.67.2.1 @@ -315,6 +315,11 @@ #endif /* LINUX_VERSION_CODE */ #endif /* __KERNEL__ */ =20 +//#ifdef __KERNEL__ +static bt_tx_buf *db_write_tx_buf; +static s32 db_write_recv; +//#endif + #ifndef __KERNEL__ static s32 sdp_sock; #endif @@ -406,6 +411,9 @@ sdp_disconnect_req(i); } }=20=20 + + unsubscribe_bt_buf(db_write_tx_buf); + db_write_recv =3D 0; } =20 #ifdef __KERNEL__ @@ -907,11 +915,7 @@ =20 len =3D MIN(count, database_query.count); =20 -#ifdef __KERNEL__ copy_to_user(buf, database_query.query, len); -#else - memcpy(buf, database_query.query, len); -#endif =20 if (database_query.count > len) { memmove(database_query.query, @@ -932,35 +936,60 @@ const char * buf, s32 count) #endif { + static data_struct db_hdl; sdp_tx_buf *sdp_buf; - bt_tx_buf *tx_buf; - data_struct *db_hdl =3D (data_struct*) buf; + s32 read1 =3D 0; + s32 read2 =3D 0; =20=09 D_PROC(__FUNCTION__ " Someone wrote %d bytes to sdp proc-file\n",count); =20 - D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = count, db_hdl->sdp_con_id); - PRINTPKT("Data to be sent to client:", db_hdl->data, db_hdl->len); + if (!bt_initiated()) + return 0; =20=09 - tx_buf =3D subscribe_bt_buf(sizeof(sdp_tx_buf) + db_hdl->len); + if (!db_write_tx_buf) { + read1 =3D MIN(sizeof db_hdl - db_write_recv, count); + copy_from_user(&db_hdl + db_write_recv, buf, read1); =20 - if (!tx_buf) { + db_write_recv +=3D read1; + + if (db_write_recv < sizeof db_hdl) + return read1; + + db_write_tx_buf =3D subscribe_bt_buf(sizeof *sdp_buf + db_hdl.len); + + if (!db_write_tx_buf) { D_ERR(__FUNCTION__ " failed to get tx buffer\n"); - return -1; + db_write_recv -=3D read1; + return -ENOMEM; } =20 - tx_buf->cur_len =3D db_hdl->len; - sdp_buf =3D (sdp_tx_buf*) (tx_buf->data); + db_write_tx_buf->cur_len =3D db_hdl.len; =20 -#ifdef __KERNEL__ - copy_from_user(sdp_buf->frame, db_hdl->data, db_hdl->len); -#else - memcpy(sdp_buf->frame, db_hdl->data, db_hdl->len); -#endif + count -=3D read1; + buf +=3D read1; + db_write_recv =3D 0; + } =20 - l2cap_send_data(tx_buf, sdp_con_list[db_hdl->sdp_con_id].l2cap); + sdp_buf =3D (sdp_tx_buf*)db_write_tx_buf->data; =20=09 - return count; + if (db_write_recv < db_hdl.len) { + read2 =3D MIN(db_hdl.len - db_write_recv, count); + copy_from_user(sdp_buf->frame + db_write_recv, buf, read2); + db_write_recv +=3D read2; + + if (db_write_recv < db_hdl.len) + return read1 + read2; } + + D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = db_hdl.len, db_hdl.sdp_con_id); + PRINTPKT("Data to be sent to client:", db_hdl.data, db_hdl.len); + + l2cap_send_data(db_write_tx_buf, sdp_con_list[db_hdl.sdp_con_id].l2cap); + db_write_tx_buf =3D NULL; + db_write_recv =3D 0; + + return read1 + read2; +} #else /* __KERNEL__ */ =20 s32 sdp_doquery(s32 fd, u8 *request, s32 len) @@ -968,11 +997,13 @@ s32 n; u8 tmpbuf[512]; data_struct *db_hdl; + s32 recv; =20 D_XMIT("sdp_doquery : sending request %d bytes\n", len); write(fd, request, len); =20=09 - n =3D read(fd, tmpbuf, 512); + if ((n =3D read(fd, tmpbuf, 512)) < 0) + return n; =20 D_REC(__FUNCTION__ ", Received %d bytes\n", n); =20=09 @@ -980,15 +1011,13 @@ =20=09 /* what if not all is written once */ =20 - if (n < (sizeof(data_struct) + db_hdl->len)) { - D_ERR("sdp_doquery : only got partial response n:%d, db_hdl->len:%d\n", = n, db_hdl->len); - print_data("The request is:", request, len); - return -1; - } + for (recv =3D n; recv < sizeof *db_hdl + db_hdl->len; recv +=3D n) + if ((n =3D read(fd, tmpbuf + recv, 512 - recv)) < 0) + return n; =20 sdp_send_data(&sdp_con_list[db_hdl->sdp_con_id], db_hdl->data, db_hdl->le= n);=20 =20=09 - return n; + return recv; } #endif =20 |
From: Gordon M. <gm...@us...> - 2001-03-24 21:12:09
|
The following files were modified in apps/bluetooth/experimental: Name Old version New version Comment ---- ----------- ----------- ------- Makefile 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20 bt_if.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20 bt_if.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 bt_ipa.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 bt_ipa.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 bt_misc.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20 bt_misc.h 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 bt_vendor.c 1.3 1.3.2.1=20=20=20=20=20=20=20=20=20 btcon.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 btd.c 1.4 1.4.2.1=20=20=20=20=20=20=20=20=20 btdisc.c 1.1 1.1.2.1=20=20=20=20=20=20=20=20=20 btinit.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20 bttest.c 1.2 1.2.2.1=20=20=20=20=20=20=20=20=20 The accompanying log: Merged from trunk The diff of the modified file(s): --- Makefile 2001/03/10 12:49:32 1.2 +++ Makefile 2001/03/24 21:11:38 1.2.2.1 @@ -5,12 +5,13 @@ include $(APPS)/Rules.elinux endif =20 -PROGS =3D btdm memul bti btinq btcon btsend btdisc +PROGS =3D btdm memul bti btinq bttest btcon btsend btdisc =20 # Define HAVE_READLINE_READLINE if you have readline support, with the inc= lude # files in $(include_dir)/readline. Define HAVE_READLINE if you have the # include files in $(include_dir). Define neither if you do not want to use # readline. + HAVE_READLINE_READLINE =3D 1 #HAVE_READLINE =3D 1 =20 @@ -19,13 +20,14 @@ INSTOWNER =3D root INSTGROUP =3D root =20 -BTDOBJS =3D btd.o bttest.o bt_ipa.o bt_vendor.o bt_if.o bt_misc.o +BTDOBJS =3D btd.o bt_ipa.o bt_vendor.o bt_if.o bt_misc.o MEMULOBJS =3D modememul.o bt_misc.o BTINITOBJS =3D btinit.o bt_vendor.o bt_if.o bt_misc.o BTCONOBJS =3D btcon.o bt_if.o bt_misc.o BTSENDOBJS =3D btsend.o bt_if.o bt_misc.o -BTDISCOBJS =3D btdisc.o bt_if.o -BTINQOBJS =3D btinq.o bt_if.o +BTDISCOBJS =3D btdisc.o bt_if.o bt_misc.o +BTINQOBJS =3D btinq.o bt_if.o bt_misc.o +BTTESTOBJS =3D bttest.o bt_misc.o bt_vendor.o bt_if.o =20 ifdef HAVE_READLINE_READLINE LDLIBS +=3D -lreadline -ltermcap @@ -63,6 +65,9 @@ $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@=09 =20 btinq: $(BTINQOBJS) + $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ + +bttest: $(BTTESTOBJS) $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@ =20 install: $(PROGS) --- bt_if.c 2001/03/13 22:21:17 1.2 +++ bt_if.c 2001/03/24 21:11:38 1.2.2.1 @@ -62,6 +62,29 @@ #include "bt_misc.h" #include "bt_conf.h" =20 + +int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len) +{ + unsigned char buf[261]; + + buf[0] =3D len; +=20=20 + memcpy(buf+1, data, len); + + print_data("data :",(char*) buf,(int) len+1); + +#ifndef BT_USERSTACK=20 + if (ioctl(bt_cfd, HCISENDRAWDATA, buf) < 0) + { + perror("ecs_testctrl"); + } +#else + printf("not yet for usermode stack...\n"); + //hci_send_raw_data(data, 16); +#endif + return 0; +} + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* Functions common for kernel and usermode stack */ /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ @@ -214,16 +237,16 @@ return result; } =20 -void +int bt_disconnect(int bt_fd, unsigned int con_id) { -#ifndef BT_USERSTACK + int ret_val; =20 - if (ioctl(bt_fd, BTDISCONNECT, &con_id) < 0) - { - perror("Disconnect"); - exit(1); - } +#ifndef BT_USERSTACK=20=20 + if ((ret_val =3D ioctl(bt_fd, BTDISCONNECT, &con_id))) + printf("Disconnect failed, %s [%d]\n", error_msg(ret_val), ret_val); + else + printf("Disconnected.\n"); #else /* fixme<3> -- only works for rfcomm */ u8 line;=09=09=09=09 @@ -236,9 +259,10 @@ return; } =20=20=20 - rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); + ret_val =3D rfcomm_disconnect_req(GET_RFCOMMLINE(con_id)); #endif - printf("Disconnected!\n"); + + return ret_val; } =20 /* Check whether this line is lower connected in stack (rfcomm ready) */ @@ -258,6 +282,21 @@ return ret; } =20 +void bt_showstatus(void) +{ +#ifdef BT_USERSTACK + + char tmp[4096]; + int len; + len =3D bt_read_internal(tmp); + tmp[len] =3D 0; + printf("%s", tmp); +#else + /*FIXME -- read /proc/bt_internal and print it on the console */ + printf("not yet...\n"); +#endif=20 +} + =20 /* fixme<1> -- add usermode stack version */ int @@ -319,6 +358,8 @@ return 0; } =20 + + void bt_waitline(int bt_fd, int line) { @@ -417,29 +458,20 @@ } =20 void -bt_set_bd_addr(int bt_cfd, int* bd) -{ - int i; - unsigned char new_bd[6]; -=20=20=20=20 - for (i =3D 0; i < 6; i++) +bt_set_bd_addr(int bt_cfd, unsigned char *bd) { - new_bd[i] =3D (unsigned char) *bd++; - } - printf("Setting BD address to: %02X:%02X:%02X:%02X:%02X:%02X\n", - new_bd[0], new_bd[1], new_bd[2], - new_bd[3], new_bd[4], new_bd[5]); + bd[0], bd[1], bd[2], + bd[3], bd[4], bd[5]); =20=20=20=20=20 #ifndef BT_USERSTACK - if (ioctl(bt_cfd, HCIWRITEBDADDR, new_bd) < 0) + if (ioctl(bt_cfd, HCIWRITEBDADDR, bd) < 0) { perror("Set bd addr"); } #else - hci_set_bd_addr(new_bd); + hci_set_bd_addr(bd); #endif=20=20=20=20 -=20 printf("Please reset HW to activate bd change\n"); } =20 @@ -449,7 +481,7 @@ int bt_set_baudrate(int bt_cfd, int spd) { int result; -=20=20 + syslog(LOG_INFO, "bt_set_baudrate %d baud", spd); #ifdef BT_USERSTACK tcflush(phys_fd, TCIOFLUSH); hci_set_baudrate(spd); @@ -473,15 +505,12 @@ } #else BD_ADDR rev_bd; - int i; -=20=20 hci_read_local_bd(rev_bd); =20 /* return as big endian */ for (i =3D 0; i < 6; i++) { bd_addr[i] =3D rev_bd[5-i]; } - #endif } =20 @@ -755,12 +784,15 @@ { switch(code) {=20 - case RES_PSMNEG: + case L2CAP_PSMNEG: return "L2CAP - PSM not valid"; - case RES_SECNEG: + case L2CAP_SECNEG: return "L2CAP - Security block"; - case RES_NOSRC: + case L2CAP_NOSRC: return "L2CAP - Remote side has no resources"; + case L2CAP_CON_UNRESPONSIVE: + return "L2CAP - Unresponsive link"; + default: return "L2CAP - unknown reason"; } @@ -768,7 +800,7 @@ break; =20=20=20=20=20 default: - return "Unknown layer - unknown reason"; + return "General failure"; } } =20 --- bt_if.h 2001/03/02 10:59:57 1.1 +++ bt_if.h 2001/03/24 21:11:38 1.1.2.1 @@ -92,10 +92,12 @@ #define MSG_LAYER_TCS 8 =20 /* Result in responses in L2CAP */ -#define RES_PSMNEG 0x02 -#define RES_SECNEG 0x03 -#define RES_NOSRC 0x04 +#define L2CAP_PSMNEG 0x02 +#define L2CAP_SECNEG 0x03 +#define L2CAP_NOSRC 0x04 =20 +#define L2CAP_CON_UNRESPONSIVE 0xf1 + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IF Macros */ =20 @@ -185,8 +187,10 @@ =20 #define HCISETBAUDRATE _IOW(BT_IOC_MAGIC, 0x70, int) #define HCIWRITEBDADDR _IOW(BT_IOC_MAGIC, 0x71, unsigned char[6]) -#define HCISENDRAWDATA _IOW(BT_IOC_MAGIC, 0x72, unsigned char[256]) =20 +/* | len 1 byte | 4 bytes hci header | data (max 256) | */ +#define HCISENDRAWDATA _IOW(BT_IOC_MAGIC, 0x72, unsigned char[261]) + /* Used to calculate opcode for HCI commands using raw interface */ #define OPCODE_MSB(ocf, ogf) ((ocf) & 0xff) #define OPCODE_LSB(ocf, ogf) (((ocf) >> 8) | (((ogf) & 0x3f) << 2)) @@ -245,21 +249,23 @@ */ =20 int bt_connect(int bt_fd, unsigned char *bd, unsigned int con_id); -void bt_disconnect(int bt_fd, unsigned int con_id); +int bt_disconnect(int bt_fd, unsigned int con_id); =20 void bt_waitline(int bt_fd, int line); void bt_waitconnection(int bt_fd, int line); void bt_waitnewconnections(int bt_fd); int bt_isconnected(int bt_cfd, int line); int bt_send(int fd, int len, int repeat); +void bt_showstatus(void); =20 /*=20 * HCI command functions=20 */ =20 +int bt_send_raw_hci(int bt_cfd, unsigned char *data, char len); void bt_inquiry(int bt_cfd, int nbr_rsp, int t); int bt_set_baudrate(int bt_cfd, int spd); -void bt_set_bd_addr(int bt_cfd, int* bd); +void bt_set_bd_addr(int bt_cfd, unsigned char *bd); void read_local_bd(int bt_cfd, unsigned char *bd_addr); void read_remote_bd(int bt_cfd, unsigned char *bd_addr); void role_switch(int bt_cfd, unsigned char *bd_addr, int role); @@ -270,6 +276,9 @@ unsigned char major_class,=20 unsigned char minor_class,=20 unsigned char format); + +void enable_dut(int bt_cfd); + =20 /* Sets friendly name in HW to hostname */ void set_local_name(int bt_cfd, const char *local_name); --- bt_ipa.c 2001/03/02 10:59:57 1.1 +++ bt_ipa.c 2001/03/24 21:11:38 1.1.2.1 @@ -46,6 +46,7 @@ #include <syslog.h> #include <sys/types.h> #include <sys/stat.h> +#include <string.h> =20 /* print in_addr */ #include <sys/socket.h> @@ -81,7 +82,9 @@ /* Sends msg to IPA socket */ int ipa_write(int ipa_fd, ipa_msg *msg) { - syslog(LOG_INFO, "ipa_send : sending ipa request (type : %d)\n", msg->ty= pe); + syslog(LOG_INFO, "ipa_send : sending ipa request (type : %d) len %d \n", + msg->type, msg->len); +=20=20 return write(ipa_fd, msg, msg->len + sizeof(struct ipa_msg)); } =20 @@ -99,6 +102,8 @@ { c =3D read(ipa_fd, &ipa_buf+offset, 256-offset);=20=20 =20 + syslog(LOG_INFO, "ipa_receive : got %d bytes", c);=20=20 + if (c < 0) return c; =20 @@ -117,25 +122,36 @@ =20=20=20 memcpy(msg, ipa_buf, offset); =20 + syslog(LOG_INFO, "Got %d bytes", offset); + return msg_len;=20=20 } =20 void show_ipset(struct ip_set* set, int line) { - printf("IP set [line:%d]\n", line); - printf(" ip : %s\n", inet_ntoa(set->ip)); + syslog(LOG_INFO, "IP set [line:%d]\n", line); + + if (set) + {=20=20=20=20 + syslog(LOG_INFO, " ip : %s\n", inet_ntoa(set->ip)); + if (set->nbr_of_dns >=3D 1) - printf(" dns1 : %s\n", inet_ntoa(set->dns[1])); + syslog(LOG_INFO, " dns1 : %s\n", inet_ntoa(set->dns[0])); + if (set->nbr_of_dns =3D=3D 2) - printf(" dns2 : %s\n", inet_ntoa(set->dns[2])); + syslog(LOG_INFO, " dns2 : %s\n", inet_ntoa(set->dns[1])); + if (set->nbr_of_wins >=3D 1) - printf(" wins 1 : %s\n", inet_ntoa(set->wins[1])); - if (set->nbr_of_dns =3D=3D 2) - printf(" wins2 : %s\n", inet_ntoa(set->wins[2])); - printf(" netmask : %s\n", inet_ntoa(set->netmask)); - printf("useradius : %d\n", set->useradius); - printf("useradiusip : %d\n", set->useradiusip); - printf("usingmasq : %d\n", set->usingmasq); + syslog(LOG_INFO, " wins 1 : %s\n", inet_ntoa(set->wins[0])); + + if (set->nbr_of_wins =3D=3D 2) + syslog(LOG_INFO, " wins2 : %s\n", inet_ntoa(set->wins[1])); + + syslog(LOG_INFO, " netmask : %s\n", inet_ntoa(set->netmask)); + syslog(LOG_INFO, "useradius : %d\n", set->useradius); + syslog(LOG_INFO, "useradiusip : %d\n", set->useradiusip); + syslog(LOG_INFO, "usingmasq : %d\n", set->usingmasq); + } } =20 #endif /* USE_IPASSIGN */ --- bt_ipa.h 2001/03/02 10:59:57 1.1 +++ bt_ipa.h 2001/03/24 21:11:38 1.1.2.1 @@ -63,8 +63,8 @@ #define IPARSP_PEERSETTINGS 11 =20 /* Status codes */ -#define IPA_STATUSFAILED 0 -#define IPA_STATUSSUCCESS 1 +#define IPA_STATUSSUCCESS 0 +#define IPA_STATUSFAILED 1 =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D*/ /* IPA Client struct */ --- bt_misc.c 2001/03/02 14:30:32 1.2 +++ bt_misc.c 2001/03/24 21:11:38 1.2.2.1 @@ -136,7 +136,7 @@ (struct sockaddr *)&server_address,=20 server_len) < 0) { syslog(LOG_ERR, "open_socket %s failed", name); - return 0; + return -1; } =20 =20 @@ -234,7 +234,7 @@ * Set server_name to the numerical IP of eth0 instead of using DNS or * relying on /etc/hosts being correct. for now. */ -char* get_local_addr(void) +void get_local_addr(char *str) { char *local_address =3D NULL; int fd =3D socket(AF_INET, SOCK_DGRAM, 0); @@ -249,7 +249,10 @@ { syslog(LOG_INFO, "could not determine local IP address!\n"); } - return local_address; + + strcpy(str, local_address); + + free(local_address); } =20 int=20 @@ -339,7 +342,7 @@ } =20 void=20 -print_data(const char *message, char *buf, int len) +print_data(const char *message, unsigned char *buf, int len) {=20 int t; printf("\n%s (%d)", message, len); @@ -347,7 +350,7 @@ { if((t%16)=3D=3D0) printf("\n "); - printf("0x%x ", buf[t]); + printf("0x%02x ", (uint)(buf[t])); } printf("\n"); } @@ -362,14 +365,13 @@ if (strncmp(pin, "disable", 7) =3D=3D 0) { printf("Disable PIN usage\n"); - system("/bin/parhandclient -nosync set root.Security.UseLANSecurity ye= s"); + system("/bin/parhandclient -nosync set root.Security.UseLANSecurity no= "); system("/bin/parhandclient sync"); return; } =20 - sprintf(exec_pinstr, "/bin/parhandclient -nosync set root.Security.PINCo= de %s", (char*) pin); -=20=20 /* Set pin in stack */ + sprintf(exec_pinstr, "/bin/parhandclient -nosync set root.Security.PINCo= de %s", (char*) pin);=20=20 =20=20=20 system("/bin/parhandclient -nosync set root.Security.UseLANSecurity yes"= ); system(exec_pinstr); --- bt_misc.h 2001/03/02 10:59:57 1.1 +++ bt_misc.h 2001/03/24 21:11:38 1.1.2.1 @@ -58,9 +58,9 @@ int open_tcpsocket(char *addrstr, int role); =20 int write_pidfile(char *pidname); -char* get_local_addr(void); +void get_local_addr(char *str); void print_bd_addr(char* str, unsigned char *bd); -void print_data(const char *message, char *buf, int len); +void print_data(const char *message, unsigned char *buf, int len); void set_pin_code(char *pin); =20 #endif /* __BT_MISC_H__*/ --- bt_vendor.c 2001/03/10 12:47:09 1.3 +++ bt_vendor.c 2001/03/24 21:11:38 1.3.2.1 @@ -318,7 +318,7 @@ /* Set the phys device to CSR default, 115200 */=20 void init_phys(int fd) { - syslog(LOG_INFO, "Setting default baud 115200"); + syslog(LOG_INFO, "Setting default speed 115200"); fd_setup(fd, 115200, USE_FLOW_CTRL); } =20 @@ -365,15 +365,6 @@ hci_write_pagescan_activity(0x50, 0x20); /* more reliable connection pro= cess */ sleep(1); /* wait for HW */ #endif - -#if 0 - /* fixme -- don't know how to change baudrate yet !*/=20 - /* Now set phys device speed to whatever HW was set to use */ - fd_setup(phys_fd, spd, USE_FLOW_CTRL);=20=20 - - tcflush(phys_fd, TCIOFLUSH); -#endif - } =20 #elif HW_USED(HW_GENERIC) --- btcon.c 2001/03/02 10:59:57 1.1 +++ btcon.c 2001/03/24 21:11:38 1.1.2.1 @@ -100,21 +100,45 @@ { switch(opt) { +=20=20=20=20=20=20 case 'a': { - int tmp[6]; + int tmp[6], all_read =3D 0; bd_str =3D optarg; - printf("Connecting to bd : %s\n", bd_str); - if (sscanf(optarg, "%x:%x:%x:%x:%x:%x", + if (sscanf(optarg, "%2x%2x%2x%2x%2x%2x", + &tmp[0], &tmp[1], &tmp[2], + &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) + {=20=20 + all_read =3D 1; + } + else if (sscanf(optarg, "%x:%x:%x:%x:%x:%x", + &tmp[0], &tmp[1], &tmp[2], + &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) + {=20=20 + all_read =3D 1; + } + else if (sscanf(optarg, "%x-%x-%x-%x-%x-%x", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6) { + all_read =3D 1; + } +=20=20=20=20=20=20=20=20 + /* now convert to real bd format if syntax was correct */ + if(all_read) + { for (i =3D 0; i < 6; i++) { bd[i] =3D (unsigned char)tmp[i];=20 } + printf("Connecting to bd : %2x:%2x:%2x:%2x:%2x:%2x\n", + bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]); } -=20=20=20=20=20=20=20=20 + else + { + printf("Invalid syntax : %s\n", bd_str); + exit(1); + } } break; =20 --- btd.c 2001/03/13 22:21:17 1.4 +++ btd.c 2001/03/24 21:11:38 1.4.2.1 @@ -50,6 +50,10 @@ =20=09=20=20=20=20=20 options:=20 =20=20=20 + -i, --hwinit=20 +=09 + default: ttyS0 +=20=20 -u, --physdev <uart device> Sets which uart device that will be used by the stack default: ttyS0 @@ -106,6 +110,8 @@ #include "bt_if.h" #include "bt_ipa.h" =20 +#define D(x) //x + /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* PPPD stuff */ =20 @@ -129,13 +135,22 @@ struct peer_struct peerlist[BT_NBR_DATAPORTS]; struct ip_set ipsetlist[BT_NBR_DATAPORTS]; =20 +static unsigned char dev[20]; +static unsigned char ip_addresses[35]; +static unsigned char ms_dns1[35]; +static unsigned char ms_dns2[35]; +static unsigned char ms_wins1[35]; +static unsigned char ms_wins2[35]; +static unsigned char netmask[35]; + static fd_set rfd; static struct timeval tv; =20 #define PEER(line) (peerlist[line]) +#define IPSET(line) (ipsetlist[line]) #define STATE(line) (peerlist[line].state) =20 -char *pppd_options[32]; +static unsigned char *pppd_options[32]; =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ /* IPA stuff */ @@ -145,7 +160,7 @@ static struct ipa_msg *msg; static unsigned char ipa_buf[256]; static int parse_ipa_response(struct ipa_msg *msg); -static int ipa_sendrequest(int line, unsigned char bd[6], +static int ipa_sendrequest(int line, unsigned char *bd, unsigned short type); #endif =20 @@ -165,6 +180,7 @@ static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu= le */ static int do_hwinit =3D 1; /* do vendor specific initialization */ static int do_reset =3D 0; /* reset hw using I/O pins */ +static int init_hw_speed =3D 0; /* not set */ static int modem_emul =3D 1; /* default modem emulation is enabled */ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ static jmp_buf jmpbuffer; /* used to jump back in program after doing rese= t */ @@ -189,7 +205,7 @@ static void btd_killchilds(void); static void sighandler(int sig); =20 -static void handle_new_connections(int bt_cfd); +static void discover_connections(int bt_cfd); static void build_pppdopts(int line, char **opts); static int start_pppd(int line, char *speedstr, char **opts); =20 @@ -210,13 +226,19 @@ } =20=20=20 /* now parse options */ -#define OPTIONS_STRING "mnRs:u:" +#define OPTIONS_STRING "i:m:nRs:u:" =20=20=20 while ((opt =3D getopt_long(argc, argv, OPTIONS_STRING, long_options, &option_index)) !=3D -1) { switch(opt) { + case 'i': + /* uart device */ + init_hw_speed =3D atoi(optarg); + syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed); + break; + case 'm': /* uart device */ modem_emul =3D atoi(optarg); @@ -270,12 +292,16 @@ exit(1); } =20=20=20 + /* Sets initial HW baudrate */ + if (init_hw_speed !=3D 0) + fd_setup(phys_fd, init_hw_speed, 1); + else init_phys(phys_fd); =20=20=20 /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20=20=20 - bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); + bt_cfd =3D bt_openctrl(); =20=20=20 init_stack(bt_cfd, atoi(speedstr)); =20=20=20 @@ -284,24 +310,22 @@ =20=20=20 /* All initialized and ready to accept connections */ =20=20=20 - bt_waitnewconnections(bt_cfd); - syslog(LOG_INFO, "handle_new_connections"); - handle_new_connections(bt_cfd); + while (1) + { + int i, waiting_iparsp =3D 0; + tv.tv_sec =3D 1; + tv.tv_usec =3D 0; =20=20=20 FD_ZERO(&rfd);=20=20 FD_SET(ipa_fd, &rfd); FD_SET(0, &rfd); =20=20=20 - while (1) - { - int i; - tv.tv_sec =3D 2; - tv.tv_usec =3D 0; result =3D select(FD_SETSIZE, &rfd, (fd_set*)0,=20 (fd_set*)0, &tv); switch (result) { case 0: + { /* Timeout, check for new rfcomm cons */ =20=20=20=20=20=20=20 /* Check for outstanding IPA requests */ @@ -310,38 +334,42 @@ { if ((STATE(i) =3D=3D WAITING_PPPCONF) || (STATE(i) =3D=3D WAITING_RETURN_PPPCONF)) - break;=20=20 + { + D(syslog(LOG_INFO, "Waiting for IPA response\n")); + waiting_iparsp =3D 1; + } i++; } -=20=20=20=20=20=20 - /* If no outstanding IPA req, simply wait for new rfcomm */ - if (i =3D=3D BT_NBR_DATAPORTS) - bt_waitnewconnections(bt_cfd);=20=20=20=20=20 =20=20=20=20=20=20=20 - handle_new_connections(bt_cfd); + if (waiting_iparsp) + break; =20=20=20=20=20=20=20 + discover_connections(bt_cfd); + } break; =20=20=20=20=20=20=20 case -1: + {=20=20 /* Error */ perror("select"); + + /* FIXME -- e.g if ipa server restarts !!! */ + } break; =20=20=20=20=20=20=20 default: { /* Got data on some fd */ int i;=20=20=20=20=20=20=20=20 +=20 for (i=3D0; i < result; i++)=20 { -=20 #ifdef USE_IPASSIGN /* IPA response */ if (FD_ISSET(ipa_fd, &rfd)) { msg =3D (struct ipa_msg*) ipa_buf; -=20=20=20=20=20=20=20=20=20=20=20=20 /* Got response from IPA, if ok then start pppd or modem emul = */ - syslog(LOG_INFO, "IPA data\n");=20=20=20=20=20=20=20=20=20=20= =20=20 ipa_read(ipa_fd, msg); parse_ipa_response(msg); } @@ -357,41 +385,44 @@ } /* main */ =20=20 /* Checks for new connections and starts pppd/modememulator */ -static void handle_new_connections(int bt_cfd) +static void discover_connections(int bt_cfd) { int line; =20=20=20 - syslog(LOG_INFO, "handle_new_connections"); + D(syslog(LOG_INFO, "discover_connections")); for (line =3D 0; line < BT_NBR_DATAPORTS; line++) { - if ((STATE(line) =3D=3D NOCONNECTION) &&=20 bt_isconnected(bt_cfd, line)) { - syslog(LOG_INFO, "We got a new connection on line : %d !\n", line); + syslog(LOG_INFO, "Found connection on line : %d !\n", line); STATE(line) =3D CONNECTED; =20=20=20=20=20=20=20 read_remote_bd(bt_cfd, PEER(line).remote_bd); print_bd_addr("remote bd ", PEER(line).remote_bd); =20=20=20=20=20=20=20 #ifdef USE_IPASSIGN - syslog(LOG_INFO, "Sending IPA request\n"); + D(syslog(LOG_INFO, "Sending IPA request\n")); +=20=20=20=20=20=20 + PEER(line).ipset =3D &IPSET(line); + STATE(line) =3D WAITING_PPPCONF; - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_GETIPSET) < 0) + if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20 + IPAREQ_GETIPSET) < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); =20 /* Build without IPA anyway */ STATE(line) =3D PPPCONF_DONE; - build_pppdopts(line, pppd_options);=20=20=20=20=20=20 - start_pppd(line, speedstr, pppd_options);=20=20=20=20=20 + build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20 + start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20 } else - syslog(LOG_INFO, "IPA request sent"); + D(syslog(LOG_INFO, "IPA request sent")); #else STATE(line) =3D PPPCONF_DONE; - build_pppdopts(line, pppd_options);=20=20=20=20=20=20 - start_pppd(line, speedstr, pppd_options);=20=20=20=20=20 + build_pppdopts(line, (char**)pppd_options);=20=20=20=20=20=20 + start_pppd(line, speedstr, (char**)pppd_options);=20=20=20=20=20 #endif=20=20 } } @@ -400,35 +431,28 @@ /* only server */ void build_pppdopts(int line, char **opts) { -=20=20 int i=3D0; - char dev[20]; - char ip_addresses[35]; - char ms_dns1[35]; - char ms_dns2[35]; - char ms_wins1[35]; - char ms_wins2[35]; - char netmask[35]; struct ip_set *ipset =3D PEER(line).ipset; + char local_ip[20]; =20=20=20 #ifdef USE_IPASSIGN show_ipset(ipset, line); #endif =20=20=20 - syslog(LOG_INFO, "build_pppdopts\n"); + D(syslog(LOG_INFO, "build_pppdopts\n")); =20=20=20 sprintf(dev, "/dev/ttyBT%d",line); =20=20=20 /* general options */ - pppd_options[i++] =3D (char*)PPPDCMD; - pppd_options[i++] =3D dev; - pppd_options[i++] =3D speedstr; + opts[i++] =3D (char*)PPPDCMD; + opts[i++] =3D dev; + opts[i++] =3D speedstr; =20=20=20 /* move these to options file ? */ - pppd_options[i++] =3D "crtscts"; - pppd_options[i++] =3D "nopersist"; - pppd_options[i++] =3D "silent"; - pppd_options[i++] =3D "passive"; + opts[i++] =3D "crtscts"; + opts[i++] =3D "nopersist"; + opts[i++] =3D "silent"; + opts[i++] =3D "passive"; =20=20=20 /* check if we have used IPA */ if (ipset) @@ -439,75 +463,80 @@ /* Use radius ? */ if (ipset->useradius) { - pppd_options[i++] =3D "useradius"; - pppd_options[i++] =3D "auth"; - pppd_options[i++] =3D "login"; + opts[i++] =3D "useradius"; + opts[i++] =3D "auth"; + opts[i++] =3D "login"; =20=20=20=20=20=20=20 if (ipset->useradiusip) { - pppd_options[i++] =3D "useautoip"; + opts[i++] =3D "useautoip"; }=20=20=20 }=20=20 else=20 { - pppd_options[i++] =3D "noauth"; + opts[i++] =3D "noauth"; }=20=20 =20=20=20=20=20 if (ipset->proxyarp) { - pppd_options[i++] =3D "proxyarp"; + opts[i++] =3D "proxyarp"; /* ktune only works on pppd version > 2.3.10 */ /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ - pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */ + opts[i++] =3D "ktune"; /* enables ip_forwarding */ }=20=20 =20 + get_local_addr(local_ip); /* local/remote ip */ - sprintf(ip_addresses, "%s:%s", get_local_addr(),=20 + sprintf(ip_addresses, "%s:%s", local_ip,=20 inet_ntoa(ipset->ip)); =20=20=20=20=20 printf("IP used : %s\n", ip_addresses); =20=20=20=20=20 + opts[i++] =3D ip_addresses; +=20=20=20=20 /* DNS */ if (ipset->nbr_of_dns > 0) { - /* at lease one... */ - pppd_options[i++] =3D "ms-dns"; + /* at least one... */ + opts[i++] =3D "ms-dns"; sprintf(ms_dns1, "%s", inet_ntoa(ipset->dns[0])); - pppd_options[i++] =3D ms_dns1; + opts[i++] =3D ms_dns1; =20=20=20=20=20=20=20 if (ipset->nbr_of_dns > 1) { - pppd_options[i++] =3D "ms-dns"; + opts[i++] =3D "ms-dns"; sprintf(ms_dns2, "%s", inet_ntoa(ipset->dns[1])); - pppd_options[i++] =3D ms_dns2; + opts[i++] =3D ms_dns2; } } =20=20=20=20=20 /* WINS */ if (ipset->nbr_of_wins > 0) { - /* at lease one... */ - pppd_options[i++] =3D "ms-wins"; + /* at least one... */ + opts[i++] =3D "ms-wins"; sprintf(ms_wins1, "%s", inet_ntoa(ipset->wins[0])); - pppd_options[i++] =3D ms_wins1; + opts[i++] =3D ms_wins1; =20=20=20=20=20=20=20 if (ipset->nbr_of_wins > 1) { - pppd_options[i++] =3D "ms-wins"; - sprintf(ms_dns2, "%s", inet_ntoa(ipset->wins[1])); - pppd_options[i++] =3D ms_wins2; + opts[i++] =3D "ms-wins"; + sprintf(ms_wins2, "%s", inet_ntoa(ipset->wins[1])); + opts[i++] =3D ms_wins2; } } =20=20=20=20=20 /* Netmask */=20=20=20=20=20=20 - pppd_options[i++] =3D "netmask"; + opts[i++] =3D "netmask"; sprintf(netmask, "%s", inet_ntoa(ipset->netmask)); - pppd_options[i++] =3D netmask; + opts[i++] =3D netmask; } else { - /* local ip */ - sprintf(ip_addresses, "%s:", get_local_addr()); + get_local_addr(local_ip); +=20=20=20=20 + /* local IP */ + sprintf(ip_addresses, "%s:", local_ip); =20=20=20=20=20 /* Use /etc/ppp/options file for remote ppp settings. IPA is needed for correct multipoint setting or use a=20 @@ -515,26 +544,28 @@ options.ttyBT1 which contains the remote IP address,=20 dns, wins etc*/ =20=20=20=20=20 - syslog(LOG_INFO, "WARNING NO REMOTE IP SET, only local %s\n",=20 + syslog(LOG_INFO, "WARNING No remote ip addr set, only local %s",=20 ip_addresses); - printf("WARNING NO REMOTE IP SET, only local %s\n", ip_addresses); =20 + opts[i++] =3D ip_addresses; + /* always do proxyarp */=20 - pppd_options[i++] =3D "proxyarp"; + opts[i++] =3D "proxyarp"; =20 /* ktune only works on pppd version > 2.3.10 */ /* similar as doing ' echo 1 > /proc/sys/net/ipv4/ip_forward */ - pppd_options[i++] =3D "ktune"; /* enables ip_forwarding */ - } + opts[i++] =3D "ktune"; /* enables ip_forwarding */ =20=20=20 - pppd_options[i] =3D NULL; + } /* end -- no ipa */ =20=20=20 -#if 1 + opts[i] =3D NULL; +=20=20 +#if 0 /* print pppd_options */ i =3D 0; syslog(LOG_INFO, "pppd options used :"); - while (pppd_options[i]) - syslog(LOG_INFO, "%s", pppd_options[i++]); + while (opts[i]) + syslog(LOG_INFO, "%s", opts[i++]); #endif } =20 @@ -543,18 +574,16 @@ char dev[20]; =20=20=20 sprintf(dev, "/dev/ttyBT%d",line); - printf("start_pppd on %s at %s baud\n", dev, speedstr); =20=20=20 /* check state */ if (STATE(line) !=3D PPPCONF_DONE) { - syslog(LOG_INFO, "Warning : ppp config not done!!!\n"); + syslog(LOG_INFO, "Warning : ppp config not done (%d)\n", STATE(line)); return -1; } =20=20=20 if (PEER(line).do_modememul)=20 { - printf("Starting modem emulator...\n"); STATE(line) =3D MODEM_STARTED; =20=20=20=20=20 /* run modem emulator in a child */ @@ -565,9 +594,9 @@ /* replace first arg with MODEMEMULCMD (is handled by=20 modem emulator) */ =20=20=20=20=20=20=20 - pppd_options[0]=3D (char*)MODEMEMULCMD;=20=20=20=20=20=20 + opts[0]=3D (char*)MODEMEMULCMD; =20=20=20=20=20=20=20 - execvp(MODEMEMULCMD, pppd_options); + execvp(MODEMEMULCMD, opts); =20=20=20=20=20=20=20 fprintf(stderr, "%s: no such file or directory\n", MODEMEMULCMD); =20=20=20=20=20=20=20 @@ -578,14 +607,13 @@ } else { - printf("Starting pppd...\n"); STATE(line) =3D PPPD_STARTED; if (!(PEER(line).pppd_pid =3D vfork())) { syslog(LOG_INFO, "Starting pppd on %s", dev); =20=20=20=20=20=20=20 - /* FIXME -- use opts inparam and not static pppd_options */ - execvp(PPPDCMD, pppd_options); + /* FIXME -- use opts inparam and not static opts */ + execvp(PPPDCMD, opts); =20=20=20=20=20=20=20 fprintf(stderr, "%s: no such file or directory\n", PPPDCMD); =20=20=20=20=20=20=20 @@ -617,7 +645,7 @@ static void sighandler(int sig) { - printf("Sighandler : %d\n", sig); + syslog(LOG_INFO, "Sighandler got signal : %d\n", sig); =20=20=20 if (sig =3D=3D SIGUSR1) { @@ -629,9 +657,16 @@ {=20=20=20=20 /* Close down phys dev, run hw_upgrade and restart btd */ btd_cleanup(); - /* execvp(hw_upgrade_prog) */ +=20 + /* FIXME -- execvp(hw_upgrade_prog) */ +=20=20=20=20 longjmp(jmpbuffer, 1); } + else if (sig =3D=3D SIGTERM) /* ? */ + {=20 + syslog(LOG_INFO, "Got SIGTERM, now exiting"); + exit(0); + } else if (sig =3D=3D SIGCHLD)=20=20 { int line =3D 0, pid, status; @@ -665,18 +700,21 @@ syslog(LOG_INFO, "PPP line %d was shutdown\n", line); =20=20=20=20=20 #ifdef USE_IPASSIGN - /* FIXME -- Now release IPA settings */ - if (ipa_sendrequest(line, PEER(line).remote_bd, IPAREQ_RELEASEIPSET) <= 0) + STATE(line) =3D WAITING_RETURN_PPPCONF; + + if (ipa_sendrequest(line, (unsigned char *)&PEER(line).remote_bd,=20 + IPAREQ_RELEASEIPSET) < 0) { syslog(LOG_INFO, "IPA request failed or no IPA server"); - /* check if still connected first ? */ + /* put peer into state NOCONNECTION, if still connected this + will be discovered in timout */ STATE(line) =3D NOCONNECTION;=20=20=20=20 }=20=20=20=20 #else - /* check if still connected first ? */ STATE(line) =3D NOCONNECTION;=20=20=20=20 #endif =20=20=20=20=20 + PEER(line).ipset =3D NULL; PEER(line).pppd_pid =3D -1; =20=20=20=20=20 return; @@ -691,6 +729,7 @@ static void init() {=20 int i; + btd_pid =3D write_pidfile(PID_FILE);=20=20 init_sighandler(); =20=20=20 @@ -714,6 +753,7 @@ if (ipa_fd < 0) { printf("Found no IPA server\n"); + exit(1);=20 } #endif =20=20=20 @@ -762,7 +802,6 @@ printf("btd_killchilds\n"); if (sdpsrv_pid > 0) { - printf("btd_killchilds SDP server\n"); syslog(LOG_INFO, "Killing SDP server\n"); kill(sdpsrv_pid, SIGTERM); =20=20=20=20=20 @@ -777,7 +816,6 @@ { if (STATE(line) =3D=3D PPPD_STARTED) { - printf("btd_killchilds PPP server on line %d\n", line); syslog(LOG_INFO, "Killing pppd on line %d\n", line); kill(PEER(line).pppd_pid, SIGTERM); if (waitpid(PEER(line).pppd_pid, NULL, 0) < 0) @@ -792,20 +830,20 @@ =20 #ifdef USE_IPASSIGN =20 -static int ipa_sendrequest(int line, unsigned char bd[6], unsigned short t= ype) +static int ipa_sendrequest(int line, unsigned char *bd, unsigned short typ= e) { unsigned char buf[IPA_MSG_MAXSIZE]; struct ipa_msg *msg; struct ipa_request *req; =20=20=20 - printf("ipa_request : type %d\n", type); + D(syslog(LOG_INFO, "ipa_request : type %d\n", type)); =20=20=20 msg =3D (struct ipa_msg*)buf; msg->type =3D type; msg->len =3D sizeof(struct ipa_request); req =3D (struct ipa_request*)msg->msg; req->id =3D line; - memcpy(&req->remote_bd, &bd, 6);=20 + memcpy(&req->remote_bd, bd, 6);=20 return ipa_write(ipa_fd, msg); } =20 @@ -816,20 +854,28 @@ case IPARSP_STATUS: { ipa_status *rsp =3D (struct ipa_status*)(msg->msg); - syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 - rsp->status, rsp->id);=20=20 + D(syslog(LOG_INFO, "ipa_parse_msg : got status %d on line\n",=20 + rsp->status, rsp->id)); =20=20=20=20=20=20=20 /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) - printf("parse_ipa_response : request failed [line:%d]\n", rsp->id); + syslog(LOG_INFO, "parse_ipa_response : request failed [line:%d]\n"= ,=20 + rsp->id); + else + D(syslog(LOG_INFO, "parse_ipa_response : request succeeded [line:%d]\n", = rsp->id)); =20=20=20=20=20=20=20 + /* put peer into NOCONNECTION, if still connected this will=20 + be discovered from timeout */ + + STATE(rsp->id) =3D NOCONNECTION; + return rsp->status; } =20=20=20=20=20 case IPARSP_PEERSETTINGS: { ipa_response* rsp =3D (struct ipa_response*)(msg->msg); - syslog(LOG_INFO, "ipa_parse_msg : got client settings\n");=20=20=20= =20=20=20 + D(syslog(LOG_INFO, "ipa_parse_msg : got client settings\n")); =20=20=20=20=20=20=20 /* Check status */ if (rsp->status =3D=3D IPA_STATUSFAILED) @@ -842,12 +888,17 @@ /* Store ipa settings in peer struct */ memcpy(PEER(rsp->id).ipset, &rsp->set, msg->len); =20=20=20=20=20=20=20 - /* print settings ! */ - show_ipset(PEER(rsp->id).ipset, rsp->id); + /* Now proceed to next state */ + if (PEER(rsp->id).state =3D=3D WAITING_PPPCONF) + { + PEER(rsp->id).state =3D PPPCONF_DONE; + }=20=20=20=20=20=20 + else + syslog(LOG_INFO, "Warning : Wrong state on line %d, should have been WAIT= ING_PPPCONF", rsp->id); =20=20=20=20=20=20=20 /* Build options and start ppp */ - build_pppdopts(rsp->id, pppd_options); - start_pppd(rsp->id, speedstr, pppd_options); + build_pppdopts(rsp->id, (char**)pppd_options); + start_pppd(rsp->id, speedstr, (char**)pppd_options); return 0; }=20 =20=20=20=20=20 --- btdisc.c 2001/03/02 10:59:57 1.1 +++ btdisc.c 2001/03/24 21:11:38 1.1.2.1 @@ -71,6 +71,7 @@ { int con_id, bt_cfd, dlci=3D-1, line, opt; char *btdev =3D "/dev/ttyBT0"; /* default */=20=20 + int ret_val; =20 #ifdef __CRIS__ /* Print header if called via http */ @@ -128,8 +129,8 @@ =20 con_id =3D CREATE_RFCOMM_ID(line, dlci); =20 - bt_disconnect(bt_cfd, con_id); + ret_val =3D bt_disconnect(bt_cfd, con_id); =20=20 close(bt_cfd); - exit(0); + exit(ret_val); } --- btinit.c 2001/03/13 22:21:17 1.2 +++ btinit.c 2001/03/24 21:11:38 1.2.2.1 @@ -107,6 +107,7 @@ =20 static int btd_pid; static char local_name[LOCAL_NAME_LENGTH+1]; /* 'friendly' name in HW modu= le */ +static int init_hw_speed =3D 0; /* not set */ static int do_hwinit =3D 1; /* do vendor specific initialization */ static int do_reset =3D 0; /* reset hw using I/O pins */ static int phys_fd =3D -1; /* physical device e.g ttyS0 */ @@ -155,6 +156,11 @@ { switch(opt) { + case 'i': + /* uart device */ + init_hw_speed =3D atoi(optarg); + syslog(LOG_INFO, "init_hw_speed %d baud\n", init_hw_speed); + break; =20 case 'n': printf("setting local name to %s\n", optarg); @@ -205,12 +211,16 @@ } =20 /* Set default speed */ + + if (init_hw_speed !=3D 0) + fd_setup(phys_fd, init_hw_speed, 1); + else init_phys(phys_fd); =20 /* Set the current tty to the bluetooth discpline */ set_bt_line_disc(phys_fd, bt_disc, physdev); =20=20=20 - bt_cfd =3D open(BT_CTRL_TTY, O_RDWR | O_NOCTTY); + bt_cfd =3D bt_openctrl(); =20 init_stack(bt_cfd, atoi(speedstr)); =20 @@ -237,6 +247,7 @@ sigemptyset(&act.sa_mask); act.sa_flags =3D 0; sigaction(SIGUSR1, &act, 0); + sigaction(SIGTERM, &act, 0); /* other sigs ? */ } =20 @@ -253,6 +264,10 @@ btd_cleanup(); =20=20 longjmp(jmpbuffer, 1); + } + if (sig =3D=3D SIGTERM) + { + exit(0); } return; } --- bttest.c 2001/03/10 12:49:32 1.2 +++ bttest.c 2001/03/24 21:11:38 1.2.2.1 @@ -39,12 +39,6 @@ * */ =20 -/*=20 - * FIXME !!! - * THIS FILE HAS NOT BEEN TESTED AFTER SPLIT UP OF BTD=20 - * AND SHOULD NOT BE USED AS IS - */ - #include <sys/time.h> #include <sys/types.h> #include <sys/ioctl.h> @@ -76,12 +70,10 @@ #include "bt_if.h" #include "bt_misc.h" #include "bt_conf.h" +#include "bt_vendor.h" =20 /* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ =20 -#define START_PPP 1 -#define QUIT_BTD 2 - #define BTD_HISTORY_FILE "/tmp/btd_history" =20 char* menu[] =3D @@ -97,9 +89,7 @@ " readbd", /* read module bd address */ " reset", /* reset board */ " role_switch <xx:xx:xx:xx:xx:xx> <role> (0=3Dmaster, 1=3Dslave)", -#ifdef BT_USERSTACK " stat ", /* similar to reading the /proc/bt */ -#endif #ifdef ECS_TEST_FUNCTIONS " ecs_entertest <handle> (hex)", " ecs_testctrl <par1,par2,...,par9> (hex)", @@ -107,7 +97,6 @@ " ecs_testcon <xx:xx:xx:xx:xx:xx> (hex)",=20=20 " enable_dut", /* enable device under test mode */ #endif - " ppp", " quit", #ifdef BT_USERSTACK "", @@ -150,27 +139,21 @@ }=20=20=20=20=20=20=20=20=20 } =20 -void=20 -testmain(void) +int +main(void) { - int start_ppp =3D 0; int bt_cfd;=20=20 =20 - if ((bt_cfd =3D open_device(BT_CTRL_TTY, O_RDWR, 0)) < 0) + /* First of all check that stack is running */ + if (!bt_isinitiated()) { - perror("Could not open BT control TTY\n"); + printf("Stack not initiated, exit\n"); exit(1); } - -// if (enter_cmd_mode) - { - read_history(BTD_HISTORY_FILE); =20 -#ifdef BT_USERSTACK - sleep(2); /* temp fix - wait for last command response to be returned = */ -#endif + bt_cfd =3D bt_openctrl(); =20 - printf("Now entering cmd line mode\n"); + read_history(BTD_HISTORY_FILE);=20=20 =20 show_menu(); =20=20=20=20=20 @@ -178,62 +161,37 @@ { int tmp; char *line =3D (char*) readline("> "); - - if (!line) - { - start_ppp =3D 0; - break; - } - add_history(line); =20=20=20=20=20=20=20 tmp =3D process_cmd(line, bt_cfd); =20 - if (tmp =3D=3D START_PPP) - { - start_ppp =3D 1; - break; - } - else if (tmp =3D=3D QUIT_BTD) + if (tmp =3D=3D QUIT_BTD) { - start_ppp =3D 0; break; } free(line); } write_history(BTD_HISTORY_FILE); - }=20=20 + exit(0); } =20 int process_cmd(char *buf, int bt_cfd) { - int bd[6]; - unsigned char my_bd_addr[6]; unsigned int tmp[11]; int repeat; int i, line; -#ifdef BT_USERSTACK - unsigned char tmp_bd[6]; /* used for byte swapping */ - int server_channel, profile; -#endif =20=20 if (!strncmp(buf, "quit", 4)) { return QUIT_BTD; } - else if (!strncmp(buf, "ppp", 3)) - { - return START_PPP; - } - - if (sscanf(buf, "rf_conn %x:%x:%x:%x:%x:%x %d %d", + else if (sscanf(buf, "rf_conn %x:%x:%x:%x:%x:%x %d %d", &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6], &tmp[7]) =3D=3D 8) { - int i; - unsigned int con_id; + unsigned int con_id, i; unsigned short srv_ch, line; unsigned char tmp_bd[6]; =20 @@ -268,118 +226,33 @@ } else if (sscanf(buf, "rf_send %d %d %d", &i, &repeat, &line) =3D=3D 3) { -#define MAXSIZE (4096*2) - struct timeval start_t, stop_t; - int bytes_tot =3D i*repeat; - int avg_speed =3D 0; /* bps */ - unsigned int ms; - char tmp[MAXSIZE]; + int btfd; char dev[20]; - int fd; - int j; - sprintf(dev, "/dev/ttyBT%d",line); - -#ifndef BT_USERSTACK=20=20=20=20 - printf("Opening %s\n", dev); - if ((fd =3D open_device(dev, O_RDWR, CLIENT)) < 0) - { - perror("open_device"); - return 0; - }=20=20=20=20 - printf("Done.\n"); - - bt_waitconnection(fd, line); - -#else - /* FIXME -- currently only uses line 0 */ - if (line !=3D 0) { - printf("No support for sending data on line %d, use line 0 instead != (userstack only)\n", line); - fd=3D-1; - return 0; - } -#endif - - if (i > MAXSIZE) - { - printf("Max 8192 bytes per write!\n"); - i =3D MAXSIZE; - bytes_tot =3D i*repeat; /* update this aswell */ - } - - /* fill them with letters... */ - for(j =3D 0; j < i; j++) - { - tmp[j] =3D (j % 25) + 65; + btfd =3D open(dev, O_RDWR | O_NOCTTY); + bt_send(bt_cfd, i, repeat); + close(btfd); } -=20=20=20=20 - printf("\nNow sending %d %d-bytes packet (%d kB) on line %d\n",=20 - repeat, i, bytes_tot/1000, line); - - gettimeofday(&start_t, NULL); -=20 - while (repeat) + else if (sscanf(buf, "setbd %x:%x:%x:%x:%x:%x", + &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5]) = =3D=3D 6) { - int n =3D 0; -#ifndef BT_USERSTACK - n =3D write(fd, tmp, i);=20=20=20 -#else - n =3D bt_write_top(tmp, i, line); -#endif + unsigned char tmp_bd[6]; =20=20=20=20=20=20=20 - if (n <=3D0) + for (i =3D 0; i < 6; i++) { - printf("couldn't write any more data...\n\n"); - bytes_tot =3D bytes_tot-repeat*i; - break; - } - - repeat--; - printf("%6d kB left to send... \r", - ((repeat*i)/1000)); - fflush(stdout); + tmp_bd[i] =3D (unsigned char)tmp[i]; } - gettimeofday(&stop_t, NULL); - printf("\ndone.\n"); =20 - ms =3D (stop_t.tv_sec-start_t.tv_sec)*1000 +=20 - (stop_t.tv_usec-start_t.tv_usec)/1000; - if (ms) - avg_speed =3D ((8*bytes_tot)/ms); - printf("Average TX rate : %d kbps (%d kB/s)\n", avg_speed, avg_speed/8= ); -#ifndef BT_USERSTACK - printf("Closing %s\n", dev); - close_device(fd); -#endif - } - else if (sscanf(buf, "setbd %x:%x:%x:%x:%x:%x", - &bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5]) =3D=3D 6) - { - bt_set_bd_addr(bt_cfd, &bd[0]); + bt_set_bd_addr(bt_cfd, &tmp_bd[0]); } else if (strncmp(buf, "readbd", 6) =3D=3D 0) { + unsigned char my_bd_addr[6];=20=20 read_local_bd(bt_cfd, my_bd_addr); } - else if (strncmp(buf, "reset", 5) =3D=3D 0) - { - /* FIXME */ -#if 0 - - close_device(bt_cfd); - close_device(phys_fd); - bt_cfd =3D -1; - phys_fd =3D -1; - reset_hw(); -#ifdef RESTART_ENABLED - /* must set baud rate to default for hw again... */ - siglongjmp(jmpbuffer, 1); -#endif - -#endif - } else if(sscanf(buf, "role_switch %x:%x:%x:%x:%x:%x %d ", - &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4], &tmp[5], &tmp[6]) =3D=3D 7) + &tmp[0], &tmp[1], &tmp[2], &tmp[3], &tmp[4],=20 + &tmp[5], &tmp[6])=3D=3D 7) { unsigned char tmp_bd[6]; =20 @@ -422,22 +295,16 @@ ericsson_tx_test(&tmp[0]); } #endif - -/* - * Non usermode stack functions for the stuff=20 - * below will be added later on - */ - -#ifdef BT_USERSTACK else if (strncmp(buf, "stat", 4) =3D=3D 0) { - - char tmp[4096]; - int len; - len =3D bt_read_internal(tmp); - tmp[len] =3D 0; - printf("%s", tmp); + bt_showstatus(); } +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ +/* FIXME !!! -- make this work for both kernel / usermode stack */ +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */ + + +#ifdef BT_USERSTACK else if (sscanf(buf, "ping %x:%x:%x:%x:%x:%x", &bd[0], &bd[1], &bd[2], &bd[3], &bd[4], &bd[5]) =3D=3D 6) { @@ -575,7 +442,6 @@ printf("> error: command not recognized or wrong syntax\n"); show_menu(); } - return 0; } =20 |
From: Gordon M. <gm...@us...> - 2001-03-24 21:12:09
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.11 1.11.2.1=20=20=20=20=20=20=20=20 sdp_parser.h 1.3 1.3.2.1=20=20=20=20=20=20=20=20=20 The accompanying log: Merged from trunk The diff of the modified file(s): --- sdp_parser.c 2001/03/06 11:07:37 1.11 +++ sdp_parser.c 2001/03/24 21:11:38 1.11.2.1 @@ -52,6 +52,7 @@ #include <sys/socket.h> #include <sys/un.h> #include <sys/ioctl.h> +#include <sys/uio.h> =20 #include "sdp_server.h" #include "sdp_parser.h" @@ -163,20 +164,23 @@ int sdp_con_id; data_struct *db_hdl; =20 + PRINTPKT(FNC, data, len);=20=20 + db_hdl =3D (data_struct*) data; + data +=3D sizeof *db_hdl; + len -=3D sizeof *db_hdl; =20 - PRINTPKT(FNC, data, len);=20=20 sdp_con_id =3D db_hdl->sdp_con_id; pkt_len =3D db_hdl->len; =20 - id =3D db_hdl->data[0]; - trans_id =3D CHAR2INT16(db_hdl->data[1], db_hdl->data[2]); - par_len =3D CHAR2INT16(db_hdl->data[3], db_hdl->data[4]); + id =3D data[0]; + trans_id =3D CHAR2INT16(data[1], data[2]); + par_len =3D CHAR2INT16(data[3], data[4]); =20 - if (par_len > (len - SDP_HDR_SIZE - sizeof(data_struct))) + if (par_len > (len - SDP_HDR_SIZE)) { - D_XMIT(FNC"Packetlength don't match recievd data length par_len%d, pkt= _len %d\n", par_len, len); - send_error_rsp(sdp_con_id, trans_id, 4); + D_XMIT(FNC"Packet length does not match received data length par_len %= d, pkt_len %d\n", par_len, len); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20 @@ -185,65 +189,67 @@ switch (id) { case SDP_ERROR_RSP: - switch (CHAR2INT16(db_hdl->data[5], db_hdl->data[6])) + switch (CHAR2INT16(data[5], data[6])) { - case 0x0001: D_ERR(FNC"Got Invalid/unsupported SDP version\n"); + case SDP_INVALID_SDP_VERSION: + D_ERR(FNC"Got Invalid/unsupported SDP version\n"); break; - case 0x0002: D_ERR(FNC"Got Invalid Service Record Handle\n"); + case SDP_INVALID_SERVICE_RECORD_HANDLE: + D_ERR(FNC"Got Invalid Service Record Handle\n"); break; - case 0x0003: D_ERR(FNC"Got Invalid request syntax\n"); + case SDP_INVALID_REQUEST_SYNTAX: + D_ERR(FNC"Got Invalid Request Syntax\n"); break; - case 0x0004: D_ERR(FNC"Got Invalid PDU Size\n"); + case SDP_INVALID_PDU_SIZE: + D_ERR(FNC"Got Invalid PDU Size\n"); break; - case 0x0005: D_ERR(FNC"Got Invalid Continuation State\n"); + case SDP_INVALID_CONTINUATION_STATE: + D_ERR(FNC"Got Invalid Continuation State\n"); break; - case 0x0006: D_ERR(FNC"Got Insufficient Resources to satisfy Request\n= "); + case SDP_INSUFFICIENT_RESOURCES: + D_ERR(FNC"Got Insufficient Resources to satisfy Request\n"); break; default: D_ERR(FNC" Error code 0x%04x is not specified\n", - CHAR2INT16(db_hdl->data[5], db_hdl->data[6])); + CHAR2INT16(data[5], data[6])); break; } break; =20=09=09 case SDP_SERVICESEARCH_REQ: D_REC(FNC"SDP_SERVICESEARCH_REQ %d bytes\n", par_len); - process_service_search_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_search_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICESEARCH_RSP: D_REC(FNC"SDP_SERVICESEARCH_RSP\n"); - process_service_search_rsp(sdp_con_id, db_hdl->data + 5); + process_service_search_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICEATTR_REQ: D_REC(FNC"SDP_SERVICEATTR_REQ\n"); - process_service_attr_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_attr_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICEATTR_RSP: D_REC(FNC"SDP_SERVICEATTR_RSP\n"); - process_service_attr_rsp(sdp_con_id, db_hdl->data + 5); + process_service_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_REQ: D_REC(FNC"SDP_SERVICESEARCHATTR_REQ\n"); - process_service_search_attr_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_search_attr_req(sdp_con_id, data + 5, par_len, trans_i= d); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_RSP: D_REC(FNC"SDP_SERVICESEARCHATTR_RSP\n"); - process_service_search_attr_rsp(sdp_con_id, db_hdl->data + 5); + process_service_search_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 default: D_REC(FNC"ERROR Invalid pdu type\n"); - /* Send an error response with error code Invalid request - syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + /* Send an error response with error code Invalid request syntax */ + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } #undef FNC @@ -253,8 +259,6 @@ process_service_search_req(int sdp_con_id, unsigned char *data, unsigned s= hort len, unsigned int trans_id) { #define FNC "process_service_search_req: " - service_search_struct *db_hdl; -=09 unsigned int service_search_uuid[12]; int service_search_uuid_cnt; unsigned char des_len; @@ -268,7 +272,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -280,7 +284,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20=09 @@ -293,7 +297,7 @@ D_REC(FNC"More than 12 UUID in one request\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } =20=09=09 @@ -333,7 +337,7 @@ D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } } @@ -350,13 +354,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 @@ -370,28 +374,20 @@ } else { - len =3D sizeof(service_search_struct); -=20=20=20=20 - db_hdl =3D (service_search_struct*) malloc(len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++,len, (int)db_= hdl); + service_search_struct db_hdl; =20=20=20=20=20 - db_hdl->db.sdp_con_id =3D sdp_con_id; - db_hdl->db.trans_id =3D trans_id; - db_hdl->db.pkt_type =3D SDP_SERVICESEARCH_REQ; + db_hdl.db.sdp_con_id =3D sdp_con_id; + db_hdl.db.trans_id =3D trans_id; + db_hdl.db.pkt_type =3D SDP_SERVICESEARCH_REQ; =20=20=20=20=20 - db_hdl->max_rec_cnt =3D max_rec_cnt; - db_hdl->service_class_cnt =3D service_search_uuid_cnt; - memcpy(db_hdl->service_class_list, service_search_uuid, - service_search_uuid_cnt * 4); + db_hdl.max_rec_cnt =3D max_rec_cnt; + db_hdl.service_class_cnt =3D service_search_uuid_cnt; + memcpy(db_hdl.service_class_list, service_search_uuid, + service_search_uuid_cnt * sizeof *service_search_uuid); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ -=20=20=20=20 - handle_query((database_query_struct*) db_hdl); -=20=20=20=20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); - free(db_hdl); + handle_query(&db_hdl.db); } -=20=20=20=20 #undef FNC } =20 @@ -429,7 +425,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -441,7 +437,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -485,13 +481,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 @@ -503,9 +499,14 @@ } else { - len =3D sizeof(service_attr_struct) + attr_list_pos * 4; + len =3D sizeof(service_attr_struct) + attr_list_pos * sizeof *attr_lis= t; =20=09 - db_hdl =3D (service_attr_struct*) malloc(len); + if (!(db_hdl =3D malloc(len))) { + D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = len); + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); + return; + } + D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, len, (int)db_= hdl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; @@ -515,11 +516,11 @@ db_hdl->max_attr_byte_cnt =3D max_attr_cnt; db_hdl->rec_hdl =3D rec_hdl; db_hdl->attr_cnt =3D attr_list_pos; - memcpy(db_hdl->attr_list, attr_list, attr_list_pos * 4); + memcpy(db_hdl->attr_list, attr_list, attr_list_pos * sizeof *attr_list= ); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ =20=20=20=20=20 - handle_query((database_query_struct*) db_hdl); + handle_query(&db_hdl->db); =20=20=20=20=20 D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); free(db_hdl); @@ -551,7 +552,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -563,7 +564,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20=20=20 @@ -609,7 +610,7 @@ else { D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } } @@ -623,7 +624,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -674,13 +675,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 @@ -692,9 +693,14 @@ } else { - tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * 4; + tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * sizeo= f *attr_list; =20=09 - db_hdl =3D (service_search_attr_struct*) malloc(tmp_len); + if (!(db_hdl =3D malloc(tmp_len))) { + D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = tmp_len); + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); + return; + } + D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, tmp_len, (int= ) db_hdl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; @@ -703,12 +709,12 @@ =20=20=20=20=20 db_hdl->max_attr_byte_cnt =3D max_attr_cnt; db_hdl->service_class_cnt =3D service_search_uuid_cnt; - memcpy(db_hdl->service_class_list, service_search_uuid, service_search= _uuid_cnt * 4); + memcpy(db_hdl->service_class_list, service_search_uuid, service_search= _uuid_cnt * sizeof *service_search_uuid); db_hdl->attr_cnt =3D attr_list_pos; - memcpy(db_hdl->attr_list, attr_list, attr_list_pos * 4); + memcpy(db_hdl->attr_list, attr_list, attr_list_pos * sizeof *attr_list= ); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ - handle_query((database_query_struct*) db_hdl); + handle_query(&db_hdl->db); =20 D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); free(db_hdl); @@ -748,8 +754,8 @@ unsigned char sdp_data[7]; unsigned short pdu_len; =20 - /* Since we not send any error information the pdu length is just the si= ze - of the error code length, whoch is two bytes */ + /* Since we do not send any error information, the pdu length is just the + size of the error code length, which is two bytes */ =20 pdu_len =3D 2; =20=20=20 @@ -794,7 +800,7 @@ return 16; case 5: *new_pos =3D 2; - return *(data + 1); + return data[1]; case 6: *new_pos =3D 3; return CHAR2INT16(data[1], data[2]); @@ -808,22 +814,20 @@ void write2stack(int sdp_con_id, char *data, int len) { - data_struct *db_hdl; - int send_len; + data_struct db_hdl; + struct iovec vec[2]; =20 D_XMIT("write2stack: writing %d bytes to sdp_con_id %d\n", len,sdp_con_i= d); =20=20=20 - send_len =3D sizeof(data_struct) + len; - db_hdl =3D (data_struct*) malloc(send_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, send_len, (int)= db_hdl); + db_hdl.sdp_con_id =3D sdp_con_id; + db_hdl.len =3D len; =20=20=20 - db_hdl->sdp_con_id =3D sdp_con_id; - db_hdl->len =3D len; - memcpy(db_hdl->data, data, len); + vec[0].iov_base =3D &db_hdl; + vec[0].iov_len =3D sizeof db_hdl; + vec[1].iov_base =3D data; + vec[1].iov_len =3D len; =20=20=20 - write(stack_if_fd, (char*) db_hdl, send_len); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); - free(db_hdl); + writev(stack_if_fd, vec, 2); } =20 #ifndef BTD_USERSTACK @@ -949,6 +953,8 @@ exit(1); } =20=20=20 + syslog(LOG_INFO, "SDP Server starting");=20=20 + xml_file =3D (argc >=3D 2 ? argv[1] : SDP_XML_FILE); proc_file =3D (argc >=3D 3 ? argv[2] : SDP_PROC_FILE); =20=20=20 --- sdp_parser.h 2001/03/04 15:46:08 1.3 +++ sdp_parser.h 2001/03/24 21:11:38 1.3.2.1 @@ -70,12 +70,18 @@ ((unsigned int)((c1) & 0xff) << 8) + \ (unsigned int)((c0) &0xff)) =20 +#define SDP_INVALID_SDP_VERSION 0x0001 +#define SDP_INVALID_SERVICE_RECORD_HANDLE 0x0002 +#define SDP_INVALID_REQUEST_SYNTAX 0x0003 +#define SDP_INVALID_PDU_SIZE 0x0004 +#define SDP_INVALID_CONTINUATION_STATE 0x0005 +#define SDP_INSUFFICIENT_RESOURCES 0x0006 + /****************** TYPE DEFINITION SECTION ******************************= ***/ =20 typedef struct data_struct { unsigned int sdp_con_id; int len; - unsigned char data[0]; } data_struct; =20 /****************** EXPORTED FUNCTION DECLARATION SECTION ****************= ***/ |
From: Gordon M. <gm...@us...> - 2001-03-24 21:11:41
|
The following file was modified in linux/include/linux/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- btdebug.h 1.37 1.37.2.1=20=20=20=20=20=20=20=20 The accompanying log: Merged from trunk The diff of the modified file(s): --- btdebug.h 2001/03/04 15:59:23 1.37 +++ btdebug.h 2001/03/24 21:11:38 1.37.2.1 @@ -73,7 +73,7 @@ /***************** Bluetooth Debug defines *******************************= ****/ =20 #define BT_DATA_DEBUG 0 -#define BT_DATAFLOW_DEBUG 0 /* print pkt */ +#define BT_DATAFLOW_DEBUG 1 /* print pkt */ =20 #define BT_DRIVER_DEBUG 1 =20 |
From: Gordon M. <gm...@us...> - 2001-03-24 19:37:18
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- bluetooth.c 1.154.2.2 1.154.2.3=20=20=20=20=20=20=20 The accompanying log: --Fixed a bug in bluetooth.c. Copying the wrong size data back to the use f= or an HCI Inquiry. The diff of the modified file(s): --- bluetooth.c 2001/03/21 23:22:31 1.154.2.2 +++ bluetooth.c 2001/03/24 19:37:17 1.154.2.3 @@ -735,7 +735,7 @@ inq_res)) < 0) goto end_inquiry; =20 - copy_to_user((s32*)arg, inq_res, size + 6 *=20 + copy_to_user((s32*)arg, inq_res, sizeof(inquiry_results) + 6 *=20 inq_res->nbr_of_units); end_inquiry: kfree(inq_res); |
From: Peter K. <pk...@us...> - 2001-03-23 16:19:38
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.13 1.14=20=20=20=20=20=20=20=20=20=20=20=20 sdp_parser.h 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: * Removed two unnecessary malloc()'s. * Fail with an error if one of the remaining malloc()'s fails. * Use writev() in send2stack() to avoid malloc(). * Use sizeof instead of constants where appropriate. The diff of the modified file(s): --- sdp_parser.c 2001/03/23 16:06:18 1.13 +++ sdp_parser.c 2001/03/23 16:19:36 1.14 @@ -52,6 +52,7 @@ #include <sys/socket.h> #include <sys/un.h> #include <sys/ioctl.h> +#include <sys/uio.h> =20 #include "sdp_server.h" #include "sdp_parser.h" @@ -163,19 +164,22 @@ int sdp_con_id; data_struct *db_hdl; =20 + PRINTPKT(FNC, data, len);=20=20 + db_hdl =3D (data_struct*) data; + data +=3D sizeof *db_hdl; + len -=3D sizeof *db_hdl; =20 - PRINTPKT(FNC, data, len);=20=20 sdp_con_id =3D db_hdl->sdp_con_id; pkt_len =3D db_hdl->len; =20 - id =3D db_hdl->data[0]; - trans_id =3D CHAR2INT16(db_hdl->data[1], db_hdl->data[2]); - par_len =3D CHAR2INT16(db_hdl->data[3], db_hdl->data[4]); + id =3D data[0]; + trans_id =3D CHAR2INT16(data[1], data[2]); + par_len =3D CHAR2INT16(data[3], data[4]); =20 - if (par_len > (len - SDP_HDR_SIZE - sizeof(data_struct))) + if (par_len > (len - SDP_HDR_SIZE)) { - D_XMIT(FNC"Packetlength don't match recievd data length par_len%d, pkt= _len %d\n", par_len, len); + D_XMIT(FNC"Packet length does not match received data length par_len %= d, pkt_len %d\n", par_len, len); send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } @@ -185,7 +189,7 @@ switch (id) { case SDP_ERROR_RSP: - switch (CHAR2INT16(db_hdl->data[5], db_hdl->data[6])) + switch (CHAR2INT16(data[5], data[6])) { case SDP_INVALID_SDP_VERSION: D_ERR(FNC"Got Invalid/unsupported SDP version\n"); @@ -207,42 +211,39 @@ break; default: D_ERR(FNC"Error code 0x%04x is not specified\n", - CHAR2INT16(db_hdl->data[5], db_hdl->data[6])); + CHAR2INT16(data[5], data[6])); break; } break; =20=09=09 case SDP_SERVICESEARCH_REQ: D_REC(FNC"SDP_SERVICESEARCH_REQ %d bytes\n", par_len); - process_service_search_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_search_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICESEARCH_RSP: D_REC(FNC"SDP_SERVICESEARCH_RSP\n"); - process_service_search_rsp(sdp_con_id, db_hdl->data + 5); + process_service_search_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICEATTR_REQ: D_REC(FNC"SDP_SERVICEATTR_REQ\n"); - process_service_attr_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_attr_req(sdp_con_id, data + 5, par_len, trans_id); break; =20=20=20=20=20 case SDP_SERVICEATTR_RSP: D_REC(FNC"SDP_SERVICEATTR_RSP\n"); - process_service_attr_rsp(sdp_con_id, db_hdl->data + 5); + process_service_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_REQ: D_REC(FNC"SDP_SERVICESEARCHATTR_REQ\n"); - process_service_search_attr_req(sdp_con_id, db_hdl->data + 5, par_len, - trans_id); + process_service_search_attr_req(sdp_con_id, data + 5, par_len, trans_i= d); break; =20=20=20=20=20 case SDP_SERVICESEARCHATTR_RSP: D_REC(FNC"SDP_SERVICESEARCHATTR_RSP\n"); - process_service_search_attr_rsp(sdp_con_id, db_hdl->data + 5); + process_service_search_attr_rsp(sdp_con_id, data + 5); break; =20=20=20=20=20 default: @@ -258,8 +259,6 @@ process_service_search_req(int sdp_con_id, unsigned char *data, unsigned s= hort len, unsigned int trans_id) { #define FNC "process_service_search_req: " - service_search_struct *db_hdl; -=09 unsigned int service_search_uuid[12]; int service_search_uuid_cnt; unsigned char des_len; @@ -375,28 +374,20 @@ } else { - len =3D sizeof(service_search_struct); -=20=20=20=20 - db_hdl =3D (service_search_struct*) malloc(len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n", malloc_dbg++,len, (int)db_= hdl); + service_search_struct db_hdl; =20=20=20=20=20 - db_hdl->db.sdp_con_id =3D sdp_con_id; - db_hdl->db.trans_id =3D trans_id; - db_hdl->db.pkt_type =3D SDP_SERVICESEARCH_REQ; + db_hdl.db.sdp_con_id =3D sdp_con_id; + db_hdl.db.trans_id =3D trans_id; + db_hdl.db.pkt_type =3D SDP_SERVICESEARCH_REQ; =20=20=20=20=20 - db_hdl->max_rec_cnt =3D max_rec_cnt; - db_hdl->service_class_cnt =3D service_search_uuid_cnt; - memcpy(db_hdl->service_class_list, service_search_uuid, - service_search_uuid_cnt * 4); + db_hdl.max_rec_cnt =3D max_rec_cnt; + db_hdl.service_class_cnt =3D service_search_uuid_cnt; + memcpy(db_hdl.service_class_list, service_search_uuid, + service_search_uuid_cnt * sizeof *service_search_uuid); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ -=20=20=20=20 - handle_query((database_query_struct*) db_hdl); -=20=20=20=20 - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); - free(db_hdl); + handle_query(&db_hdl.db); } -=20=20=20=20 #undef FNC } =20 @@ -508,9 +499,14 @@ } else { - len =3D sizeof(service_attr_struct) + attr_list_pos * 4; + len =3D sizeof(service_attr_struct) + attr_list_pos * sizeof *attr_lis= t; =20=09 - db_hdl =3D (service_attr_struct*) malloc(len); + if (!(db_hdl =3D malloc(len))) { + D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = len); + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); + return; + } + D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, len, (int)db_= hdl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; @@ -520,11 +516,11 @@ db_hdl->max_attr_byte_cnt =3D max_attr_cnt; db_hdl->rec_hdl =3D rec_hdl; db_hdl->attr_cnt =3D attr_list_pos; - memcpy(db_hdl->attr_list, attr_list, attr_list_pos * 4); + memcpy(db_hdl->attr_list, attr_list, attr_list_pos * sizeof *attr_list= ); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ =20=20=20=20=20 - handle_query((database_query_struct*) db_hdl); + handle_query(&db_hdl->db); =20=20=20=20=20 D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); free(db_hdl); @@ -697,9 +693,14 @@ } else { - tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * 4; + tmp_len =3D sizeof(service_search_attr_struct) + attr_list_pos * sizeo= f *attr_list; =20=09 - db_hdl =3D (service_search_attr_struct*) malloc(tmp_len); + if (!(db_hdl =3D malloc(tmp_len))) { + D_ERR(__FUNCTION__ ": malloc failed to allocate %d bytes!\n", = tmp_len); + send_error_rsp(sdp_con_id, trans_id, SDP_INSUFFICIENT_RESOURCE= S); + return; + } + D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, tmp_len, (int= ) db_hdl); =20=20=20=20=20 db_hdl->db.sdp_con_id =3D sdp_con_id; @@ -708,12 +709,12 @@ =20=20=20=20=20 db_hdl->max_attr_byte_cnt =3D max_attr_cnt; db_hdl->service_class_cnt =3D service_search_uuid_cnt; - memcpy(db_hdl->service_class_list, service_search_uuid, service_search= _uuid_cnt * 4); + memcpy(db_hdl->service_class_list, service_search_uuid, service_search= _uuid_cnt * sizeof *service_search_uuid); db_hdl->attr_cnt =3D attr_list_pos; - memcpy(db_hdl->attr_list, attr_list, attr_list_pos * 4); + memcpy(db_hdl->attr_list, attr_list, attr_list_pos * sizeof *attr_list= ); =20=20=20=20=20 /* Here we ask the database for the requested attributes */ - handle_query((database_query_struct*) db_hdl); + handle_query(&db_hdl->db); =20 D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); free(db_hdl); @@ -753,8 +754,8 @@ unsigned char sdp_data[7]; unsigned short pdu_len; =20 - /* Since we not send any error information the pdu length is just the si= ze - of the error code length, whoch is two bytes */ + /* Since we do not send any error information, the pdu length is just the + size of the error code length, which is two bytes */ =20 pdu_len =3D 2; =20=20=20 @@ -799,7 +800,7 @@ return 16; case 5: *new_pos =3D 2; - return *(data + 1); + return data[1]; case 6: *new_pos =3D 3; return CHAR2INT16(data[1], data[2]); @@ -813,22 +814,20 @@ void write2stack(int sdp_con_id, char *data, int len) { - data_struct *db_hdl; - int send_len; + data_struct db_hdl; + struct iovec vec[2]; =20 D_XMIT("write2stack: writing %d bytes to sdp_con_id %d\n", len,sdp_con_i= d); =20=20=20 - send_len =3D sizeof(data_struct) + len; - db_hdl =3D (data_struct*) malloc(send_len); - D_MEM("---> malloc%d %d bytes at 0x%08x\n",malloc_dbg++, send_len, (int)= db_hdl); + db_hdl.sdp_con_id =3D sdp_con_id; + db_hdl.len =3D len; =20=20=20 - db_hdl->sdp_con_id =3D sdp_con_id; - db_hdl->len =3D len; - memcpy(db_hdl->data, data, len); + vec[0].iov_base =3D &db_hdl; + vec[0].iov_len =3D sizeof db_hdl; + vec[1].iov_base =3D data; + vec[1].iov_len =3D len; =20=20=20 - write(stack_if_fd, (char*) db_hdl, send_len); - D_MEM("<--- free%d 0x%08x\n",malloc_dbg--, (int) db_hdl); - free(db_hdl); + writev(stack_if_fd, vec, 2); } =20 #ifndef BTD_USERSTACK --- sdp_parser.h 2001/03/23 16:06:18 1.4 +++ sdp_parser.h 2001/03/23 16:19:36 1.5 @@ -82,7 +82,6 @@ typedef struct data_struct { unsigned int sdp_con_id; int len; - unsigned char data[0]; } data_struct; =20 /****************** EXPORTED FUNCTION DECLARATION SECTION ****************= ***/ |
From: Peter K. <pk...@us...> - 2001-03-23 16:06:20
|
The following files were modified in apps/bluetooth/sdp_server: Name Old version New version Comment ---- ----------- ----------- ------- sdp_parser.c 1.12 1.13=20=20=20=20=20=20=20=20=20=20=20=20 sdp_parser.h 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Added definitions for the various SDP errors. The diff of the modified file(s): --- sdp_parser.c 2001/03/21 17:17:38 1.12 +++ sdp_parser.c 2001/03/23 16:06:18 1.13 @@ -176,7 +176,7 @@ if (par_len > (len - SDP_HDR_SIZE - sizeof(data_struct))) { D_XMIT(FNC"Packetlength don't match recievd data length par_len%d, pkt= _len %d\n", par_len, len); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20 @@ -187,17 +187,23 @@ case SDP_ERROR_RSP: switch (CHAR2INT16(db_hdl->data[5], db_hdl->data[6])) { - case 0x0001: D_ERR(FNC"Got Invalid/unsupported SDP version\n"); + case SDP_INVALID_SDP_VERSION: + D_ERR(FNC"Got Invalid/unsupported SDP version\n"); break; - case 0x0002: D_ERR(FNC"Got Invalid Service Record Handle\n"); + case SDP_INVALID_SERVICE_RECORD_HANDLE: + D_ERR(FNC"Got Invalid Service Record Handle\n"); break; - case 0x0003: D_ERR(FNC"Got Invalid request syntax\n"); + case SDP_INVALID_REQUEST_SYNTAX: + D_ERR(FNC"Got Invalid Request Syntax\n"); break; - case 0x0004: D_ERR(FNC"Got Invalid PDU Size\n"); + case SDP_INVALID_PDU_SIZE: + D_ERR(FNC"Got Invalid PDU Size\n"); break; - case 0x0005: D_ERR(FNC"Got Invalid Continuation State\n"); + case SDP_INVALID_CONTINUATION_STATE: + D_ERR(FNC"Got Invalid Continuation State\n"); break; - case 0x0006: D_ERR(FNC"Got Insufficient Resources to satisfy Request\n= "); + case SDP_INSUFFICIENT_RESOURCES: + D_ERR(FNC"Got Insufficient Resources to satisfy Request\n"); break; default: D_ERR(FNC" Error code 0x%04x is not specified\n", @@ -241,9 +247,8 @@ =20=20=20=20=20 default: D_REC(FNC"ERROR Invalid pdu type\n"); - /* Send an error response with error code Invalid request - syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + /* Send an error response with error code Invalid request syntax */ + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } #undef FNC @@ -268,7 +273,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -280,7 +285,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20=09 @@ -293,7 +298,7 @@ D_REC(FNC"More than 12 UUID in one request\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); break; } =20=09=09 @@ -333,7 +338,7 @@ D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } } @@ -350,13 +355,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 @@ -429,7 +434,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -441,7 +446,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -485,13 +490,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 @@ -551,7 +556,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -563,7 +568,7 @@ { D_REC(FNC"Incorrect packet: Incorrect length field or whole packet was= not received\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20=20=20 @@ -609,7 +614,7 @@ else { D_REC(FNC"Unknown UUID size 0x%02x\n",data[cur_pos]); - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } } @@ -623,7 +628,7 @@ { D_REC(FNC"Incorrect packet: Data Element Sequence expected\n"); /* Send an error msg with error code Invalid request syntax */ - send_error_rsp(sdp_con_id, trans_id, 3); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_REQUEST_SYNTAX); return; } =20 @@ -674,13 +679,13 @@ if (len < cur_pos) { D_ERR(__FUNCTION__", packet len shorter than actual packet lengthlen:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } else if (len > cur_pos) { D_ERR(__FUNCTION__", packet len longer than actual packet length len:%= d cur_pos:%d\n", len, cur_pos); - send_error_rsp(sdp_con_id, trans_id, 4); + send_error_rsp(sdp_con_id, trans_id, SDP_INVALID_PDU_SIZE); return; } =20=20=20 --- sdp_parser.h 2001/03/04 15:46:08 1.3 +++ sdp_parser.h 2001/03/23 16:06:18 1.4 @@ -70,6 +70,13 @@ ((unsigned int)((c1) & 0xff) << 8) + \ (unsigned int)((c0) &0xff)) =20 +#define SDP_INVALID_SDP_VERSION 0x0001 +#define SDP_INVALID_SERVICE_RECORD_HANDLE 0x0002 +#define SDP_INVALID_REQUEST_SYNTAX 0x0003 +#define SDP_INVALID_PDU_SIZE 0x0004 +#define SDP_INVALID_CONTINUATION_STATE 0x0005 +#define SDP_INSUFFICIENT_RESOURCES 0x0006 + /****************** TYPE DEFINITION SECTION ******************************= ***/ =20 typedef struct data_struct { |
From: Peter K. <pk...@us...> - 2001-03-23 15:21:05
|
The following file was modified in linux/drivers/char/bluetooth: Name Old version New version Comment ---- ----------- ----------- ------- sdp.c 1.67 1.68=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: sdp_database_write() should now handle split writes. The diff of the modified file(s): --- sdp.c 2001/03/06 11:06:24 1.67 +++ sdp.c 2001/03/23 15:21:04 1.68 @@ -315,6 +315,11 @@ #endif /* LINUX_VERSION_CODE */ #endif /* __KERNEL__ */ =20 +#ifdef __KERNEL__ +static bt_tx_buf *db_write_tx_buf; +static s32 db_write_recv; +#endif + #ifndef __KERNEL__ static s32 sdp_sock; #endif @@ -406,6 +411,9 @@ sdp_disconnect_req(i); } }=20=20 + + unsubscribe_bt_buf(db_write_tx_buf); + db_write_recv =3D 0; } =20 #ifdef __KERNEL__ @@ -907,11 +915,7 @@ =20 len =3D MIN(count, database_query.count); =20 -#ifdef __KERNEL__ copy_to_user(buf, database_query.query, len); -#else - memcpy(buf, database_query.query, len); -#endif =20 if (database_query.count > len) { memmove(database_query.query, @@ -932,35 +936,60 @@ const char * buf, s32 count) #endif { + static data_struct db_hdl; sdp_tx_buf *sdp_buf; - bt_tx_buf *tx_buf; - data_struct *db_hdl =3D (data_struct*) buf; + s32 read1 =3D 0; + s32 read2 =3D 0; =20=09 D_PROC(__FUNCTION__ " Someone wrote %d bytes to sdp proc-file\n",count); =20 - D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = count, db_hdl->sdp_con_id); - PRINTPKT("Data to be sent to client:", db_hdl->data, db_hdl->len); + if (!bt_initiated()) + return 0; =20=09 - tx_buf =3D subscribe_bt_buf(sizeof(sdp_tx_buf) + db_hdl->len); + if (!db_write_tx_buf) { + read1 =3D MIN(sizeof db_hdl - db_write_recv, count); + copy_from_user(&db_hdl + db_write_recv, buf, read1); =20 - if (!tx_buf) { + db_write_recv +=3D read1; + + if (db_write_recv < sizeof db_hdl) + return read1; + + db_write_tx_buf =3D subscribe_bt_buf(sizeof *sdp_buf + db_hdl.len); + + if (!db_write_tx_buf) { D_ERR(__FUNCTION__ " failed to get tx buffer\n"); - return -1; + db_write_recv -=3D read1; + return -ENOMEM; } =20 - tx_buf->cur_len =3D db_hdl->len; - sdp_buf =3D (sdp_tx_buf*) (tx_buf->data); + db_write_tx_buf->cur_len =3D db_hdl.len; =20 -#ifdef __KERNEL__ - copy_from_user(sdp_buf->frame, db_hdl->data, db_hdl->len); -#else - memcpy(sdp_buf->frame, db_hdl->data, db_hdl->len); -#endif + count -=3D read1; + buf +=3D read1; + db_write_recv =3D 0; + } =20 - l2cap_send_data(tx_buf, sdp_con_list[db_hdl->sdp_con_id].l2cap); + sdp_buf =3D (sdp_tx_buf*)db_write_tx_buf->data; =20=09 - return count; + if (db_write_recv < db_hdl.len) { + read2 =3D MIN(db_hdl.len - db_write_recv, count); + copy_from_user(sdp_buf->frame + db_write_recv, buf, read2); + db_write_recv +=3D read2; + + if (db_write_recv < db_hdl.len) + return read1 + read2; } + + D_XMIT(__FUNCTION__ " preparing to send %d bytes data to sdp_con[%d]\n", = db_hdl.len, db_hdl.sdp_con_id); + PRINTPKT("Data to be sent to client:", db_hdl.data, db_hdl.len); + + l2cap_send_data(db_write_tx_buf, sdp_con_list[db_hdl.sdp_con_id].l2cap); + db_write_tx_buf =3D NULL; + db_write_recv =3D 0; + + return read1 + read2; +} #else /* __KERNEL__ */ =20 s32 sdp_doquery(s32 fd, u8 *request, s32 len) @@ -968,11 +997,13 @@ s32 n; u8 tmpbuf[512]; data_struct *db_hdl; + s32 recv; =20 D_XMIT("sdp_doquery : sending request %d bytes\n", len); write(fd, request, len); =20=09 - n =3D read(fd, tmpbuf, 512); + if ((n =3D read(fd, tmpbuf, 512)) < 0) + return n; =20 D_REC(__FUNCTION__ ", Received %d bytes\n", n); =20=09 @@ -980,15 +1011,13 @@ =20=09 /* what if not all is written once */ =20 - if (n < (sizeof(data_struct) + db_hdl->len)) { - D_ERR("sdp_doquery : only got partial response n:%d, db_hdl->len:%d\n", = n, db_hdl->len); - print_data("The request is:", request, len); - return -1; - } + for (recv =3D n; recv < sizeof *db_hdl + db_hdl->len; recv +=3D n) + if ((n =3D read(fd, tmpbuf + recv, 512 - recv)) < 0) + return n; =20 sdp_send_data(&sdp_con_list[db_hdl->sdp_con_id], db_hdl->data, db_hdl->le= n);=20 =20=09 - return n; + return recv; } #endif =20 |