1 /*- 2 * server.h 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 * 6 * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 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. 17 * 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 28 * SUCH DAMAGE. 29 * 30 * $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $ 31 */ 32 33 #ifndef _SERVER_H_ 34 #define _SERVER_H_ 35 36 /* 37 * File descriptor index entry 38 */ 39 40 struct fd_idx 41 { 42 unsigned valid : 1; /* descriptor is valid */ 43 unsigned server : 1; /* descriptor is listening */ 44 unsigned control : 1; /* descriptor is a control socket */ 45 unsigned priv : 1; /* descriptor is privileged */ 46 unsigned reserved : 1; 47 unsigned rsp_cs : 11; /* response continuation state */ 48 uint16_t rsp_size; /* response size */ 49 uint16_t rsp_limit; /* response limit */ 50 uint16_t omtu; /* outgoing MTU */ 51 uint8_t *rsp; /* outgoing buffer */ 52 }; 53 54 typedef struct fd_idx fd_idx_t; 55 typedef struct fd_idx * fd_idx_p; 56 57 /* 58 * SDP server 59 */ 60 61 struct server 62 { 63 uint32_t imtu; /* incoming MTU */ 64 uint8_t *req; /* incoming buffer */ 65 int32_t maxfd; /* max. descriptor is the set */ 66 fd_set fdset; /* current descriptor set */ 67 fd_idx_p fdidx; /* descriptor index */ 68 struct sockaddr_l2cap req_sa; /* local address */ 69 }; 70 71 typedef struct server server_t; 72 typedef struct server * server_p; 73 74 /* 75 * External API 76 */ 77 78 int32_t server_init(server_p srv, const char *control); 79 void server_shutdown(server_p srv); 80 int32_t server_do(server_p srv); 81 82 int32_t server_prepare_service_search_response(server_p srv, int32_t fd); 83 int32_t server_send_service_search_response(server_p srv, int32_t fd); 84 85 int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd); 86 int32_t server_send_service_attribute_response(server_p srv, int32_t fd); 87 88 int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd); 89 #define server_send_service_search_attribute_response \ 90 server_send_service_attribute_response 91 92 int32_t server_prepare_service_register_response(server_p srv, int32_t fd); 93 int32_t server_send_service_register_response(server_p srv, int32_t fd); 94 95 int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd); 96 #define server_send_service_unregister_response \ 97 server_send_service_register_response 98 99 int32_t server_prepare_service_change_response(server_p srv, int32_t fd); 100 #define server_send_service_change_response \ 101 server_send_service_register_response 102 103 #endif /* ndef _SERVER_H_ */ 104