summaryrefslogtreecommitdiffstats
path: root/lib/src/protocol/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/protocol/tcp.c')
-rw-r--r--lib/src/protocol/tcp.c28
1 files changed, 20 insertions, 8 deletions
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);