aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/.clang-format1
-rw-r--r--lib/CMakeLists.txt2
-rw-r--r--lib/includes/hicn/compat.h5
-rw-r--r--lib/includes/hicn/ops.h622
-rw-r--r--lib/includes/hicn/protocol/ah.h17
-rw-r--r--lib/src/CMakeLists.txt2
-rw-r--r--lib/src/compat.c23
-rw-r--r--lib/src/ops.c13
-rw-r--r--lib/src/protocol/ah.c86
-rw-r--r--lib/src/protocol/icmp.c251
-rw-r--r--lib/src/protocol/ipv4.c195
-rw-r--r--lib/src/protocol/ipv6.c184
-rw-r--r--lib/src/protocol/tcp.c211
13 files changed, 954 insertions, 658 deletions
diff --git a/lib/.clang-format b/lib/.clang-format
index 8b5c955ce..351a70e20 100644
--- a/lib/.clang-format
+++ b/lib/.clang-format
@@ -18,4 +18,3 @@ ForEachMacros:
- 'vec_foreach_index'
- 'vec_foreach_index_backwards'
- 'vlib_foreach_rx_tx'
-
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 0512b7c64..65c1cd4ee 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -11,7 +11,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
+cmake_minimum_required (VERSION 3.10 FATAL_ERROR)
project(libhicn C)
#include(CTest)
diff --git a/lib/includes/hicn/compat.h b/lib/includes/hicn/compat.h
index 35b6e6fc5..486c82348 100644
--- a/lib/includes/hicn/compat.h
+++ b/lib/includes/hicn/compat.h
@@ -454,7 +454,10 @@ int hicn_data_get_payload_type (const hicn_header_t *data,
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);
#endif /* HICN_COMPAT_H */
/*
diff --git a/lib/includes/hicn/ops.h b/lib/includes/hicn/ops.h
index 7d4ae86d8..e5b1c088c 100644
--- a/lib/includes/hicn/ops.h
+++ b/lib/includes/hicn/ops.h
@@ -30,8 +30,8 @@
/*
* hICN operations on packets
*
- * All prototypes take an hicn_type_t parameter as their first argument, as this
- * decides the sequence of protocols that are being used by the different
+ * All prototypes take an hicn_type_t parameter as their first argument, as
+ * this decides the sequence of protocols that are being used by the different
* operations.
*/
@@ -42,7 +42,7 @@ typedef struct hicn_ops_s
* @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);
+ int (*init_packet_header) (hicn_type_t type, hicn_protocol_t *h);
/**
* @brief Retrieves an Interest locator
@@ -51,8 +51,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_interest_locator) (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address);
/**
* @brief Sets an Interest locator
@@ -61,8 +61,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_interest_locator) (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address);
/**
* @brief Retrieves an Interest name
@@ -71,8 +71,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_interest_name) (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name);
/**
* @brief Sets an Interest name
@@ -81,8 +81,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_interest_name) (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name);
/**
* @brief Retrieves an Interest name suffix
@@ -91,9 +91,8 @@ typedef struct hicn_ops_s
* @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);
+ 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
@@ -102,8 +101,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_interest_name_suffix) (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix);
/**
* @brief Set flag to mark current packet as interest
@@ -111,7 +110,7 @@ typedef struct hicn_ops_s
* @param [in,out] h - Buffer holding the Interest packet
* @return hICN error code
*/
- int (*mark_packet_as_interest) (hicn_type_t type, hicn_protocol_t * h);
+ int (*mark_packet_as_interest) (hicn_type_t type, hicn_protocol_t *h);
/**
* @brief Set flag to mark current packet as data
@@ -119,7 +118,7 @@ typedef struct hicn_ops_s
* @param [in,out] h - Buffer holding the Interest packet
* @return hICN error code
*/
- int (*mark_packet_as_data) (hicn_type_t type, hicn_protocol_t * h);
+ int (*mark_packet_as_data) (hicn_type_t type, hicn_protocol_t *h);
/**
* @brief Clear the necessary Interest fields in order to hash it
@@ -127,7 +126,7 @@ typedef struct hicn_ops_s
* @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);
+ int (*reset_interest_for_hash) (hicn_type_t type, hicn_protocol_t *h);
/**
* @brief Retrieves a Data locator
@@ -136,8 +135,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_data_locator) (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address);
/**
* @brief Sets a Data locator
@@ -146,8 +145,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_data_locator) (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address);
/**
* @brief Retrieves a Data name
@@ -156,8 +155,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_data_name) (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name);
/**
* @brief Sets a Data name
@@ -166,8 +165,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_data_name) (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name);
/**
* @brief Retrieves a Data name suffix
@@ -176,8 +175,8 @@ typedef struct hicn_ops_s
* @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);
+ 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
@@ -186,8 +185,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_data_name_suffix) (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix);
/**
* @brief Retrieves a Data pathlabel
@@ -196,8 +195,8 @@ typedef struct hicn_ops_s
* @param [out] pathlabel - Retrieved pathlabel
* @return hICN error code
*/
- int (*get_data_pathlabel) (hicn_type_t type, const hicn_protocol_t * h,
- u32 * pathlabel);
+ int (*get_data_pathlabel) (hicn_type_t type, const hicn_protocol_t *h,
+ u32 *pathlabel);
/**
* @brief Sets a Data pathlabel
@@ -206,7 +205,7 @@ typedef struct hicn_ops_s
* @param [in] pathlabel - Pathlabel to set
* @return hICN error code
*/
- int (*set_data_pathlabel) (hicn_type_t type, hicn_protocol_t * h,
+ int (*set_data_pathlabel) (hicn_type_t type, hicn_protocol_t *h,
const u32 pathlabel);
/**
@@ -216,7 +215,7 @@ typedef struct hicn_ops_s
* @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,
+ int (*update_data_pathlabel) (hicn_type_t type, hicn_protocol_t *h,
const hicn_faceid_t face_id);
/**
@@ -225,7 +224,7 @@ typedef struct hicn_ops_s
* @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);
+ int (*reset_data_for_hash) (hicn_type_t type, hicn_protocol_t *h);
/**
* @brief Retrieves an Interest or Data lifetime
@@ -234,8 +233,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_lifetime) (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_lifetime_t *lifetime);
/**
* @brief Sets an Interest or Data lifetime
@@ -244,7 +243,7 @@ typedef struct hicn_ops_s
* @param [in] pathlabel - Lifetime to set
* @return hICN error code
*/
- int (*set_lifetime) (hicn_type_t type, hicn_protocol_t * h,
+ int (*set_lifetime) (hicn_type_t type, hicn_protocol_t *h,
const hicn_lifetime_t lifetime);
/**
@@ -257,19 +256,20 @@ typedef struct hicn_ops_s
* 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,
+ 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, or zero if no partial checksum available
+ * @param [in] partial_csum - Partial checksum, or zero if no partial
+ * checksum available
* @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,
+ int (*verify_checksums) (hicn_type_t type, hicn_protocol_t *h,
u16 partial_csum, size_t payload_length);
/**
@@ -281,9 +281,9 @@ typedef struct hicn_ops_s
* 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);
+ 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)
@@ -297,11 +297,10 @@ typedef struct hicn_ops_s
* before update it
* @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,
- u8 reset_pl);
+ 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,
+ u8 reset_pl);
/**
* @brief Return the packet length
@@ -310,8 +309,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_length) (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *length);
/**
* @brief Return the current packet header length
@@ -320,9 +319,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_current_header_length) (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length);
/**
* @brief Return the packet header length
@@ -331,8 +329,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_header_length) (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length);
/**
* @brief Return the packet payload length
@@ -341,8 +339,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_payload_length) (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *payload_length);
/**
* @brief Sets the packet paylaod length
@@ -351,7 +349,7 @@ typedef struct hicn_ops_s
* @parma [out] payload_length - Payload length to set
* @return hICN error code
*/
- int (*set_payload_length) (hicn_type_t type, hicn_protocol_t * h,
+ int (*set_payload_length) (hicn_type_t type, hicn_protocol_t *h,
size_t payload_length);
/**
@@ -361,8 +359,8 @@ typedef struct hicn_ops_s
* @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);
+ 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
@@ -371,18 +369,41 @@ typedef struct hicn_ops_s
* @param [in] signature_size - Signature size to set
* @return hICN error code
*/
- int (*set_signature_size) (hicn_type_t type, hicn_protocol_t * h,
+ int (*set_signature_size) (hicn_type_t type, hicn_protocol_t *h,
size_t signature_size);
/**
+ * @brief Sets an Interest or Data signature gap between maximum size and
+ * real 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_gap) (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t signature_gap);
+
+ /**
+ * @brief gets an Interest or Data signature gap between maximum size and
+ * real size
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [in] signature_size - retrieve the gap between maximum size and
+ * real size
+ * @return hICN error code
+ */
+ int (*get_signature_gap) (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *signature_gap);
+
+ /**
* @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);
+ int (*get_signature_timestamp) (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp);
/**
* @brief Sets the signature timestamp
@@ -391,9 +412,8 @@ typedef struct hicn_ops_s
* @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);
-
+ int (*set_signature_timestamp) (hicn_type_t type, hicn_protocol_t *h,
+ uint64_t signature_timestamp);
/**
* @brief Gets the signature validation algorithm
@@ -402,8 +422,8 @@ typedef struct hicn_ops_s
* @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);
+ int (*get_validation_algorithm) (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm);
/**
* @brief Sets the signature validation algorithm
@@ -412,9 +432,8 @@ typedef struct hicn_ops_s
* @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);
-
+ int (*set_validation_algorithm) (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t validation_algorithm);
/**
* @brief Gets the key id
@@ -423,8 +442,8 @@ typedef struct hicn_ops_s
* @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);
+ 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
@@ -433,62 +452,69 @@ typedef struct hicn_ops_s
* @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);
+ int (*set_key_id) (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id);
- /**
+ /**
* @brief Get a pointer to the signature field in the packet
* @param [in] type - hICN packet type
* @param [in,out] h - Buffer holding the Interest or Data packet
- * @param [out] signature - Pointer to the memory region holding the signature
+ * @param [out] signature - Pointer to the memory region holding the
+ * signature
* @return hICN error code
*/
- int (*get_signature) (hicn_type_t type, hicn_protocol_t * h,
- uint8_t ** signature);
+ int (*get_signature) (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t **signature);
} hicn_ops_t;
-#define DECLARE_HICN_OPS(protocol) \
- 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(mark_packet_as_interest, protocol ## _mark_packet_as_interest), \
- ATTR_INIT(mark_packet_as_data, protocol ## _mark_packet_as_data), \
- 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), \
- ATTR_INIT(get_signature, protocol ## _get_signature), \
+#define DECLARE_HICN_OPS(protocol) \
+ 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 (mark_packet_as_interest, protocol##_mark_packet_as_interest), \
+ ATTR_INIT (mark_packet_as_data, protocol##_mark_packet_as_data), \
+ 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 (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), \
+ ATTR_INIT (get_signature, protocol##_get_signature), \
+ ATTR_INIT (set_signature_gap, protocol##_set_signature_gap), \
+ ATTR_INIT (set_signature_size, protocol##_set_signature_size), \
+ ATTR_INIT (get_signature_gap, protocol##_get_signature_gap), \
}
/**
@@ -500,13 +526,14 @@ extern const hicn_ops_t *const hicn_ops_vft[];
/*
* Helpers for writing recursive protocol operations on packet headers
*
- * NOTE : we cannot use a shift operation as IPPROTO_NONE != 0 (and 0 is IPv4...)
+ * NOTE : we cannot use a shift operation as IPPROTO_NONE != 0 (and 0 is
+ * IPv4...)
*/
always_inline hicn_type_t
TYPE_POP (hicn_type_t type)
{
#ifndef _WIN32
- return HICN_TYPE(type.l2, type.l3, type.l4, IPPROTO_NONE);
+ return HICN_TYPE (type.l2, type.l3, type.l4, IPPROTO_NONE);
#else
hicn_type_t new_type;
new_type.l1 = type.l2;
@@ -518,17 +545,19 @@ TYPE_POP (hicn_type_t type)
}
always_inline hicn_protocol_t *
-PAYLOAD (hicn_type_t type, const hicn_protocol_t * h)
+PAYLOAD (hicn_type_t type, const hicn_protocol_t *h)
{
size_t header_length;
- int rc = hicn_ops_vft[type.l1]->get_current_header_length (type, h,
- &header_length);
+ int rc =
+ hicn_ops_vft[type.l1]->get_current_header_length (type, h, &header_length);
if (rc < 0)
return NULL;
return (hicn_protocol_t *) ((u8 *) h + header_length);
}
-#define CHILD_OPS(f, type, h, ...) (hicn_ops_vft[type.l2]->f(TYPE_POP(type), PAYLOAD(type, h), ## __VA_ARGS__))
+#define CHILD_OPS(f, type, h, ...) \
+ (hicn_ops_vft[type.l2]->f (TYPE_POP (type), PAYLOAD (type, h), \
+ ##__VA_ARGS__))
/** Shortcuts to entry points in VFT */
#define HICN_OPS4 hicn_ops_vft[IPPROTO_IP]
@@ -536,125 +565,300 @@ PAYLOAD (hicn_type_t type, const hicn_protocol_t * h)
/* Helpers for simple declarations */
-#define DECLARE_init_packet_header(protocol, error) \
- int protocol ## _init_packet_header(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_init_packet_header(protocol, error) \
+ int protocol##_init_packet_header (hicn_type_t type, hicn_protocol_t *h) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_interest_locator(protocol, error) \
- int protocol ## _get_interest_locator(hicn_type_t type, const hicn_protocol_t * h, ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_interest_locator(protocol, error) \
+ int protocol##_get_interest_locator ( \
+ hicn_type_t type, const hicn_protocol_t *h, ip46_address_t *ip_address) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_interest_locator(protocol, error) \
- int protocol ## _set_interest_locator(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_interest_locator(protocol, error) \
+ int protocol##_set_interest_locator (hicn_type_t type, hicn_protocol_t *h, \
+ const ip46_address_t *ip_address) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_interest_name(protocol, error) \
- int protocol ## _get_interest_name(hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_interest_name(protocol, error) \
+ int protocol##_get_interest_name ( \
+ hicn_type_t type, const hicn_protocol_t *h, hicn_name_t *name) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_interest_name(protocol, error) \
- int protocol ## _set_interest_name(hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_interest_name(protocol, error) \
+ int protocol##_set_interest_name (hicn_type_t type, hicn_protocol_t *h, \
+ const hicn_name_t *name) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_interest_name_suffix(protocol, error) \
- int protocol ## _get_interest_name_suffix(hicn_type_t type, const hicn_protocol_t * h, hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_interest_name_suffix(protocol, error) \
+ int protocol##_get_interest_name_suffix ( \
+ hicn_type_t type, const hicn_protocol_t *h, hicn_name_suffix_t *suffix) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_interest_name_suffix(protocol, error) \
- int protocol ## _set_interest_name_suffix(hicn_type_t type, hicn_protocol_t * h, const hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_interest_name_suffix(protocol, error) \
+ int protocol##_set_interest_name_suffix ( \
+ hicn_type_t type, hicn_protocol_t *h, const hicn_name_suffix_t *suffix) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_mark_packet_as_interest(protocol, error) \
- int protocol ## _mark_packet_as_interest(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_mark_packet_as_interest(protocol, error) \
+ int protocol##_mark_packet_as_interest (hicn_type_t type, \
+ hicn_protocol_t *h) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
+
+#define DECLARE_mark_packet_as_data(protocol, error) \
+ int protocol##_mark_packet_as_data (hicn_type_t type, hicn_protocol_t *h) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_mark_packet_as_data(protocol, error) \
- int protocol ## _mark_packet_as_data(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_reset_interest_for_hash(protocol, error) \
+ int protocol##_reset_interest_for_hash (hicn_type_t type, \
+ hicn_protocol_t *h) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_reset_interest_for_hash(protocol, error) \
- int protocol ## _reset_interest_for_hash(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_data_locator(protocol, error) \
+ int protocol##_get_data_locator ( \
+ hicn_type_t type, const hicn_protocol_t *h, ip46_address_t *ip_address) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
+
+#define DECLARE_set_data_locator(protocol, error) \
+ int protocol##_set_data_locator (hicn_type_t type, hicn_protocol_t *h, \
+ const ip46_address_t *ip_address) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_data_locator(protocol, error) \
- int protocol ## _get_data_locator(hicn_type_t type, const hicn_protocol_t * h, ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_data_name(protocol, error) \
+ int protocol##_get_data_name (hicn_type_t type, const hicn_protocol_t *h, \
+ hicn_name_t *name) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_data_locator(protocol, error) \
- int protocol ## _set_data_locator(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * ip_address) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_data_name(protocol, error) \
+ int protocol##_set_data_name (hicn_type_t type, hicn_protocol_t *h, \
+ const hicn_name_t *name) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_data_name(protocol, error) \
- int protocol ## _get_data_name(hicn_type_t type, const hicn_protocol_t * h, hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_data_name_suffix(protocol, error) \
+ int protocol##_get_data_name_suffix ( \
+ hicn_type_t type, const hicn_protocol_t *h, hicn_name_suffix_t *suffix) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_data_name(protocol, error) \
- int protocol ## _set_data_name(hicn_type_t type, hicn_protocol_t * h, const hicn_name_t * name) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_data_name_suffix(protocol, error) \
+ int protocol##_set_data_name_suffix (hicn_type_t type, hicn_protocol_t *h, \
+ const hicn_name_suffix_t *suffix) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_data_name_suffix(protocol, error) \
- int protocol ## _get_data_name_suffix(hicn_type_t type, const hicn_protocol_t * h, hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_data_pathlabel(protocol, error) \
+ int protocol##_get_data_pathlabel ( \
+ hicn_type_t type, const hicn_protocol_t *h, u32 *pathlabel) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_data_name_suffix(protocol, error) \
- int protocol ## _set_data_name_suffix(hicn_type_t type, hicn_protocol_t * h, const hicn_name_suffix_t * suffix) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_data_pathlabel(protocol, error) \
+ int protocol##_set_data_pathlabel (hicn_type_t type, hicn_protocol_t *h, \
+ const u32 pathlabel) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_data_pathlabel(protocol, error) \
- int protocol ## _get_data_pathlabel(hicn_type_t type, const hicn_protocol_t * h, u32 * pathlabel) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_update_data_pathlabel(protocol, error) \
+ int protocol##_update_data_pathlabel (hicn_type_t type, hicn_protocol_t *h, \
+ const hicn_faceid_t face_id) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_data_pathlabel(protocol, error) \
- int protocol ## _set_data_pathlabel(hicn_type_t type, hicn_protocol_t * h, const u32 pathlabel) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_reset_data_for_hash(protocol, error) \
+ int protocol##_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_update_data_pathlabel(protocol, error) \
- int protocol ## _update_data_pathlabel(hicn_type_t type, hicn_protocol_t * h, const hicn_faceid_t face_id) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_lifetime(protocol, error) \
+ int protocol##_get_lifetime (hicn_type_t type, const hicn_protocol_t *h, \
+ hicn_lifetime_t *lifetime) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_reset_data_for_hash(protocol, error) \
- int protocol ## _reset_data_for_hash(hicn_type_t type, hicn_protocol_t * h) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_lifetime(protocol, error) \
+ int protocol##_set_lifetime (hicn_type_t type, hicn_protocol_t *h, \
+ const hicn_lifetime_t lifetime) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_lifetime(protocol, error) \
- int protocol ## _get_lifetime(hicn_type_t type, const hicn_protocol_t * h, hicn_lifetime_t * lifetime) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_update_checksums(protocol, error) \
+ int protocol##_update_checksums (hicn_type_t type, hicn_protocol_t *h, \
+ u16 partial_csum, size_t payload_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_lifetime(protocol, error) \
- int protocol ## _set_lifetime(hicn_type_t type, hicn_protocol_t * h, const hicn_lifetime_t lifetime) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_verify_checksums(protocol, error) \
+ int protocol##_verify_checksums (hicn_type_t type, hicn_protocol_t *h, \
+ u16 partial_csum, size_t payload_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_update_checksums(protocol, error) \
- int protocol ## _update_checksums(hicn_type_t type, hicn_protocol_t * h, u16 partial_csum, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_rewrite_interest(protocol, error) \
+ int protocol##_rewrite_interest (hicn_type_t type, hicn_protocol_t *h, \
+ const ip46_address_t *addr_new, \
+ ip46_address_t *addr_old) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_verify_checksums(protocol, error) \
- int protocol ## _verify_checksums(hicn_type_t type, hicn_protocol_t * h, u16 partial_csum, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_rewrite_data(protocol, error) \
+ int protocol##_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, u8 reset_pl) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_rewrite_interest(protocol, error) \
- int protocol ## _rewrite_interest(hicn_type_t type, hicn_protocol_t * h, const ip46_address_t * addr_new, ip46_address_t * addr_old) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_length(protocol, error) \
+ int protocol##_get_length (hicn_type_t type, const hicn_protocol_t *h, \
+ size_t *length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_rewrite_data(protocol, error) \
- int protocol ## _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, u8 reset_pl) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_current_header_length(protocol, error) \
+ int protocol##_get_current_header_length ( \
+ hicn_type_t type, const hicn_protocol_t *h, size_t *header_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_length(protocol, error) \
- int protocol ## _get_length(hicn_type_t type, const hicn_protocol_t * h, size_t * length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_header_length(protocol, error) \
+ int protocol##_get_header_length ( \
+ hicn_type_t type, const hicn_protocol_t *h, size_t *header_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_current_header_length(protocol, error) \
- int protocol ## _get_current_header_length(hicn_type_t type, const hicn_protocol_t * h, size_t * header_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_payload_length(protocol, error) \
+ int protocol##_get_payload_length ( \
+ hicn_type_t type, const hicn_protocol_t *h, size_t *payload_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_header_length(protocol, error) \
- int protocol ## _get_header_length(hicn_type_t type, const hicn_protocol_t * h, size_t * header_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_payload_length(protocol, error) \
+ int protocol##_set_payload_length (hicn_type_t type, hicn_protocol_t *h, \
+ size_t payload_length) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_payload_length(protocol, error) \
- int protocol ## _get_payload_length(hicn_type_t type, const hicn_protocol_t * h, size_t * payload_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_signature_size(protocol, error) \
+ int protocol##_get_signature_size ( \
+ hicn_type_t type, const hicn_protocol_t *h, size_t *signature_size) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_payload_length(protocol, error) \
- int protocol ## _set_payload_length(hicn_type_t type, hicn_protocol_t * h, size_t payload_length) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_signature_size(protocol, error) \
+ int protocol##_set_signature_size (hicn_type_t type, hicn_protocol_t *h, \
+ size_t signature_size) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_signature_size(protocol, error) \
- int protocol ## _get_signature_size(hicn_type_t type, const hicn_protocol_t * h, size_t * signature_size) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_signature_gap(protocol, error) \
+ int protocol##_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, \
+ uint8_t signature_size) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_signature_size(protocol, error) \
- int protocol ## _set_signature_size(hicn_type_t type, hicn_protocol_t * h, size_t signature_size) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_signature_gap(protocol, error) \
+ int protocol##_get_signature_gap ( \
+ hicn_type_t type, const hicn_protocol_t *h, uint8_t *signature_size) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_signature_timestamp(protocol, error) \
- int protocol ## _set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h, uint64_t signature_timestamp) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_signature_timestamp(protocol, error) \
+ int protocol##_set_signature_timestamp ( \
+ hicn_type_t type, hicn_protocol_t *h, uint64_t signature_timestamp) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_signature_timestamp(protocol, error) \
- int protocol ## _get_signature_timestamp(hicn_type_t type, const hicn_protocol_t * h, uint64_t * signature_timestamp) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_signature_timestamp(protocol, error) \
+ int protocol##_get_signature_timestamp (hicn_type_t type, \
+ const hicn_protocol_t *h, \
+ uint64_t *signature_timestamp) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_validation_algorithm(protocol, error) \
- int protocol ## _set_validation_algorithm(hicn_type_t type, hicn_protocol_t * h, uint8_t validation_algorithm) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_validation_algorithm(protocol, error) \
+ int protocol##_set_validation_algorithm ( \
+ hicn_type_t type, hicn_protocol_t *h, uint8_t validation_algorithm) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_validation_algorithm(protocol, error) \
- int protocol ## _get_validation_algorithm(hicn_type_t type, const hicn_protocol_t * h, uint8_t * validation_algorithm) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_validation_algorithm(protocol, error) \
+ int protocol##_get_validation_algorithm (hicn_type_t type, \
+ const hicn_protocol_t *h, \
+ uint8_t *validation_algorithm) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_set_key_id(protocol, error) \
- int protocol ## _set_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t * key_id) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_set_key_id(protocol, error) \
+ int protocol##_set_key_id (hicn_type_t type, hicn_protocol_t *h, \
+ uint8_t *key_id) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_key_id(protocol, error) \
- int protocol ## _get_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t ** key_id, uint8_t *key_id_size) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_key_id(protocol, error) \
+ int protocol##_get_key_id (hicn_type_t type, hicn_protocol_t *h, \
+ uint8_t **key_id, uint8_t *key_id_size) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
-#define DECLARE_get_signature(protocol, error) \
- int protocol ## _get_signature(hicn_type_t type, hicn_protocol_t * h, uint8_t ** signature) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_signature(protocol, error) \
+ int protocol##_get_signature (hicn_type_t type, hicn_protocol_t *h, \
+ uint8_t **signature) \
+ { \
+ return HICN_LIB_ERROR_##error; \
+ }
#endif /* HICN_OPS_H */
diff --git a/lib/includes/hicn/protocol/ah.h b/lib/includes/hicn/protocol/ah.h
index a59a5051a..575da80d7 100644
--- a/lib/includes/hicn/protocol/ah.h
+++ b/lib/includes/hicn/protocol/ah.h
@@ -35,16 +35,19 @@
typedef struct
{
- u8 nh; // (to match with reserved in IPSEC AH)
- u8 payloadlen; // Len of signature/HMAC in 4-bytes words
+ u8 nh; // (to match with reserved in IPSEC AH)
+ u8 payloadlen; // Len of signature/HMAC in 4-bytes words (maximum size)
union
{
u16 reserved;
struct
{
- u8 validationAlgorithm; // As defined in parc_SignerAlgorithm.h
- u8 unused; // Unused (to match with reserved in IPSEC AH)
+ u8 validationAlgorithm; // As defined in parc_SignerAlgorithm.h
+ u8 signatureGap; // used to match IPSEC specification and to
+ // have the real size of the signature(without
+ // padding). It is the result of Maximum
+ // signature size - real size
};
};
union
@@ -60,12 +63,12 @@ typedef struct
u32 timestamp_as_u32[2];
};
// ICV would follow
- u8 keyId[32]; // Hash of the pub key
+ u8 keyId[32]; // Hash of pub key
/* 44 B + validationPayload */
- u8 validationPayload[0]; // Holds the signature
+ u8 validationPayload[0]; // Holds the signature
} _ah_header_t;
-#define AH_HDRLEN sizeof(_ah_header_t)
+#define AH_HDRLEN sizeof (_ah_header_t)
static_assert (EXPECTED_AH_HDRLEN == AH_HDRLEN,
"Size of AH Struct does not match its expected size.");
diff --git a/lib/src/CMakeLists.txt b/lib/src/CMakeLists.txt
index f410e3d83..2588bde8b 100644
--- a/lib/src/CMakeLists.txt
+++ b/lib/src/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND LIBHICN_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/common.c
${CMAKE_CURRENT_SOURCE_DIR}/compat.c
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 779a47315..932c11d9e 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -392,6 +392,22 @@ hicn_packet_set_signature_size (hicn_format_t format, hicn_header_t *h,
}
int
+hicn_packet_get_signature_gap (hicn_format_t format, const hicn_header_t *h,
+ uint8_t *bytes)
+{
+ hicn_type_t type = hicn_format_to_type (format);
+ return hicn_ops_vft[type.l1]->get_signature_gap (type, &h->protocol, bytes);
+}
+
+int
+hicn_packet_set_signature_gap (hicn_format_t format, hicn_header_t *h,
+ uint8_t bytes)
+{
+ hicn_type_t type = hicn_format_to_type (format);
+ return hicn_ops_vft[type.l1]->set_signature_gap (type, &h->protocol, bytes);
+}
+
+int
hicn_packet_set_signature_timestamp (hicn_format_t format, hicn_header_t *h,
uint64_t signature_timestamp)
{
@@ -1041,8 +1057,8 @@ int
hicn_interest_set_name (hicn_format_t format, hicn_header_t *interest,
const hicn_name_t *name)
{
- int ret_err =
- hicn_packet_reset_ece (format, interest); // interest packet -> ece flag unset
+ int ret_err = hicn_packet_reset_ece (
+ format, interest); // interest packet -> ece flag unset
if (ret_err < 0)
return HICN_LIB_ERROR_UNEXPECTED;
return hicn_packet_set_name (format, interest, name, _INTEREST);
@@ -1134,7 +1150,8 @@ int
hicn_data_set_name (hicn_format_t format, hicn_header_t *data,
const hicn_name_t *name)
{
- int ret_err = hicn_packet_set_ece (format, data); // data packet -> ece flag set
+ int ret_err =
+ hicn_packet_set_ece (format, data); // data packet -> ece flag set
if (ret_err < 0)
return HICN_LIB_ERROR_UNEXPECTED;
return hicn_packet_set_name (format, data, name, _DATA);
diff --git a/lib/src/ops.c b/lib/src/ops.c
index d49138398..ef12e9bf0 100644
--- a/lib/src/ops.c
+++ b/lib/src/ops.c
@@ -23,7 +23,6 @@
#endif
#include <stdlib.h>
#include <hicn/ops.h>
-
#include <hicn/header.h>
extern const hicn_ops_t hicn_ops_ipv4;
@@ -73,6 +72,8 @@ DECLARE_get_validation_algorithm (none, NONE);
DECLARE_set_key_id (none, NONE);
DECLARE_get_key_id (none, NONE);
DECLARE_get_signature (none, NONE);
+DECLARE_get_signature_gap (none, NONE);
+DECLARE_set_signature_gap (none, NONE);
DECLARE_HICN_OPS (none);
/**
@@ -81,11 +82,11 @@ DECLARE_HICN_OPS (none);
*/
const hicn_ops_t *const hicn_ops_vft[] = {
/* 0 */ [IPPROTO_IP] = &hicn_ops_ipv4,
- /* 1 */ [IPPROTO_ICMP] = &hicn_ops_icmp,
- /* 6 */ [IPPROTO_TCP] = &hicn_ops_tcp,
- /* 41 */ [IPPROTO_IPV6] = &hicn_ops_ipv6,
- /* 51 */ [IPPROTO_AH] = &hicn_ops_ah,
- /* 58 */ [IPPROTO_ICMPV6] = &hicn_ops_icmp,
+ /* 1 */[IPPROTO_ICMP] = &hicn_ops_icmp,
+ /* 6 */[IPPROTO_TCP] = &hicn_ops_tcp,
+ /* 41 */[IPPROTO_IPV6] = &hicn_ops_ipv6,
+ /* 51 */[IPPROTO_AH] = &hicn_ops_ah,
+ /* 58 */[IPPROTO_ICMPV6] = &hicn_ops_icmp,
[IPPROTO_NONE] = &hicn_ops_none,
};
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index 03f3af04a..13340eae1 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -18,7 +18,7 @@
* @brief hICN operations for AH header
*/
-#include <string.h> // memcpy
+#include <string.h> // memcpy
#include <hicn/common.h>
#include <hicn/error.h>
#include <hicn/header.h>
@@ -31,8 +31,8 @@ DECLARE_get_interest_name (ah, UNEXPECTED);
DECLARE_set_interest_name (ah, UNEXPECTED);
DECLARE_get_interest_name_suffix (ah, UNEXPECTED);
DECLARE_set_interest_name_suffix (ah, UNEXPECTED);
-DECLARE_mark_packet_as_interest (ah, UNEXPECTED)
-DECLARE_mark_packet_as_data (ah, UNEXPECTED)
+DECLARE_mark_packet_as_interest (ah, UNEXPECTED);
+DECLARE_mark_packet_as_data (ah, UNEXPECTED);
DECLARE_get_data_locator (ah, UNEXPECTED);
DECLARE_set_data_locator (ah, UNEXPECTED);
DECLARE_get_data_name (ah, UNEXPECTED);
@@ -48,21 +48,20 @@ DECLARE_get_payload_length (ah, UNEXPECTED);
DECLARE_set_payload_length (ah, UNEXPECTED);
int
-ah_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
+ah_init_packet_header (hicn_type_t type, hicn_protocol_t *h)
{
/* *INDENT-OFF* */
- h->ah = (_ah_header_t)
- {
- .nh = (u8)0,
- .payloadlen = (u8)0,
- .reserved = (u16)0,
- };
+ h->ah = (_ah_header_t){
+ .nh = (u8) 0,
+ .payloadlen = (u8) 0,
+ .reserved = (u16) 0,
+ };
/* *INDENT-ON* */
return CHILD_OPS (init_packet_header, type, h);
}
int
-ah_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ah_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
size_t signature_size;
int rc =
@@ -74,7 +73,7 @@ ah_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ah_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ah_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
size_t signature_size;
int rc =
@@ -86,7 +85,7 @@ ah_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ah_update_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
+ah_update_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
size_t payload_length)
{
/* Nothing to do as there is no checksum in AH */
@@ -94,7 +93,7 @@ ah_update_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
}
int
-ah_verify_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
+ah_verify_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
size_t payload_length)
{
/* Nothing to do as there is no checksum in AH */
@@ -102,17 +101,16 @@ ah_verify_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
}
int
-ah_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new,
- ip46_address_t * addr_old)
+ah_rewrite_interest (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *addr_new, ip46_address_t *addr_old)
{
/* Nothing to do on signature */
return HICN_LIB_ERROR_NONE;
}
int
-ah_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new, ip46_address_t * addr_old,
+ah_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, u8 reset_pl)
{
/* Nothing to do on signature */
@@ -120,22 +118,22 @@ ah_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
}
int
-ah_get_length (hicn_type_t type, const hicn_protocol_t * h, size_t * length)
+ah_get_length (hicn_type_t type, const hicn_protocol_t *h, size_t *length)
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
}
int
-ah_get_current_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ah_get_current_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = AH_HDRLEN + (h->ah.payloadlen << 2);
return HICN_LIB_ERROR_NONE;
}
int
-ah_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ah_get_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
size_t child_header_length = 0;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -146,22 +144,22 @@ ah_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ah_get_signature (hicn_type_t type, hicn_protocol_t * h, uint8_t ** signature)
+ah_get_signature (hicn_type_t type, hicn_protocol_t *h, uint8_t **signature)
{
*signature = h->ah.validationPayload;
return HICN_LIB_ERROR_NONE;
}
int
-ah_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
- size_t * signature_size)
+ah_get_signature_size (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *signature_size)
{
*signature_size = h->ah.payloadlen << 2;
return HICN_LIB_ERROR_NONE;
}
int
-ah_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
+ah_set_signature_size (hicn_type_t type, hicn_protocol_t *h,
const size_t signature_size)
{
h->ah.payloadlen = (u8) (signature_size >> 2);
@@ -169,7 +167,7 @@ ah_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
}
int
-ah_set_signature_timestamp (hicn_type_t type, hicn_protocol_t * h,
+ah_set_signature_timestamp (hicn_type_t type, hicn_protocol_t *h,
uint64_t signature_timestamp)
{
uint64_t netwok_order_timestamp = htonll (signature_timestamp);
@@ -178,8 +176,8 @@ ah_set_signature_timestamp (hicn_type_t type, hicn_protocol_t * h,
}
int
-ah_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+ah_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp)
{
memcpy (signature_timestamp, h->ah.timestamp_as_u8, sizeof (uint64_t));
*signature_timestamp = ntohll (*signature_timestamp);
@@ -187,7 +185,7 @@ ah_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ah_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
+ah_set_validation_algorithm (hicn_type_t type, hicn_protocol_t *h,
uint8_t validation_algorithm)
{
h->ah.validationAlgorithm = validation_algorithm;
@@ -195,23 +193,37 @@ ah_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
}
int
-ah_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+ah_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm)
{
*validation_algorithm = h->ah.validationAlgorithm;
return HICN_LIB_ERROR_NONE;
}
int
-ah_set_key_id (hicn_type_t type, hicn_protocol_t * h, uint8_t * key_id)
+ah_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, uint8_t gap)
+{
+ h->ah.signatureGap = gap;
+ return HICN_LIB_ERROR_NONE;
+}
+
+int
+ah_get_signature_gap (hicn_type_t type, const hicn_protocol_t *h, uint8_t *gap)
+{
+ *gap = h->ah.signatureGap;
+ return HICN_LIB_ERROR_NONE;
+}
+
+int
+ah_set_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id)
{
memcpy (h->ah.keyId, key_id, sizeof (h->ah.keyId));
return HICN_LIB_ERROR_NONE;
}
int
-ah_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t ** key_id, uint8_t * key_id_size)
+ah_get_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t **key_id,
+ uint8_t *key_id_size)
{
*key_id = h->ah.keyId;
*key_id_size = sizeof (h->ah.keyId);
diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c
index a16353427..5783cf52c 100644
--- a/lib/src/protocol/icmp.c
+++ b/lib/src/protocol/icmp.c
@@ -15,45 +15,47 @@
#include <string.h>
#include <hicn/protocol/icmp.h>
-
#include <hicn/error.h>
#include <hicn/ops.h>
-DECLARE_get_interest_locator (icmp, UNEXPECTED)
-DECLARE_set_interest_locator (icmp, UNEXPECTED)
-DECLARE_get_interest_name (icmp, UNEXPECTED)
-DECLARE_set_interest_name (icmp, UNEXPECTED)
-DECLARE_get_interest_name_suffix (icmp, UNEXPECTED)
-DECLARE_set_interest_name_suffix (icmp, UNEXPECTED)
-DECLARE_mark_packet_as_interest (icmp, UNEXPECTED)
-DECLARE_mark_packet_as_data (icmp, UNEXPECTED)
-DECLARE_get_data_locator (icmp, UNEXPECTED)
-DECLARE_set_data_locator (icmp, UNEXPECTED)
-DECLARE_get_data_name (icmp, UNEXPECTED)
-DECLARE_set_data_name (icmp, UNEXPECTED)
-DECLARE_get_data_name_suffix (icmp, UNEXPECTED)
-DECLARE_set_data_name_suffix (icmp, UNEXPECTED)
-DECLARE_get_data_pathlabel (icmp, UNEXPECTED)
-DECLARE_set_data_pathlabel (icmp, UNEXPECTED)
-DECLARE_update_data_pathlabel (icmp, UNEXPECTED)
-DECLARE_get_lifetime (icmp, UNEXPECTED)
-DECLARE_set_lifetime (icmp, UNEXPECTED)
-DECLARE_get_length (icmp, UNEXPECTED)
-DECLARE_get_payload_length (icmp, UNEXPECTED)
-DECLARE_set_payload_length (icmp, UNEXPECTED)
-DECLARE_get_signature (icmp, UNEXPECTED)
-
-int icmp_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
-{
- h->icmp = (_icmp_header_t)
- {
- .type = 0,.code = 0,.csum = 0,};
-
- return HICN_LIB_ERROR_NONE; // CHILD_OPS(init_packet_header, type, h->icmp);
-}
-
-int
-icmp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
+DECLARE_get_interest_locator (icmp, UNEXPECTED);
+DECLARE_set_interest_locator (icmp, UNEXPECTED);
+DECLARE_get_interest_name (icmp, UNEXPECTED);
+DECLARE_set_interest_name (icmp, UNEXPECTED);
+DECLARE_get_interest_name_suffix (icmp, UNEXPECTED);
+DECLARE_set_interest_name_suffix (icmp, UNEXPECTED);
+DECLARE_mark_packet_as_interest (icmp, UNEXPECTED);
+DECLARE_mark_packet_as_data (icmp, UNEXPECTED);
+DECLARE_get_data_locator (icmp, UNEXPECTED);
+DECLARE_set_data_locator (icmp, UNEXPECTED);
+DECLARE_get_data_name (icmp, UNEXPECTED);
+DECLARE_set_data_name (icmp, UNEXPECTED);
+DECLARE_get_data_name_suffix (icmp, UNEXPECTED);
+DECLARE_set_data_name_suffix (icmp, UNEXPECTED);
+DECLARE_get_data_pathlabel (icmp, UNEXPECTED);
+DECLARE_set_data_pathlabel (icmp, UNEXPECTED);
+DECLARE_update_data_pathlabel (icmp, UNEXPECTED);
+DECLARE_get_lifetime (icmp, UNEXPECTED);
+DECLARE_set_lifetime (icmp, UNEXPECTED);
+DECLARE_get_length (icmp, UNEXPECTED);
+DECLARE_get_payload_length (icmp, UNEXPECTED);
+DECLARE_set_payload_length (icmp, UNEXPECTED);
+DECLARE_get_signature (icmp, UNEXPECTED);
+
+int
+icmp_init_packet_header (hicn_type_t type, hicn_protocol_t *h)
+{
+ h->icmp = (_icmp_header_t){
+ .type = 0,
+ .code = 0,
+ .csum = 0,
+ };
+
+ return HICN_LIB_ERROR_NONE; // CHILD_OPS(init_packet_header, type, h->icmp);
+}
+
+int
+icmp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
h->icmp.csum = 0;
@@ -61,7 +63,7 @@ icmp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-icmp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
+icmp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
h->icmp.csum = 0;
@@ -69,93 +71,94 @@ icmp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-icmp_update_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+icmp_update_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
-// h->icmp.csum = 0;
-// h->icmp.csum = csum(h->bytes, TCP_HDRLEN + payload_length, ~partial_csum);
-//
-// return CHILD_OPS(update_checksums, type, h->icmp, 0, payload_length);
+ // h->icmp.csum = 0;
+ // h->icmp.csum = csum(h->bytes, TCP_HDRLEN + payload_length,
+ // ~partial_csum);
+ //
+ // return CHILD_OPS(update_checksums, type, h->icmp, 0, payload_length);
}
int
-icmp_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+icmp_verify_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
-// if (csum(h->bytes, TCP_HDRLEN + payload_length, ~partial_csum) != 0)
-// return HICN_LIB_ERROR_CORRUPTED_PACKET;
-// return CHILD_OPS(verify_checksums, type, h->icmp, 0, payload_length);
+ // if (csum(h->bytes, TCP_HDRLEN + payload_length, ~partial_csum) != 0)
+ // return HICN_LIB_ERROR_CORRUPTED_PACKET;
+ // return CHILD_OPS(verify_checksums, type, h->icmp, 0, payload_length);
}
int
-icmp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new,
- ip46_address_t * addr_old)
+icmp_rewrite_interest (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *addr_new,
+ ip46_address_t *addr_old)
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
-// u16 *icmp_checksum = &(h->icmp.csum);
-//
-// /*
-// * Padding fields are set to zero so we can apply checksum on the
-// * whole struct by interpreting it as IPv6 in all cases
-// *
-// * v4 code would be:
-// * csum = ip_csum_sub_even (*icmp_checksum, h->ipv4.saddr.as_u32);
-// * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
-// */
-// u16 csum = ip_csum_sub_even (*icmp_checksum, h->ipv6.saddr.as_u64[0]);
-// csum = ip_csum_sub_even (csum, h->ipv6.saddr.as_u64[1]);
-// csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[0]);
-// csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[1]);
-//
-// *icmp_checksum = ip_csum_fold (csum);
-//
-// return HICN_LIB_ERROR_NONE;
-}
-
-int
-icmp_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new, ip46_address_t * addr_old,
+ // u16 *icmp_checksum = &(h->icmp.csum);
+ //
+ // /*
+ // * Padding fields are set to zero so we can apply checksum on the
+ // * whole struct by interpreting it as IPv6 in all cases
+ // *
+ // * v4 code would be:
+ // * csum = ip_csum_sub_even (*icmp_checksum, h->ipv4.saddr.as_u32);
+ // * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
+ // */
+ // u16 csum = ip_csum_sub_even (*icmp_checksum, h->ipv6.saddr.as_u64[0]);
+ // csum = ip_csum_sub_even (csum, h->ipv6.saddr.as_u64[1]);
+ // csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[0]);
+ // csum = ip_csum_add_even (csum, h->ipv6.saddr.as_u64[1]);
+ //
+ // *icmp_checksum = ip_csum_fold (csum);
+ //
+ // return HICN_LIB_ERROR_NONE;
+}
+
+int
+icmp_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, u8 reset_pl)
{
return HICN_LIB_ERROR_NOT_IMPLEMENTED;
-// u16 *icmp_checksum = &(h->icmp.csum);
-//
-// /*
-// * Padding fields are set to zero so we can apply checksum on the
-// * whole struct by interpreting it as IPv6 in all cases
-// *
-// * v4 code would be:
-// * csum = ip_csum_sub_even (*icmp_checksum, h->ipv4.saddr.as_u32);
-// * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
-// */
-// u16 csum = ip_csum_sub_even (*icmp_checksum, addr_old->ip6.as_u64[0]);
-// csum = ip_csum_sub_even (*icmp_checksum, addr_old->ip6.as_u64[1]);
-// csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[0]);
-// csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[1]);
-//
-// csum = ip_csum_sub_even (csum, h->icmp.pathlabel);
-// icmp_update_data_pathlabel(type, h, face_id);
-// csum = ip_csum_add_even (csum, h->icmp.pathlabel);
-//
-// *icmp_checksum = ip_csum_fold (csum);
-//
-// return HICN_LIB_ERROR_NONE;
-}
-
-int
-icmp_get_current_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ // u16 *icmp_checksum = &(h->icmp.csum);
+ //
+ // /*
+ // * Padding fields are set to zero so we can apply checksum on the
+ // * whole struct by interpreting it as IPv6 in all cases
+ // *
+ // * v4 code would be:
+ // * csum = ip_csum_sub_even (*icmp_checksum, h->ipv4.saddr.as_u32);
+ // * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
+ // */
+ // u16 csum = ip_csum_sub_even (*icmp_checksum, addr_old->ip6.as_u64[0]);
+ // csum = ip_csum_sub_even (*icmp_checksum, addr_old->ip6.as_u64[1]);
+ // csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[0]);
+ // csum = ip_csum_add_even (csum, addr_new->ip6.as_u64[1]);
+ //
+ // csum = ip_csum_sub_even (csum, h->icmp.pathlabel);
+ // icmp_update_data_pathlabel(type, h, face_id);
+ // csum = ip_csum_add_even (csum, h->icmp.pathlabel);
+ //
+ // *icmp_checksum = ip_csum_fold (csum);
+ //
+ // return HICN_LIB_ERROR_NONE;
+}
+
+int
+icmp_get_current_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = ICMP_HDRLEN;
return HICN_LIB_ERROR_NONE;
}
int
-icmp_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+icmp_get_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
size_t child_header_length = 0;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -167,57 +170,69 @@ icmp_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-icmp_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
- size_t * signature_size)
+icmp_get_signature_size (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *signature_size)
{
return CHILD_OPS (get_signature_size, type, h, signature_size);
}
int
-icmp_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
+icmp_set_signature_size (hicn_type_t type, hicn_protocol_t *h,
size_t signature_size)
{
return CHILD_OPS (set_signature_size, type, h, signature_size);
}
int
-icmp_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
- uint64_t signature_timestamp)
+icmp_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, uint8_t gap)
+{
+ return CHILD_OPS (set_signature_gap, type, h, gap);
+}
+
+int
+icmp_get_signature_gap (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *gap)
+{
+ return CHILD_OPS (get_signature_gap, type, h, gap);
+}
+
+int
+icmp_set_signature_timestamp (hicn_type_t type, hicn_protocol_t *h,
+ uint64_t signature_timestamp)
{
return CHILD_OPS (set_signature_timestamp, type, h, signature_timestamp);
}
int
-icmp_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+icmp_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp)
{
return CHILD_OPS (get_signature_timestamp, type, h, signature_timestamp);
}
int
-icmp_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
- uint8_t validation_algorithm)
+icmp_set_validation_algorithm (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t validation_algorithm)
{
return CHILD_OPS (set_validation_algorithm, type, h, validation_algorithm);
}
int
-icmp_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+icmp_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm)
{
return CHILD_OPS (get_validation_algorithm, type, h, validation_algorithm);
}
int
-icmp_set_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t *key_id)
+icmp_set_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id)
{
return CHILD_OPS (set_key_id, type, h, key_id);
}
int
-icmp_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size)
+icmp_get_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t **key_id,
+ uint8_t *key_id_size)
{
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c
index 73ce12ee0..cf50f9996 100644
--- a/lib/src/protocol/ipv4.c
+++ b/lib/src/protocol/ipv4.c
@@ -33,12 +33,12 @@
#include <hicn/header.h>
#include <hicn/protocol/ipv4.h>
-
-int ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * payload_length);
+typedef unsigned short u_short;
+int ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *payload_length);
int
-ipv4_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
+ipv4_init_packet_header (hicn_type_t type, hicn_protocol_t *h)
{
size_t total_header_length;
int rc =
@@ -46,37 +46,41 @@ ipv4_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
if (rc < 0)
return rc;
- h->ipv4 = (_ipv4_header_t)
- {
- .version_ihl =
- (IPV4_DEFAULT_VERSION << 4) | (0x0f & IPV4_DEFAULT_IHL),.tos =
- IPV4_DEFAULT_TOS,.len = htons ((u16) total_header_length),.id =
- htons (IPV4_DEFAULT_ID),.frag_off =
- htons (IPV4_DEFAULT_FRAG_OFF),.ttl = HICN_DEFAULT_TTL,.protocol =
- type.l2,.csum = 0,.saddr.as_u32 = 0,.daddr.as_u32 = 0,};
+ h->ipv4 = (_ipv4_header_t){
+ .version_ihl = (IPV4_DEFAULT_VERSION << 4) | (0x0f & IPV4_DEFAULT_IHL),
+ .tos = IPV4_DEFAULT_TOS,
+ .len = htons ((u16) total_header_length),
+ .id = htons (IPV4_DEFAULT_ID),
+ .frag_off = htons (IPV4_DEFAULT_FRAG_OFF),
+ .ttl = HICN_DEFAULT_TTL,
+ .protocol = type.l2,
+ .csum = 0,
+ .saddr.as_u32 = 0,
+ .daddr.as_u32 = 0,
+ };
return CHILD_OPS (init_packet_header, type, h);
}
int
-ipv4_get_interest_locator (hicn_type_t type, const hicn_protocol_t * h,
- ip46_address_t * ip_address)
+ipv4_get_interest_locator (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address)
{
ip_address->ip4 = h->ipv4.saddr;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_set_interest_locator (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * ip_address)
+ipv4_set_interest_locator (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address)
{
h->ipv4.saddr = ip_address->ip4;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_interest_name (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_t * name)
+ipv4_get_interest_name (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name)
{
name->ip4.prefix_as_ip4 = h->ipv4.daddr;
#ifndef HICN_VPP_PLUGIN
@@ -87,41 +91,41 @@ ipv4_get_interest_name (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv4_set_interest_name (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_t * name)
+ipv4_set_interest_name (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name)
{
h->ipv4.daddr = name->ip4.prefix_as_ip4;
return CHILD_OPS (set_interest_name_suffix, type, h, &(name->ip4.suffix));
}
int
-ipv4_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+ipv4_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
return CHILD_OPS (get_interest_name_suffix, type, h, suffix);
}
int
-ipv4_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+ipv4_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
return CHILD_OPS (set_interest_name_suffix, type, h, suffix);
}
int
-ipv4_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+ipv4_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t *h)
{
return CHILD_OPS (mark_packet_as_interest, type, h);
}
int
-ipv4_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+ipv4_mark_packet_as_data (hicn_type_t type, hicn_protocol_t *h)
{
return CHILD_OPS (mark_packet_as_data, type, h);
}
int
-ipv4_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ipv4_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
/* Sets everything to 0 up to IP destination address */
memset (&(h->ipv4), 0, 16);
@@ -130,24 +134,24 @@ ipv4_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ipv4_get_data_locator (hicn_type_t type, const hicn_protocol_t * h,
- ip46_address_t * ip_address)
+ipv4_get_data_locator (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address)
{
ip_address->ip4 = h->ipv4.daddr;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_set_data_locator (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * ip_address)
+ipv4_set_data_locator (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address)
{
h->ipv4.daddr = ip_address->ip4;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_data_name (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_t * name)
+ipv4_get_data_name (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name)
{
name->ip4.prefix_as_ip4 = h->ipv4.saddr;
#ifndef HICN_VPP_PLUGIN
@@ -158,50 +162,50 @@ ipv4_get_data_name (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv4_set_data_name (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_t * name)
+ipv4_set_data_name (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name)
{
h->ipv4.saddr = name->ip4.prefix_as_ip4;
return CHILD_OPS (set_data_name_suffix, type, h, &(name->ip4.suffix));
}
int
-ipv4_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+ipv4_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
return CHILD_OPS (get_data_name_suffix, type, h, suffix);
}
int
-ipv4_set_data_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+ipv4_set_data_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
return CHILD_OPS (set_data_name_suffix, type, h, suffix);
}
int
-ipv4_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t * h,
- u32 * pathlabel)
+ipv4_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t *h,
+ u32 *pathlabel)
{
return CHILD_OPS (get_data_pathlabel, type, h, pathlabel);
}
int
-ipv4_set_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+ipv4_set_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const u32 pathlabel)
{
return CHILD_OPS (set_data_pathlabel, type, h, pathlabel);
}
int
-ipv4_update_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+ipv4_update_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const hicn_faceid_t face_id)
{
return CHILD_OPS (update_data_pathlabel, type, h, face_id);
}
int
-ipv4_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ipv4_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
/* Sets everything to 0 up to source address */
memset (&h->ipv4, 0, 12);
@@ -212,22 +216,22 @@ ipv4_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ipv4_get_lifetime (hicn_type_t type, const hicn_protocol_t * h,
- hicn_lifetime_t * lifetime)
+ipv4_get_lifetime (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_lifetime_t *lifetime)
{
return CHILD_OPS (get_lifetime, type, h, lifetime);
}
int
-ipv4_set_lifetime (hicn_type_t type, hicn_protocol_t * h,
+ipv4_set_lifetime (hicn_type_t type, hicn_protocol_t *h,
const hicn_lifetime_t lifetime)
{
return CHILD_OPS (set_lifetime, type, h, lifetime);
}
int
-ipv4_update_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+ipv4_update_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
/*
* Checksum field is not accounted for in lower layers, so we can compute
@@ -254,7 +258,8 @@ ipv4_update_checksums (hicn_type_t type, hicn_protocol_t * h,
ipv4_pseudo_header_t psh;
psh.ip_src = h->ipv4.saddr;
psh.ip_dst = h->ipv4.daddr;
- /* Size is u32 and not u16, we cannot copy and need to care about endianness */
+ /* Size is u32 and not u16, we cannot copy and need to care about endianness
+ */
psh.size = htons (ntohs (h->ipv4.len) - (u16) IPV4_HDRLEN);
psh.zero = 0;
psh.protocol = (u8) h->ipv4.protocol;
@@ -270,8 +275,8 @@ ipv4_update_checksums (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv4_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+ipv4_verify_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
/*
* Checksum field is not accounted for in lower layers, so we can compute
@@ -292,7 +297,8 @@ ipv4_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
ipv4_pseudo_header_t psh;
psh.ip_src = h->ipv4.saddr;
psh.ip_dst = h->ipv4.daddr;
- /* Size is u32 and not u16, we cannot copy and need to care about endianness */
+ /* Size is u32 and not u16, we cannot copy and need to care about endianness
+ */
psh.size = htons (ntohs (h->ipv4.len) - (u16) IPV4_HDRLEN);
psh.zero = 0;
psh.protocol = (u8) h->ipv4.protocol;
@@ -304,9 +310,9 @@ ipv4_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv4_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new,
- ip46_address_t * addr_old)
+ipv4_rewrite_interest (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *addr_new,
+ ip46_address_t *addr_old)
{
// ASSERT(addr_old == NULL);
addr_old->ip4 = h->ipv4.saddr;
@@ -322,8 +328,8 @@ ipv4_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv4_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new, ip46_address_t * addr_old,
+ipv4_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, u8 reset_pl)
{
// ASSERT(addr_old == NULL);
@@ -336,36 +342,37 @@ ipv4_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
h->ipv4.csum = 0;
h->ipv4.csum = csum (&h->ipv4, IPV4_HDRLEN, 0);
- return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id, reset_pl);
+ return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id,
+ reset_pl);
}
int
-ipv4_get_current_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv4_get_current_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = IPV4_HDRLEN;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv4_get_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = h->ipv4.len;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_current_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv4_get_current_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = IPV4_HDRLEN;
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv4_get_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
size_t child_header_length = 0;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -376,8 +383,8 @@ ipv4_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * payload_length)
+ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *payload_length)
{
size_t child_header_length;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -388,76 +395,88 @@ ipv4_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv4_set_payload_length (hicn_type_t type, hicn_protocol_t * h,
+ipv4_set_payload_length (hicn_type_t type, hicn_protocol_t *h,
size_t payload_length)
{
size_t child_header_length;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
if (rc < 0)
return rc;
- h->ipv4.len = htons ((u_short) (payload_length + IPV4_HDRLEN + child_header_length));
+ h->ipv4.len =
+ htons ((u_short) (payload_length + IPV4_HDRLEN + child_header_length));
return HICN_LIB_ERROR_NONE;
}
int
-ipv4_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
- size_t * signature_size)
+ipv4_get_signature_size (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *signature_size)
{
return CHILD_OPS (get_signature_size, type, h, signature_size);
}
int
-ipv4_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
+ipv4_set_signature_size (hicn_type_t type, hicn_protocol_t *h,
size_t signature_size)
{
return CHILD_OPS (set_signature_size, type, h, signature_size);
}
int
-ipv4_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
- uint64_t signature_timestamp)
+ipv4_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, uint8_t gap)
+{
+ return CHILD_OPS (set_signature_gap, type, h, gap);
+}
+
+int
+ipv4_get_signature_gap (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *gap)
+{
+ return CHILD_OPS (get_signature_gap, type, h, gap);
+}
+
+int
+ipv4_set_signature_timestamp (hicn_type_t type, hicn_protocol_t *h,
+ uint64_t signature_timestamp)
{
return CHILD_OPS (set_signature_timestamp, type, h, signature_timestamp);
}
int
-ipv4_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+ipv4_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp)
{
return CHILD_OPS (get_signature_timestamp, type, h, signature_timestamp);
}
int
-ipv4_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
- uint8_t validation_algorithm)
+ipv4_set_validation_algorithm (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t validation_algorithm)
{
return CHILD_OPS (set_validation_algorithm, type, h, validation_algorithm);
}
int
-ipv4_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+ipv4_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm)
{
return CHILD_OPS (get_validation_algorithm, type, h, validation_algorithm);
}
int
-ipv4_set_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t *key_id)
+ipv4_set_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id)
{
return CHILD_OPS (set_key_id, type, h, key_id);
}
int
-ipv4_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size)
+ipv4_get_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t **key_id,
+ uint8_t *key_id_size)
{
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
int
-ipv4_get_signature (hicn_type_t type, hicn_protocol_t * h,
- uint8_t ** signature)
+ipv4_get_signature (hicn_type_t type, hicn_protocol_t *h, uint8_t **signature)
{
return CHILD_OPS (get_signature, type, h, signature);
}
diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c
index bf8123497..7ac55b2be 100644
--- a/lib/src/protocol/ipv6.c
+++ b/lib/src/protocol/ipv6.c
@@ -15,17 +15,16 @@
#include <stdlib.h>
#include <string.h>
-
#include <hicn/common.h>
#include <hicn/error.h>
#include <hicn/ops.h>
-int
-ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * payload_length);
+typedef unsigned short u_short;
+int ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *payload_length);
int
-ipv6_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
+ipv6_init_packet_header (hicn_type_t type, hicn_protocol_t *h)
{
size_t total_header_length;
int rc = CHILD_OPS (get_header_length, type, h, &total_header_length);
@@ -33,13 +32,12 @@ ipv6_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
return rc;
/* *INDENT-OFF* */
- h->ipv6 = (_ipv6_header_t)
- {
- .saddr = {{ 0 }}
- ,.daddr = {{ 0 }}
- ,.version_class_flow = htonl ((IPV6_DEFAULT_VERSION << 28) |
- (IPV6_DEFAULT_TRAFFIC_CLASS << 20) |
- (IPV6_DEFAULT_FLOW_LABEL & 0xfffff)),
+ h->ipv6 = (_ipv6_header_t){
+ .saddr = { { 0 } },
+ .daddr = { { 0 } },
+ .version_class_flow = htonl ((IPV6_DEFAULT_VERSION << 28) |
+ (IPV6_DEFAULT_TRAFFIC_CLASS << 20) |
+ (IPV6_DEFAULT_FLOW_LABEL & 0xfffff)),
.len = htons ((u16) total_header_length),
.nxt = type.l2,
.hlim = HICN_DEFAULT_TTL,
@@ -49,24 +47,24 @@ ipv6_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
}
int
-ipv6_get_interest_locator (hicn_type_t type, const hicn_protocol_t * h,
- ip46_address_t * ip_address)
+ipv6_get_interest_locator (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address)
{
ip_address->ip6 = h->ipv6.saddr;
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_set_interest_locator (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * ip_address)
+ipv6_set_interest_locator (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address)
{
h->ipv6.saddr = ip_address->ip6;
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_get_interest_name (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_t * name)
+ipv6_get_interest_name (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name)
{
name->ip6.prefix_as_ip6 = h->ipv6.daddr;
#ifndef HICN_VPP_PLUGIN
@@ -77,41 +75,41 @@ ipv6_get_interest_name (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv6_set_interest_name (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_t * name)
+ipv6_set_interest_name (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name)
{
h->ipv6.daddr = name->ip6.prefix_as_ip6;
return CHILD_OPS (set_interest_name_suffix, type, h, &(name->ip6.suffix));
}
int
-ipv6_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+ipv6_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
return CHILD_OPS (get_interest_name_suffix, type, h, suffix);
}
int
-ipv6_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+ipv6_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
return CHILD_OPS (set_interest_name_suffix, type, h, suffix);
}
int
-ipv6_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+ipv6_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t *h)
{
return CHILD_OPS (mark_packet_as_interest, type, h);
}
int
-ipv6_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+ipv6_mark_packet_as_data (hicn_type_t type, hicn_protocol_t *h)
{
return CHILD_OPS (mark_packet_as_data, type, h);
}
int
-ipv6_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ipv6_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
/* Sets everything to 0 up to IP destination address */
memset (&(h->ipv6), 0, 24);
@@ -120,24 +118,24 @@ ipv6_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ipv6_get_data_locator (hicn_type_t type, const hicn_protocol_t * h,
- ip46_address_t * ip_address)
+ipv6_get_data_locator (hicn_type_t type, const hicn_protocol_t *h,
+ ip46_address_t *ip_address)
{
ip_address->ip6 = h->ipv6.daddr;
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_set_data_locator (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * ip_address)
+ipv6_set_data_locator (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *ip_address)
{
h->ipv6.daddr = ip_address->ip6;
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_get_data_name (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_t * name)
+ipv6_get_data_name (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_t *name)
{
name->ip6.prefix_as_ip6 = h->ipv6.saddr;
#ifndef HICN_VPP_PLUGIN
@@ -148,50 +146,50 @@ ipv6_get_data_name (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv6_set_data_name (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_t * name)
+ipv6_set_data_name (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_t *name)
{
h->ipv6.saddr = name->ip6.prefix_as_ip6;
return CHILD_OPS (set_data_name_suffix, type, h, &(name->ip6.suffix));
}
int
-ipv6_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+ipv6_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
return CHILD_OPS (get_data_name_suffix, type, h, suffix);
}
int
-ipv6_set_data_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+ipv6_set_data_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
return CHILD_OPS (set_data_name_suffix, type, h, suffix);
}
int
-ipv6_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t * h,
- u32 * pathlabel)
+ipv6_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t *h,
+ u32 *pathlabel)
{
return CHILD_OPS (get_data_pathlabel, type, h, pathlabel);
}
int
-ipv6_set_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+ipv6_set_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const u32 pathlabel)
{
return CHILD_OPS (set_data_pathlabel, type, h, pathlabel);
}
int
-ipv6_update_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+ipv6_update_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const hicn_faceid_t face_id)
{
return CHILD_OPS (update_data_pathlabel, type, h, face_id);
}
int
-ipv6_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
+ipv6_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
/* IP: Set everithing to 0 up to destination address */
memset (&h->ipv6, 0, 8);
@@ -202,22 +200,22 @@ ipv6_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
}
int
-ipv6_get_lifetime (hicn_type_t type, const hicn_protocol_t * h,
- hicn_lifetime_t * lifetime)
+ipv6_get_lifetime (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_lifetime_t *lifetime)
{
return CHILD_OPS (get_lifetime, type, h, lifetime);
}
int
-ipv6_set_lifetime (hicn_type_t type, hicn_protocol_t * h,
+ipv6_set_lifetime (hicn_type_t type, hicn_protocol_t *h,
const hicn_lifetime_t lifetime)
{
return CHILD_OPS (set_lifetime, type, h, lifetime);
}
int
-ipv6_update_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+ipv6_update_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
/* Retrieve payload length if not specified */
if (payload_length == ~0)
@@ -231,7 +229,8 @@ ipv6_update_checksums (hicn_type_t type, hicn_protocol_t * h,
ipv6_pseudo_header_t psh;
psh.ip_src = h->ipv6.saddr;
psh.ip_dst = h->ipv6.daddr;
- /* Size is u32 and not u16, we cannot copy and need to care about endianness */
+ /* Size is u32 and not u16, we cannot copy and need to care about endianness
+ */
psh.size = htonl (ntohs (h->ipv6.len));
psh.zeros = 0;
psh.zero = 0;
@@ -248,8 +247,8 @@ ipv6_update_checksums (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv6_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
- u16 partial_csum, size_t payload_length)
+ipv6_verify_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
+ size_t payload_length)
{
/* Retrieve payload length if not specified */
if (payload_length == ~0)
@@ -263,7 +262,8 @@ ipv6_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
ipv6_pseudo_header_t pseudo;
pseudo.ip_src = h->ipv6.saddr;
pseudo.ip_dst = h->ipv6.daddr;
- /* Size is u32 and not u16, we cannot copy and need to care about endianness */
+ /* Size is u32 and not u16, we cannot copy and need to care about endianness
+ */
pseudo.size = htonl (ntohs (h->ipv6.len));
pseudo.zeros = 0;
pseudo.zero = 0;
@@ -280,9 +280,9 @@ ipv6_verify_checksums (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv6_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new,
- ip46_address_t * addr_old)
+ipv6_rewrite_interest (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *addr_new,
+ ip46_address_t *addr_old)
{
// ASSERT(addr_old == NULL);
addr_old->ip6 = h->ipv6.saddr;
@@ -292,36 +292,37 @@ ipv6_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
}
int
-ipv6_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new, ip46_address_t * addr_old,
+ipv6_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, u8 reset_pl)
{
// ASSERT(addr_old == NULL);
addr_old->ip6 = h->ipv6.daddr;
h->ipv6.daddr = addr_new->ip6;
- return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id, reset_pl);
+ return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id,
+ reset_pl);
}
int
-ipv6_get_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv6_get_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = IPV6_HDRLEN + ntohs (h->ipv6.len);
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_get_current_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv6_get_current_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = IPV6_HDRLEN;
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+ipv6_get_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
size_t child_header_length = 0;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -332,8 +333,8 @@ ipv6_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * payload_length)
+ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *payload_length)
{
size_t child_header_length;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -344,76 +345,87 @@ ipv6_get_payload_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-ipv6_set_payload_length (hicn_type_t type, hicn_protocol_t * h,
+ipv6_set_payload_length (hicn_type_t type, hicn_protocol_t *h,
size_t payload_length)
{
size_t child_header_length;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
if (rc < 0)
return rc;
- h->ipv6.len = htons ( (u_short) (payload_length + child_header_length));
+ h->ipv6.len = htons ((u_short) (payload_length + child_header_length));
return HICN_LIB_ERROR_NONE;
}
int
-ipv6_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
- size_t * signature_size)
+ipv6_get_signature_size (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *signature_size)
{
return CHILD_OPS (get_signature_size, type, h, signature_size);
}
int
-ipv6_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
+ipv6_set_signature_size (hicn_type_t type, hicn_protocol_t *h,
size_t signature_size)
{
return CHILD_OPS (set_signature_size, type, h, signature_size);
}
int
-ipv6_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
- uint64_t signature_timestamp)
+ipv6_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, uint8_t gap)
+{
+ return CHILD_OPS (set_signature_gap, type, h, gap);
+}
+
+int
+ipv6_get_signature_gap (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *gap)
+{
+ return CHILD_OPS (get_signature_gap, type, h, gap);
+}
+
+int
+ipv6_set_signature_timestamp (hicn_type_t type, hicn_protocol_t *h,
+ uint64_t signature_timestamp)
{
return CHILD_OPS (set_signature_timestamp, type, h, signature_timestamp);
}
int
-ipv6_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+ipv6_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp)
{
return CHILD_OPS (get_signature_timestamp, type, h, signature_timestamp);
}
int
-ipv6_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
- uint8_t validation_algorithm)
+ipv6_set_validation_algorithm (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t validation_algorithm)
{
return CHILD_OPS (set_validation_algorithm, type, h, validation_algorithm);
}
int
-ipv6_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+ipv6_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm)
{
return CHILD_OPS (get_validation_algorithm, type, h, validation_algorithm);
}
int
-ipv6_set_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t *key_id)
+ipv6_set_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id)
{
return CHILD_OPS (set_key_id, type, h, key_id);
}
int
-ipv6_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size)
+ipv6_get_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t **key_id,
+ uint8_t *key_id_size)
{
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
int
-ipv6_get_signature (hicn_type_t type, hicn_protocol_t * h,
- uint8_t ** signature)
+ipv6_get_signature (hicn_type_t type, hicn_protocol_t *h, uint8_t **signature)
{
return CHILD_OPS (get_signature, type, h, signature);
}
diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c
index 95f93c6af..cfeac1907 100644
--- a/lib/src/protocol/tcp.c
+++ b/lib/src/protocol/tcp.c
@@ -15,23 +15,22 @@
#include <string.h>
#include <hicn/protocol/tcp.h>
-
#include <hicn/error.h>
#include <hicn/ops.h>
-#define TCP_DEFAULT_SRC_PORT 0x8000
-#define TCP_DEFAULT_DST_PORT 0x0080
-#define TCP_DEFAULT_WINDOW_SIZE 0 // In [2, 65535]
-#define TCP_DEFAULT_HLEN 20
-#define TCP_DEFAULT_DATA_OFFSET_RES (TCP_DEFAULT_HLEN >> 2) << 4
-#define TCP_DEFAULT_CWR 0
-#define TCP_DEFAULT_ECE 0
-#define TCP_DEFAULT_URG 0
-#define TCP_DEFAULT_ACK 0
-#define TCP_DEFAULT_PSH 0
-#define TCP_DEFAULT_RST 0
-#define TCP_DEFAULT_SYN 1
-#define TCP_DEFAULT_FIN 0
+#define TCP_DEFAULT_SRC_PORT 0x8000
+#define TCP_DEFAULT_DST_PORT 0x0080
+#define TCP_DEFAULT_WINDOW_SIZE 0 // In [2, 65535]
+#define TCP_DEFAULT_HLEN 20
+#define TCP_DEFAULT_DATA_OFFSET_RES (TCP_DEFAULT_HLEN >> 2) << 4
+#define TCP_DEFAULT_CWR 0
+#define TCP_DEFAULT_ECE 0
+#define TCP_DEFAULT_URG 0
+#define TCP_DEFAULT_ACK 0
+#define TCP_DEFAULT_PSH 0
+#define TCP_DEFAULT_RST 0
+#define TCP_DEFAULT_SYN 1
+#define TCP_DEFAULT_FIN 0
DECLARE_get_interest_locator (tcp, UNEXPECTED);
DECLARE_set_interest_locator (tcp, UNEXPECTED);
@@ -46,7 +45,7 @@ DECLARE_get_payload_length (tcp, UNEXPECTED);
DECLARE_set_payload_length (tcp, UNEXPECTED);
always_inline int
-check_tcp_checksum(u16 csum)
+check_tcp_checksum (u16 csum)
{
/* As per RFC1624
* In one's complement, there are two representations of zero: the all
@@ -68,18 +67,18 @@ check_tcp_checksum(u16 csum)
}
int
-tcp_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
+tcp_init_packet_header (hicn_type_t type, hicn_protocol_t *h)
{
- h->tcp = (_tcp_header_t) {
+ h->tcp = (_tcp_header_t){
.sport = htons (TCP_DEFAULT_SRC_PORT),
.dport = htons (TCP_DEFAULT_DST_PORT),
.seq = 0,
.seq_ack = 0,
.data_offset_and_reserved = TCP_DEFAULT_DATA_OFFSET_RES,
- .flags =
- TCP_DEFAULT_CWR << 7 | TCP_DEFAULT_ECE << 6 | TCP_DEFAULT_URG << 5 |
- TCP_DEFAULT_ACK << 4 | TCP_DEFAULT_PSH << 3 | TCP_DEFAULT_RST << 2 |
- TCP_DEFAULT_SYN << 1 | TCP_DEFAULT_FIN << 0,
+ .flags = TCP_DEFAULT_CWR << 7 | TCP_DEFAULT_ECE << 6 |
+ TCP_DEFAULT_URG << 5 | TCP_DEFAULT_ACK << 4 |
+ TCP_DEFAULT_PSH << 3 | TCP_DEFAULT_RST << 2 |
+ TCP_DEFAULT_SYN << 1 | TCP_DEFAULT_FIN << 0,
.window = htons (TCP_DEFAULT_WINDOW_SIZE),
.csum = 0xffff,
.urg_ptr = 65000,
@@ -93,16 +92,16 @@ tcp_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
}
int
-tcp_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+tcp_get_interest_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
*suffix = ntohl (h->tcp.name_suffix);
return HICN_LIB_ERROR_NONE;
}
int
-tcp_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+tcp_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
h->tcp.name_suffix = htonl (*suffix);
@@ -110,21 +109,21 @@ tcp_set_interest_name_suffix (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t * h)
+tcp_mark_packet_as_interest (hicn_type_t type, hicn_protocol_t *h)
{
h->tcp.flags &= ~HICN_TCP_FLAG_ECE;
return HICN_LIB_ERROR_NONE;
}
int
-tcp_mark_packet_as_data (hicn_type_t type, hicn_protocol_t * h)
+tcp_mark_packet_as_data (hicn_type_t type, hicn_protocol_t *h)
{
h->tcp.flags |= HICN_TCP_FLAG_ECE;
return HICN_LIB_ERROR_NONE;
}
int
-tcp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
+tcp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
memset (&(h->tcp), 0, 4);
memset (&(h->tcp.seq_ack), 0, 12);
@@ -132,33 +131,32 @@ tcp_reset_interest_for_hash (hicn_type_t type, hicn_protocol_t * h)
return CHILD_OPS (reset_interest_for_hash, type, h);
}
-
int
-tcp_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t * h,
- hicn_name_suffix_t * suffix)
+tcp_get_data_name_suffix (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_name_suffix_t *suffix)
{
*suffix = ntohl (h->tcp.name_suffix);
return HICN_LIB_ERROR_NONE;
}
int
-tcp_set_data_name_suffix (hicn_type_t type, hicn_protocol_t * h,
- const hicn_name_suffix_t * suffix)
+tcp_set_data_name_suffix (hicn_type_t type, hicn_protocol_t *h,
+ const hicn_name_suffix_t *suffix)
{
h->tcp.name_suffix = htonl (*suffix);
return HICN_LIB_ERROR_NONE;
}
int
-tcp_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t * h,
- u32 * pathlabel)
+tcp_get_data_pathlabel (hicn_type_t type, const hicn_protocol_t *h,
+ u32 *pathlabel)
{
*pathlabel = h->tcp.seq_ack;
return HICN_LIB_ERROR_NONE;
}
int
-tcp_set_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+tcp_set_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const u32 pathlabel)
{
h->tcp.seq_ack = pathlabel;
@@ -166,7 +164,7 @@ tcp_set_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_update_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
+tcp_update_data_pathlabel (hicn_type_t type, hicn_protocol_t *h,
const hicn_faceid_t face_id)
{
hicn_pathlabel_t pl =
@@ -181,7 +179,7 @@ tcp_update_data_pathlabel (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
+tcp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t *h)
{
memset (&(h->tcp), 0, 4);
memset (&(h->tcp.seq_ack), 0, 12);
@@ -189,18 +187,17 @@ tcp_reset_data_for_hash (hicn_type_t type, hicn_protocol_t * h)
return CHILD_OPS (reset_data_for_hash, type, h);
}
-
int
-tcp_get_lifetime (hicn_type_t type, const hicn_protocol_t * h,
- hicn_lifetime_t * lifetime)
+tcp_get_lifetime (hicn_type_t type, const hicn_protocol_t *h,
+ hicn_lifetime_t *lifetime)
{
- *lifetime =
- ntohs (h->tcp.urg_ptr) << (h->tcp.data_offset_and_reserved & 0xF);
+ *lifetime = ntohs (h->tcp.urg_ptr)
+ << (h->tcp.data_offset_and_reserved & 0xF);
return HICN_LIB_ERROR_NONE;
}
int
-tcp_set_lifetime (hicn_type_t type, hicn_protocol_t * h,
+tcp_set_lifetime (hicn_type_t type, hicn_protocol_t *h,
const hicn_lifetime_t lifetime)
{
u8 multiplier = 0;
@@ -210,13 +207,13 @@ tcp_set_lifetime (hicn_type_t type, hicn_protocol_t * h,
{
h->tcp.urg_ptr = htons (HICN_MAX_LIFETIME_SCALED);
h->tcp.data_offset_and_reserved =
- (h->
- tcp.data_offset_and_reserved & ~0x0F) | HICN_MAX_LIFETIME_MULTIPLIER;
+ (h->tcp.data_offset_and_reserved & ~0x0F) |
+ HICN_MAX_LIFETIME_MULTIPLIER;
return HICN_LIB_ERROR_NONE;
}
- while (lifetime_scaled > HICN_MAX_LIFETIME_SCALED
- && multiplier <= HICN_MAX_LIFETIME_MULTIPLIER)
+ while (lifetime_scaled > HICN_MAX_LIFETIME_SCALED &&
+ multiplier <= HICN_MAX_LIFETIME_MULTIPLIER)
{
multiplier++;
lifetime_scaled = lifetime_scaled >> 1;
@@ -230,7 +227,7 @@ tcp_set_lifetime (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_update_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
+tcp_update_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
size_t payload_length)
{
h->tcp.csum = 0;
@@ -246,45 +243,46 @@ tcp_update_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
}
int
-tcp_verify_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum,
+tcp_verify_checksums (hicn_type_t type, hicn_protocol_t *h, u16 partial_csum,
size_t payload_length)
{
if (PREDICT_TRUE (partial_csum != 0))
{
partial_csum = ~partial_csum;
}
-
+
if (csum (h, TCP_HDRLEN + payload_length, partial_csum) != 0)
return HICN_LIB_ERROR_CORRUPTED_PACKET;
return CHILD_OPS (verify_checksums, type, h, 0, payload_length);
}
-#define TCP_OFFSET_MASK 13
-#define TCP_OFFSET_DATA_OFFSET 12
+#define TCP_OFFSET_MASK 13
+#define TCP_OFFSET_DATA_OFFSET 12
#define TCP_OFFSET_IN_BITS_DATA_OFFSET 0
#define TCP_OFFSET_IN_BITS_RESERVED 4
-#define TCP_OFFSET_IN_BITS_NS 7
-
-#define TCP_DEFAULT_SRC_PORT 0x8000
-#define TCP_DEFAULT_DST_PORT 0x0080
-#define TCP_DEFAULT_WINDOW_SIZE 0 // In [2, 65535]
-#define TCP_DEFAULT_DATA_OFFSET 5 // Size of the TCP header in words (= 4 bytes). Must be greater or equal than 5.
-#define TCP_DEFAULT_CWR 0
-#define TCP_DEFAULT_ECE 0
-#define TCP_DEFAULT_URG 0
-#define TCP_DEFAULT_ACK 0
-#define TCP_DEFAULT_PSH 0
-#define TCP_DEFAULT_RST 0
-#define TCP_DEFAULT_SYN 1
-#define TCP_DEFAULT_FIN 0
+#define TCP_OFFSET_IN_BITS_NS 7
+
+#define TCP_DEFAULT_SRC_PORT 0x8000
+#define TCP_DEFAULT_DST_PORT 0x0080
+#define TCP_DEFAULT_WINDOW_SIZE 0 // In [2, 65535]
+#define TCP_DEFAULT_DATA_OFFSET \
+ 5 // Size of the TCP header in words (= 4 bytes). Must be greater or equal
+ // than 5.
+#define TCP_DEFAULT_CWR 0
+#define TCP_DEFAULT_ECE 0
+#define TCP_DEFAULT_URG 0
+#define TCP_DEFAULT_ACK 0
+#define TCP_DEFAULT_PSH 0
+#define TCP_DEFAULT_RST 0
+#define TCP_DEFAULT_SYN 1
+#define TCP_DEFAULT_FIN 0
int
-tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new,
- ip46_address_t * addr_old)
+tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t *h,
+ const ip46_address_t *addr_new, ip46_address_t *addr_old)
{
u16 *tcp_checksum = &(h->tcp.csum);
- int ret = check_tcp_checksum(*tcp_checksum);
+ int ret = check_tcp_checksum (*tcp_checksum);
if (ret)
{
@@ -299,7 +297,8 @@ tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
* csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32);
* csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
*/
- ip_csum_t csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (h->ipv6.saddr.as_u64[0]));
+ ip_csum_t csum =
+ ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (h->ipv6.saddr.as_u64[0]));
csum = ip_csum_sub_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1]));
csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[0]));
csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1]));
@@ -310,19 +309,20 @@ tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
- const ip46_address_t * addr_new, ip46_address_t * addr_old,
+tcp_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, u8 reset_pl)
{
u16 *tcp_checksum = &(h->tcp.csum);
- int ret = check_tcp_checksum(*tcp_checksum);
+ int ret = check_tcp_checksum (*tcp_checksum);
/*
* update path label
*/
u16 old_pl = h->tcp.seq_ack;
- if(reset_pl) h->tcp.seq_ack = 0;
+ if (reset_pl)
+ h->tcp.seq_ack = 0;
tcp_update_data_pathlabel (type, h, face_id);
if (ret)
@@ -338,8 +338,10 @@ tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
* csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32);
* csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32);
*/
- ip_csum_t csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[0]));
- csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[1]));
+ ip_csum_t csum =
+ ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[0]));
+ csum =
+ ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[1]));
csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[0]));
csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[1]));
@@ -352,16 +354,16 @@ tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h,
}
int
-tcp_get_current_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+tcp_get_current_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
*header_length = TCP_HDRLEN;
return HICN_LIB_ERROR_NONE;
}
int
-tcp_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
- size_t * header_length)
+tcp_get_header_length (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *header_length)
{
size_t child_header_length = 0;
int rc = CHILD_OPS (get_header_length, type, h, &child_header_length);
@@ -373,64 +375,75 @@ tcp_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
-tcp_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
- size_t * signature_size)
+tcp_get_signature_size (hicn_type_t type, const hicn_protocol_t *h,
+ size_t *signature_size)
{
return CHILD_OPS (get_signature_size, type, h, signature_size);
}
int
-tcp_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
+tcp_set_signature_size (hicn_type_t type, hicn_protocol_t *h,
size_t signature_size)
{
return CHILD_OPS (set_signature_size, type, h, signature_size);
}
int
-tcp_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
- uint64_t signature_timestamp)
+tcp_set_signature_gap (hicn_type_t type, hicn_protocol_t *h, uint8_t gap)
+{
+ return CHILD_OPS (set_signature_gap, type, h, gap);
+}
+
+int
+tcp_get_signature_gap (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *gap)
+{
+ return CHILD_OPS (get_signature_gap, type, h, gap);
+}
+
+int
+tcp_set_signature_timestamp (hicn_type_t type, hicn_protocol_t *h,
+ uint64_t signature_timestamp)
{
return CHILD_OPS (set_signature_timestamp, type, h, signature_timestamp);
}
int
-tcp_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+tcp_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t *h,
+ uint64_t *signature_timestamp)
{
return CHILD_OPS (get_signature_timestamp, type, h, signature_timestamp);
}
int
-tcp_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
- uint8_t validation_algorithm)
+tcp_set_validation_algorithm (hicn_type_t type, hicn_protocol_t *h,
+ uint8_t validation_algorithm)
{
return CHILD_OPS (set_validation_algorithm, type, h, validation_algorithm);
}
int
-tcp_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+tcp_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t *h,
+ uint8_t *validation_algorithm)
{
return CHILD_OPS (get_validation_algorithm, type, h, validation_algorithm);
}
int
-tcp_set_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t *key_id)
+tcp_set_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t *key_id)
{
return CHILD_OPS (set_key_id, type, h, key_id);
}
int
-tcp_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size)
+tcp_get_key_id (hicn_type_t type, hicn_protocol_t *h, uint8_t **key_id,
+ uint8_t *key_id_size)
{
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
int
-tcp_get_signature (hicn_type_t type, hicn_protocol_t * h,
- uint8_t ** signature)
+tcp_get_signature (hicn_type_t type, hicn_protocol_t *h, uint8_t **signature)
{
return CHILD_OPS (get_signature, type, h, signature);
}