Hybrid ICN (hICN) plugin  v21.06-rc0-4-g18fa668
Macros | Enumerations | Functions
compat.h File Reference

Implementation of the compatibility layer. More...

#include "common.h"
#include "header.h"
#include "name.h"
Include dependency graph for compat.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define HFO_INET   1 << 0
 
#define HFO_INET6   1 << 1
 
#define HFO_TCP   1 << 2
 
#define HFO_ICMP   1 << 3
 
#define HFO_AH   1 << 4
 
#define _is_ipv4(format)   ((format & HFO_INET))
 
#define _is_ipv6(format)   ((format & HFO_INET6) >> 1)
 
#define _is_tcp(format)   ((format & HFO_TCP) >> 2)
 
#define _is_icmp(format)   ((format & HFO_ICMP) >> 3)
 
#define _is_ah(format)   ((format & HFO_AH) >> 4)
 
#define HICN_V6_MIN_HDR_LEN   6 /* bytes */
 
#define HICN_V4_MIN_HDR_LEN   4 /* bytes */
 
#define HICN_MIN_HDR_LEN   HICN_V6_MIN_HDR_LEN
 

Enumerations

enum  hicn_format_t {
  HF_UNSPEC = 0, HF_INET_TCP = HFO_INET | HFO_TCP, HF_INET6_TCP = HFO_INET6 | HFO_TCP, HF_INET_ICMP = HFO_INET | HFO_ICMP,
  HF_INET6_ICMP = HFO_INET6 | HFO_ICMP, HF_INET_TCP_AH = HFO_INET | HFO_TCP | HFO_AH, HF_INET6_TCP_AH = HFO_INET6 | HFO_TCP | HFO_AH, HF_INET_ICMP_AH = HFO_INET | HFO_ICMP | HFO_AH,
  HF_INET6_ICMP_AH = HFO_INET6 | HFO_ICMP | HFO_AH
}
 

Functions

int hicn_packet_init_header (hicn_format_t format, hicn_header_t *packet)
 Parse packet headers and return hICN format. More...
 
int hicn_packet_get_format (const hicn_header_t *packet, hicn_format_t *format)
 Parse packet headers and return hICN format. More...
 
int hicn_packet_compute_checksum (hicn_format_t format, hicn_header_t *packet)
 Update checksums in packet headers. More...
 
int hicn_packet_compute_header_checksum (hicn_format_t format, hicn_header_t *packet, u16 init_sum)
 compute the checksum of the packet header, adding init_sum to the final value More...
 
int hicn_packet_check_integrity_no_payload (hicn_format_t format, hicn_header_t *packet, u16 init_sum)
 Verify checksums in packet headers. More...
 
int hicn_packet_get_header_length_from_format (hicn_format_t format, size_t *header_length)
 Return total length of hicn headers (but signature payload) More...
 
int hicn_packet_get_header_length (hicn_format_t format, const hicn_header_t *packet, size_t *header_length)
 Return total length of hicn headers (before payload) More...
 
int hicn_packet_get_payload_length (hicn_format_t format, const hicn_header_t *packet, size_t *payload_length)
 Return payload length. More...
 
int hicn_packet_set_payload_length (hicn_format_t format, hicn_header_t *packet, const size_t payload_length)
 Sets payload length. More...
 
int hicn_packet_compare (const hicn_header_t *packet1, const hicn_header_t *packet2)
 Compare two hICN packets. More...
 
int hicn_packet_get_name (hicn_format_t format, const hicn_header_t *packet, hicn_name_t *name, u8 is_interest)
 Retrieve the name of an interest/data packet. More...
 
int hicn_packet_set_name (hicn_format_t format, hicn_header_t *packet, const hicn_name_t *name, u8 is_interest)
 Sets the name of an interest/data packet. More...
 
int hicn_packet_set_payload (hicn_format_t format, hicn_header_t *packet, const u8 *payload, u16 payload_length)
 Sets the payload of a packet. More...
 
int hicn_packet_get_payload (hicn_format_t format, const hicn_header_t *packet, u8 **payload, size_t *payload_size, bool hard_copy)
 Retrieves the payload of a packet. More...
 
int hicn_packet_get_locator (hicn_format_t format, const hicn_header_t *packet, ip_address_t *prefix, bool is_interest)
 Retrieve the locator of an interest / data packet. More...
 
int hicn_packet_set_locator (hicn_format_t format, hicn_header_t *packet, const ip_address_t *prefix, bool is_interest)
 Sets the locator of an interest / data packet. More...
 
int hicn_packet_get_signature_size (hicn_format_t format, const hicn_header_t *packet, size_t *bytes)
 Retrieves the signature size. More...
 
int hicn_packet_set_signature_size (hicn_format_t format, hicn_header_t *packet, size_t bytes)
 Sets the signature size. More...
 
int hicn_packet_set_signature_timestamp (hicn_format_t format, hicn_header_t *h, uint64_t signature_timestamp)
 Sets the signature size. More...
 
int hicn_packet_get_signature_timestamp (hicn_format_t format, const hicn_header_t *h, uint64_t *signature_timestamp)
 Sets the signature size. More...
 
int hicn_packet_set_validation_algorithm (hicn_format_t format, hicn_header_t *h, uint8_t validation_algorithm)
 Sets the signature size. More...
 
int hicn_packet_get_validation_algorithm (hicn_format_t format, const hicn_header_t *h, uint8_t *validation_algorithm)
 Sets the signature size. More...
 
int hicn_packet_set_key_id (hicn_format_t format, hicn_header_t *h, uint8_t *key_id)
 Sets the signature size. More...
 
int hicn_packet_get_key_id (hicn_format_t format, hicn_header_t *h, uint8_t **key_id, uint8_t *key_id_length)
 Sets the signature size. More...
 
int hicn_packet_get_hoplimit (const hicn_header_t *packet, u8 *hops)
 Retrieves the packet hop limit. More...
 
int hicn_packet_set_hoplimit (hicn_header_t *packet, u8 hops)
 Sets the packet hop limit. More...
 
int hicn_packet_copy_header (hicn_format_t format, const hicn_header_t *packet, hicn_header_t *destination, bool copy_ah)
 
int hicn_packet_get_lifetime (const hicn_header_t *packet, u32 *lifetime)
 
int hicn_packet_set_lifetime (hicn_header_t *packet, u32 lifetime)
 
int hicn_packet_get_reserved_bits (const hicn_header_t *packet, u8 *reserved_bits)
 
int hicn_packet_set_reserved_bits (hicn_header_t *packet, const u8 reserved_bits)
 
int hicn_packet_get_payload_type (const hicn_header_t *packet, hicn_payload_type_t *payload_type)
 
int hicn_packet_set_payload_type (hicn_header_t *packet, const hicn_payload_type_t payload_type)
 
int hicn_packet_set_syn (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_reset_syn (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_test_syn (hicn_format_t format, const hicn_header_t *packet, bool *flag)
 
int hicn_packet_set_ack (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_reset_ack (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_test_ack (hicn_format_t format, const hicn_header_t *packet, bool *flag)
 
int hicn_packet_set_rst (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_reset_rst (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_test_rst (hicn_format_t format, const hicn_header_t *packet, bool *flag)
 
int hicn_packet_set_fin (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_reset_fin (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_test_fin (hicn_format_t format, const hicn_header_t *packet, bool *flag)
 
int hicn_packet_set_ece (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_reset_ece (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_test_ece (hicn_format_t format, const hicn_header_t *packet, bool *flag)
 
int hicn_packet_set_src_port (hicn_format_t format, hicn_header_t *packet, u16 src_port)
 
int hicn_packet_get_src_port (hicn_format_t format, const hicn_header_t *packet, u16 *src_port)
 
int hicn_packet_set_dst_port (hicn_format_t format, hicn_header_t *packet, u16 dst_port)
 
int hicn_packet_get_dst_port (hicn_format_t format, const hicn_header_t *packet, u16 *dst_port)
 
int hicn_packet_get_signature (hicn_format_t format, hicn_header_t *packet, uint8_t **sign_buf)
 
int hicn_interest_get_name (hicn_format_t format, const hicn_header_t *interest, hicn_name_t *name)
 
int hicn_interest_set_name (hicn_format_t format, hicn_header_t *interest, const hicn_name_t *name)
 
int hicn_interest_get_locator (hicn_format_t format, const hicn_header_t *interest, ip_address_t *prefix)
 
int hicn_interest_set_locator (hicn_format_t format, hicn_header_t *interest, const ip_address_t *prefix)
 
int hicn_interest_compare (const hicn_header_t *interest_1, const hicn_header_t *interest_2)
 
int hicn_interest_set_lifetime (hicn_header_t *interest, u32 lifetime)
 
int hicn_interest_get_lifetime (const hicn_header_t *interest, u32 *lifetime)
 
int hicn_interest_get_header_length (hicn_format_t format, const hicn_header_t *interest, size_t *header_length)
 
int hicn_interest_get_payload_length (hicn_format_t format, const hicn_header_t *interest, size_t *payload_length)
 
int hicn_interest_set_payload (hicn_format_t format, hicn_header_t *interest, const u8 *payload, size_t payload_length)
 
int hicn_interest_get_payload (hicn_format_t format, const hicn_header_t *interest, u8 **payload, size_t *payload_size, bool hard_copy)
 
int hicn_interest_reset_for_hash (hicn_format_t format, hicn_header_t *packet)
 
int hicn_data_get_name (hicn_format_t format, const hicn_header_t *data, hicn_name_t *name)
 
int hicn_data_set_name (hicn_format_t format, hicn_header_t *data, const hicn_name_t *name)
 
int hicn_data_get_locator (hicn_format_t format, const hicn_header_t *data, ip_address_t *prefix)
 
int hicn_data_set_locator (hicn_format_t format, hicn_header_t *data, const ip_address_t *prefix)
 
int hicn_data_compare (const hicn_header_t *data_1, const hicn_header_t *data_2)
 
int hicn_data_get_expiry_time (const hicn_header_t *data, u32 *expiry_time)
 
int hicn_data_set_expiry_time (hicn_header_t *data, u32 expiry_time)
 
int hicn_data_get_header_length (hicn_format_t format, hicn_header_t *data, size_t *header_length)
 
int hicn_data_get_payload_length (hicn_format_t format, const hicn_header_t *data, size_t *payload_length)
 
int hicn_data_get_path_label (const hicn_header_t *data, u32 *path_label)
 
int hicn_data_set_path_label (hicn_header_t *data, u32 path_label)
 
int hicn_data_get_payload (hicn_format_t format, const hicn_header_t *data, u8 **payload, size_t *payload_size, bool hard_copy)
 
int hicn_data_set_payload (hicn_format_t format, hicn_header_t *data, const u8 *payload, size_t payload_length)
 
int hicn_data_get_payload_type (const hicn_header_t *data, hicn_payload_type_t *payload_type)
 
int hicn_data_set_payload_type (hicn_header_t *data, hicn_payload_type_t payload_type)
 
int hicn_data_reset_for_hash (hicn_format_t format, hicn_header_t *packet)
 
int hicn_packet_get_signature_gap (hicn_format_t format, const hicn_header_t *h, uint8_t *bytes)
 
int hicn_packet_set_signature_gap (hicn_format_t format, hicn_header_t *h, uint8_t bytes)
 

Detailed Description

Implementation of the compatibility layer.

The structure of the core API has evolved to support operations of a variety of packet formats in addition to IPv4/TCP and IPv6/TCP, namely with the use of ICMP for signalization and AH headers for integrity. The new API format has been designed to scale better with the multiplicity of packet formats, and provide a unified interface on top. We maintain an interface for the former API in this file, which mainly acts as a wrapper on top of new calls.

Macro Definition Documentation

◆ HICN_V6_MIN_HDR_LEN

#define HICN_V6_MIN_HDR_LEN   6 /* bytes */

Minimum required header length to determine the type and length of a supposed hICN packet. This should be equal to the maximum value over all possible hICN packet formats, and less than the minimum possible IP packet size.

Function Documentation

◆ hicn_packet_check_integrity_no_payload()

int hicn_packet_check_integrity_no_payload ( hicn_format_t  format,
hicn_header_t packet,
u16  init_sum 
)

Verify checksums in packet headers.

Parameters
[in]format- hICN format
[in,out]packet- packet header
Returns
hICN error code

◆ hicn_packet_compare()

int hicn_packet_compare ( const hicn_header_t packet1,
const hicn_header_t packet2 
)

Compare two hICN packets.

Parameters
[in]packet_1- First packet
[in]packet_2- Second packet
Returns
0 if both packets are considered equal, any other value otherwise.

◆ hicn_packet_compute_checksum()

int hicn_packet_compute_checksum ( hicn_format_t  format,
hicn_header_t packet 
)

Update checksums in packet headers.

Parameters
[in]format- hICN format
[in,out]packet- packet header
Returns
hICN error code

◆ hicn_packet_compute_header_checksum()

int hicn_packet_compute_header_checksum ( hicn_format_t  format,
hicn_header_t packet,
u16  init_sum 
)

compute the checksum of the packet header, adding init_sum to the final value

Parameters
[in]format- hICN format
[in,out]packet- packet header
[in]init_sum- value to add to the final checksum
Returns
hICN error code

◆ hicn_packet_get_format()

int hicn_packet_get_format ( const hicn_header_t packet,
hicn_format_t *  format 
)

Parse packet headers and return hICN format.

Parameters
[in]h- hICN header
[out]format- hICN format
Returns
hICN error code

◆ hicn_packet_get_header_length()

int hicn_packet_get_header_length ( hicn_format_t  format,
const hicn_header_t packet,
size_t *  header_length 
)

Return total length of hicn headers (before payload)

Parameters
[in]format- hICN format
[in]packet- packet header
[out]header_length- Total length of headers
Returns
hICN error code

◆ hicn_packet_get_header_length_from_format()

int hicn_packet_get_header_length_from_format ( hicn_format_t  format,
size_t *  header_length 
)

Return total length of hicn headers (but signature payload)

Parameters
[in]format- hICN format
[out]header_length- Total length of headers
Returns
hICN error code

◆ hicn_packet_get_hoplimit()

int hicn_packet_get_hoplimit ( const hicn_header_t packet,
u8 *  hops 
)

Retrieves the packet hop limit.

Parameters
[in]packet- packet header
[out]hops- Retrieved hop limit
Returns
hICN error code

◆ hicn_packet_get_key_id()

int hicn_packet_get_key_id ( hicn_format_t  format,
hicn_header_t h,
uint8_t **  key_id,
uint8_t *  key_id_length 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]key_id- Retrieved key id
Returns
hICN error code

◆ hicn_packet_get_locator()

int hicn_packet_get_locator ( hicn_format_t  format,
const hicn_header_t packet,
ip_address_t prefix,
bool  is_interest 
)

Retrieve the locator of an interest / data packet.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]ip_address- retrieved locator
[in]is_interest- Flag to determine whether it is an interest (1) or data packet (0)
Returns
hICN error code

◆ hicn_packet_get_name()

int hicn_packet_get_name ( hicn_format_t  format,
const hicn_header_t packet,
hicn_name_t name,
u8  is_interest 
)

Retrieve the name of an interest/data packet.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]name- name holding the result
[in]is_interest- Flag to determine whether it is an interest (1) or data packet (0)
Returns
hICN error code

◆ hicn_packet_get_payload()

int hicn_packet_get_payload ( hicn_format_t  format,
const hicn_header_t packet,
u8 **  payload,
size_t *  payload_size,
bool  hard_copy 
)

Retrieves the payload of a packet.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]payload- pointer to buffer for storing the result
[out]payload_length- size of the retreived payload
[in]hard_copy- Flag : if true (eg. 1), a copy of the payload is made into the payload buffer, otherwise (0) the pointer is changed to point to the payload offset in the packet.
Returns
hICN error code

NOTE:

  • The buffer holding payload is assumed sufficiently large

◆ hicn_packet_get_payload_length()

int hicn_packet_get_payload_length ( hicn_format_t  format,
const hicn_header_t packet,
size_t *  payload_length 
)

Return payload length.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]payload_length- payload length
Returns
hICN error code

◆ hicn_packet_get_signature_size()

int hicn_packet_get_signature_size ( hicn_format_t  format,
const hicn_header_t packet,
size_t *  bytes 
)

Retrieves the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]bytes- Retrieved signature size
Returns
hICN error code

◆ hicn_packet_get_signature_timestamp()

int hicn_packet_get_signature_timestamp ( hicn_format_t  format,
const hicn_header_t h,
uint64_t *  signature_timestamp 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]signature_timestamp- Retrieved signature timestamp
Returns
hICN error code

◆ hicn_packet_get_validation_algorithm()

int hicn_packet_get_validation_algorithm ( hicn_format_t  format,
const hicn_header_t h,
uint8_t *  validation_algorithm 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[out]validation_algorithm- Retrieved validation algorithm
Returns
hICN error code

◆ hicn_packet_init_header()

int hicn_packet_init_header ( hicn_format_t  format,
hicn_header_t packet 
)

Parse packet headers and return hICN format.

Parameters
[in]format- hICN Format
[in,out]packet- Buffer containing the hICN header to be initialized
Returns
hICN error code

◆ hicn_packet_set_hoplimit()

int hicn_packet_set_hoplimit ( hicn_header_t packet,
u8  hops 
)

Sets the packet hop limit.

Parameters
[in]packet- packet header
[in]hops- Hop limit to set
Returns
hICN error code

◆ hicn_packet_set_key_id()

int hicn_packet_set_key_id ( hicn_format_t  format,
hicn_header_t h,
uint8_t *  key_id 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[in]key_id- Key id to set
Returns
hICN error code

◆ hicn_packet_set_locator()

int hicn_packet_set_locator ( hicn_format_t  format,
hicn_header_t packet,
const ip_address_t prefix,
bool  is_interest 
)

Sets the locator of an interest / data packet.

Parameters
[in]format- hICN format
[in,out]packet- packet header
[out]ip_address- retrieved locator
[in]is_interest- Flag to determine whether it is an interest (1) or data packet (0)
Returns
hICN error code

◆ hicn_packet_set_name()

int hicn_packet_set_name ( hicn_format_t  format,
hicn_header_t packet,
const hicn_name_t name,
u8  is_interest 
)

Sets the name of an interest/data packet.

Parameters
[in]format- hICN format
[in,out]packet- packet header
[in]name- name to set into packet
[in]is_interest- Flag to determine whether it is an interest (1) or data packet (0)
Returns
hICN error code

◆ hicn_packet_set_payload()

int hicn_packet_set_payload ( hicn_format_t  format,
hicn_header_t packet,
const u8 *  payload,
u16  payload_length 
)

Sets the payload of a packet.

Parameters
[in]format- hICN format
[in,out]packet- packet header
[in]payload- payload to set
[in]payload_length- size of the payload to set
Returns
hICN error code

NOTE:

  • The buffer holding payload is assumed sufficiently large
  • This function updates header fields with the new length, but no checksum.

◆ hicn_packet_set_payload_length()

int hicn_packet_set_payload_length ( hicn_format_t  format,
hicn_header_t packet,
const size_t  payload_length 
)

Sets payload length.

Parameters
[in]format- hICN format
[in,out]packet- packet header
[in]payload_length- payload length
Returns
hICN error code

◆ hicn_packet_set_signature_size()

int hicn_packet_set_signature_size ( hicn_format_t  format,
hicn_header_t packet,
size_t  bytes 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[in]bytes- Retrieved signature size
Returns
hICN error code

◆ hicn_packet_set_signature_timestamp()

int hicn_packet_set_signature_timestamp ( hicn_format_t  format,
hicn_header_t h,
uint64_t  signature_timestamp 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[in]signature_timestamp- Signature timestamp to set
Returns
hICN error code

◆ hicn_packet_set_validation_algorithm()

int hicn_packet_set_validation_algorithm ( hicn_format_t  format,
hicn_header_t h,
uint8_t  validation_algorithm 
)

Sets the signature size.

Parameters
[in]format- hICN format
[in]packet- packet header
[in]validation_algorithm- Validation algorithm to set
Returns
hICN error code