OpenVPN
Data Structures | Macros | Functions
fragment.h File Reference
#include "common.h"
#include "buffer.h"
#include "interval.h"
#include "mtu.h"
#include "shaper.h"
#include "error.h"
Include dependency graph for fragment.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fragment
 Structure for reassembling one incoming fragmented packet. More...
 
struct  fragment_list
 List of fragment structures for reassembling multiple incoming packets concurrently. More...
 
struct  fragment_master
 Fragmentation and reassembly state for one VPN tunnel instance. More...
 

Macros

#define N_FRAG_BUF   25
 Number of packet buffers for reassembling incoming fragmented packets. More...
 
#define FRAG_TTL_SEC   10
 Time-to-live in seconds for a fragment. More...
 
#define FRAG_WAKEUP_INTERVAL   5
 Interval in seconds between calls to wakeup code. More...
 
#define FRAG_MAP_MASK   0xFFFFFFFF
 Mask for reassembly map. More...
 
#define MAX_FRAGS   32
 Maximum number of fragments per packet. More...
 
#define N_SEQ_ID   256
 One more than the maximum fragment sequence ID, above which the IDs wrap to zero. More...
 
#define MAX_FRAG_PKT_SIZE   65536
 (Not used) Maximum packet size before fragmenting. More...
 

Functions

void fragment_wakeup (struct fragment_master *f, struct frame *frame)
 
Functions for initialization and cleanup
struct fragment_masterfragment_init (struct frame *frame)
 Allocate and initialize a fragment_master structure. More...
 
void fragment_frame_init (struct fragment_master *f, const struct frame *frame)
 Allocate internal packet buffers for a fragment_master structure. More...
 
void fragment_free (struct fragment_master *f)
 Free a fragment_master structure and its internal packet buffers. More...
 
Functions for processing packets received from a remote OpenVPN peer
void fragment_incoming (struct fragment_master *f, struct buffer *buf, const struct frame *frame)
 Process an incoming packet, which may or may not be fragmented. More...
 
Functions for processing packets to be sent to a remote OpenVPN peer
void fragment_outgoing (struct fragment_master *f, struct buffer *buf, const struct frame *frame)
 Process an outgoing packet, which may or may not need to be fragmented. More...
 
bool fragment_ready_to_send (struct fragment_master *f, struct buffer *buf, const struct frame *frame)
 Check whether outgoing fragments are ready to be send, and if so make one available. More...
 
static bool fragment_outgoing_defined (struct fragment_master *f)
 Check whether a fragment_master structure contains fragments ready to be sent. More...
 
Functions for regular housekeeping
static void fragment_housekeeping (struct fragment_master *f, struct frame *frame, struct timeval *tv)
 Perform housekeeping of a fragment_master structure. More...
 

Fragment header

Todo:
Add description of fragment header format.
#define hton_fragment_header_type(x)   htonl(x)
 Convert a fragment_header_type from host to network order. More...
 
#define ntoh_fragment_header_type(x)   ntohl(x)
 Convert a fragment_header_type from network to host order. More...
 
#define FRAG_TYPE_MASK   0x00000003
 Bit mask for fragment type info. More...
 
#define FRAG_TYPE_SHIFT   0
 Bit shift for fragment type info. More...
 
#define FRAG_WHOLE   0
 Fragment type indicating packet is whole. More...
 
#define FRAG_YES_NOTLAST   1
 Fragment type indicating packet is part of a fragmented packet, but not the last part in the sequence. More...
 
#define FRAG_YES_LAST   2
 Fragment type indicating packet is the last part in the sequence of parts. More...
 
#define FRAG_TEST   3
 Fragment type not implemented yet. More...
 
#define FRAG_SEQ_ID_MASK   0x000000ff
 Bit mask for fragment sequence ID. More...
 
#define FRAG_SEQ_ID_SHIFT   2
 Bit shift for fragment sequence ID. More...
 
#define FRAG_ID_MASK   0x0000001f
 Bit mask for fragment ID. More...
 
#define FRAG_ID_SHIFT   10
 Bit shift for fragment ID. More...
 
#define FRAG_SIZE_MASK   0x00003fff
 Bit mask for fragment size. More...
 
#define FRAG_SIZE_SHIFT   15
 Bit shift for fragment size. More...
 
#define FRAG_SIZE_ROUND_SHIFT   2
 Bit shift for fragment size rounding. More...
 
#define FRAG_SIZE_ROUND_MASK   ((1 << FRAG_SIZE_ROUND_SHIFT) - 1)
 Bit mask for fragment size rounding. More...
 
#define FRAG_EXTRA_MASK   0x0000ffff
 Bit mask for extra bits. More...
 
#define FRAG_EXTRA_SHIFT   15
 Bit shift for extra bits. More...
 
typedef uint32_t fragment_header_type
 Fragmentation information is stored in a 32-bit packet header. More...
 

Detailed Description

Data Channel Fragmentation module header file.

Definition in file fragment.h.

Macro Definition Documentation

◆ FRAG_MAP_MASK

#define FRAG_MAP_MASK   0xFFFFFFFF

Mask for reassembly map.

Definition at line 71 of file fragment.h.

◆ MAX_FRAG_PKT_SIZE

#define MAX_FRAG_PKT_SIZE   65536

(Not used) Maximum packet size before fragmenting.

Definition at line 154 of file fragment.h.

◆ MAX_FRAGS

#define MAX_FRAGS   32

Maximum number of fragments per packet.

Definition at line 73 of file fragment.h.

◆ N_SEQ_ID

#define N_SEQ_ID   256

One more than the maximum fragment sequence ID, above which the IDs wrap to zero.

Should be a power of 2.

Definition at line 142 of file fragment.h.