Rework stop path.
[dragonfly.git] / usr.sbin / sdpd / server.h
blob74411d18c05f0cd809e330daddba248553aac7f4
1 /* $NetBSD: server.h,v 1.3 2007/11/09 20:08:41 plunky Exp $ */
2 /* $DragonFly: src/usr.sbin/sdpd/server.h,v 1.1 2008/01/06 21:51:30 hasso Exp $ */
4 /*-
5 * Copyright (c) 2006 Itronix Inc.
6 * All rights reserved.
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.
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.
33 * server.h
35 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
36 * All rights reserved.
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.
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.
59 * $Id: server.h,v 1.2 2007/11/30 07:39:37 griffin Exp $
60 * $FreeBSD: src/usr.sbin/bluetooth/sdpd/server.h,v 1.2 2005/12/06 17:56:36 emax Exp $
63 #ifndef _SERVER_H_
64 #define _SERVER_H_
67 * File descriptor index entry
70 struct fd_idx
72 unsigned valid : 1; /* descriptor is valid */
73 unsigned server : 1; /* descriptor is listening */
74 unsigned control : 1; /* descriptor is a control socket */
75 unsigned priv : 1; /* descriptor is privileged */
76 unsigned reserved : 1;
77 unsigned rsp_cs : 11; /* response continuation state */
78 uint16_t rsp_size; /* response size */
79 uint16_t rsp_limit; /* response limit */
80 uint16_t omtu; /* outgoing MTU */
81 uint8_t *rsp; /* outgoing buffer */
84 typedef struct fd_idx fd_idx_t;
85 typedef struct fd_idx * fd_idx_p;
88 * SDP server
91 struct server
93 uint16_t imtu; /* incoming MTU */
94 uint8_t *req; /* incoming buffer */
95 int32_t maxfd; /* max. descriptor is the set */
96 fd_set fdset; /* current descriptor set */
97 fd_idx_p fdidx; /* descriptor index */
98 struct sockaddr_bt req_sa; /* local address */
99 const char *sgroup; /* privileged group */
102 typedef struct server server_t;
103 typedef struct server * server_p;
106 * External API
109 int32_t server_init(server_p srv, const char *control, char const *sgroup);
110 void server_shutdown(server_p srv);
111 int32_t server_do(server_p srv);
113 int server_get_service_search_pattern(uint8_t const **buf, uint8_t const *end, uint128_t *uuid);
115 int32_t server_prepare_service_search_response(server_p srv, int32_t fd);
116 int32_t server_send_service_search_response(server_p srv, int32_t fd);
118 int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd);
119 int32_t server_send_service_attribute_response(server_p srv, int32_t fd);
121 int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd);
122 #define server_send_service_search_attribute_response \
123 server_send_service_attribute_response
125 int32_t server_prepare_service_register_response(server_p srv, int32_t fd);
126 int32_t server_send_service_register_response(server_p srv, int32_t fd);
128 int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd);
129 #define server_send_service_unregister_response \
130 server_send_service_register_response
132 int32_t server_prepare_service_change_response(server_p srv, int32_t fd);
133 #define server_send_service_change_response \
134 server_send_service_register_response
136 #endif /* ndef _SERVER_H_ */