aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJordan Augé <jordan.auge+fdio@cisco.com>2019-01-21 13:25:59 +0100
committerJordan Augé <jordan.auge+fdio@cisco.com>2019-01-21 15:35:34 +0100
commit8a2e408a3fc20f1055a8ca796a4d32ebc9fb9aa0 (patch)
tree6924ea2da917504e9381cf54ce976e56ff66d0dd /lib
parent29fb58203e5a44dbfafc6b788f50ca412c5f3c4b (diff)
HICN-4 - Fix Windows compilation issue with named struct initializers
Change-Id: I9c9e8780ec1132d3d74b6202b9b142ed64b4e13f Signed-off-by: Jordan Augé <jordan.auge+fdio@cisco.com>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/src/base.h33
-rwxr-xr-xlib/src/common.h19
-rwxr-xr-xlib/src/compat.c45
-rwxr-xr-xlib/src/mapme.h11
-rwxr-xr-xlib/src/ops.h643
5 files changed, 385 insertions, 366 deletions
diff --git a/lib/src/base.h b/lib/src/base.h
index c1bd23aeb..2c082af89 100755
--- a/lib/src/base.h
+++ b/lib/src/base.h
@@ -64,6 +64,11 @@ typedef union
u8 l3; /**< Third layer */
u8 l2; /**< Second layer */
u8 l1; /**< First layer */
+#elif _WIN32 /* Windows is assumed little-endian */
+ u8 l1;
+ u8 l2;
+ u8 l3;
+ u8 l4;
#else
#error "Unsupported endianness"
#endif
@@ -73,11 +78,31 @@ typedef union
} hicn_type_t;
/* Common protocol layers */
-#define HICN_TYPE_IPV4_TCP (hicn_type_t) {{ .l4 = IPPROTO_NONE, .l3 = IPPROTO_NONE, .l2 = IPPROTO_TCP, .l1 = IPPROTO_IP }}
-#define HICN_TYPE_IPV4_ICMP (hicn_type_t) {{ .l4 = IPPROTO_NONE, .l3 = IPPROTO_NONE, .l2 = IPPROTO_ICMP, .l1 = IPPROTO_IP }}
-#define HICN_TYPE_IPV6_TCP (hicn_type_t) {{ .l4 = IPPROTO_NONE, .l3 = IPPROTO_NONE, .l2 = IPPROTO_TCP, .l1 = IPPROTO_IPV6 }}
-#define HICN_TYPE_IPV6_ICMP (hicn_type_t) {{ .l4 = IPPROTO_NONE, .l3 = IPPROTO_NONE, .l2 = IPPROTO_ICMPV6, .l1 = IPPROTO_IPV6 }}
+/* Common protocol layers */
+#ifndef _WIN32
+#define HICN_TYPE(x,y,z,t) (hicn_type_t) {{ .l1 = x, .l2 = y, .l3 = z, .l4 = t }}
+#else
+inline hicn_type_t
+HICN_TYPE(int x, int y, int z, int t)
+{
+ hicn_type_t type;
+ type.l1 = x;
+ type.l2 = y;
+ type.l3 = z;
+ type.l4 = t;
+ return type;
+}
+#endif
+#define HICN_TYPE_IPV4_TCP HICN_TYPE(IPPROTO_IP, IPPROTO_TCP, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV4_ICMP HICN_TYPE(IPPROTO_IP, IPPROTO_ICMP, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV6_TCP HICN_TYPE(IPPROTO_IPV6, IPPROTO_TCP, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV6_ICMP HICN_TYPE(IPPROTO_IPV6, IPPROTO_ICMPV6, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV4_TCP_AH HICN_TYPE(IPPROTO_IP, IPPROTO_TCP, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV4_ICMP_AH HICN_TYPE(IPPROTO_IP, IPPROTO_ICMP, IPPROTO_NONE, IPPROTO_NONE);
+#define HICN_TYPE_IPV6_TCP_AH HICN_TYPE(IPPROTO_IPV6, IPPROTO_TCP, IPPROTO_AH, IPPROTO_NONE);
+#define HICN_TYPE_IPV6_ICMP_AH HICN_TYPE(IPPROTO_IPV6, IPPROTO_ICMPV6, IPPROTO_AH, IPPROTO_NONE);
+#define HICN_TYPE_NONE HICN_TYPE(IPPROTO_NONE, IPPROTO_NONE, IPPROTO_NONE, IPPROTO_NONE);
/**
* @brief hICN Payload type
diff --git a/lib/src/common.h b/lib/src/common.h
index 9ddbdeb09..dd488d43b 100755
--- a/lib/src/common.h
+++ b/lib/src/common.h
@@ -63,6 +63,25 @@ typedef uint8_t u8;
#endif /* ! HICN_VPP_PLUGIN */
/*
+ * Windows compilers do not support named initilizers when .h files are included
+ * inside C++ files. For readability, we either use the following macro, or
+ * duplicate some code, with the intent of preserving those safeguards for
+ * non-Windows platforms.
+ */
+#ifndef _WIN32
+#define ATTR_INIT(key, value) .key = value
+#else
+#define ATTR_INIT(key, value) value
+#endif
+
+/* Endianness detection for Windows platforms */
+#ifdef _WIN32
+#define __ORDER_LITTLE_ENDIAN__ 0x41424344UL
+#define __ORDER_BIG_ENDIAN__ 0x44434241UL
+#define __BYTE_ORDER__ ('ABCD')
+#endif
+
+/*
* IP address types
*/
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 7d9eef025..8b558a56e 100755
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -91,52 +91,25 @@ hicn_format_to_type (hicn_format_t format)
switch (format)
{
case HF_INET_TCP:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_NONE,.l2 = IPPROTO_TCP,.l1 =
- IPPROTO_IP};
+ return HICN_TYPE_IPV4_TCP;
case HF_INET6_TCP:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_NONE,.l2 = IPPROTO_TCP,.l1 =
- IPPROTO_IPV6};
+ return HICN_TYPE_IPV6_TCP;
case HF_INET_ICMP:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_NONE,.l2 = IPPROTO_ICMP,.l1 =
- IPPROTO_IP};
+ return HICN_TYPE_IPV4_ICMP;
case HF_INET6_ICMP:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_NONE,.l2 = IPPROTO_ICMPV6,.l1 =
- IPPROTO_IPV6};
+ return HICN_TYPE_IPV6_ICMP;
case HF_INET_TCP_AH:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_AH,.l2 = IPPROTO_TCP,.l1 = IPPROTO_IP};
+ return HICN_TYPE_IPV4_TCP_AH;
case HF_INET6_TCP_AH:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_AH,.l2 = IPPROTO_TCP,.l1 =
- IPPROTO_IPV6};
+ return HICN_TYPE_IPV6_TCP_AH;
case HF_INET_ICMP_AH:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_AH,.l2 = IPPROTO_ICMP,.l1 =
- IPPROTO_IP};
+ return HICN_TYPE_IPV4_ICMP_AH;
case HF_INET6_ICMP_AH:
- return (hicn_type_t)
- {
- .l4 = IPPROTO_NONE,.l3 = IPPROTO_AH,.l2 = IPPROTO_ICMPV6,.l1 =
- IPPROTO_IPV6};
+ return HICN_TYPE_IPV6_ICMP_AH;
default:
break;
}
- return (hicn_type_t)
- {
- {
- IPPROTO_NONE}
- };
+ return HICN_TYPE_NONE;
}
/**
diff --git a/lib/src/mapme.h b/lib/src/mapme.h
index 460c15282..00c7ca798 100755
--- a/lib/src/mapme.h
+++ b/lib/src/mapme.h
@@ -47,10 +47,10 @@ typedef struct
/** @brief Default MAP-Me configuration */
static const hicn_mapme_conf_t hicn_mapme_conf = {
- .enabled = false,
- .timescale = 0,
- .retx = 50,
- .discovery = true,
+ ATTR_INIT(enabled, false),
+ ATTR_INIT(timescale, 0),
+ ATTR_INIT(retx, 50),
+ ATTR_INIT(discovery, true),
};
/** @brief MAP-Me update sequence number */
@@ -84,9 +84,6 @@ int hicn_mapme_parse_packet (const u8 * packet, hicn_prefix_t * prefix,
/* Implementation & parsing : ICMP Redirect */
-#define HEADER_TYPE_MAPME4 (hicn_type_t) {0, IPPROTO_ICMPRD, IPPROTO_ICMP, IPPROTO_IP}
-#define HEADER_TYPE_MAPME6 (hicn_type_t) {0, IPPROTO_ICMPRD, IPPROTO_ICMP, IPPROTO_IPV6}
-
#define HICN_MAPME_ACK_FLAG (0x20 | 0x60)
#define HICN_MAPME_ICMP_TYPE_IPV4 5
diff --git a/lib/src/ops.h b/lib/src/ops.h
index d56e6ae4a..b698a53fd 100755
--- a/lib/src/ops.h
+++ b/lib/src/ops.h
@@ -37,430 +37,430 @@
typedef struct hicn_ops_s
{
- /** Protocol name */
- const char *name;
-
- /**
- * @brief Initialize the headers of the hicn packet
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the packet
- */
+ /**
+ * @brief Initialize the headers of the hicn packet
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the packet
+ */
int (*init_packet_header) (hicn_type_t type, hicn_protocol_t * h);
- /**
- * @brief Retrieves an Interest locator
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest packet
- * @param [out] ip_address - Retrieved locator
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves an Interest locator
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest packet
+ * @param [out] ip_address - Retrieved locator
+ * @return hICN error code
+ */
int (*get_interest_locator) (hicn_type_t type, const hicn_protocol_t * h,
ip46_address_t * ip_address);
- /**
- * @brief Sets an Interest locator
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest packet
- * @param [in] ip_address - Locator to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets an Interest locator
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @param [in] ip_address - Locator to set
+ * @return hICN error code
+ */
int (*set_interest_locator) (hicn_type_t type, hicn_protocol_t * h,
const ip46_address_t * ip_address);
- /**
- * @brief Retrieves an Interest name
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest packet
- * @param [out] name - Retrieved name
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves an Interest name
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest packet
+ * @param [out] name - Retrieved name
+ * @return hICN error code
+ */
int (*get_interest_name) (hicn_type_t type, const hicn_protocol_t * h,
hicn_name_t * name);
- /**
- * @brief Sets an Interest name
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest packet
- * @param [in] name - Name to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets an Interest name
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @param [in] name - Name to set
+ * @return hICN error code
+ */
int (*set_interest_name) (hicn_type_t type, hicn_protocol_t * h,
const hicn_name_t * name);
- /**
- * @brief Retrieves an Interest name suffix
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest packet
- * @param [out] suffix - Retrieved name suffix
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves an Interest name suffix
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest packet
+ * @param [out] suffix - Retrieved name suffix
+ * @return hICN error code
+ */
int (*get_interest_name_suffix) (hicn_type_t type,
const hicn_protocol_t * h,
hicn_name_suffix_t * suffix);
- /**
- * @brief Sets an Interest name suffix
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest packet
- * @param [in] suffix - Name suffix to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets an Interest name suffix
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @param [in] suffix - Name suffix to set
+ * @return hICN error code
+ */
int (*set_interest_name_suffix) (hicn_type_t type, hicn_protocol_t * h,
const hicn_name_suffix_t * suffix);
- /**
- * @brief Clear the necessary Interest fields in order to hash it
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest packet
- * @return hICN error code
- */
+ /**
+ * @brief Clear the necessary Interest fields in order to hash it
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest packet
+ * @return hICN error code
+ */
int (*reset_interest_for_hash) (hicn_type_t type, hicn_protocol_t * h);
- /**
- * @brief Retrieves a Data locator
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Data packet
- * @param [out] ip_address - Retrieved locator
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves a Data locator
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Data packet
+ * @param [out] ip_address - Retrieved locator
+ * @return hICN error code
+ */
int (*get_data_locator) (hicn_type_t type, const hicn_protocol_t * h,
ip46_address_t * ip_address);
- /**
- * @brief Sets a Data locator
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @param [in] ip_address - Locator to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets a Data locator
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @param [in] ip_address - Locator to set
+ * @return hICN error code
+ */
int (*set_data_locator) (hicn_type_t type, hicn_protocol_t * h,
const ip46_address_t * ip_address);
- /**
- * @brief Retrieves a Data name
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Data packet
- * @param [out] name - Retrieved name
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves a Data name
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Data packet
+ * @param [out] name - Retrieved name
+ * @return hICN error code
+ */
int (*get_data_name) (hicn_type_t type, const hicn_protocol_t * h,
hicn_name_t * name);
- /**
- * @brief Sets a Data name
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @param [in] name - Name to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets a Data name
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @param [in] name - Name to set
+ * @return hICN error code
+ */
int (*set_data_name) (hicn_type_t type, hicn_protocol_t * h,
const hicn_name_t * name);
- /**
- * @brief Retrieves a Data name suffix
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Data packet
- * @param [out] suffix - Retrieved name suffix
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves a Data name suffix
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Data packet
+ * @param [out] suffix - Retrieved name suffix
+ * @return hICN error code
+ */
int (*get_data_name_suffix) (hicn_type_t type, const hicn_protocol_t * h,
hicn_name_suffix_t * suffix);
- /**
- * @brief Sets a Data name suffix
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @param [in] suffix - Name suffix to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets a Data name suffix
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @param [in] suffix - Name suffix to set
+ * @return hICN error code
+ */
int (*set_data_name_suffix) (hicn_type_t type, hicn_protocol_t * h,
const hicn_name_suffix_t * suffix);
- /**
- * @brief Retrieves a Data pathlabel
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Data packet
- * @param [out] pathlabel - Retrieved pathlabel
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves a Data pathlabel
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Data packet
+ * @param [out] pathlabel - Retrieved pathlabel
+ * @return hICN error code
+ */
int (*get_data_pathlabel) (hicn_type_t type, const hicn_protocol_t * h,
u32 * pathlabel);
- /**
- * @brief Sets a Data pathlabel
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @param [in] pathlabel - Pathlabel to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets a Data pathlabel
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @param [in] pathlabel - Pathlabel to set
+ * @return hICN error code
+ */
int (*set_data_pathlabel) (hicn_type_t type, hicn_protocol_t * h,
const u32 pathlabel);
- /**
- * @brief Update a Data pathlabel with a new face identifier
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @param [in] pathlabel - Face identifier used to update pathlabel
- * @return hICN error code
- */
+ /**
+ * @brief Update a Data pathlabel with a new face identifier
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @param [in] pathlabel - Face identifier used to update pathlabel
+ * @return hICN error code
+ */
int (*update_data_pathlabel) (hicn_type_t type, hicn_protocol_t * h,
const hicn_faceid_t face_id);
- /**
- * @brief Clear the necessary Data fields in order to hash it
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Data packet
- * @return hICN error code
- */
+ /**
+ * @brief Clear the necessary Data fields in order to hash it
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Data packet
+ * @return hICN error code
+ */
int (*reset_data_for_hash) (hicn_type_t type, hicn_protocol_t * h);
- /**
- * @brief Retrieves an Interest or Data lifetime
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest or Data packet
- * @param [out] pathlabel - Retrieved lifetime
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves an Interest or Data lifetime
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest or Data packet
+ * @param [out] pathlabel - Retrieved lifetime
+ * @return hICN error code
+ */
int (*get_lifetime) (hicn_type_t type, const hicn_protocol_t * h,
hicn_lifetime_t * lifetime);
- /**
- * @brief Sets an Interest or Data lifetime
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [in] pathlabel - Lifetime to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets an Interest or Data lifetime
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] pathlabel - Lifetime to set
+ * @return hICN error code
+ */
int (*set_lifetime) (hicn_type_t type, hicn_protocol_t * h,
const hicn_lifetime_t lifetime);
- /**
- * @brief Update all checksums in packet headers
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the packet
- * @param [in] partial_csum - Partial checksum (set to 0, used internally to
- * carry intermediate values from IP pseudo-header)
- * @param [in] payload_length - Payload length (can be set to 0, retrieved
- * and used internally to carry payload length across protocol headers)
- * @return hICN error code
- */
+ /**
+ * @brief Update all checksums in packet headers
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the packet
+ * @param [in] partial_csum - Partial checksum (set to 0, used internally to
+ * carry intermediate values from IP pseudo-header)
+ * @param [in] payload_length - Payload length (can be set to 0, retrieved
+ * and used internally to carry payload length across protocol headers)
+ * @return hICN error code
+ */
int (*update_checksums) (hicn_type_t type, hicn_protocol_t * h,
u16 partial_csum, size_t payload_length);
- /**
- * @brief Validate all checksums in packet headers
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the packet
- * @param [in] partial_csum - Partial checksum (set to 0, used internally to
- * carry intermediate values from IP pseudo-header)
- * @param [in] payload_length - Payload length (can be set to 0, retrieved
- * and used internally to carry payload length across protocol headers)
- * @return hICN error code
- */
+ /**
+ * @brief Validate all checksums in packet headers
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the packet
+ * @param [in] partial_csum - Partial checksum (set to 0, used internally to
+ * carry intermediate values from IP pseudo-header)
+ * @param [in] payload_length - Payload length (can be set to 0, retrieved
+ * and used internally to carry payload length across protocol headers)
+ * @return hICN error code
+ */
int (*verify_checksums) (hicn_type_t type, hicn_protocol_t * h,
u16 partial_csum, size_t payload_length);
- /**
- * @brief Rewrite an Interest packet header (locator)
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest packet
- * @param [in] addr_new - New locator
- * @param [in] addr_old - Old locator (set to NULL, used internally to
- * compute incremental checksums)
- * @return hICN error code
- */
+ /**
+ * @brief Rewrite an Interest packet header (locator)
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest packet
+ * @param [in] addr_new - New locator
+ * @param [in] addr_old - Old locator (set to NULL, used internally to
+ * compute incremental checksums)
+ * @return hICN error code
+ */
int (*rewrite_interest) (hicn_type_t type, hicn_protocol_t * h,
const ip46_address_t * addr_new,
ip46_address_t * addr_old);
- /**
- * @brief Rewrite a Data packet header (locator + pathlabel)
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Data packet
- * @param [in] addr_new - New locator
- * @param [in] addr_old - Old locator (set to NULL, used internally to
- * compute incremental checksums)
- * @param [in] face_id - Face identifier used to update pathlabel
- * @return hICN error code
- */
+ /**
+ * @brief Rewrite a Data packet header (locator + pathlabel)
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Data packet
+ * @param [in] addr_new - New locator
+ * @param [in] addr_old - Old locator (set to NULL, used internally to
+ * compute incremental checksums)
+ * @param [in] face_id - Face identifier used to update pathlabel
+ * @return hICN error code
+ */
int (*rewrite_data) (hicn_type_t type, hicn_protocol_t * h,
const ip46_address_t * addr_new,
ip46_address_t * addr_old,
const hicn_faceid_t face_id);
- /**
- * @brief Return the packet length
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the packet
- * @parma [out] length - Returned packet length
- * @return hICN error code
- */
+ /**
+ * @brief Return the packet length
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the packet
+ * @parma [out] length - Returned packet length
+ * @return hICN error code
+ */
int (*get_length) (hicn_type_t type, const hicn_protocol_t * h,
size_t * length);
- /**
- * @brief Return the current packet header length
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the packet
- * @parma [out] header_length - Returned packet current header length
- * @return hICN error code
- */
+ /**
+ * @brief Return the current packet header length
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the packet
+ * @parma [out] header_length - Returned packet current header length
+ * @return hICN error code
+ */
int (*get_current_header_length) (hicn_type_t type,
const hicn_protocol_t * h,
size_t * header_length);
- /**
- * @brief Return the packet header length
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the packet
- * @parma [out] header_length - Returned packet header length
- * @return hICN error code
- */
+ /**
+ * @brief Return the packet header length
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the packet
+ * @parma [out] header_length - Returned packet header length
+ * @return hICN error code
+ */
int (*get_header_length) (hicn_type_t type, const hicn_protocol_t * h,
size_t * header_length);
- /**
- * @brief Return the packet payload length
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the packet
- * @parma [out] payload_length - Returned packet payload length
- * @return hICN error code
- */
+ /**
+ * @brief Return the packet payload length
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the packet
+ * @parma [out] payload_length - Returned packet payload length
+ * @return hICN error code
+ */
int (*get_payload_length) (hicn_type_t type, const hicn_protocol_t * h,
size_t * payload_length);
- /**
- * @brief Sets the packet paylaod length
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the packet
- * @parma [out] payload_length - Payload length to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets the packet paylaod length
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the packet
+ * @parma [out] payload_length - Payload length to set
+ * @return hICN error code
+ */
int (*set_payload_length) (hicn_type_t type, hicn_protocol_t * h,
size_t payload_length);
- /**
- * @brief Retrieves an Interest or Data signature size
- * @param [in] type - hICN packet type
- * @param [in] h - Buffer holding the Interest or Data packet
- * @param [out] signature_size - Retrieved signature size
- * @return hICN error code
- */
+ /**
+ * @brief Retrieves an Interest or Data signature size
+ * @param [in] type - hICN packet type
+ * @param [in] h - Buffer holding the Interest or Data packet
+ * @param [out] signature_size - Retrieved signature size
+ * @return hICN error code
+ */
int (*get_signature_size) (hicn_type_t type, const hicn_protocol_t * h,
size_t * signature_size);
- /**
- * @brief Sets an Interest or Data signature size
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [in] signature_size - Signature size to set
- * @return hICN error code
- */
+ /**
+ * @brief Sets an Interest or Data signature size
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] signature_size - Signature size to set
+ * @return hICN error code
+ */
int (*set_signature_size) (hicn_type_t type, hicn_protocol_t * h,
size_t signature_size);
- /**
- * @brief Sets the signature timestamp
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [in] signature_timestamp - Signature timestamp to set
- * @return hICN error code
- */
+ /**
+ * @brief Gets the signature timestamp
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [out] signature_timestamp - Retrieved signature timestamp
+ * @return hICN error code
+ */
+ int (*get_signature_timestamp) (hicn_type_t type, const hicn_protocol_t * h,
+ uint64_t *signature_timestamp);
+
+ /**
+ * @brief Sets the signature timestamp
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] signature_timestamp - Signature timestamp to set
+ * @return hICN error code
+ */
int (*set_signature_timestamp) (hicn_type_t type, hicn_protocol_t * h,
uint64_t signature_timestamp);
- /**
- * @brief Gets the signature timestamp
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [out] signature_timestamp - Retrieved signature timestamp
- * @return hICN error code
- */
- int (*get_signature_timestamp) (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t *signature_timestamp);
- /**
- * @brief Sets the signature validation algorithm
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [in] validation_algorithm - Validation algorithm enumeration
- * @return hICN error code
- */
+ /**
+ * @brief Gets the signature validation algorithm
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [out] validation_algorithm - Retrieved validation_algorithm
+ * @return hICN error code
+ */
+ int (*get_validation_algorithm) (hicn_type_t type, const hicn_protocol_t * h,
+ uint8_t *validation_algorithm);
+
+ /**
+ * @brief Sets the signature validation algorithm
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] validation_algorithm - Validation algorithm enumeration
+ * @return hICN error code
+ */
int (*set_validation_algorithm) (hicn_type_t type, hicn_protocol_t * h,
uint8_t validation_algorithm);
- /**
- * @brief Gets the signature validation algorithm
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [out] validation_algorithm - Retrieved validation_algorithm
- * @return hICN error code
- */
- int (*get_validation_algorithm) (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t *validation_algorithm);
- /**
- * @brief Sets the key id
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [in] key_id - Key id first byte address
- * @return hICN error code
- */
+ /**
+ * @brief Gets the key id
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [out] key_id - Retrieved key id first byte address
+ * @return hICN error code
+ */
+ int (*get_key_id) (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t **key_id, uint8_t *key_id_size);
+
+ /**
+ * @brief Sets the key id
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] key_id - Key id first byte address
+ * @return hICN error code
+ */
int (*set_key_id) (hicn_type_t type, hicn_protocol_t * h,
uint8_t *key_id);
- /**
- * @brief Gets the key id
- * @param [in] type - hICN packet type
- * @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [out] key_id - Retrieved key id first byte address
- * @return hICN error code
- */
- int (*get_key_id) (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size);
} hicn_ops_t;
#define DECLARE_HICN_OPS(protocol) \
- const hicn_ops_t hicn_ops_ ## protocol = { \
- .init_packet_header = protocol ## _init_packet_header, \
- .get_interest_locator = protocol ## _get_interest_locator, \
- .set_interest_locator = protocol ## _set_interest_locator, \
- .get_interest_name = protocol ## _get_interest_name, \
- .set_interest_name = protocol ## _set_interest_name, \
- .get_interest_name_suffix = protocol ## _get_interest_name_suffix, \
- .set_interest_name_suffix = protocol ## _set_interest_name_suffix, \
- .reset_interest_for_hash = protocol ## _reset_interest_for_hash, \
- .get_data_locator = protocol ## _get_data_locator, \
- .set_data_locator = protocol ## _set_data_locator, \
- .get_data_name = protocol ## _get_data_name, \
- .set_data_name = protocol ## _set_data_name, \
- .get_data_name_suffix = protocol ## _get_data_name_suffix, \
- .set_data_name_suffix = protocol ## _set_data_name_suffix, \
- .get_data_pathlabel = protocol ## _get_data_pathlabel, \
- .set_data_pathlabel = protocol ## _set_data_pathlabel, \
- .update_data_pathlabel = protocol ## _update_data_pathlabel, \
- .reset_data_for_hash = protocol ## _reset_data_for_hash, \
- .get_lifetime = protocol ## _get_lifetime, \
- .set_lifetime = protocol ## _set_lifetime, \
- .update_checksums = protocol ## _update_checksums, \
- .verify_checksums = protocol ## _verify_checksums, \
- .rewrite_interest = protocol ## _rewrite_interest, \
- .rewrite_data = protocol ## _rewrite_data, \
- .get_length = protocol ## _get_length, \
- .get_current_header_length= protocol ## _get_current_header_length, \
- .get_header_length = protocol ## _get_header_length, \
- .get_payload_length = protocol ## _get_payload_length, \
- .set_payload_length = protocol ## _set_payload_length, \
- .get_signature_size = protocol ## _get_signature_size, \
- .set_signature_size = protocol ## _set_signature_size, \
- .set_signature_timestamp = protocol ## _set_signature_timestamp, \
- .get_signature_timestamp = protocol ## _get_signature_timestamp, \
- .set_validation_algorithm = protocol ## _set_validation_algorithm, \
- .get_validation_algorithm = protocol ## _get_validation_algorithm, \
- .set_key_id = protocol ## _set_key_id, \
- .get_key_id = protocol ## _get_key_id, \
- }
+ const hicn_ops_t hicn_ops_ ## protocol = { \
+ ATTR_INIT(init_packet_header, protocol ## _init_packet_header), \
+ ATTR_INIT(get_interest_locator, protocol ## _get_interest_locator), \
+ ATTR_INIT(set_interest_locator, protocol ## _set_interest_locator), \
+ ATTR_INIT(get_interest_name, protocol ## _get_interest_name), \
+ ATTR_INIT(set_interest_name, protocol ## _set_interest_name), \
+ ATTR_INIT(get_interest_name_suffix, protocol ## _get_interest_name_suffix), \
+ ATTR_INIT(set_interest_name_suffix, protocol ## _set_interest_name_suffix), \
+ ATTR_INIT(reset_interest_for_hash, protocol ## _reset_interest_for_hash), \
+ ATTR_INIT(get_data_locator, protocol ## _get_data_locator), \
+ ATTR_INIT(set_data_locator, protocol ## _set_data_locator), \
+ ATTR_INIT(get_data_name, protocol ## _get_data_name), \
+ ATTR_INIT(set_data_name, protocol ## _set_data_name), \
+ ATTR_INIT(get_data_name_suffix, protocol ## _get_data_name_suffix), \
+ ATTR_INIT(set_data_name_suffix, protocol ## _set_data_name_suffix), \
+ ATTR_INIT(get_data_pathlabel, protocol ## _get_data_pathlabel), \
+ ATTR_INIT(set_data_pathlabel, protocol ## _set_data_pathlabel), \
+ ATTR_INIT(update_data_pathlabel, protocol ## _update_data_pathlabel), \
+ ATTR_INIT(reset_data_for_hash, protocol ## _reset_data_for_hash), \
+ ATTR_INIT(get_lifetime, protocol ## _get_lifetime), \
+ ATTR_INIT(set_lifetime, protocol ## _set_lifetime), \
+ ATTR_INIT(update_checksums, protocol ## _update_checksums), \
+ ATTR_INIT(verify_checksums, protocol ## _verify_checksums), \
+ ATTR_INIT(rewrite_interest, protocol ## _rewrite_interest), \
+ ATTR_INIT(rewrite_data, protocol ## _rewrite_data), \
+ ATTR_INIT(get_length, protocol ## _get_length), \
+ ATTR_INIT(get_current_header_length,protocol ## _get_current_header_length),\
+ ATTR_INIT(get_header_length, protocol ## _get_header_length), \
+ ATTR_INIT(get_payload_length, protocol ## _get_payload_length), \
+ ATTR_INIT(set_payload_length, protocol ## _set_payload_length), \
+ ATTR_INIT(get_signature_size, protocol ## _get_signature_size), \
+ ATTR_INIT(set_signature_size, protocol ## _set_signature_size), \
+ ATTR_INIT(get_signature_timestamp, protocol ## _get_signature_timestamp), \
+ ATTR_INIT(set_signature_timestamp, protocol ## _set_signature_timestamp), \
+ ATTR_INIT(get_validation_algorithm, protocol ## _get_validation_algorithm), \
+ ATTR_INIT(set_validation_algorithm, protocol ## _set_validation_algorithm), \
+ ATTR_INIT(get_key_id, protocol ## _get_key_id), \
+ ATTR_INIT(set_key_id, protocol ## _set_key_id), \
+ }
/**
* @brief Protocol-independent packet operations VFT
@@ -476,11 +476,16 @@ extern const hicn_ops_t *const hicn_ops_vft[];
always_inline hicn_type_t
TYPE_POP (hicn_type_t type)
{
- return (hicn_type_t)
- {
- {
- .l1 = type.l2,.l2 = type.l3,.l3 = type.l4,.l4 = IPPROTO_NONE,}
- };
+#ifndef _WIN32
+ return HICN_TYPE(type.l2, type.l3, type.l4, IPPROTO_NONE);
+#else
+ hicn_type_t new_type;
+ new_type.l1 = type.l2;
+ new_type.l2 = type.l3;
+ new_type.l3 = type.l4;
+ new_type.l4 = IPPROTO_NONE;
+ return new_type;
+#endif
}
always_inline hicn_protocol_t *