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

hICN name helpers. More...

#include <stdbool.h>
#include <netinet/in.h>
#include <hicn/util/ip_address.h>
#include "common.h"
Include dependency graph for name.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hicn_prefix_t
 
union  hicn_v4_name_t
 
union  hicn_v6_name_t
 
struct  hicn_iov_name_t
 
struct  hicn_name_t
 

Macros

#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)
 

Typedefs

typedef u32 hicn_name_suffix_t
 

Enumerations

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
}
 

Functions

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...
 

Detailed Description

hICN name helpers.

The purpose of the file is to offer an efficient, platform- and protocol- independent way to manipulate hICN names.

Function Documentation

◆ hicn_name_compare()

int hicn_name_compare ( const hicn_name_t name_1,
const hicn_name_t name_2,
bool  consider_segment 
)

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()

int hicn_name_copy ( hicn_name_t dst,
const hicn_name_t src 
)

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]ResultinghICN name
Returns
hICN error code

◆ hicn_name_create_from_ip_prefix()

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.

Parameters
[in]ip_address- IP address
[in]idSegment - identifier
[out]Resulting- hICN name
Returns
hICN error code

◆ hicn_name_empty()

int hicn_name_empty ( hicn_name_t name)

Test whether an hICN name is empty.

Parameters
[in]name- Name to test
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()

u8 hicn_name_get_length ( const hicn_name_t name)

Returns the length of an hICN name.

Parameters
[in]name- hICN name
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()

int hicn_name_to_ip_prefix ( const hicn_name_t name,
ip_prefix_t 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()

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.

Parameters
[in]ip_address- Input IP address
[out]prefix- Resulting prefix
Returns
hICN error code