xref: /btstack/src/btstack_network.h (revision 6b65794db8e2b018da30909c31e5ce969914bcea)
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 
37fe5a6c4eSMilanka Ringwald /**
38fe5a6c4eSMilanka Ringwald  * @title Network Interface
39fe5a6c4eSMilanka Ringwald  *
40b2cc109cSMatthias Ringwald  */
41b2cc109cSMatthias Ringwald 
4280e33422SMatthias Ringwald #ifndef BTSTACK_NETWORK_H
4380e33422SMatthias 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 
52fe5a6c4eSMilanka Ringwald /* API_START */
53fe5a6c4eSMilanka Ringwald 
54b2cc109cSMatthias Ringwald /**
55a7473022SMatthias Ringwald  * @brief Initialize network interface
56b2cc109cSMatthias Ringwald  * @param send_packet_callback
57b2cc109cSMatthias Ringwald  */
58b2cc109cSMatthias Ringwald void btstack_network_init(void (*send_packet_callback)(const uint8_t * packet, uint16_t size));
59b2cc109cSMatthias Ringwald 
60b2cc109cSMatthias Ringwald /**
61b2cc109cSMatthias Ringwald  * @brief Bring up network interfacd
62b2cc109cSMatthias Ringwald  * @param network_address
63b2cc109cSMatthias Ringwald  * @return 0 if ok
64b2cc109cSMatthias Ringwald  */
65b2cc109cSMatthias Ringwald int  btstack_network_up(bd_addr_t network_address);
66b2cc109cSMatthias Ringwald 
67b2cc109cSMatthias Ringwald /**
68a7473022SMatthias Ringwald  * @brief Shut down network interfacd
69b2cc109cSMatthias Ringwald  * @param network_address
70b2cc109cSMatthias Ringwald  * @return 0 if ok
71b2cc109cSMatthias Ringwald  */
72b2cc109cSMatthias Ringwald int  btstack_network_down(void);
73b2cc109cSMatthias Ringwald 
74b2cc109cSMatthias Ringwald /**
75b2cc109cSMatthias Ringwald  * @brief Receive packet on network interface, e.g., forward packet to TCP/IP stack
76b2cc109cSMatthias Ringwald  * @param packet
77b2cc109cSMatthias Ringwald  * @param size
78b2cc109cSMatthias Ringwald  */
79a7473022SMatthias Ringwald void btstack_network_process_packet(const uint8_t * packet, uint16_t size);
80b2cc109cSMatthias Ringwald 
81b2cc109cSMatthias Ringwald /**
82a7473022SMatthias Ringwald  * @brief Notify network interface that packet from send_packet_callback was sent and the next packet can be delivered.
83b2cc109cSMatthias Ringwald  */
84b2cc109cSMatthias Ringwald void btstack_network_packet_sent(void);
85b2cc109cSMatthias Ringwald 
8684693d68SMatthias Ringwald /**
8784693d68SMatthias Ringwald  * @brief Get network name after network was activated
8884693d68SMatthias Ringwald  * @note e.g. tapX on Linux, might not be useful on all platforms
89*6b65794dSMilanka Ringwald  * @return network name
9084693d68SMatthias Ringwald  */
9184693d68SMatthias Ringwald const char * btstack_network_get_name(void);
92b2cc109cSMatthias Ringwald 
93fe5a6c4eSMilanka Ringwald /* API_END */
94fe5a6c4eSMilanka Ringwald 
95b2cc109cSMatthias Ringwald #if defined __cplusplus
96b2cc109cSMatthias Ringwald }
97b2cc109cSMatthias Ringwald #endif
98b2cc109cSMatthias Ringwald 
99b2cc109cSMatthias Ringwald #endif
100