4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $
38 * File descriptor index entry
43 unsigned valid : 1; /* descriptor is valid */
44 unsigned server : 1; /* descriptor is listening */
45 unsigned control : 1; /* descriptor is a control socket */
46 unsigned priv : 1; /* descriptor is privileged */
47 unsigned reserved : 1;
48 unsigned rsp_cs : 11; /* response continuation state */
49 uint16_t rsp_size; /* response size */
50 uint16_t rsp_limit; /* response limit */
51 uint16_t omtu; /* outgoing MTU */
52 uint8_t *rsp; /* outgoing buffer */
55 typedef struct fd_idx fd_idx_t;
56 typedef struct fd_idx * fd_idx_p;
64 uint32_t imtu; /* incoming MTU */
65 uint8_t *req; /* incoming buffer */
66 int32_t maxfd; /* max. descriptor is the set */
67 fd_set fdset; /* current descriptor set */
68 fd_idx_p fdidx; /* descriptor index */
69 struct sockaddr_l2cap req_sa; /* local address */
72 typedef struct server server_t;
73 typedef struct server * server_p;
79 int32_t server_init(server_p srv, const char *control);
80 void server_shutdown(server_p srv);
81 int32_t server_do(server_p srv);
83 int32_t server_prepare_service_search_response(server_p srv, int32_t fd);
84 int32_t server_send_service_search_response(server_p srv, int32_t fd);
86 int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd);
87 int32_t server_send_service_attribute_response(server_p srv, int32_t fd);
89 int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd);
90 #define server_send_service_search_attribute_response \
91 server_send_service_attribute_response
93 int32_t server_prepare_service_register_response(server_p srv, int32_t fd);
94 int32_t server_send_service_register_response(server_p srv, int32_t fd);
96 int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd);
97 #define server_send_service_unregister_response \
98 server_send_service_register_response
100 int32_t server_prepare_service_change_response(server_p srv, int32_t fd);
101 #define server_send_service_change_response \
102 server_send_service_register_response
104 #endif /* ndef _SERVER_H_ */