-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
conn: Simplify and overhaul conn API
This change overhauls the `conn` API in the following manner: * for every `conn` objects now also one can add a callback for asynchronous reception on creation * a common address type for both IPv4 and IPv6 addresses was introduced * instead of having addresses, address length and ports/protocols given separately a new data type called "end points" for every connectivity type is introduced `conn_ep_x_t`, consisting of the address, its family and its port/protocol * send for connection-less communication was simplified by not requiring source information anymore. It can be supplied however by (optionally) providing an already created `conn` object * TCP connection establishment was simplified: listen/connect functions were dropped, instead a user can either give the remote end point on creation (implicit connect) or omit it (implicit listen)
- Loading branch information
Showing
6 changed files
with
262 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (C) 2016 Freie Universität Berlin | ||
* | ||
* 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_addr Address abstractions | ||
* @ingroup net_conn | ||
* @brief Address abstractions for usage with @ref net_conn. | ||
* @{ | ||
* | ||
* @file | ||
* @brief Address abstraction definitions for @ref net_conn. | ||
* | ||
* @author Martine Lenders <mlenders@inf.fu-berlin.de> | ||
*/ | ||
#ifndef CONN_ADDR_H_ | ||
#define CONN_ADDR_H_ | ||
|
||
#include "net/ipv4/addr.h" | ||
#include "net/ipv6/addr.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Type to abstract both IPv4 and IPv6 addresses | ||
*/ | ||
typedef union { | ||
#ifdef CONN_HAS_IPV6 | ||
ipv6_addr_t ipv6; /**< IPv6 address mode */ | ||
#endif | ||
ipv4_addr_t ipv4; /**< IPv4 address mode */ | ||
} conn_addr_ip_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* CONn_ADDR_H_ */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright (C) 2016 Freie Universität Berlin | ||
* | ||
* 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_ep End points | ||
* @ingroup net_conn | ||
* @brief Protocol specific end points for connectivity objects. | ||
* @{ | ||
* | ||
* @file | ||
* @brief Type definitions of protocol specific end points for connectivity | ||
* objects. | ||
* | ||
* @author Martine Lenders <mlenders@inf.fu-berlin.de> | ||
*/ | ||
#ifndef CONN_EP_H_ | ||
#define CONN_EP_H_ | ||
|
||
#include <stdint.h> | ||
|
||
#include "net/conn/addr.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief An end point for a raw IPv4/IPv6 connectivity object. | ||
*/ | ||
typedef struct { | ||
conn_addr_ip_t addr; /**< IP address */ | ||
int family; /**< family of conn_ep_ip_t::addr */ | ||
uint8_t proto; /**< protocol for the IPv4/IPv6 end point */ | ||
} conn_ep_ip_t; | ||
|
||
/** | ||
* @brief An end point for a UDP connectivity object. | ||
*/ | ||
typedef struct { | ||
conn_addr_ip_t addr; /**< IP address */ | ||
int family; /**< family of conn_ep_udp_t::addr */ | ||
uint16_t port; /**< port for the UDP end point */ | ||
} conn_ep_udp_t; | ||
|
||
/** | ||
* @brief An end point for a TCP connectivity object. | ||
*/ | ||
typedef struct { | ||
conn_addr_ip_t addr; /**< IP address */ | ||
int family; /**< family of conn_ep_tcp_t::addr */ | ||
uint16_t port; /**< port for the TCP end point */ | ||
} conn_ep_tcp_t; | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* CONN_EP_H_ */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.