master-thesis/p4src/checksums.p4

44 lines
1.2 KiB
Plaintext
Raw Normal View History

/* -*- 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-02-28 10:09:45 +00:00
bit<32> icmp6_len = 32; /* for icmp6 NS */
2019-02-28 10:06:11 +00:00
2019-02-23 20:05:46 +00:00
update_checksum (
hdr.icmp6.isValid(),
{
2019-02-23 20:05:46 +00:00
hdr.ipv6.src_addr, /* 128 */
hdr.ipv6.dst_addr, /* 128 */
2019-02-28 10:09:45 +00:00
icmp6_len, /* 32 */
2019-02-23 20:05:46 +00:00
24w0, /* 24 0's */
PROTO_ICMP6 /* 8 */
2019-02-23 20:07:05 +00:00
},
2019-02-23 20:05:46 +00:00
hdr.icmp6.checksum,
2019-02-28 09:56:22 +00:00
HashAlgorithm.csum16
);
}
}
#endif