File: sdpclt.h

package info (click to toggle)
affix 2.1.1-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,908 kB
  • ctags: 1,247
  • sloc: ansic: 13,807; sh: 7,119; yacc: 232; makefile: 152; lex: 126; python: 56
file content (280 lines) | stat: -rw-r--r-- 8,317 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/* 
   Affix - Bluetooth Protocol Stack for Linux
   Copyright (C) 2001,2002 Nokia Corporation
   Author: Dmitry Kasatkin <dmitry.kasatkin@nokia.com>

   Original Author: Guruprasad Krishnamurthy <kgprasad@hotmail.com>

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU General Public License as published by the
   Free Software Foundation; either version 2 of the License, or (at your
   option) any later version.

   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License along
   with this program; if not, write to the Free Software Foundation, Inc.,
   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

/*
   $Id: sdpclt.h,v 1.41 2003/04/15 10:47:06 kds Exp $

   SDP service discovery client API definitions

   Fixes:
		Dmitry Kasatkin		: bug fixes, cleanup, re-arrangement, 
					  continuation state, mtu
*/
	 
#ifndef SDP_CLT_H
#define SDP_CLT_H

#include <stdio.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdlib.h>

#include <affix/bluetooth.h>
#include <affix/btcore.h>

#include <affix/sdp.h>

__BEGIN_DECLS

#define SDP_SVC_PROVIDER		0x01
#define SDP_SVC_SERVER			0x02

#define MAX_LEN_UUID_STR		37	// The maximum string length

/* SDP */
extern struct affix_tupla ProtocolMnemonic[];
extern struct affix_tupla ServiceClassMnemonic[];

int sdp_init(int flags);
void sdp_cleanup(void);

int sdp_connect(struct sockaddr_affix *saddr);
void sdp_close(int srvHandle);
int sdp_connect_local(void);

slist_t *sdp_get_seq(sdpdata_t *data);

sdpdata_t *sdp_put_u8(uint8_t val);
sdpdata_t *sdp_append_u8(sdpdata_t *seq, uint8_t val);
uint8_t sdp_get_u8(sdpdata_t *data);
sdpdata_t *sdp_put_i8(int8_t val);
sdpdata_t *sdp_append_i8(sdpdata_t *seq, int8_t val);
int8_t sdp_get_i8(sdpdata_t *data);
sdpdata_t *sdp_put_bool(int8_t val);
sdpdata_t *sdp_append_bool(sdpdata_t *seq, int8_t val);
int8_t sdp_get_bool(sdpdata_t *data);
sdpdata_t *sdp_put_u16(uint16_t val);
sdpdata_t *sdp_append_u16(sdpdata_t *seq, uint16_t val);
uint16_t sdp_get_u16(sdpdata_t *data);
sdpdata_t *sdp_put_i16(int16_t val);
sdpdata_t *sdp_append_i16(sdpdata_t *seq, int16_t val);
int16_t sdp_get_i16(sdpdata_t *data);
sdpdata_t *sdp_put_u32(uint32_t val);
sdpdata_t *sdp_append_u32(sdpdata_t *seq, uint32_t val);
uint32_t sdp_get_u32(sdpdata_t *data);
sdpdata_t *sdp_put_i32(int32_t val);
sdpdata_t *sdp_append_i32(sdpdata_t *seq, int32_t val);
int32_t sdp_get_i32(sdpdata_t *data);
sdpdata_t *sdp_put_u64(uint64_t val);
sdpdata_t *sdp_append_u64(sdpdata_t *seq, uint64_t val);
uint64_t sdp_get_u64(sdpdata_t *data);
sdpdata_t *sdp_put_i64(int64_t val);
sdpdata_t *sdp_append_i64(sdpdata_t *seq, int64_t val);
int64_t sdp_get_i64(sdpdata_t *data);
sdpdata_t *sdp_put_u128(uint128_t *val);
sdpdata_t *sdp_append_u128(sdpdata_t *seq, uint128_t *val);
uint128_t *sdp_get_u128(sdpdata_t *data);
sdpdata_t *sdp_put_i128(int128_t *val);
sdpdata_t *sdp_append_i128(sdpdata_t *seq, int128_t *val);
int128_t *sdp_get_i128(sdpdata_t *data);
sdpdata_t *sdp_put_uuid(uuid_t *val);
sdpdata_t *sdp_append_uuid(sdpdata_t *seq, uuid_t *val);
uuid_t *sdp_get_uuid(sdpdata_t *data);
sdpdata_t *sdp_put_uuid16(uint16_t val);
sdpdata_t *sdp_append_uuid16(sdpdata_t *seq, uint16_t val);
sdpdata_t *sdp_put_uuid32(uint32_t val);
sdpdata_t *sdp_append_uuid32(sdpdata_t *seq, uint32_t val);
sdpdata_t *sdp_put_uuid128(uint128_t *val);
sdpdata_t *sdp_append_uuid128(sdpdata_t *seq, uint128_t *val);
sdpdata_t *sdp_put_str(char *str);
sdpdata_t *sdp_append_str(sdpdata_t *seq, char *str);
char *sdp_get_str(sdpdata_t *data);
sdpdata_t *sdp_put_url(char *url);
sdpdata_t *sdp_append_url(sdpdata_t *seq, char *str);
char *sdp_get_url(sdpdata_t *data);
sdpdata_t *sdp_create_seq(void);
sdpdata_t *sdp_append_seq(sdpdata_t *seq);
slist_t *sdp_get_seq(sdpdata_t *data);
sdpdata_t *sdp_create_alt(void);
sdpdata_t *sdp_append_alt(sdpdata_t *seq);


int __sdp_search_req(
		struct sockaddr_affix *sa,
		slist_t *svcSearchList, 
		uint16_t maxSvcRecordCount,
		slist_t **svcResponseList,
		uint16_t *handleCount
		);



typedef enum attributeRequestType {
	IndividualAttributes=1,
	RangeOfAttributes
} sdp_attrreq_t;


int __sdp_attr_req(
		struct sockaddr_affix *sa,
		uint32_t svcHandle,
		sdp_attrreq_t attrReqType,
		slist_t *attrIDList,
		uint16_t maxAttrIDByteCount,
		sdpsvc_t **_svcRec,
		uint16_t *maxAttrResponseByteCount
		);


int __sdp_search_attr_req(
		struct sockaddr_affix *sa,
		slist_t *svcSearchList, 
		sdp_attrreq_t attrReqType,
		slist_t *attrIDList,
		uint16_t maxAttrByteCount,
		slist_t **svcResponseList,
		uint16_t *maxAttrResponseByteCount
		);


int sdp_search_req(
		int srvHandle,
		slist_t *svcSearchList, 
		uint16_t maxSvcRecordCount,
		slist_t **svcResponseList,
		uint16_t *handleCountInResponse);
int sdp_attr_req(
		int srvHandle,
		uint32_t svcHandle,
		sdp_attrreq_t attrReqType,
		slist_t *attrIDList,
		uint16_t maxAttrIDByteCount,
		sdpsvc_t	**_svcRec,
		uint16_t *maxAttrResponseByteCount);
int sdp_search_attr_req(
		int srvHandle,
		slist_t *svcSearchList, 
		sdp_attrreq_t attrReqType,
		slist_t *attrIDList,
		uint16_t maxAttrByteCount,
		slist_t **svcResponseList,
		uint16_t *maxAttrResponseByteCount);


static inline char *sdp_get_string_attr(sdpsvc_t *svcRec, uint16_t attrID)
{
	sdpdata_t	*data;
	
	data = sdp_get_attr(svcRec, attrID);
	if (!data)
		return NULL;
	return sdp_get_str(data);
}

int sdp_is_proto_alt(sdpsvc_t *svcRec);
int sdp_get_proto_alt_attr(sdpsvc_t *svcRec, void **seq, void **state);
int sdp_get_proto_attr(sdpsvc_t *svcRec, void *alt, uuid_t **uuid, void **param, void **state);

int sdp_get_uuid_attr(sdpsvc_t *svcRec, uint16_t attrID, uuid_t **uuid, void **state);

static inline int sdp_get_class_attr(sdpsvc_t *svcRec, uuid_t **uuid, void **state)
{
	return sdp_get_uuid_attr(svcRec, SDP_ATTR_SERVICE_CLASSID_LIST, uuid, state); 
}

static inline int sdp_get_subgroup_attr(sdpsvc_t *svcRec, uuid_t **uuid, void **state)
{
	return sdp_get_uuid_attr(svcRec, SDP_ATTR_BROWSE_GROUP_LIST, uuid, state); 
}

int sdp_get_ttl_attr(sdpsvc_t *svcRec, uint32_t *svcTTLInfo);

int sdp_get_state_attr(sdpsvc_t *svcRec, uint32_t *svcRecState);

int sdp_get_availability_attr(sdpsvc_t *svcRec, uint8_t *svcAvail);

uuid_t *sdp_get_service_attr(sdpsvc_t *svcRec);

uuid_t *sdp_get_group_attr(sdpsvc_t *svcRec);
int sdp_is_group(sdpsvc_t *svcRec);

int sdp_get_lang_attr(sdpsvc_t *svcRec, slist_t **langSeq);

int sdp_get_profile_attr(sdpsvc_t *svcRec, uuid_t **uuid, uint16_t *ver, void **state);

int sdp_get_dbstate_attr(sdpsvc_t *svcRec, uint32_t *svcDBState);

int sdp_get_version_attr(sdpsvc_t *svcRec, uint16_t *ver, void **state);

int sdp_get_info_attr(sdpsvc_t *svcRec, char **name, char **prov, char **desc);

/* -------------------------------------------- */

void sdp_val2uuid16(uuid_t *uuid, uint16_t value16Bit);
void sdp_val2uuid32(uuid_t *uuid, uint32_t value32Bit);
void sdp_val2uuid128(uuid_t *uuid, uint128_t *value128Bit);

int sdp_match_uuid(slist_t *searchPattern, slist_t *targetPattern);
int sdp_uuidcmp(uuid_t *u1, uuid_t *u2);
int sdp_uuidcmp32(uuid_t *u1, uint32_t u2);

void sdp_print_uuid(uuid_t *uuid);  

int sdp_uuid2val(uuid_t *uuid);
int _sdp_uuid2str(uuid_t *uuid, char *str, size_t n);
char *sdp_uuid2str(uuid_t *uuid);

char *sdp_proto2str(uuid_t *uuid);
char *sdp_class2str(uuid_t *uuid);
char *sdp_profile2str(uuid_t *uuid);

/* new */
int sdp_get_rfcomm_port(sdpsvc_t *svcRec);
int sdp_find_uuid(sdpsvc_t *svcRec,  uint32_t uuid32);

uuid_t *s_list_append_uuid16(slist_t **list, uint16_t uuid16);
uuid_t *s_list_append_uuid32(slist_t **list, uint32_t uuid32);

int sdp_uuidcmp(uuid_t *u1, uuid_t *u2);

static inline sdpdata_t *sdp_append_data(sdpdata_t *seq, sdpdata_t *data)
{
	if (!data)
		return NULL;
	s_list_append(&seq->value.dataSeq, data);
	seq->unitSize += data->unitSize;
	return data;
}

static inline void sdp_remove_data(sdpdata_t *seq, sdpdata_t *data)
{
	if (!data)
		return;
	s_list_remove(&seq->value.dataSeq, data);
	seq->unitSize -= data->unitSize;
	sdp_free_data(data);
}


__END_DECLS

#endif //SDP_CLT_H