xref: /freebsd/usr.sbin/bluetooth/sdpd/server.h (revision 1e413cf93298b5b97441a21d9a50fdcd0ee9945e)
1 /*
2  * server.h
3  *
4  * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
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  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $
29  * $FreeBSD$
30  */
31 
32 #ifndef _SERVER_H_
33 #define _SERVER_H_
34 
35 /*
36  * File descriptor index entry
37  */
38 
39 struct fd_idx
40 {
41 	unsigned	 valid    : 1;	/* descriptor is valid */
42 	unsigned	 server   : 1;	/* descriptor is listening */
43 	unsigned	 control  : 1;	/* descriptor is a control socket */
44 	unsigned	 priv     : 1;	/* descriptor is privileged */
45 	unsigned	 reserved : 1;
46 	unsigned	 rsp_cs   : 11; /* response continuation state */
47 	uint16_t	 rsp_size;	/* response size */
48 	uint16_t	 rsp_limit;	/* response limit */
49 	uint16_t	 omtu;		/* outgoing MTU */
50 	uint8_t		*rsp;		/* outgoing buffer */
51 };
52 
53 typedef struct fd_idx	fd_idx_t;
54 typedef struct fd_idx *	fd_idx_p;
55 
56 /*
57  * SDP server
58  */
59 
60 struct server
61 {
62 	uint32_t		 imtu;		/* incoming MTU */
63 	uint8_t			*req;		/* incoming buffer */
64 	int32_t			 maxfd;		/* max. descriptor is the set */
65 	fd_set			 fdset;		/* current descriptor set */
66 	fd_idx_p		 fdidx;		/* descriptor index */
67 	struct sockaddr_l2cap	 req_sa;	/* local address */
68 };
69 
70 typedef struct server	server_t;
71 typedef struct server *	server_p;
72 
73 /*
74  * External API
75  */
76 
77 int32_t	server_init(server_p srv, const char *control);
78 void	server_shutdown(server_p srv);
79 int32_t	server_do(server_p srv);
80 
81 int32_t	server_prepare_service_search_response(server_p srv, int32_t fd);
82 int32_t	server_send_service_search_response(server_p srv, int32_t fd);
83 
84 int32_t	server_prepare_service_attribute_response(server_p srv, int32_t fd);
85 int32_t	server_send_service_attribute_response(server_p srv, int32_t fd);
86 
87 int32_t	server_prepare_service_search_attribute_response(server_p srv, int32_t fd);
88 #define	server_send_service_search_attribute_response \
89 	server_send_service_attribute_response
90 
91 int32_t	server_prepare_service_register_response(server_p srv, int32_t fd);
92 int32_t	server_send_service_register_response(server_p srv, int32_t fd);
93 
94 int32_t	server_prepare_service_unregister_response(server_p srv, int32_t fd);
95 #define	server_send_service_unregister_response \
96 	server_send_service_register_response
97 
98 int32_t	server_prepare_service_change_response(server_p srv, int32_t fd);
99 #define	server_send_service_change_response \
100 	server_send_service_register_response
101 
102 #endif /* ndef _SERVER_H_ */
103