2019-07-10 07:07:17 +00:00
|
|
|
#ifndef NICO_DELTA_CHECKSUM
|
|
|
|
#define NICO_DELTA_CHECKSUM
|
|
|
|
|
2019-07-10 11:38:59 +00:00
|
|
|
action v4sum() {
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v4sum = 0;
|
2019-07-10 11:38:59 +00:00
|
|
|
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v4sum = meta.v4sum + ipv4.src_addr[15:0]; // 16 bit
|
|
|
|
meta.v4sum = meta.v4sum + ipv4.src_addr[31:16]; // 16 bit
|
|
|
|
meta.v4sum = meta.v4sum + ipv4.dst_addr[15:0]; // 16 bit
|
|
|
|
meta.v4sum = meta.v4sum + ipv4.dst_addr[31:16]; // 16 bit
|
2019-07-10 11:38:59 +00:00
|
|
|
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v4sum = meta.v4sum + ipv4.totalLen -20; // 16 bit
|
|
|
|
meta.v4sum = meta.v4sum + (bit<16>) ipv4.protocol; // 8 bit
|
2019-07-10 11:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
action v6sum() {
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v6sum = 0;
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[15:0]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[31:16]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[47:32]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[63:48]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[79:64]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[95:80]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[111:96]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.src_addr[127:112]; // 16 bit
|
2019-07-10 11:38:59 +00:00
|
|
|
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[15:0]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[31:16]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[47:32]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[63:48]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[79:64]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[95:80]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[111:96]; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + ipv6.dst_addr[127:112]; // 16 bit
|
2019-07-10 11:38:59 +00:00
|
|
|
|
2019-07-10 11:42:37 +00:00
|
|
|
meta.v6sum = meta.v6sum + ipv6.payload_length; // 16 bit
|
|
|
|
meta.v6sum = meta.v6sum + (bit<16>) ipv6.next_header; // 8 bit
|
2019-07-10 11:38:59 +00:00
|
|
|
}
|
2019-07-10 07:07:17 +00:00
|
|
|
|
|
|
|
#endif
|