diff --git a/p4src/checksums.p4 b/p4src/checksums.p4 index aa10451..6f087da 100644 --- a/p4src/checksums.p4 +++ b/p4src/checksums.p4 @@ -21,26 +21,19 @@ control MyVerifyChecksum(inout headers hdr, inout metadata meta) { control MyComputeChecksum(inout headers hdr, inout metadata meta) { apply { + bit<32> icmp6_len = (bit<32>) hdr.ipv6.payload_length; - if(meta.calc_icmp6_checksum) { - hdr.icmp6.checksum = 42; /* must be correct */ - } - - // verify_checksum_with_payload(in bool condition, in T data, inout O checksum, HashAlgorithm algo); - // GRRRRR bit<32> icmp6_len = 32; /* for icmp6 NS */ - - // GRRRRR update_checksum ( - // GRRRRR hdr.icmp6.isValid(), - // GRRRRR { - // GRRRRR hdr.ipv6.src_addr, /* 128 */ - // GRRRRR hdr.ipv6.dst_addr, /* 128 */ - // GRRRRR icmp6_len, /* 32 */ - // GRRRRR 24w0, /* 24 0's */ - // GRRRRR PROTO_ICMP6 /* 8 */ - // GRRRRR }, - // GRRRRR hdr.icmp6.checksum, - // GRRRRR HashAlgorithm.csum16 - // GRRRRR ); + update_checksum_with_payload(meta.calc_icmp6_checksum, + { + hdr.ipv6.src_addr, /* 128 */ + hdr.ipv6.dst_addr, /* 128 */ + icmp6_len, /* 32 */ + 24w0, /* 24 0's */ + PROTO_ICMP6 /* 8 */ + }, + hdr.icmp6.checksum, + HashAlgorithm.csum16 + ); } }