gnrc/conn.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
22 #ifndef GNRC_CONN_H
23 #define GNRC_CONN_H
24 
25 #include <stdbool.h>
26 #include <stdint.h>
27 #include "net/ipv6/addr.h"
28 #include "net/gnrc.h"
29 #include "sched.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
39 typedef struct {
43 } conn_t;
44 
50 struct conn_ip {
55  uint8_t local_addr[sizeof(ipv6_addr_t)];
56  size_t local_addr_len;
57 };
58 
64 struct conn_udp {
70  uint8_t local_addr[sizeof(ipv6_addr_t)];
71  size_t local_addr_len;
72 };
73 
83 static inline void gnrc_conn_reg(gnrc_netreg_entry_t *entry, gnrc_nettype_t type,
84  uint32_t demux_ctx)
85 {
87  gnrc_netreg_register(type, entry);
88 }
89 
102 bool gnrc_conn6_set_local_addr(uint8_t *conn_addr, const ipv6_addr_t *addr);
103 
123 int gnrc_conn_recvfrom(conn_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len,
124  uint16_t *port);
125 
126 #ifdef __cplusplus
127 }
128 #endif
129 
130 #endif /* GNRC_CONN_H */
131 
uint8_t local_addr[sizeof(ipv6_addr_t)]
local IP address
Definition: gnrc/conn.h:70
Connection base class.
Definition: gnrc/conn.h:39
gnrc_nettype_t l3_type
Network layer type of the connection.
Definition: gnrc/conn.h:40
Entry to the Network protocol registry.
Definition: netreg.h:142
volatile kernel_pid_t sched_active_pid
Process ID of active thread.
Definitions for IPv6 addresses.
gnrc_netreg_entry_t netreg_entry
net_gnrc_netreg entry for the connection
Definition: gnrc/conn.h:42
gnrc_nettype_t l3_type
Network layer type of the connection.
Definition: gnrc/conn.h:51
bool gnrc_conn6_set_local_addr(uint8_t *conn_addr, const ipv6_addr_t *addr)
Sets local address for a connection.
UDP connection type.
Definition: gnrc/conn.h:64
size_t local_addr_len
length of struct conn_ip::local_addr
Definition: gnrc/conn.h:56
int gnrc_conn_recvfrom(conn_t *conn, void *data, size_t max_len, void *addr, size_t *addr_len, uint16_t *port)
Generic recvfrom.
Scheduler API definition.
Raw connection type.
Definition: gnrc/conn.h:50
Includes all essential GNRC network stack base modules.
static void gnrc_netreg_entry_init_pid(gnrc_netreg_entry_t *entry, uint32_t demux_ctx, kernel_pid_t pid)
Initializes a netreg entry dynamically with PID.
Definition: netreg.h:204
gnrc_nettype_t l4_type
Transport layer type of the connection.
Definition: gnrc/conn.h:67
int gnrc_netreg_register(gnrc_nettype_t type, gnrc_netreg_entry_t *entry)
Registers a thread to the registry.
gnrc_nettype_t l4_type
Transport layer type of the connection.
Definition: gnrc/conn.h:52
gnrc_nettype_t l3_type
Network layer type of the connection.
Definition: gnrc/conn.h:65
size_t local_addr_len
length of struct conn_ip::local_addr
Definition: gnrc/conn.h:71
uint8_t local_addr[sizeof(ipv6_addr_t)]
local IP address
Definition: gnrc/conn.h:55
static void gnrc_conn_reg(gnrc_netreg_entry_t *entry, gnrc_nettype_t type, uint32_t demux_ctx)
Bind connection to demux context.
Definition: gnrc/conn.h:83
gnrc_nettype_t l4_type
Transport layer type of the connection.
Definition: gnrc/conn.h:41
Data type to represent an IPv6 address.
Definition: ipv6/addr.h:74
gnrc_nettype_t
Definition of protocol types in the network stack.
Definition: nettype.h:42
gnrc_netreg_entry_t netreg_entry
net_gnrc_netreg entry for the connection
Definition: gnrc/conn.h:54
gnrc_netreg_entry_t netreg_entry
net_gnrc_netreg entry for the connection
Definition: gnrc/conn.h:69