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