master-thesis/p4debug/bug2-cast-in-checksum/checksums.p4
Nico Schottelius decb0c516d syntax correct
2019-03-06 19:52:27 +01:00

41 lines
1.1 KiB
Text

/* -*- P4_16 -*- */
#ifndef CHECKSUMS_P4
#define CHECKSUMS_P4
#include <core.p4>
#include <v1model.p4>
#include "headers.p4"
/*************************************************************************
************* C H E C K S U M V E R I F I C A T I O N *************
*************************************************************************/
control MyVerifyChecksum(inout headers hdr, inout metadata meta) {
apply {}
}
/*************************************************************************
************** C H E C K S U M C O M P U T A T I O N **************
*************************************************************************/
control MyComputeChecksum(inout headers hdr, inout metadata meta) {
apply {
update_checksum_with_payload(meta.do_cksum == 1,
{
hdr.ipv6.src_addr, /* 128 */
hdr.ipv6.dst_addr, /* 128 */
(bit<32>) hdr.ipv6.payload_length,
24w0, /* 24 0's */
PROTO_ICMP6 /* 8 */
},
hdr.icmp6.checksum,
HashAlgorithm.csum16
);
}
}
#endif