diff options
Diffstat (limited to 'lib/src/protocol')
-rw-r--r-- | lib/src/protocol/ah.c | 2 | ||||
-rw-r--r-- | lib/src/protocol/icmp.c | 2 | ||||
-rw-r--r-- | lib/src/protocol/ipv4.c | 4 | ||||
-rw-r--r-- | lib/src/protocol/ipv6.c | 20 | ||||
-rw-r--r-- | lib/src/protocol/tcp.c | 28 |
5 files changed, 33 insertions, 23 deletions
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c index da08d1ee8..03f3af04a 100644 --- a/lib/src/protocol/ah.c +++ b/lib/src/protocol/ah.c @@ -113,7 +113,7 @@ ah_rewrite_interest (hicn_type_t type, hicn_protocol_t * h, int 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) + const hicn_faceid_t face_id, u8 reset_pl) { /* Nothing to do on signature */ return HICN_LIB_ERROR_NONE; diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c index b24c0f11e..a16353427 100644 --- a/lib/src/protocol/icmp.c +++ b/lib/src/protocol/icmp.c @@ -118,7 +118,7 @@ icmp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h, 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) + const hicn_faceid_t face_id, u8 reset_pl) { return HICN_LIB_ERROR_NOT_IMPLEMENTED; // u16 *icmp_checksum = &(h->icmp.csum); diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c index 781907231..73ce12ee0 100644 --- a/lib/src/protocol/ipv4.c +++ b/lib/src/protocol/ipv4.c @@ -324,7 +324,7 @@ 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, - const hicn_faceid_t face_id) + const hicn_faceid_t face_id, u8 reset_pl) { // ASSERT(addr_old == NULL); addr_old->ip4 = h->ipv4.daddr; @@ -336,7 +336,7 @@ 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); + return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id, reset_pl); } int diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c index f23b01cd8..bf8123497 100644 --- a/lib/src/protocol/ipv6.c +++ b/lib/src/protocol/ipv6.c @@ -220,19 +220,13 @@ 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) + if (payload_length == ~0) { int rc = ipv6_get_payload_length (type, h, &payload_length); if (rc < 0) return rc; } - /* Ignore the payload if payload_length = ~0 */ - if (payload_length == ~0) - { - payload_length = 0; - } - /* Build pseudo-header */ ipv6_pseudo_header_t psh; psh.ip_src = h->ipv6.saddr; @@ -258,7 +252,7 @@ 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) + if (payload_length == ~0) { int rc = ipv6_get_payload_length (type, h, &payload_length); if (rc < 0) @@ -276,7 +270,11 @@ ipv6_verify_checksums (hicn_type_t type, hicn_protocol_t * h, pseudo.protocol = h->ipv6.nxt; /* Compute partial checksum based on pseudo-header */ - partial_csum = csum (&pseudo, IPV6_PSHDRLEN, 0); + if (partial_csum != 0) + { + partial_csum = ~partial_csum; + } + partial_csum = csum (&pseudo, IPV6_PSHDRLEN, partial_csum); return CHILD_OPS (verify_checksums, type, h, partial_csum, payload_length); } @@ -296,13 +294,13 @@ 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, - const hicn_faceid_t face_id) + 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); + return CHILD_OPS (rewrite_data, type, h, addr_new, addr_old, face_id, reset_pl); } int diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c index c6099bf8f..95f93c6af 100644 --- a/lib/src/protocol/tcp.c +++ b/lib/src/protocol/tcp.c @@ -170,12 +170,12 @@ tcp_update_data_pathlabel (hicn_type_t type, hicn_protocol_t * h, const hicn_faceid_t face_id) { hicn_pathlabel_t pl = - (hicn_pathlabel_t) ((h->tcp.pathlabel & HICN_PATH_LABEL_MASK) >> (32 - - HICN_PATH_LABEL_SIZE)); + (hicn_pathlabel_t) (h->tcp.seq_ack >> (32 - HICN_PATH_LABEL_SIZE)); + hicn_pathlabel_t new_pl; update_pathlabel (pl, face_id, &new_pl); - h->tcp.pathlabel = new_pl; + h->tcp.seq_ack = (new_pl << (32 - HICN_PATH_LABEL_SIZE)); return HICN_LIB_ERROR_NONE; } @@ -249,7 +249,12 @@ int tcp_verify_checksums (hicn_type_t type, hicn_protocol_t * h, u16 partial_csum, size_t payload_length) { - if (csum (h, TCP_HDRLEN + payload_length, ~partial_csum) != 0) + 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); } @@ -307,11 +312,19 @@ 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, - const hicn_faceid_t face_id) + const hicn_faceid_t face_id, u8 reset_pl) { + u16 *tcp_checksum = &(h->tcp.csum); 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; + tcp_update_data_pathlabel (type, h, face_id); + if (ret) { return ret; @@ -330,9 +343,8 @@ tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h, 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])); - csum = ip_csum_sub_even (csum, h->tcp.pathlabel); - tcp_update_data_pathlabel (type, h, face_id); - csum = ip_csum_add_even (csum, h->tcp.pathlabel); + csum = ip_csum_sub_even (csum, old_pl); + csum = ip_csum_add_even (csum, h->tcp.seq_ack); *tcp_checksum = ip_csum_fold (csum); |