[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bluetooth-dev] ask a question in sdp.c

In the sdp.c, there are two variables: role and initiator.
1) when the sdp is client, role=0, initiator=TRUE. Is this true?
2) If the above OK, in the sdp_receive_data(l2cap_con *l2cap, u8* data, u32 len). There is
sdp_receive_data(l2cap_con *l2cap, u8* data, u32 len)
 sdp_con *sdp;
 data_struct *db_hdl;
 D_REC(__FUNCTION__ "\n");
 if (role == 0) {
  print_data(__FUNCTION__, data, len);
 PRINTPKT(__FUNCTION__, data, len); 
 sdp = (sdp_con*) l2cap->upper_con;
#ifndef __KERNEL__
 if (sdp_sock < 0) {
  send_error_rsp(sdp, le16_to_cpu(get_unaligned((u16 *)&data[1])), 6);
 /* If __KERNEL__ mode, we must bounce the received data   */
 /* up if this stack initiated the request.                */
#if __KERNEL__
 if (sdp->initiator) {
  u8 *dataPointer = NULL;
  /* Grab a copy of the data to send up.                  */
  dataPointer = (u8 *) kmalloc(len, GFP_ATOMIC);
  memcpy(dataPointer, data, len);
  bt_send_sdp_data_received(sdp->line, dataPointer, len);
 } else
  db_hdl = (data_struct*)database_query.query;
  db_hdl->l2cap_mtu = l2cap->remote_mtu;
  db_hdl->sdp_con_id = sdp->id;
  db_hdl->len = len;
  memcpy(db_hdl->data, data, len);
  database_query.count = sizeof(data_struct) + len;
#ifdef __KERNEL__
  D_PROC("wake_up process %i (%s) awakening\n", current->pid, current->comm);
  D_PROC("wake_up process %i (%s) woke up\n", current->pid, current->comm);
  sdp_doquery(sdp_sock, database_query.query, database_query.count);
In the above code, when sdp is client, the code will not be excuted, because if (role==0) { ...; return; }.
How to explain this? And the diffrent of role and initiator?
Thanks very much.