|
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
|