1b2cc109cSMatthias Ringwald /* 2b2cc109cSMatthias Ringwald * 3b2cc109cSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 4b2cc109cSMatthias Ringwald * modification, are permitted provided that the following conditions 5b2cc109cSMatthias Ringwald * are met: 6b2cc109cSMatthias Ringwald * 7b2cc109cSMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 8b2cc109cSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 9b2cc109cSMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 10b2cc109cSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 11b2cc109cSMatthias Ringwald * documentation and/or other materials provided with the distribution. 12b2cc109cSMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 13b2cc109cSMatthias Ringwald * contributors may be used to endorse or promote products derived 14b2cc109cSMatthias Ringwald * from this software without specific prior written permission. 15b2cc109cSMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 16b2cc109cSMatthias Ringwald * personal benefit and not for any commercial purpose or for 17b2cc109cSMatthias Ringwald * monetary gain. 18b2cc109cSMatthias Ringwald * 19b2cc109cSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 20b2cc109cSMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21b2cc109cSMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22b2cc109cSMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 23b2cc109cSMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24b2cc109cSMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 25b2cc109cSMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 26b2cc109cSMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27b2cc109cSMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28b2cc109cSMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29b2cc109cSMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30b2cc109cSMatthias Ringwald * SUCH DAMAGE. 31b2cc109cSMatthias Ringwald * 32b2cc109cSMatthias Ringwald * Please inquire about commercial licensing options at 33b2cc109cSMatthias Ringwald * [email protected] 34b2cc109cSMatthias Ringwald * 35b2cc109cSMatthias Ringwald */ 36b2cc109cSMatthias Ringwald 37b2cc109cSMatthias Ringwald /* 38b2cc109cSMatthias Ringwald * btstack_network.h 39b2cc109cSMatthias Ringwald * Network interface abstraction 40b2cc109cSMatthias Ringwald */ 41b2cc109cSMatthias Ringwald 42*80e33422SMatthias Ringwald #ifndef BTSTACK_NETWORK_H 43*80e33422SMatthias Ringwald #define BTSTACK_NETWORK_H 44b2cc109cSMatthias Ringwald 45b2cc109cSMatthias Ringwald #include <stdint.h> 46a7473022SMatthias Ringwald #include "bluetooth.h" 47b2cc109cSMatthias Ringwald 48b2cc109cSMatthias Ringwald #if defined __cplusplus 49b2cc109cSMatthias Ringwald extern "C" { 50b2cc109cSMatthias Ringwald #endif 51b2cc109cSMatthias Ringwald 52b2cc109cSMatthias Ringwald /** 53a7473022SMatthias Ringwald * @brief Initialize network interface 54b2cc109cSMatthias Ringwald * @param send_packet_callback 55b2cc109cSMatthias Ringwald */ 56b2cc109cSMatthias Ringwald void btstack_network_init(void (*send_packet_callback)(const uint8_t * packet, uint16_t size)); 57b2cc109cSMatthias Ringwald 58b2cc109cSMatthias Ringwald /** 59b2cc109cSMatthias Ringwald * @brief Bring up network interfacd 60b2cc109cSMatthias Ringwald * @param network_address 61b2cc109cSMatthias Ringwald * @return 0 if ok 62b2cc109cSMatthias Ringwald */ 63b2cc109cSMatthias Ringwald int btstack_network_up(bd_addr_t network_address); 64b2cc109cSMatthias Ringwald 65b2cc109cSMatthias Ringwald /** 66a7473022SMatthias Ringwald * @brief Shut down network interfacd 67b2cc109cSMatthias Ringwald * @param network_address 68b2cc109cSMatthias Ringwald * @return 0 if ok 69b2cc109cSMatthias Ringwald */ 70b2cc109cSMatthias Ringwald int btstack_network_down(void); 71b2cc109cSMatthias Ringwald 72b2cc109cSMatthias Ringwald /** 73b2cc109cSMatthias Ringwald * @brief Receive packet on network interface, e.g., forward packet to TCP/IP stack 74b2cc109cSMatthias Ringwald * @param packet 75b2cc109cSMatthias Ringwald * @param size 76b2cc109cSMatthias Ringwald */ 77a7473022SMatthias Ringwald void btstack_network_process_packet(const uint8_t * packet, uint16_t size); 78b2cc109cSMatthias Ringwald 79b2cc109cSMatthias Ringwald /** 80a7473022SMatthias Ringwald * @brief Notify network interface that packet from send_packet_callback was sent and the next packet can be delivered. 81b2cc109cSMatthias Ringwald */ 82b2cc109cSMatthias Ringwald void btstack_network_packet_sent(void); 83b2cc109cSMatthias Ringwald 8484693d68SMatthias Ringwald /** 8584693d68SMatthias Ringwald * @brief Get network name after network was activated 8684693d68SMatthias Ringwald * @note e.g. tapX on Linux, might not be useful on all platforms 8784693d68SMatthias Ringwald * @returns network name 8884693d68SMatthias Ringwald */ 8984693d68SMatthias Ringwald const char * btstack_network_get_name(void); 90b2cc109cSMatthias Ringwald 91b2cc109cSMatthias Ringwald #if defined __cplusplus 92b2cc109cSMatthias Ringwald } 93b2cc109cSMatthias Ringwald #endif 94b2cc109cSMatthias Ringwald 95b2cc109cSMatthias Ringwald #endif 96