xref: /btstack/src/btstack_network.h (revision 2c4f9bbb6d93b3f1a90ed62ac67e4cd019f0736a)
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  *  btstack_network.h
39  *  Network interface abstraction
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 /**
53  * @brief Initialize network interface
54  * @param send_packet_callback
55  */
56 void btstack_network_init(void (*send_packet_callback)(const uint8_t * packet, uint16_t size));
57 
58 /**
59  * @brief Bring up network interfacd
60  * @param network_address
61  * @return 0 if ok
62  */
63 int  btstack_network_up(bd_addr_t network_address);
64 
65 /**
66  * @brief Shut down network interfacd
67  * @param network_address
68  * @return 0 if ok
69  */
70 int  btstack_network_down(void);
71 
72 /**
73  * @brief Receive packet on network interface, e.g., forward packet to TCP/IP stack
74  * @param packet
75  * @param size
76  */
77 void btstack_network_process_packet(const uint8_t * packet, uint16_t size);
78 
79 /**
80  * @brief Notify network interface that packet from send_packet_callback was sent and the next packet can be delivered.
81  */
82 void btstack_network_packet_sent(void);
83 
84 /**
85  * @brief Get network name after network was activated
86  * @note e.g. tapX on Linux, might not be useful on all platforms
87  * @returns network name
88  */
89 const char * btstack_network_get_name(void);
90 
91 #if defined __cplusplus
92 }
93 #endif
94 
95 #endif
96