gnrc_tcp_pkt.h File Reference

TCP packet handling declarations. More...

Detailed Description

TCP packet handling declarations.

Author
Simon Brummer simon.nosp@m..bru.nosp@m.mmer@.nosp@m.post.nosp@m.eo.de

Definition in file gnrc_tcp_pkt.h.

#include <stdint.h>
#include "net/gnrc.h"
#include "net/gnrc/tcp/tcb.h"
+ Include dependency graph for gnrc_tcp_pkt.h:

Go to the source code of this file.

int _gnrc_tcp_pkt_build_reset_from_pkt (gnrc_pktsnip_t **out_pkt, gnrc_pktsnip_t *in_pkt)
 Build a reset packet from an incoming packet. More...
 
int _gnrc_tcp_pkt_build (gnrc_tcp_tcb_t *tcb, gnrc_pktsnip_t **out_pkt, uint16_t *seq_con, const uint16_t ctl, const uint32_t seq_num, const uint32_t ack_num, void *payload, const size_t payload_len)
 Build and allocate a TCB packet, TCB stores pointer to new packet. More...
 
int _gnrc_tcp_pkt_send (gnrc_tcp_tcb_t *tcb, gnrc_pktsnip_t *out_pkt, const uint16_t seq_con, const bool retransmit)
 Sends packet to peer. More...
 
int _gnrc_tcp_pkt_chk_seq_num (const gnrc_tcp_tcb_t *tcb, const uint32_t seq_num, const uint32_t seg_len)
 Verify sequence number. More...
 
uint32_t _gnrc_tcp_pkt_get_seg_len (gnrc_pktsnip_t *pkt)
 Extracts the length of a segment. More...
 
uint32_t _gnrc_tcp_pkt_get_pay_len (gnrc_pktsnip_t *pkt)
 Calculates a packets payload length. More...
 
int _gnrc_tcp_pkt_setup_retransmit (gnrc_tcp_tcb_t *tcb, gnrc_pktsnip_t *pkt, const bool retransmit)
 Adds a packet to the retransmission mechanism. More...
 
int _gnrc_tcp_pkt_acknowledge (gnrc_tcp_tcb_t *tcb, const uint32_t ack)
 Acknowledges and removes packet from the retransmission mechanism. More...
 
uint16_t _gnrc_tcp_pkt_calc_csum (const gnrc_pktsnip_t *hdr, const gnrc_pktsnip_t *pseudo_hdr, const gnrc_pktsnip_t *payload)
 Calculates checksum over payload, TCP header and network layer header. More...
 

Function Documentation

◆ _gnrc_tcp_pkt_acknowledge()

int _gnrc_tcp_pkt_acknowledge ( gnrc_tcp_tcb_t tcb,
const uint32_t  ack 
)

Acknowledges and removes packet from the retransmission mechanism.

Parameters
[in,out]tcbTCB holding the connection information.
[in]ackAcknowldegment number used to acknowledge packets.
Returns
Zero on success. -ENODATA if there is nothing to acknowledge.

◆ _gnrc_tcp_pkt_build()

int _gnrc_tcp_pkt_build ( gnrc_tcp_tcb_t tcb,
gnrc_pktsnip_t **  out_pkt,
uint16_t *  seq_con,
const uint16_t  ctl,
const uint32_t  seq_num,
const uint32_t  ack_num,
void *  payload,
const size_t  payload_len 
)

Build and allocate a TCB packet, TCB stores pointer to new packet.

Parameters
[in,out]tcbTCB holding the connection information.
[out]out_pktPointer to packet to build.
[out]seq_conSequence number consumption of built packet.
[in]ctlControl bits to set in out_pkt.
[in]seq_numSequence number of the new packet.
[in]ack_numAcknowledgment number of the new packet.
[in]payloadPointer to payload buffer.
[in]payload_lenPayload size.
Returns
Zero on success. -ENOMEM if pktbuf is full.

◆ _gnrc_tcp_pkt_build_reset_from_pkt()

int _gnrc_tcp_pkt_build_reset_from_pkt ( gnrc_pktsnip_t **  out_pkt,
gnrc_pktsnip_t in_pkt 
)

Build a reset packet from an incoming packet.

Note
This function builds a reset from an incoming packet in cases where the connection has not been established.
Parameters
[out]out_pktOutgoing reset packet
[in]in_pktIncoming packet
Returns
Zero on success -ENOMEM if pktbuf is full.

◆ _gnrc_tcp_pkt_calc_csum()

uint16_t _gnrc_tcp_pkt_calc_csum ( const gnrc_pktsnip_t hdr,
const gnrc_pktsnip_t pseudo_hdr,
const gnrc_pktsnip_t payload 
)

Calculates checksum over payload, TCP header and network layer header.

Parameters
[in]hdrGnrc_pktsnip_t to TCP header.
[in]pseudo_hdrGnrc_pktsnip_t to network layer header.
[in]payloadGnrc_pktsnip_t to payload.
Returns
Non-zero checksum if given network layer is supported. Zero if given network layer is not supported.

◆ _gnrc_tcp_pkt_chk_seq_num()

int _gnrc_tcp_pkt_chk_seq_num ( const gnrc_tcp_tcb_t tcb,
const uint32_t  seq_num,
const uint32_t  seg_len 
)

Verify sequence number.

Parameters
[in,out]tcbTCB holding the connection information.
[in]seq_numSequence number from the segment.
[in]seg_lenLength of a segments payload.
Returns
Zero if the sequence number is acceptable. Negative value if the sequence number is not acceptable.

◆ _gnrc_tcp_pkt_get_pay_len()

uint32_t _gnrc_tcp_pkt_get_pay_len ( gnrc_pktsnip_t pkt)

Calculates a packets payload length.

Parameters
[in]pktPacket to calculate payload length.
Returns
The packets payload length in bytes.

◆ _gnrc_tcp_pkt_get_seg_len()

uint32_t _gnrc_tcp_pkt_get_seg_len ( gnrc_pktsnip_t pkt)

Extracts the length of a segment.

Parameters
[in]pktPacket to calculate the segments length.
Returns
Segments length in bytes (== sequence number consumption).

◆ _gnrc_tcp_pkt_send()

int _gnrc_tcp_pkt_send ( gnrc_tcp_tcb_t tcb,
gnrc_pktsnip_t out_pkt,
const uint16_t  seq_con,
const bool  retransmit 
)

Sends packet to peer.

Parameters
[in,out]tcbTCB holding the connection information.
[in]out_pktPointer to packet to send.
[in]seq_conSequence number consumption of the packet to send.
[in]retransmitFlag so mark that packet this is a retransmission.
Returns
Zero on success. -EINVAL if out_pkt was NULL.

◆ _gnrc_tcp_pkt_setup_retransmit()

int _gnrc_tcp_pkt_setup_retransmit ( gnrc_tcp_tcb_t tcb,
gnrc_pktsnip_t pkt,
const bool  retransmit 
)

Adds a packet to the retransmission mechanism.

Parameters
[in,out]tcbTCB holding the connection information.
[in]pktPacket to add to the retransmission mechanism.
[in]retransmitFlag used to indicate that pkt is a retransmit.
Returns
Zero on success. -ENOMEM if the retransmission queue is full. -EINVAL if pkt is null.