• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2001-2002  Nokia Corporation
6  *  Copyright (C) 2002-2003  Maxim Krasnyansky <maxk@qualcomm.com>
7  *  Copyright (C) 2002-2010  Marcel Holtmann <marcel@holtmann.org>
8  *  Copyright (C) 2002-2003  Stephen Crane <steve.crane@rococosoft.com>
9  *
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful,
17  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  *  GNU General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License
22  *  along with this program; if not, write to the Free Software
23  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24  *
25  */
26 
27 #include <bluetooth/bluetooth.h>
28 #include <bluetooth/sdp.h>
29 
30 #ifdef SDP_DEBUG
31 #include <syslog.h>
32 #define SDPDBG(fmt, arg...) syslog(LOG_DEBUG, "%s: " fmt "\n", __func__ , ## arg)
33 #else
34 #define SDPDBG(fmt...)
35 #endif
36 
37 typedef struct request {
38 	bdaddr_t device;
39 	bdaddr_t bdaddr;
40 	int      local;
41 	int      sock;
42 	int      mtu;
43 	int      flags;
44 	uint8_t  *buf;
45 	int      len;
46 } sdp_req_t;
47 
48 void handle_request(int sk, uint8_t *data, int len);
49 
50 int service_register_req(sdp_req_t *req, sdp_buf_t *rsp);
51 int service_update_req(sdp_req_t *req, sdp_buf_t *rsp);
52 int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp);
53 
54 void register_public_browse_group(void);
55 void register_server_service(void);
56 void register_device_id(const uint16_t vendor, const uint16_t product,
57 						const uint16_t version);
58 
59 int record_sort(const void *r1, const void *r2);
60 void sdp_svcdb_reset(void);
61 void sdp_svcdb_collect_all(int sock);
62 void sdp_svcdb_set_collectable(sdp_record_t *rec, int sock);
63 void sdp_svcdb_collect(sdp_record_t *rec);
64 sdp_record_t *sdp_record_find(uint32_t handle);
65 void sdp_record_add(const bdaddr_t *device, sdp_record_t *rec);
66 int sdp_record_remove(uint32_t handle);
67 sdp_list_t *sdp_get_record_list(void);
68 sdp_list_t *sdp_get_access_list(void);
69 int sdp_check_access(uint32_t handle, bdaddr_t *device);
70 uint32_t sdp_next_handle(void);
71 
72 uint32_t sdp_get_time(void);
73 
74 #define SDP_SERVER_COMPAT (1 << 0)
75 #define SDP_SERVER_MASTER (1 << 1)
76 
77 int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags);
78 void stop_sdp_server(void);
79 
80 int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec);
81 int remove_record_from_server(uint32_t handle);
82 
83 void sdp_init_services_list(bdaddr_t *device);
84 static inline int android_get_control_socket(const char *name);
85