aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src')
-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
8 files changed, 526 insertions, 439 deletions
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);
}