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