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 
84  char *target_addr, uint16_t target_port,
85  uint16_t local_port);
86 
115  const char *local_addr, uint16_t local_port);
116 
139 ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len,
140  const uint32_t user_timeout_duration_us);
141 
169 ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len,
170  const uint32_t user_timeout_duration_us);
171 
180 void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb);
181 
190 void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb);
191 
203 int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr);
204 
215 gnrc_pktsnip_t *gnrc_tcp_hdr_build(gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst);
216 
217 #ifdef __cplusplus
218 }
219 #endif
220 
221 #endif /* NET_GNRC_TCP_H */
222 
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.
int gnrc_tcp_open_active(gnrc_tcp_tcb_t *tcb, uint8_t address_family, char *target_addr, uint16_t target_port, uint16_t local_port)
Opens a connection actively.
uint16_t local_port
Local connections port number.
Definition: tcb.h:58
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
signed int ssize_t
Used for a count of bytes or an error indication.
Definition: msp430_types.h:89
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&#39;s IPv6 implementation.
int gnrc_tcp_init(void)
Initialize TCP.
int gnrc_tcp_open_passive(gnrc_tcp_tcb_t *tcb, uint8_t address_family, const char *local_addr, uint16_t local_port)
Opens a connection passively, by waiting for an incomming request.
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.