hICN name helpers.
More...
#include <stdbool.h>
#include <netinet/in.h>
#include <hicn/util/ip_address.h>
#include "common.h"
Go to the source code of this file.
|
|
#define | TCP_SEQNO_LEN 4 /* bytes */ |
| |
|
#define | HICN_V4_PREFIX_LEN IPV4_ADDR_LEN |
| |
|
#define | HICN_V6_PREFIX_LEN IPV6_ADDR_LEN |
| |
|
#define | HICN_SEGMENT_LEN TCP_SEQNO_LEN |
| |
|
#define | HICN_V6_NAME_LEN (HICN_V6_PREFIX_LEN + HICN_SEGMENT_LEN) /* 20 bytes */ |
| |
|
#define | HICN_V4_NAME_LEN (HICN_V4_PREFIX_LEN + HICN_SEGMENT_LEN) /* 8 bytes */ |
| |
|
#define | HICN_NAME_COMPONENT_SIZE 2 |
| |
|
#define | UNSPEC 1 << 0 |
| |
|
#define | HNT_CONTIGUOUS 1 << 1 |
| |
|
#define | HNT_IOV 1 << 2 |
| |
|
#define | HNT_INET 1 << 3 |
| |
|
#define | HNT_INET6 1 << 4 |
| |
|
#define | _is_unspec(name) ((name->type & UNSPEC)) |
| |
|
#define | _is_contiguous(name) ((name->type & HNT_CONTIGUOUS) >> 1) |
| |
|
#define | _is_iov(name) ((name->type & HNT_IOV) >> 2) |
| |
|
#define | _is_inet4(name) ((name->type & HNT_INET) >> 3) |
| |
|
#define | _is_inet6(name) ((name->type & HNT_INET6) >> 4) |
| |
|
|
typedef u32 | hicn_name_suffix_t |
| |
|
| enum | hicn_name_type_t {
HNT_UNSPEC = UNSPEC,
HNT_CONTIGUOUS_V4 = HNT_CONTIGUOUS | HNT_INET,
HNT_CONTIGUOUS_V6 = HNT_CONTIGUOUS | HNT_INET6,
HNT_IOV_V4 = HNT_IOV | HNT_INET,
HNT_IOV_V6 = HNT_IOV | HNT_INET6,
HNT_UNSPEC = UNSPEC,
HNT_CONTIGUOUS_V4 = HNT_CONTIGUOUS | HNT_INET,
HNT_CONTIGUOUS_V6 = HNT_CONTIGUOUS | HNT_INET6,
HNT_IOV_V4 = HNT_IOV | HNT_INET,
HNT_IOV_V6 = HNT_IOV | HNT_INET6
} |
| |
|
| int | hicn_name_create (const char *ip_address, u32 id, hicn_name_t *name) |
| | Create an hICN name from IP address in presentation format. More...
|
| |
| int | hicn_name_create_from_ip_prefix (const ip_prefix_t *prefix, u32 id, hicn_name_t *name) |
| | Create an hICN name from IP address. More...
|
| |
| u8 | hicn_name_get_length (const hicn_name_t *name) |
| | Returns the length of an hICN name. More...
|
| |
| int | hicn_name_compare (const hicn_name_t *name_1, const hicn_name_t *name_2, bool consider_segment) |
| | Compare two hICN names. More...
|
| |
| int | hicn_name_hash (const hicn_name_t *name, u32 *hash, bool consider_suffix) |
| | Provides a 32-bit hash of an hICN name. More...
|
| |
| int | hicn_name_empty (hicn_name_t *name) |
| | Test whether an hICN name is empty. More...
|
| |
| int | hicn_name_copy (hicn_name_t *dst, const hicn_name_t *src) |
| | Copy an hICN name. More...
|
| |
| int | hicn_name_copy_to_destination (u8 *dst, const hicn_name_t *src, bool copy_suffix) |
| | Copy an hICN name to a buffer. More...
|
| |
| int | hicn_name_set_seq_number (hicn_name_t *name, u32 seq_number) |
| | Sets the segment part of an hICN name. More...
|
| |
| int | hicn_name_get_seq_number (const hicn_name_t *name, u32 *seq_number) |
| | Retrieves the segment part of an hICN name. More...
|
| |
| int | hicn_name_to_sockaddr_address (const hicn_name_t *name, struct sockaddr *ip_address) |
| | Convert an hICN name to a socket address. More...
|
| |
| int | hicn_name_to_ip_prefix (const hicn_name_t *name, ip_prefix_t *ip_prefix) |
| | Convert an hICN name to an IP address. More...
|
| |
| int | hicn_name_ntop (const hicn_name_t *src, char *dst, size_t len) |
| | Convert an hICN name to presentation format. More...
|
| |
| int | hicn_name_pton (const char *src, hicn_name_t *dst) |
| | Convert an hICN name from presentation format. More...
|
| |
| int | hicn_name_get_family (const hicn_name_t *name, int *family) |
| | Returns the IP address family of an hICN name. More...
|
| |
| int | hicn_prefix_create_from_ip_prefix (const ip_prefix_t *ip_prefix, hicn_prefix_t *prefix) |
| | Creates an hICN prefix from an IP address. More...
|
| |
hICN name helpers.
The purpose of the file is to offer an efficient, platform- and protocol- independent way to manipulate hICN names.
◆ hicn_name_compare()
Compare two hICN names.
- Parameters
-
| [in] | name_1 | - First name to compare |
| [in] | name_2 | - Second name to compare |
| [in] | consider_segment | - Flag indicating whether the segment part has to be considered |
- Returns
- An integer less than, equal to, or greater than zero if name_1 is found, respectively, to be lest than, to match, or be greater than name_2 based on numeric order.
◆ hicn_name_copy()
Copy an hICN name.
- Parameters
-
| [out] | dst | - Destination name |
| [in] | src | - Source name to copy |
- Returns
- hICN error code
◆ hicn_name_copy_to_destination()
| int hicn_name_copy_to_destination |
( |
u8 * |
dst, |
|
|
const hicn_name_t * |
src, |
|
|
bool |
copy_suffix |
|
) |
| |
Copy an hICN name to a buffer.
- Parameters
-
| [out] | dst | - Destination buffer |
| [in] | src | - Source name to copy |
| [in] | copy_suffix | - Flag indicating whether the suffix has to be considered |
◆ hicn_name_create()
| int hicn_name_create |
( |
const char * |
ip_address, |
|
|
u32 |
id, |
|
|
hicn_name_t * |
name |
|
) |
| |
Create an hICN name from IP address in presentation format.
- Parameters
-
| [in] | ip_address | - IP address |
| [in] | id | - Segment identifier |
| [out] | Resulting | hICN name |
- Returns
- hICN error code
◆ hicn_name_create_from_ip_prefix()
Create an hICN name from IP address.
- Parameters
-
| [in] | ip_address | - IP address |
| [in] | id | Segment - identifier |
| [out] | Resulting | - hICN name |
- Returns
- hICN error code
◆ hicn_name_empty()
Test whether an hICN name is empty.
- Parameters
-
- Returns
- 0 if the name is empty, any other value otherwise (implementation returns 1)
◆ hicn_name_get_family()
| int hicn_name_get_family |
( |
const hicn_name_t * |
name, |
|
|
int * |
family |
|
) |
| |
Returns the IP address family of an hICN name.
- Parameters
-
| [in] | name | - Name to lookup |
| [out] | family | - Resulting IP address family (AF_INET or AF_INET6) |
- Returns
- hICN error code
◆ hicn_name_get_length()
Returns the length of an hICN name.
- Parameters
-
- Returns
- Name length
◆ hicn_name_get_seq_number()
| int hicn_name_get_seq_number |
( |
const hicn_name_t * |
name, |
|
|
u32 * |
seq_number |
|
) |
| |
Retrieves the segment part of an hICN name.
- Parameters
-
| [in,out] | name | - hICN name |
| [in] | seq_number | - Segment identifier |
- Returns
- hICN error code
◆ hicn_name_hash()
| int hicn_name_hash |
( |
const hicn_name_t * |
name, |
|
|
u32 * |
hash, |
|
|
bool |
consider_suffix |
|
) |
| |
Provides a 32-bit hash of an hICN name.
- Parameters
-
| [in] | name | - Name to hash |
| [out] | hash | - Resulting hash |
| [in] | consider_suffix | - Consider the suffix in the hash computation |
- Returns
- hICN error code
◆ hicn_name_ntop()
| int hicn_name_ntop |
( |
const hicn_name_t * |
src, |
|
|
char * |
dst, |
|
|
size_t |
len |
|
) |
| |
Convert an hICN name to presentation format.
- Parameters
-
| [in] | src | - Name to convert |
| [out] | dst | - Buffer to receive the name in presentation format |
| [in] | len | - Number of bytes available in the buffer |
- Returns
- hICN error code
◆ hicn_name_pton()
| int hicn_name_pton |
( |
const char * |
src, |
|
|
hicn_name_t * |
dst |
|
) |
| |
Convert an hICN name from presentation format.
- Parameters
-
| [in] | src | - Name in presentation format to parse |
| [out] | dst | - Resulting name |
- Returns
- hICN error code
◆ hicn_name_set_seq_number()
| int hicn_name_set_seq_number |
( |
hicn_name_t * |
name, |
|
|
u32 |
seq_number |
|
) |
| |
Sets the segment part of an hICN name.
- Parameters
-
| [in,out] | name | - hICN name to modify |
| [in] | seq_number | - Segment identifier |
- Returns
- hICN error code
◆ hicn_name_to_ip_prefix()
Convert an hICN name to an IP address.
- Parameters
-
| [in] | name | - Name to convert |
| [out] | ip_address | - Resulting IP address |
- Returns
- hICN error code
◆ hicn_name_to_sockaddr_address()
| int hicn_name_to_sockaddr_address |
( |
const hicn_name_t * |
name, |
|
|
struct sockaddr * |
ip_address |
|
) |
| |
Convert an hICN name to a socket address.
- Parameters
-
| [in] | name | - Name to convert |
| [out] | ip_address | - Resulting socket address |
- Returns
- hICN error code
◆ hicn_prefix_create_from_ip_prefix()
Creates an hICN prefix from an IP address.
- Parameters
-
| [in] | ip_address | - Input IP address |
| [out] | prefix | - Resulting prefix |
- Returns
- hICN error code