11de7b4b8SPedro F. Giffuni /*- 207be7a6cSMaksim Yevmenkin * provider.h 307be7a6cSMaksim Yevmenkin * 4*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 51de7b4b8SPedro F. Giffuni * 607be7a6cSMaksim Yevmenkin * Copyright (c) 2004 Maksim Yevmenkin <m_evmenkin@yahoo.com> 707be7a6cSMaksim Yevmenkin * All rights reserved. 807be7a6cSMaksim Yevmenkin * 907be7a6cSMaksim Yevmenkin * Redistribution and use in source and binary forms, with or without 1007be7a6cSMaksim Yevmenkin * modification, are permitted provided that the following conditions 1107be7a6cSMaksim Yevmenkin * are met: 1207be7a6cSMaksim Yevmenkin * 1. Redistributions of source code must retain the above copyright 1307be7a6cSMaksim Yevmenkin * notice, this list of conditions and the following disclaimer. 1407be7a6cSMaksim Yevmenkin * 2. Redistributions in binary form must reproduce the above copyright 1507be7a6cSMaksim Yevmenkin * notice, this list of conditions and the following disclaimer in the 1607be7a6cSMaksim Yevmenkin * documentation and/or other materials provided with the distribution. 1707be7a6cSMaksim Yevmenkin * 1807be7a6cSMaksim Yevmenkin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1907be7a6cSMaksim Yevmenkin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2007be7a6cSMaksim Yevmenkin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2107be7a6cSMaksim Yevmenkin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2207be7a6cSMaksim Yevmenkin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2307be7a6cSMaksim Yevmenkin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2407be7a6cSMaksim Yevmenkin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2507be7a6cSMaksim Yevmenkin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2607be7a6cSMaksim Yevmenkin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2707be7a6cSMaksim Yevmenkin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2807be7a6cSMaksim Yevmenkin * SUCH DAMAGE. 2907be7a6cSMaksim Yevmenkin * 3007be7a6cSMaksim Yevmenkin * $Id: provider.h,v 1.6 2004/01/13 01:54:39 max Exp $ 3107be7a6cSMaksim Yevmenkin */ 3207be7a6cSMaksim Yevmenkin 3307be7a6cSMaksim Yevmenkin #ifndef _PROVIDER_H_ 3407be7a6cSMaksim Yevmenkin #define _PROVIDER_H_ 3507be7a6cSMaksim Yevmenkin 3607be7a6cSMaksim Yevmenkin /* 3707be7a6cSMaksim Yevmenkin * Provider of service 3807be7a6cSMaksim Yevmenkin */ 3907be7a6cSMaksim Yevmenkin 4007be7a6cSMaksim Yevmenkin struct profile; 4107be7a6cSMaksim Yevmenkin 4207be7a6cSMaksim Yevmenkin struct provider 4307be7a6cSMaksim Yevmenkin { 4407be7a6cSMaksim Yevmenkin struct profile *profile; /* profile */ 4507be7a6cSMaksim Yevmenkin void *data; /* profile data */ 4607be7a6cSMaksim Yevmenkin uint32_t handle; /* record handle */ 4707be7a6cSMaksim Yevmenkin bdaddr_t bdaddr; /* provider's BDADDR */ 4807be7a6cSMaksim Yevmenkin int32_t fd; /* session descriptor */ 4907be7a6cSMaksim Yevmenkin TAILQ_ENTRY(provider) provider_next; /* all providers */ 5007be7a6cSMaksim Yevmenkin }; 5107be7a6cSMaksim Yevmenkin 5207be7a6cSMaksim Yevmenkin typedef struct provider provider_t; 5307be7a6cSMaksim Yevmenkin typedef struct provider * provider_p; 5407be7a6cSMaksim Yevmenkin 5507be7a6cSMaksim Yevmenkin #define provider_match_bdaddr(p, b) \ 5607be7a6cSMaksim Yevmenkin (memcmp(b, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \ 5707be7a6cSMaksim Yevmenkin memcmp(&(p)->bdaddr, NG_HCI_BDADDR_ANY, sizeof(bdaddr_t)) == 0 || \ 5807be7a6cSMaksim Yevmenkin memcmp(&(p)->bdaddr, b, sizeof(bdaddr_t)) == 0) 5907be7a6cSMaksim Yevmenkin 6007be7a6cSMaksim Yevmenkin int32_t provider_register_sd (int32_t fd); 6107be7a6cSMaksim Yevmenkin provider_p provider_register (profile_p const profile, 6207be7a6cSMaksim Yevmenkin bdaddr_p const bdaddr, 6307be7a6cSMaksim Yevmenkin int32_t fd, 6407be7a6cSMaksim Yevmenkin uint8_t const *data, 6507be7a6cSMaksim Yevmenkin uint32_t datalen); 6607be7a6cSMaksim Yevmenkin 6707be7a6cSMaksim Yevmenkin void provider_unregister (provider_p provider); 6807be7a6cSMaksim Yevmenkin int32_t provider_update (provider_p provider, 6907be7a6cSMaksim Yevmenkin uint8_t const *data, 7007be7a6cSMaksim Yevmenkin uint32_t datalen); 7107be7a6cSMaksim Yevmenkin provider_p provider_by_handle (uint32_t handle); 7207be7a6cSMaksim Yevmenkin provider_p provider_get_first (void); 7307be7a6cSMaksim Yevmenkin provider_p provider_get_next (provider_p provider); 7407be7a6cSMaksim Yevmenkin uint32_t provider_get_change_state (void); 7507be7a6cSMaksim Yevmenkin 7607be7a6cSMaksim Yevmenkin #endif /* ndef _PROVIDER_H_ */ 77