Loading...
Searching...
No Matches
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 SOCK_HAS_IPV6
30#include "net/sock.h"
31#else
32#ifdef MODULE_GNRC_IPV6
33#include "net/gnrc/ipv6.h"
34#endif
35#endif
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/* Note: This value if configurable for test purposes. Do not override it.
42 * Changing this value may lead to errors that are hard to track down.
43 */
44#ifndef GNRC_TCP_NO_TIMEOUT
48#define GNRC_TCP_NO_TIMEOUT (UINT32_MAX)
49#endif
50
51#ifdef SOCK_HAS_IPV6
52/* Reuse sock endpoint if sock is available and supporting IPv6. */
53typedef struct _sock_tl_ep gnrc_tcp_ep_t;
54
55#else
60typedef struct {
61 int family;
62 union {
63#ifdef MODULE_GNRC_IPV6
64 uint8_t ipv6[sizeof(ipv6_addr_t)];
65#endif
66 uint8_t dummy;
67 } addr;
68 uint16_t netif;
69 uint16_t port;
71#endif
72
87int gnrc_tcp_ep_init(gnrc_tcp_ep_t *ep, int family, const uint8_t *addr, size_t addr_size,
88 uint16_t port, uint16_t netif);
89
104int gnrc_tcp_ep_from_str(gnrc_tcp_ep_t *ep, const char *str);
105
115
123
131
158int gnrc_tcp_open(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *remote, uint16_t local_port);
159
182int gnrc_tcp_listen(gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_tcb_t *tcbs, size_t tcbs_len,
183 const gnrc_tcp_ep_t *local);
184
207 const uint32_t user_timeout_duration_ms);
208
234ssize_t gnrc_tcp_send(gnrc_tcp_tcb_t *tcb, const void *data, const size_t len,
235 const uint32_t user_timeout_duration_ms);
236
268ssize_t gnrc_tcp_recv(gnrc_tcp_tcb_t *tcb, void *data, const size_t max_len,
269 const uint32_t user_timeout_duration_ms);
270
280
290
302
316
330
344
356int gnrc_tcp_calc_csum(const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr);
357
368gnrc_pktsnip_t *gnrc_tcp_hdr_build(gnrc_pktsnip_t *payload, uint16_t src, uint16_t dst);
369
370#ifdef __cplusplus
371}
372#endif
373
374#endif /* NET_GNRC_TCP_H */
Definitions for GNRC's IPv6 implementation.
void gnrc_tcp_close(gnrc_tcp_tcb_t *tcb)
Close a TCP connection.
void gnrc_tcp_tcb_queue_init(gnrc_tcp_tcb_queue_t *queue)
Initialize Transmission Control Block (TCB) queue.
void gnrc_tcp_stop_listen(gnrc_tcp_tcb_queue_t *queue)
Close connections and stop listening on TCB queue.
int gnrc_tcp_init(void)
Initialize TCP.
int gnrc_tcp_queue_get_local(gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_ep_t *ep)
Gets the local end point of a TCB queue.
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_get_local(gnrc_tcp_tcb_t *tcb, gnrc_tcp_ep_t *ep)
Get the local end point of a connected TCB.
int gnrc_tcp_accept(gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_tcb_t **tcb, const uint32_t user_timeout_duration_ms)
Accept TCP connection from listening queue.
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.
int gnrc_tcp_ep_from_str(gnrc_tcp_ep_t *ep, const char *str)
Construct TCP connection endpoint from string.
int gnrc_tcp_get_remote(gnrc_tcp_tcb_t *tcb, gnrc_tcp_ep_t *ep)
Get the remote end point of a connected TCB.
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.
int gnrc_tcp_listen(gnrc_tcp_tcb_queue_t *queue, gnrc_tcp_tcb_t *tcbs, size_t tcbs_len, const gnrc_tcp_ep_t *local)
Configures a sequence of TCBs to wait for incoming connections.
void gnrc_tcp_abort(gnrc_tcp_tcb_t *tcb)
Abort a TCP connection.
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(gnrc_tcp_tcb_t *tcb, const gnrc_tcp_ep_t *remote, uint16_t local_port)
Opens a connection.
void gnrc_tcp_tcb_init(gnrc_tcp_tcb_t *tcb)
Initialize Transmission Control Block (TCB)
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.
General definitions for network packets and their helper functions.
Common sock API definitions.
Common IP-based transport layer end point.
Definition sock.h:215
union _sock_tl_ep::@384 addr
address
uint8_t ipv6[16]
IPv6 address mode.
Definition sock.h:230
Type to represent parts (either headers or payload) of a packet, called snips.
Definition pkt.h:108
Address information for a single TCP connection endpoint.
Definition tcp.h:60
uint16_t netif
Network interface ID.
Definition tcp.h:68
int family
IP address family.
Definition tcp.h:61
uint16_t port
Port number (in host byte order)
Definition tcp.h:69
uint8_t dummy
Enable build without network module.
Definition tcp.h:66
TCP queue type.
Definition sock_types.h:114
TCP sock type.
Definition sock_types.h:101
GNRC TCP transmission control block (TCB)
Data type to represent an IPv6 address.
Definition addr.h:72