Helium
Data Structures | Macros | Typedefs | Functions
frag.h File Reference

Internal header file for fragmentation support. More...

#include <stddef.h>
#include <time.h>
Include dependency graph for frag.h:

Go to the source code of this file.

Data Structures

struct  he_fragment_entry_node
 
struct  he_fragment_entry
 
struct  he_fragment_table
 

Macros

#define MAX_FRAGMENT_ENTRIES   65536
 

Typedefs

typedef struct he_conn he_conn_t
 
typedef struct he_fragment_entry_node he_fragment_entry_node_t
 
typedef struct he_fragment_entry he_fragment_entry_t
 
typedef struct he_fragment_table he_fragment_table_t
 

Functions

he_return_code_t he_internal_frag_and_send_message (he_conn_t *conn, uint8_t *packet, uint16_t length, uint16_t frag_size)
 Fragment a packet and send it over the secured tunnel as multiple messages. More...
 
void he_fragment_entry_reset (he_fragment_entry_t *entry)
 Reset the given fragment entry. More...
 
int he_fragment_entry_update (he_fragment_entry_t *entry, uint8_t *data, uint16_t offset, size_t length, uint8_t mf, bool *assembled)
 Update the given fragment entry with a new fragment. More...
 
he_fragment_table_the_internal_fragment_table_create (size_t num_entries)
 Create and initialize a new fragment table. More...
 
he_fragment_entry_the_internal_fragment_table_find (he_fragment_table_t *tbl, uint16_t frag_id)
 Find entry for the given fragment id. More...
 
void he_internal_fragment_table_delete (he_fragment_table_t *tbl, uint16_t frag_id)
 Delete entry from the fragment table. More...
 
void he_internal_fragment_table_destroy (he_fragment_table_t *tbl)
 Destroy the given he_fragment_table and free up all memory. More...
 

Detailed Description

Internal header file for fragmentation support.

Lightway Core Copyright (C) 2023 Express VPN International Ltd.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Function Documentation

◆ he_fragment_entry_reset()

void he_fragment_entry_reset ( he_fragment_entry_t entry)

Reset the given fragment entry.

Parameters
entryA pointer to a valid fragment entry

◆ he_fragment_entry_update()

int he_fragment_entry_update ( he_fragment_entry_t entry,
uint8_t *  data,
uint16_t  offset,
size_t  length,
uint8_t  mf,
bool *  assembled 
)

Update the given fragment entry with a new fragment.

Parameters
entryA pointer to a valid fragment entry
dataA pointer to the fragment data
offsetOffset of the fragment in the original packet in bytes
lengthLength of the fragment
mfMore Fragment flag
assembled(out) Indicate if the packet has been fully reassembled.
Returns
Returns HE_SUCCESS if the fragment entry is updated without error.
Note
This function may allocates or free memory.

◆ he_internal_frag_and_send_message()

he_return_code_t he_internal_frag_and_send_message ( he_conn_t conn,
uint8_t *  packet,
uint16_t  length,
uint16_t  frag_size 
)

Fragment a packet and send it over the secured tunnel as multiple messages.

Parameters
connA pointer to a valid connection
packetA pointer to the raw packet to be sent
lengthThe length of the packet
frag_sizeSize of each fragment in bytes
Returns
HE_SUCCESS if the packet is fragmented and sent successfully

Lightway Core Copyright (C) 2023 Express VPN International Ltd.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

◆ he_internal_fragment_table_create()

he_fragment_table_t* he_internal_fragment_table_create ( size_t  num_entries)

Create and initialize a new fragment table.

Parameters
num_entriesNumber of fragment entries can be used in the fragment table. If it's 0, the default value MAX_FRAGMENT_ENTRIES will be used.
Returns
Pointer to a he_fragment_table_t struct.
Note
This function allocates memory, the caller must call he_internal_fragment_table_destroy after use.

◆ he_internal_fragment_table_delete()

void he_internal_fragment_table_delete ( he_fragment_table_t tbl,
uint16_t  frag_id 
)

Delete entry from the fragment table.

Parameters
tblPointer to a valid he_fragment_table_t struct.
frag_idFragment Identifier

◆ he_internal_fragment_table_destroy()

void he_internal_fragment_table_destroy ( he_fragment_table_t tbl)

Destroy the given he_fragment_table and free up all memory.

Parameters
tblA pointer to a valid he_fragment_table struct.

◆ he_internal_fragment_table_find()

he_fragment_entry_t* he_internal_fragment_table_find ( he_fragment_table_t tbl,
uint16_t  frag_id 
)

Find entry for the given fragment id.

Parameters
tblPointer to a valid he_fragment_table_t struct.
frag_idFragment Identifier
Returns
Pointer to the fragment entry of the given id. It may return NULL if the function failed to allocate memory for a new entry.
Note
This function may allocate memory.