1124758Semax/*
2124758Semax * provider.h
3124758Semax *
4124758Semax * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5124758Semax * All rights reserved.
6124758Semax *
7124758Semax * Redistribution and use in source and binary forms, with or without
8124758Semax * modification, are permitted provided that the following conditions
9124758Semax * are met:
10124758Semax * 1. Redistributions of source code must retain the above copyright
11124758Semax *    notice, this list of conditions and the following disclaimer.
12124758Semax * 2. Redistributions in binary form must reproduce the above copyright
13124758Semax *    notice, this list of conditions and the following disclaimer in the
14124758Semax *    documentation and/or other materials provided with the distribution.
15124758Semax *
16124758Semax * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17124758Semax * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18124758Semax * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19124758Semax * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20124758Semax * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21124758Semax * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22124758Semax * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23124758Semax * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24124758Semax * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25124758Semax * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26124758Semax * SUCH DAMAGE.
27124758Semax *
28124758Semax * $Id: provider.h,v 1.6 2004/01/13 01:54:39 max Exp $
29124758Semax * $FreeBSD$
30124758Semax */
31124758Semax
32124758Semax#ifndef _PROVIDER_H_
33124758Semax#define _PROVIDER_H_
34124758Semax
35124758Semax/*
36124758Semax * Provider of service
37124758Semax */
38124758Semax
39124758Semaxstruct profile;
40124758Semax
41124758Semaxstruct provider
42124758Semax{
43124758Semax	struct profile 		*profile;		/* profile */
44124758Semax	void			*data;			/* profile data */
45124758Semax	uint32_t		 handle;		/* record handle */
46124758Semax	bdaddr_t		 bdaddr;		/* provider's BDADDR */
47124758Semax	int32_t			 fd;			/* session descriptor */
48124758Semax	TAILQ_ENTRY(provider)	 provider_next;		/* all providers */
49124758Semax};
50124758Semax
51124758Semaxtypedef struct provider		provider_t;
52124758Semaxtypedef struct provider	*	provider_p;
53124758Semax
54124758Semax#define		provider_match_bdaddr(p, b) \
55124758Semax	(memcmp(b, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \
56124758Semax	 memcmp(&(p)->bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \
57124758Semax	 memcmp(&(p)->bdaddr, b, sizeof(bdaddr_t)) == 0)
58124758Semax
59124758Semaxint32_t		provider_register_sd		(int32_t fd);
60124758Semaxprovider_p	provider_register		(profile_p const profile,
61124758Semax						 bdaddr_p const bdaddr,
62124758Semax						 int32_t fd,
63124758Semax						 uint8_t const *data,
64124758Semax						 uint32_t datalen);
65124758Semax
66124758Semaxvoid		provider_unregister		(provider_p provider);
67124758Semaxint32_t		provider_update			(provider_p provider,
68124758Semax						 uint8_t const *data,
69124758Semax						 uint32_t datalen);
70124758Semaxprovider_p	provider_by_handle		(uint32_t handle);
71124758Semaxprovider_p	provider_get_first		(void);
72124758Semaxprovider_p	provider_get_next		(provider_p provider);
73124758Semaxuint32_t	provider_get_change_state	(void);
74124758Semax
75124758Semax#endif /* ndef _PROVIDER_H_ */
76