conn.h
3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_conn Application connection API
* @ingroup net
* @deprecated Please use @ref net_sock instead
* @brief Provides a minimal common API for applications to connect to the
* different network stacks.
*
* About
* =====
*
* ~~~~~~~~~~~~~~~~~~~~~
* +---------------+
* | Application |
* +---------------+
* ^
* |
* v
* conn
* ^
* |
* v
* +---------------+
* | Network Stack |
* +---------------+
* ~~~~~~~~~~~~~~~~~~~~~
*
* This module provides a minimal set of functions to establish a connection using
* different types of connections. Together, they serve as a common API
* that connects application- and network stack code.
*
* Currently the following connection types are defined:
*
* * @ref conn_ip_t (net/conn/ip.h): raw IP connections
* * @ref conn_tcp_t (net/conn/tcp.h): TCP connections
* * @ref conn_udp_t (net/conn/udp.h): UDP connections
*
* Each network stack must implement at least one connection type.
*
* Note that there might be no relation between the different connection types.
* For simplicity and modularity this API doesn't put any restriction of the actual
* implementation of the type. For example, one implementation might choose
* to have all connection types have a common base class or use the raw IPv6
* connection type to send e.g. UDP packets, while others will keep them
* completely separate from each other.
*
* How To Use
* ==========
*
* A RIOT application uses the functions provided by one or more of the connection types
* headers (for example @ref conn_udp_t), regardless of the network stack it uses.
* The network stack used under the bonnet is specified by including the appropriate
* module (for example USEMODULE += gnrc_conn_udp)
*
* This allows for network stack agnostic code on the application layer.
* The application code to establish a connection is always the same, allowing
* the network stack underneath to be switched simply by changing the USEMODULE
* definition in the application's Makefile.
*
* @{
*
* @file
* @brief Application connection API definitions
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Oliver Hahm <oliver.hahm@inria.fr>
*/
#ifndef NET_CONN_H_
#define NET_CONN_H_
#include "net/conn/ip.h"
#include "net/conn/tcp.h"
#include "net/conn/udp.h"
#include "net/ipv6/addr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Find the best matching source address for a given prefix
*
* @param[in] dst Pointer to the IPv6 address to find a match for
* Must not be NULL
*
* @return NULL if no matching address on any interface could be found
* @return pointer to an IPv6 address configured on an interface with the best
* match to @p dst
*/
ipv6_addr_t *conn_find_best_source(const ipv6_addr_t *dst);
#ifdef __cplusplus
}
#endif
#endif /* NET_CONN_H_ */
/** @} */