• 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 typedef struct {
60 	uint32_t timestamp;
61 	union {
62 		uint16_t maxBytesSent;
63 		uint16_t lastIndexSent;
64 	} cStateValue;
65 } sdp_cont_state_t;
66 
67 #define SDP_CONT_STATE_SIZE (sizeof(uint8_t) + sizeof(sdp_cont_state_t))
68 
69 sdp_buf_t *sdp_get_cached_rsp(sdp_cont_state_t *cstate);
70 void sdp_cstate_cache_init(void);
71 void sdp_cstate_clean_buf(void);
72 
73 int record_sort(const void *r1, const void *r2);
74 void sdp_svcdb_reset(void);
75 void sdp_svcdb_collect_all(int sock);
76 void sdp_svcdb_set_collectable(sdp_record_t *rec, int sock);
77 void sdp_svcdb_collect(sdp_record_t *rec);
78 sdp_record_t *sdp_record_find(uint32_t handle);
79 void sdp_record_add(const bdaddr_t *device, sdp_record_t *rec);
80 int sdp_record_remove(uint32_t handle);
81 sdp_list_t *sdp_get_record_list(void);
82 sdp_list_t *sdp_get_access_list(void);
83 int sdp_check_access(uint32_t handle, bdaddr_t *device);
84 uint32_t sdp_next_handle(void);
85 
86 uint32_t sdp_get_time();
87 
88 #define SDP_SERVER_COMPAT (1 << 0)
89 #define SDP_SERVER_MASTER (1 << 1)
90 
91 int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags);
92 void stop_sdp_server(void);
93 
94 int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec);
95 int remove_record_from_server(uint32_t handle);
96 
97 void create_ext_inquiry_response(const char *name,
98 					int8_t tx_power, sdp_list_t *services,
99 					uint8_t *data);
100 static inline int android_get_control_socket(const char *name);
101