2019-02-21 22:19:17 +00:00
|
|
|
/* -*- 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 {
|
2019-03-30 13:59:46 +00:00
|
|
|
|
2019-03-30 16:02:18 +00:00
|
|
|
update_checksum_with_payload(meta.chk_icmp6 == 1,
|
2019-03-06 14:15:46 +00:00
|
|
|
{
|
|
|
|
hdr.ipv6.src_addr, /* 128 */
|
|
|
|
hdr.ipv6.dst_addr, /* 128 */
|
2019-03-06 16:38:43 +00:00
|
|
|
meta.cast_length, /* 32 */
|
2019-03-06 14:15:46 +00:00
|
|
|
24w0, /* 24 0's */
|
2019-03-06 23:33:41 +00:00
|
|
|
PROTO_ICMP6, /* 8 */
|
|
|
|
hdr.icmp6.type, /* 8 */
|
|
|
|
hdr.icmp6.code /* 8 */
|
2019-03-06 14:15:46 +00:00
|
|
|
},
|
|
|
|
hdr.icmp6.checksum,
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
);
|
2019-03-23 13:39:56 +00:00
|
|
|
|
|
|
|
/* checksumming for icmp6_na_ns_option */
|
2019-03-30 16:01:04 +00:00
|
|
|
update_checksum_with_payload(meta.chk_icmp6_na_ns == 1,
|
2019-03-23 13:39:56 +00:00
|
|
|
{
|
|
|
|
hdr.ipv6.src_addr, /* 128 */
|
|
|
|
hdr.ipv6.dst_addr, /* 128 */
|
|
|
|
meta.cast_length, /* 32 */
|
|
|
|
24w0, /* 24 0's */
|
|
|
|
PROTO_ICMP6, /* 8 */
|
|
|
|
hdr.icmp6.type, /* 8 */
|
|
|
|
hdr.icmp6.code, /* 8 */
|
|
|
|
|
|
|
|
hdr.icmp6_na_ns.router,
|
|
|
|
hdr.icmp6_na_ns.solicitated,
|
|
|
|
hdr.icmp6_na_ns.override,
|
|
|
|
hdr.icmp6_na_ns.reserved,
|
|
|
|
hdr.icmp6_na_ns.target_addr,
|
|
|
|
|
|
|
|
hdr.icmp6_option_link_layer_addr.type,
|
|
|
|
hdr.icmp6_option_link_layer_addr.ll_length,
|
|
|
|
hdr.icmp6_option_link_layer_addr.mac_addr
|
|
|
|
},
|
|
|
|
hdr.icmp6.checksum,
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
);
|
|
|
|
|
2019-03-30 16:02:18 +00:00
|
|
|
update_checksum_with_payload(meta.chk_icmp == 1,
|
2019-03-27 17:01:11 +00:00
|
|
|
{
|
|
|
|
hdr.icmp.type,
|
|
|
|
hdr.icmp.code
|
|
|
|
},
|
|
|
|
hdr.icmp.checksum,
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
);
|
2019-02-21 22:19:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|