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

[bluetooth-dev] sdp_server.c problem?



Hi,

In the Bluetooth v1.1 specification section 2.7.2 on SDP, it 
says that a "A service search pattern is said to match a service 
record if each and every UUID in the service search pattern is 
contained within any of the service record's attribute values."

The sdp_server.c function get_all_rec_hdl() returns a list of 
service records containing _any_ (instead of every) UUID in the
service search pattern.

For example, suppose I do a search request for all serial
ports (0x1101) using RFCOMM (0x0003).  This may be redundant,
but it is valid.  The current get_all_rec_hdl() returns not just
the serial port handle, but also the handle for everything
using RFCOMM... This doesn't seem correct - I would expect just
to get the serial port handle back.

I've attached a patch below that fixes the problem.  I renamed 
remove_duplicated_rec_hdl() to remove_unmatched_rec_hdl().  Instead
of removing duplicated entries, it removes all entries that were
not matched by every UUID in the search pattern (i.e., duplicated
service_class_cnt times).

Thanks,
Will


Index: sdp_server.c
===================================================================
RCS file: /cvsroot/openbt/apps/bluetooth/sdp_server/sdp_server.c,v
retrieving revision 1.30
diff -a -u -d -r1.30 sdp_server.c
--- sdp_server.c        2001/08/22 17:46:37     1.30
+++ sdp_server.c        2001/10/18 06:13:42
@@ -124,8 +124,8 @@
 void set_sdp_hdr(unsigned char *hdr, unsigned char pkt_type,
                  unsigned short trans_id, unsigned short len);
 
-unsigned int* remove_duplicated_rec_hdl(unsigned int *rec_hdl_list_in,
-                               unsigned int cnt_in);
+unsigned int* remove_unmatched_rec_hdl(unsigned int *rec_hdl_list_in,
+                               unsigned int cnt_in, unsigned int
service_class_
cnt);
 unsigned int* get_all_rec_hdl(unsigned int *service_class_list,
                      unsigned int service_class_cnt);
 unsigned int get_record_handle(unsigned short service_class, int fd);
@@ -412,23 +412,26 @@
 }
 
 unsigned int*
-remove_duplicated_rec_hdl(unsigned int *rec_hdl_list_in, unsigned int
cnt_in)  
+remove_unmatched_rec_hdl(unsigned int *rec_hdl_list_in, unsigned int
cnt_in,
+                          unsigned int service_class_cnt)  
 {
     static unsigned int rec_hdl_list_out[128];
     unsigned int i, j, cnt_out = 0;
     unsigned int existing = FALSE;
+    unsigned int tmp_cnt;
     
     for (i = 0; i < cnt_in; i++)
     {
-      for (j = 0; j < cnt_out; j++)
+      tmp_cnt = 1;
+      for (j = i+1; j < cnt_in; j++)
       {
-     if (rec_hdl_list_in[i] == rec_hdl_list_out[j])
+     if (rec_hdl_list_in[i] == rec_hdl_list_in[j])
      {
-       existing = TRUE;
+       tmp_cnt++;
      }
       }
       
-      if(!existing)
+      if( tmp_cnt == service_class_cnt )
       {
      rec_hdl_list_out[cnt_out] = rec_hdl_list_in[i];
      D_RHDL(__FUNCTION__": ||| Keeping record_handle 0x%08x |||",
rec_hdl_list_
out[cnt_out]);
@@ -491,7 +494,8 @@
  
   D_RHDL("Now __remove__ duplicated entries ?!?!?\n");
  
-  tmp_hdl_list = remove_duplicated_rec_hdl(rec_hdl_list, rec_hdl_cnt);
+  tmp_hdl_list = remove_unmatched_rec_hdl(rec_hdl_list, rec_hdl_cnt,
+                                           service_class_cnt);
  
   return tmp_hdl_list;
 }
-
To unsubscribe from this list: send the line "unsubscribe bluetooth-dev" in
the body of a message to majordomo@xxxxxxx.com