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 reserved : 2; 45 unsigned rsp_cs : 11; /* response continuation state */ 46 uint16_t rsp_size; /* response size */ 47 uint16_t rsp_limit; /* response limit */ 48 uint16_t omtu; /* outgoing MTU */ 49 uint8_t *rsp; /* outgoing buffer */ 50 }; 51 52 typedef struct fd_idx fd_idx_t; 53 typedef struct fd_idx * fd_idx_p; 54 55 /* 56 * SDP server 57 */ 58 59 struct server 60 { 61 uint32_t imtu; /* incoming MTU */ 62 uint8_t *req; /* incoming buffer */ 63 int32_t maxfd; /* max. descriptor is the set */ 64 fd_set fdset; /* current descriptor set */ 65 fd_idx_p fdidx; /* descriptor index */ 66 struct sockaddr_l2cap req_sa; /* local address */ 67 }; 68 69 typedef struct server server_t; 70 typedef struct server * server_p; 71 72 /* 73 * External API 74 */ 75 76 int32_t server_init(server_p srv, const char *control); 77 void server_shutdown(server_p srv); 78 int32_t server_do(server_p srv); 79 80 int32_t server_prepare_service_search_response(server_p srv, int32_t fd); 81 int32_t server_send_service_search_response(server_p srv, int32_t fd); 82 83 int32_t server_prepare_service_attribute_response(server_p srv, int32_t fd); 84 int32_t server_send_service_attribute_response(server_p srv, int32_t fd); 85 86 int32_t server_prepare_service_search_attribute_response(server_p srv, int32_t fd); 87 #define server_send_service_search_attribute_response \ 88 server_send_service_attribute_response 89 90 int32_t server_prepare_service_register_response(server_p srv, int32_t fd); 91 int32_t server_send_service_register_response(server_p srv, int32_t fd); 92 93 int32_t server_prepare_service_unregister_response(server_p srv, int32_t fd); 94 #define server_send_service_unregister_response \ 95 server_send_service_register_response 96 97 int32_t server_prepare_service_change_response(server_p srv, int32_t fd); 98 #define server_send_service_change_response \ 99 server_send_service_register_response 100 101 #endif /* ndef _SERVER_H_ */ 102