gnrc/tcp.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2017 Simon Brummer
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 NET_GNRC_TCP_H
23 #define NET_GNRC_TCP_H
24 
25 #include <stdint.h>
26 #include "net/gnrc/pkt.h"
27 #include "net/gnrc/tcp/tcb.h"
28 
29 #ifdef MODULE_GNRC_IPV6
30 #include "net/gnrc/ipv6.h"
31 #endif
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
45 int gnrc_tcp_init(void);
46 
54 
82 int gnrc_tcp_open_active(gnrc_tcp_tcb_t *tcb, const uint8_t address_family,
83  const uint8_t *target_addr, const uint16_t target_port,
84  const uint16_t local_port);
85 
112 int gnrc_tcp_open_passive(gnrc_tcp_tcb_t *tcb, const uint8_t address_family,
113  const uint8_t *local_addr, const uint16_t local_port);
114 
137 ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len,
138  const uint32_t user_timeout_duration_us);
139 
167 ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len,
168  const uint32_t user_timeout_duration_us);
169 
178 void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb);
179 
188 void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb);
189 
201 int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr);
202 
213 gnrc_pktsnip_t *gnrc_tcp_hdr_build(gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst);
214 
215 #ifdef __cplusplus
216 }
217 #endif
218 
219 #endif /* NET_GNRC_TCP_H */
220 
GNRC TCP transmission control block (TCB)
General definitions for network packets and their helper functions.
gnrc_pktsnip_t * gnrc_tcp_hdr_build(gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst)
Adds a TCP header to a given payload.
uint16_t local_port
Local connections port number.
Definition: tcb.h:57
void gnrc_tcp_tcb_init(gnrc_tcp_tcb_t *tcb)
Initialize Transmission Control Block (TCB)
Transmission control block of GNRC TCP.
Definition: tcb.h:51
void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb)
Abort a TCP connection.
uint8_t address_family
Address Family of local_addr / peer_addr.
Definition: tcb.h:52
void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb)
Close a TCP connection.
ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len, const uint32_t user_timeout_duration_us)
Receive Data from the peer.
Definitions for GNRC's IPv6 implementation.
int gnrc_tcp_open_passive(gnrc_tcp_tcb_t *tcb, const uint8_t address_family, const uint8_t *local_addr, const uint16_t local_port)
Opens a connection passively, by waiting for an incomming request.
int gnrc_tcp_init(void)
Initialize TCP.
ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len, const uint32_t user_timeout_duration_us)
Transmit data to connected peer.
Type to represent parts (either headers or payload) of a packet, called snips.
uint8_t local_addr[sizeof(ipv6_addr_t)]
Local IP address.
Definition: tcb.h:54
int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr)
Calculate and set checksum in TCP header.
int gnrc_tcp_open_active(gnrc_tcp_tcb_t *tcb, const uint8_t address_family, const uint8_t *target_addr, const uint16_t target_port, const uint16_t local_port)
Opens a connection actively.