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 
41 typedef struct {
42  int family;
43  union {
44 #ifdef MODULE_GNRC_IPV6
45  uint8_t ipv6[sizeof(ipv6_addr_t)];
46 #endif
47  uint8_t dummy;
48  } addr;
49  uint16_t netif;
50  uint16_t port;
52 
67 int gnrc_tcp_ep_init(gnrc_tcp_ep_t *ep, int family, const uint8_t *addr, size_t addr_size,
68  uint16_t port, uint16_t netif);
69 
84 int gnrc_tcp_ep_from_str(gnrc_tcp_ep_t *ep, const char *str);
85 
94 int gnrc_tcp_init(void);
95 
103 
129 int gnrc_tcp_open_active(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *remote,
130  uint16_t local_port);
131 
155 int gnrc_tcp_open_passive(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *local);
156 
179 ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len,
180  const uint32_t user_timeout_duration_ms);
181 
210 ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len,
211  const uint32_t user_timeout_duration_ms);
212 
221 void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb);
222 
231 void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb);
232 
244 int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr);
245 
256 gnrc_pktsnip_t *gnrc_tcp_hdr_build(gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst);
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 
262 #endif /* NET_GNRC_TCP_H */
263 
gnrc_tcp_hdr_build
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.
gnrc_tcp_close
void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb)
Close a TCP connection.
ipv6_addr_t
Data type to represent an IPv6 address.
Definition: addr.h:74
gnrc_tcp_calc_csum
int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr)
Calculate and set checksum in TCP header.
gnrc_tcp_ep_t::port
uint16_t port
Port number (in host byte order)
Definition: tcp.h:50
gnrc_tcp_open_active
int gnrc_tcp_open_active(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *remote, uint16_t local_port)
Opens a connection actively.
_transmission_control_block
Transmission control block of GNRC TCP.
Definition: tcb.h:45
gnrc_tcp_ep_t::dummy
uint8_t dummy
Enable build without network module.
Definition: tcp.h:47
gnrc_tcp_ep_t::netif
uint16_t netif
Network interface ID.
Definition: tcp.h:49
gnrc_tcp_recv
ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len, const uint32_t user_timeout_duration_ms)
Receive Data from the peer.
gnrc_tcp_send
ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len, const uint32_t user_timeout_duration_ms)
Transmit data to connected peer.
gnrc_tcp_ep_from_str
int gnrc_tcp_ep_from_str(gnrc_tcp_ep_t *ep, const char *str)
Construct TCP connection endpoint from string.
gnrc_tcp_abort
void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb)
Abort a TCP connection.
pkt.h
General definitions for network packets and their helper functions.
gnrc_tcp_ep_t
Address information for a single TCP connection endpoint.
Definition: tcp.h:41
gnrc_tcp_ep_init
int gnrc_tcp_ep_init(gnrc_tcp_ep_t *ep, int family, const uint8_t *addr, size_t addr_size, uint16_t port, uint16_t netif)
Initialize TCP connection endpoint.
ipv6.h
Definitions for GNRC's IPv6 implementation.
gnrc_tcp_tcb_init
void gnrc_tcp_tcb_init(gnrc_tcp_tcb_t *tcb)
Initialize Transmission Control Block (TCB)
gnrc_tcp_init
int gnrc_tcp_init(void)
Initialize TCP.
tcb.h
GNRC TCP transmission control block (TCB)
gnrc_tcp_ep_t::family
int family
IP address family.
Definition: tcp.h:42
gnrc_tcp_open_passive
int gnrc_tcp_open_passive(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *local)
Opens a connection passively, by waiting for an incoming request.
gnrc_pktsnip
Type to represent parts (either headers or payload) of a packet, called snips.
Definition: pkt.h:108