provider.h revision 124758
1166060Smarius/*
2166060Smarius * provider.h
3166060Smarius *
4166060Smarius * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5166060Smarius * All rights reserved.
6166060Smarius *
7166060Smarius * Redistribution and use in source and binary forms, with or without
8166060Smarius * modification, are permitted provided that the following conditions
9166060Smarius * are met:
10166060Smarius * 1. Redistributions of source code must retain the above copyright
11166060Smarius *    notice, this list of conditions and the following disclaimer.
12166060Smarius * 2. Redistributions in binary form must reproduce the above copyright
13166060Smarius *    notice, this list of conditions and the following disclaimer in the
14166060Smarius *    documentation and/or other materials provided with the distribution.
15166060Smarius *
16166060Smarius * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17166060Smarius * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18166060Smarius * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19166060Smarius * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20166060Smarius * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21166060Smarius * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22166060Smarius * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23166060Smarius * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24166060Smarius * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25166060Smarius * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26166060Smarius * SUCH DAMAGE.
27166060Smarius *
28166060Smarius * $Id: provider.h,v 1.6 2004/01/13 01:54:39 max Exp $
29166060Smarius * $FreeBSD: head/usr.sbin/bluetooth/sdpd/provider.h 124758 2004-01-20 20:48:26Z emax $
30166060Smarius */
31166060Smarius
32166060Smarius#ifndef _PROVIDER_H_
33166060Smarius#define _PROVIDER_H_
34166060Smarius
35166060Smarius/*
36166060Smarius * Provider of service
37166060Smarius */
38166060Smarius
39166060Smariusstruct profile;
40166060Smarius
41166060Smariusstruct provider
42166060Smarius{
43166060Smarius	struct profile 		*profile;		/* profile */
44166060Smarius	void			*data;			/* profile data */
45166060Smarius	uint32_t		 handle;		/* record handle */
46166060Smarius	bdaddr_t		 bdaddr;		/* provider's BDADDR */
47166060Smarius	int32_t			 fd;			/* session descriptor */
48166060Smarius	TAILQ_ENTRY(provider)	 provider_next;		/* all providers */
49166060Smarius};
50166060Smarius
51166060Smariustypedef struct provider		provider_t;
52166060Smariustypedef struct provider	*	provider_p;
53166060Smarius
54166060Smarius#define		provider_match_bdaddr(p, b) \
55166060Smarius	(memcmp(b, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \
56166060Smarius	 memcmp(&(p)->bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \
57166060Smarius	 memcmp(&(p)->bdaddr, b, sizeof(bdaddr_t)) == 0)
58166060Smarius
59166060Smariusint32_t		provider_register_sd		(int32_t fd);
60166060Smariusprovider_p	provider_register		(profile_p const profile,
61166060Smarius						 bdaddr_p const bdaddr,
62166060Smarius						 int32_t fd,
63166060Smarius						 uint8_t const *data,
64166060Smarius						 uint32_t datalen);
65166060Smarius
66172066Smariusvoid		provider_unregister		(provider_p provider);
67166060Smariusint32_t		provider_update			(provider_p provider,
68166060Smarius						 uint8_t const *data,
69166060Smarius						 uint32_t datalen);
70166060Smariusprovider_p	provider_by_handle		(uint32_t handle);
71166060Smariusprovider_p	provider_get_first		(void);
72166060Smariusprovider_p	provider_get_next		(provider_p provider);
73166060Smariusuint32_t	provider_get_change_state	(void);
74166060Smarius
75166060Smarius#endif /* ndef _PROVIDER_H_ */
76166060Smarius