xref: /dragonfly/usr.sbin/sdpd/provider.h (revision c3b249e6)
1 /* $NetBSD: provider.h,v 1.2 2007/11/09 20:08:41 plunky Exp $ */
2 /* $DragonFly: src/usr.sbin/sdpd/provider.h,v 1.1 2008/01/06 21:51:30 hasso Exp $ */
3 
4 /*-
5  * Copyright (c) 2006 Itronix Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. The name of Itronix Inc. may not be used to endorse
17  *    or promote products derived from this software without specific
18  *    prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY ITRONIX INC. ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL ITRONIX INC. BE LIABLE FOR ANY
24  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27  * ON ANY THEORY OF LIABILITY, WHETHER IN
28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  * provider.h
34  *
35  * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
36  * All rights reserved.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57  * SUCH DAMAGE.
58  *
59  * $Id: provider.h,v 1.2 2007/11/30 07:39:37 griffin Exp $
60  * $FreeBSD: src/usr.sbin/bluetooth/sdpd/provider.h,v 1.1 2004/01/20 20:48:26 emax Exp $
61  */
62 
63 #ifndef _PROVIDER_H_
64 #define _PROVIDER_H_
65 
66 /*
67  * Provider of service
68  */
69 
70 struct profile;
71 
72 struct provider
73 {
74 	struct profile		*profile;		/* profile */
75 	void			*data;			/* profile data */
76 	uint32_t		 handle;		/* record handle */
77 	bdaddr_t		 bdaddr;		/* provider's BDADDR */
78 	int32_t			 fd;			/* session descriptor */
79 	TAILQ_ENTRY(provider)	 provider_next;		/* all providers */
80 };
81 
82 typedef struct provider		provider_t;
83 typedef struct provider	*	provider_p;
84 
85 #define		provider_match_bdaddr(p, b) \
86 	(bdaddr_any(b) || bdaddr_any(&(p)->bdaddr) || \
87 	 bdaddr_same(&(p)->bdaddr, (b)))
88 
89 int32_t		provider_register_sd		(int32_t fd);
90 provider_p	provider_register		(profile_p const profile,
91 						 bdaddr_t const *bdaddr,
92 						 int32_t fd,
93 						 uint8_t const *data,
94 						 uint32_t datalen);
95 
96 void		provider_unregister		(provider_p provider);
97 int32_t		provider_update			(provider_p provider,
98 						 uint8_t const *data,
99 						 uint32_t datalen);
100 provider_p	provider_by_handle		(uint32_t handle);
101 provider_p	provider_get_first		(void);
102 provider_p	provider_get_next		(provider_p provider);
103 uint32_t	provider_get_change_state	(void);
104 
105 int		provider_match_uuid		(provider_p provider,
106 						 uint128_t *ulist, int ucount);
107 
108 int32_t server_prepare_attr_list(provider_p const, uint8_t const *, uint8_t const *,
109 		uint8_t *, uint8_t const *);
110 
111 #endif /* ndef _PROVIDER_H_ */
112