|
libschc
|
#include <string.h>#include <stdio.h>#include "jsmn.h"#include "picocoap.h"#include "compressor.h"#include "schc_config.h"#include "rules/rule_config.h"Functions | |
| static void | get_node_ip (schc_ipaddr_t *node_ip) |
| Get the node its IP address as set during initialization. More... | |
| static struct schc_device * | get_device_by_id (uint32_t device_id) |
| Get a device by it's id. More... | |
| int8_t | set_rule_id (struct schc_rule_t *schc_rule, uint8_t *data) |
| struct schc_rule_t * | get_schc_rule_by_reliability_mode (struct schc_rule_t *schc_rule, reliability_mode mode, uint32_t device_id) |
| static struct schc_rule_t * | get_schc_rule_by_layer_ids (uint8_t ip_rule_id, uint8_t udp_rule_id, uint8_t coap_rule_id, uint32_t device_id, reliability_mode mode) |
| struct schc_rule_t * | get_schc_rule_by_rule_id (uint8_t *rule_arr, uint32_t device_id) |
| static uint8_t | compress (schc_bitarray_t *dst, schc_bitarray_t *src, const struct schc_layer_rule_t *rule, direction DI) |
| The compression mechanism. More... | |
| static uint8_t | decompress (struct schc_layer_rule_t *rule, schc_bitarray_t *src, schc_bitarray_t *dst, direction DI) |
| The decompression mechanism. More... | |
| static struct schc_layer_rule_t * | schc_find_rule_from_header (schc_bitarray_t *src, uint32_t device_id, schc_layer_t layer, direction DI) |
| Find a matching rule for a layer. More... | |
| static void | swap_ipv6_source_and_destination (uint8_t *ptr) |
| Swaps the IPv6 source and destination. More... | |
| static uint8_t | equal (struct schc_field *target_field, unsigned char *field_value, uint16_t field_offset) |
| The equal matching operator. More... | |
| static uint8_t | ignore (struct schc_field *target_field, unsigned char *field_value, uint16_t field_offset) |
| The ignore matching operator. More... | |
| static uint8_t | MSB (struct schc_field *target_field, unsigned char *field_value, uint16_t field_offset) |
| The MSB matching operator MSB(x): a match is obtained if the most significant (leftmost) x bits of the packet header field value are equal to the TV in the Rule. More... | |
| static uint8_t | matchmap (struct schc_field *target_field, unsigned char *field_value, uint16_t field_offset) |
| The match-map matching operator match-mapping: With match-mapping, the Target Value is a list of values. More... | |
| static void | set_node_ip (schc_ipaddr_t *node_ip) |
| Notifies the compressor about the node its IP address. More... | |
| 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 *dst, uint32_t device_id, direction dir, struct schc_rule_t **schc_rule) |
| Compresses a CoAP/UDP/IP packet. More... | |
| static uint16_t | compute_length (unsigned char *data, uint16_t data_len) |
| Set the packet length for the UDP and IP headers. More... | |
| static uint16_t | chksum (uint16_t sum, const uint8_t *data, uint16_t len) |
| uint16_t | compute_checksum (unsigned char *data) |
| Calculates the UDP checksum and sets the appropriate header fields. More... | |
| 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... | |
Variables | |
| static schc_ipaddr_t | node_ip_6 |
| jsmn_parser | json_parser |
| jsmntok_t | json_token [JSON_TOKENS] |
|
static |
|
static |
The compression mechanism.
| dst_arr | the bit array in which to copy the contents to |
| src_arr | the original header |
| rule | the rule to match the compression with |
| uint16_t compute_checksum | ( | unsigned char * | data | ) |
Calculates the UDP checksum and sets the appropriate header fields.
| data | pointer to the data packet |
|
static |
Set the packet length for the UDP and IP headers.
| data | pointer to the data packet |
| data_len | the length of the total packet |
|
static |
The decompression mechanism.
| rule | pointer to the rule to use during the decompression |
| src | the received SCHC bit buffer |
| dst | the buffer to store the decompressed, original packet |
|
static |
The equal matching operator.
| target_field | the field from the rule |
| field_value | the value from the header to compare with the rule value |
| field_offset | the offset (in bits), starting from the field value pointer |
|
static |
Get a device by it's id.
| device_id | the id of the device |
|
static |
Get the node its IP address as set during initialization.
|
static |
| struct schc_rule_t* get_schc_rule_by_reliability_mode | ( | struct schc_rule_t * | schc_rule, |
| reliability_mode | mode, | ||
| uint32_t | device_id | ||
| ) |
| struct schc_rule_t* get_schc_rule_by_rule_id | ( | uint8_t * | rule_arr, |
| uint32_t | device_id | ||
| ) |
|
static |
The ignore matching operator.
| target_field | the field from the rule |
| field_value | the value from the header to compare with the rule value |
|
static |
The match-map matching operator match-mapping: With match-mapping, the Target Value is a list of values.
Each value of the list is identified by an index. Compression is achieved by sending the index instead of the original header field value.
| target_field | the field from the rule |
| field_value | the value from the header to compare with the rule value |
|
static |
The MSB matching operator MSB(x): a match is obtained if the most significant (leftmost) x bits of the packet header field value are equal to the TV in the Rule.
The x parameter of the MSB MO indicates how many bits are involved in the comparison. If the FL is described as variable, the x parameter must be a multiple of the FL unit. For example, x must be multiple of 8 if the unit of the variable length is bytes.
| target_field | the field from the rule |
| field_value | the value from the header to compare with the rule value |
| 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.
| data | pointer to the original packet |
| total_length | the length of the packet |
| dst | pointer to the bit array object, where the compressed packet will be stored. Can later be passed to fragmenter |
| device_id | the device id to find a rule for |
| direction | the direction of the flow UP: LPWAN to IPv6 or DOWN: IPv6 to LPWAN |
| device_type | the device type: NETWORK_GATEWAY or DEVICE |
| schc_rule | a pointer to a schc rule struct to return the rule that was found |
| uint8_t schc_compressor_init | ( | uint8_t | src[16] | ) |
Initializes the SCHC compressor.
| node_ip | a pointer to the source it's ip address |
| 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.
| data | pointer to the received data |
| buf | pointer where to save the decompressed packet |
| device_id | the device its id |
| total_length | the total length of the received data |
| direction | the direction of the flow (UP: LPWAN to IPv6, DOWN: IPv6 to LPWAN) |
|
static |
Find a matching rule for a layer.
| schc_bitarray | the bit array as received from the network note: a conversion is required for CoAP to decode the options |
| device_id | the device to find an IP rule for |
| schc_layer | the layer for which to find a rule for |
|
static |
Notifies the compressor about the node its IP address.
| node_ip | pointer to the ip address array |
| int8_t set_rule_id | ( | struct schc_rule_t * | schc_rule, |
| uint8_t * | data | ||
| ) |
|
static |
Swaps the IPv6 source and destination.
| ptr | pointer to the ipv6 header |
| jsmn_parser json_parser |
| jsmntok_t json_token[JSON_TOKENS] |
|
static |
1.8.17