libschc
Functions
compressor.h File Reference
#include "bit_operations.h"
#include "schc.h"

Go to the source code of this file.

Functions

int8_t set_rule_id (struct schc_rule_t *schc_rule, uint8_t *data)
 
uint8_t schc_compressor_init (uint8_t src[16])
 Initializes the SCHC compressor. More...
 
int16_t schc_compress (uint8_t *data, uint16_t total_length, schc_bitarray_t *buf, uint32_t device_id, direction dir, struct schc_rule_t **schc_rule)
 Compresses a CoAP/UDP/IP packet. More...
 
struct schc_rule_tget_schc_rule_by_reliability_mode (struct schc_rule_t *schc_rule, reliability_mode mode, uint32_t device_id)
 
struct schc_rule_tget_schc_rule_by_rule_id (uint8_t *rule_id, uint32_t device_id)
 
uint16_t schc_decompress (schc_bitarray_t *bit_arr, uint8_t *buf, uint32_t device_id, uint16_t total_length, direction dir)
 Construct the header from the layered set of rules. More...
 

Function Documentation

◆ get_schc_rule_by_reliability_mode()

struct schc_rule_t* get_schc_rule_by_reliability_mode ( struct schc_rule_t schc_rule,
reliability_mode  mode,
uint32_t  device_id 
)

◆ get_schc_rule_by_rule_id()

struct schc_rule_t* get_schc_rule_by_rule_id ( uint8_t *  rule_id,
uint32_t  device_id 
)

◆ schc_compress()

int16_t schc_compress ( uint8_t *  data,
uint16_t  total_length,
schc_bitarray_t dst,
uint32_t  device_id,
direction  dir,
struct schc_rule_t **  schc_rule 
)

Compresses a CoAP/UDP/IP packet.

Parameters
datapointer to the original packet
total_lengththe length of the packet
dstpointer to the bit array object, where the compressed packet will be stored. Can later be passed to fragmenter
device_idthe device id to find a rule for
directionthe direction of the flow UP: LPWAN to IPv6 or DOWN: IPv6 to LPWAN
device_typethe device type: NETWORK_GATEWAY or DEVICE
schc_rulea pointer to a schc rule struct to return the rule that was found
Returns
length the length of the compressed packet -1 on a memory overflow
Note
the compressor will only look for rules configured with the NOT_FRAGMENTED reliability mode

◆ schc_compressor_init()

uint8_t schc_compressor_init ( uint8_t  src[16])

Initializes the SCHC compressor.

Parameters
node_ipa pointer to the source it's ip address
Returns
error error codes on error

◆ schc_decompress()

uint16_t schc_decompress ( schc_bitarray_t bit_arr,
uint8_t *  buf,
uint32_t  device_id,
uint16_t  total_length,
direction  dir 
)

Construct the header from the layered set of rules.

Parameters
datapointer to the received data
bufpointer where to save the decompressed packet
device_idthe device its id
total_lengththe total length of the received data
directionthe direction of the flow (UP: LPWAN to IPv6, DOWN: IPv6 to LPWAN)
Returns
length length of the newly constructed packet 0 the rule was not found

◆ set_rule_id()

int8_t set_rule_id ( struct schc_rule_t schc_rule,
uint8_t *  data 
)