/*-1* server.h2*3* SPDX-License-Identifier: BSD-2-Clause4*5* Copyright (c) 2004 Maksim Yevmenkin <[email protected]>6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions and the following disclaimer.13* 2. Redistributions in binary form must reproduce the above copyright14* notice, this list of conditions and the following disclaimer in the15* documentation and/or other materials provided with the distribution.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE21* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*29* $Id: server.h,v 1.5 2004/01/13 01:54:39 max Exp $30*/3132#ifndef _SERVER_H_33#define _SERVER_H_3435/*36* File descriptor index entry37*/3839struct fd_idx40{41unsigned valid : 1; /* descriptor is valid */42unsigned server : 1; /* descriptor is listening */43unsigned control : 1; /* descriptor is a control socket */44unsigned priv : 1; /* descriptor is privileged */45unsigned reserved : 1;46unsigned rsp_cs : 11; /* response continuation state */47uint16_t rsp_size; /* response size */48uint16_t rsp_limit; /* response limit */49uint16_t omtu; /* outgoing MTU */50uint8_t *rsp; /* outgoing buffer */51};5253typedef struct fd_idx fd_idx_t;54typedef struct fd_idx * fd_idx_p;5556/*57* SDP server58*/5960struct server61{62uint32_t imtu; /* incoming MTU */63uint8_t *req; /* incoming buffer */64int32_t maxfd; /* max. descriptor is the set */65fd_set fdset; /* current descriptor set */66fd_idx_p fdidx; /* descriptor index */67struct sockaddr_l2cap req_sa; /* local address */68};6970typedef struct server server_t;71typedef struct server * server_p;7273/*74* External API75*/7677int32_t server_init(server_p srv, const char *control);78void server_shutdown(server_p srv);79int32_t server_do(server_p srv);8081int32_t server_prepare_service_search_response(server_p srv, int32_t fd);82int32_t server_send_service_search_response(server_p srv, int32_t fd);8384int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd);85int32_t server_send_service_attribute_response(server_p srv, int32_t fd);8687int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd);88#define server_send_service_search_attribute_response \89server_send_service_attribute_response9091int32_t server_prepare_service_register_response(server_p srv, int32_t fd);92int32_t server_send_service_register_response(server_p srv, int32_t fd);9394int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd);95#define server_send_service_unregister_response \96server_send_service_register_response9798int32_t server_prepare_service_change_response(server_p srv, int32_t fd);99#define server_send_service_change_response \100server_send_service_register_response101102#endif /* ndef _SERVER_H_ */103104105