54#define FRAG_TTL_SEC 10
57#define FRAG_WAKEUP_INTERVAL 5
71#define FRAG_MAP_MASK 0xFFFFFFFF
152#define MAX_FRAG_PKT_SIZE 65536
192#define hton_fragment_header_type(x) htonl(x)
196#define ntoh_fragment_header_type(x) ntohl(x)
200#define FRAG_TYPE_MASK 0x00000003
202#define FRAG_TYPE_SHIFT 0
206#define FRAG_YES_NOTLAST 1
209#define FRAG_YES_LAST 2
217#define FRAG_SEQ_ID_MASK 0x000000ff
219#define FRAG_SEQ_ID_SHIFT 2
221#define FRAG_ID_MASK 0x0000001f
223#define FRAG_ID_SHIFT 10
235#define FRAG_SIZE_MASK 0x00003fff
237#define FRAG_SIZE_SHIFT 15
239#define FRAG_SIZE_ROUND_SHIFT 2
240#define FRAG_SIZE_ROUND_MASK ((1 << FRAG_SIZE_ROUND_SHIFT) - 1)
248#define FRAG_EXTRA_MASK 0x0000ffff
250#define FRAG_EXTRA_SHIFT 15
438 return f->outgoing.len > 0;
uint32_t fragment_header_type
Fragmentation information is stored in a 32-bit packet header.
static void fragment_housekeeping(struct fragment_master *f, struct frame *frame, struct timeval *tv)
Perform housekeeping of a fragment_master structure.
void fragment_frame_init(struct fragment_master *f, const struct frame *frame)
Allocate internal packet buffers for a fragment_master structure.
static bool fragment_outgoing_defined(struct fragment_master *f)
Check whether a fragment_master structure contains fragments ready to be sent.
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.
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.
#define N_FRAG_BUF
Number of packet buffers for reassembling incoming fragmented packets.
void fragment_wakeup(struct fragment_master *f, struct frame *frame)
struct fragment_master * fragment_init(struct frame *frame)
Allocate and initialize a fragment_master structure.
void fragment_free(struct fragment_master *f)
Free a fragment_master structure and its internal packet buffers.
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.
bool event_timeout_trigger(struct event_timeout *et, struct timeval *tv, const int et_const_retry)
This is the principal function for testing and triggering recurring timers.
Wrapper structure for dynamically allocated memory.
List of fragment structures for reassembling multiple incoming packets concurrently.
int seq_id
Highest fragmentation sequence ID of the packets currently being reassembled.
int index
Index of the packet being reassembled with the highest fragmentation sequence ID into the fragment_li...
struct fragment fragments[N_FRAG_BUF]
Array of reassembly structures, each can contain one whole packet.
Fragmentation and reassembly state for one VPN tunnel instance.
struct buffer outgoing
Buffer containing the remaining parts of the fragmented packet being sent.
int outgoing_frag_id
The fragment ID of the next part to be sent.
struct event_timeout wakeup
Timeout structure used by the main event loop to know when to do fragmentation housekeeping.
struct fragment_list incoming
List of structures for reassembling incoming packets.
int outgoing_seq_id
Fragment sequence ID of the current fragmented packet waiting to be sent.
int outgoing_frag_size
Size in bytes of each part to be sent, except for the last part which may be smaller.
struct buffer outgoing_return
Buffer used by fragment_ready_to_send() to return a part to send.
Structure for reassembling one incoming fragmented packet.
int max_frag_size
Maximum size of each fragment.
unsigned int map
Reassembly map for recording which fragments have been received.
bool defined
Whether reassembly is currently taking place in this structure.
time_t timestamp
Timestamp for time-to-live purposes.
struct buffer buf
Buffer in which received datagrams are reassembled.
Packet geometry parameters.