4 * Copyright (c) 2006 Itronix Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of Itronix Inc. may not be used to endorse
16 * or promote products derived from this software without specific
17 * prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 * Copyright (c) 2009 The NetBSD Foundation, Inc.
33 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
34 * All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
45 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 #include <sys/types.h>
62 #include <sys/queue.h>
64 #include <bluetooth.h>
69 * Service Record entry
73 bool valid
; /* record is current */
74 uint32_t handle
; /* ServiceRecord handle */
75 sdp_data_t data
; /* ServiceRecord data */
76 bdaddr_t bdaddr
; /* restricted device address */
77 int refcnt
; /* reference count */
78 fd_set refset
; /* reference bitset */
79 LIST_ENTRY(record
) next
; /* next ServiceRecord */
80 uint8_t ext
[0]; /* raw data storage ... */
83 typedef struct record record_t
;
86 * File descriptor (client) index entry
89 bool valid
; /* descriptor is valid */
90 bool server
; /* descriptor is listening */
91 bool control
;/* descriptor is control socket */
92 bool priv
; /* descriptor may modify service record db */
93 uint16_t omtu
; /* outgoing MTU */
94 uint16_t offset
; /* stored ContinuationState */
95 bdaddr_t bdaddr
; /* clients local device address */
98 typedef struct fd_idx fd_idx_t
;
104 uint16_t imtu
; /* incoming MTU */
105 uint8_t * ibuf
; /* input buffer */
106 size_t ctllen
; /* control msg buffer length */
107 uint8_t * ctlbuf
; /* control msg buffer */
108 sdp_pdu_t pdu
; /* PDU header */
109 uint16_t omtu
; /* outgoing MTU */
110 uint8_t * obuf
; /* output buffer */
111 uint32_t handle
; /* next ServiceRecordHandle */
112 LIST_HEAD(, record
) rlist
; /* ServiceRecord list */
113 int fdmax
; /* descriptor max index */
114 fd_idx_t
* fdidx
; /* descriptor index */
115 fd_set fdset
; /* current descriptor set */
116 const char * sgroup
; /* privileged group */
119 typedef struct server server_t
;
122 uint16_t compat_register_request(server_t
*, int);
123 uint16_t compat_change_request(server_t
*, int);
126 bool db_init(server_t
*);
127 bool db_next(server_t
*, int, record_t
**);
128 void db_select_ssp(server_t
*, int, sdp_data_t
*);
129 void db_select_handle(server_t
*, int, uint32_t);
130 bool db_create(server_t
*, int, const bdaddr_t
*, uint32_t, sdp_data_t
*);
131 void db_unselect(server_t
*, int);
132 void db_release(server_t
*, int);
135 void log_open(char const *, bool);
136 void log_close(void);
137 void log_emerg(char const *, ...);
138 void log_alert(char const *, ...);
139 void log_crit(char const *, ...);
140 void log_err(char const *, ...);
141 void log_warning(char const *, ...);
142 void log_notice(char const *, ...);
143 void log_info(char const *, ...);
144 void log_debug(char const *, ...);
147 uint16_t record_insert_request(server_t
*, int);
148 uint16_t record_update_request(server_t
*, int);
149 uint16_t record_remove_request(server_t
*, int);
152 bool server_init(server_t
*, const char *, const char *);
153 void server_shutdown(server_t
*);
154 bool server_do(server_t
*);
155 void server_error_response(server_t
*, int, uint16_t);
158 uint16_t service_search_request(server_t
*, int);
159 uint16_t service_attribute_request(server_t
*, int);
160 uint16_t service_search_attribute_request(server_t
*, int);
162 #endif /* _SDPD_H_ */