|
|
|
@ -87,6 +87,103 @@ control MyComputeChecksum(inout headers hdr, inout metadata meta) {
|
|
|
|
|
},
|
|
|
|
|
hdr.ipv4.hdrChecksum,
|
|
|
|
|
HashAlgorithm.csum16);
|
|
|
|
|
|
|
|
|
|
update_checksum_with_payload(meta.chk_udp_v4 == 1,
|
|
|
|
|
{
|
|
|
|
|
hdr.ipv4.src_addr,
|
|
|
|
|
hdr.ipv4.dst_addr,
|
|
|
|
|
8w0,
|
|
|
|
|
hdr.ipv4.protocol,
|
|
|
|
|
meta.length_without_ip_header,
|
|
|
|
|
|
|
|
|
|
// UDP header
|
|
|
|
|
hdr.udp.src_port,
|
|
|
|
|
hdr.udp.dst_port,
|
|
|
|
|
hdr.udp.payload_length,
|
|
|
|
|
},
|
|
|
|
|
hdr.udp.checksum,
|
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
update_checksum_with_payload(meta.chk_udp_v6 == 1,
|
|
|
|
|
{
|
|
|
|
|
hdr.ipv6.src_addr, /* 128 */
|
|
|
|
|
hdr.ipv6.dst_addr, /* 128 */
|
|
|
|
|
meta.length_without_ip_header, /* 32 */
|
|
|
|
|
24w0, /* 24 */
|
|
|
|
|
hdr.ipv6.next_header, /* 8 */
|
|
|
|
|
/* total: 324 */
|
|
|
|
|
|
|
|
|
|
// UDP header
|
|
|
|
|
hdr.udp.src_port, /* 16 */
|
|
|
|
|
hdr.udp.dst_port, /* 16 */
|
|
|
|
|
hdr.udp.payload_length, /* 16 */
|
|
|
|
|
/* all: 372 */
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
hdr.udp.checksum,
|
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
update_checksum_with_payload(meta.chk_tcp_v4 == 1,
|
|
|
|
|
{
|
|
|
|
|
hdr.ipv4.src_addr,
|
|
|
|
|
hdr.ipv4.dst_addr,
|
|
|
|
|
8w0,
|
|
|
|
|
hdr.ipv4.protocol,
|
|
|
|
|
meta.length_without_ip_header,
|
|
|
|
|
|
|
|
|
|
// TCP header
|
|
|
|
|
hdr.tcp.src_port,
|
|
|
|
|
hdr.tcp.dst_port,
|
|
|
|
|
hdr.tcp.seqNo,
|
|
|
|
|
hdr.tcp.ackNo,
|
|
|
|
|
hdr.tcp.data_offset,
|
|
|
|
|
hdr.tcp.res,
|
|
|
|
|
hdr.tcp.cwr,
|
|
|
|
|
hdr.tcp.ece,
|
|
|
|
|
hdr.tcp.urg,
|
|
|
|
|
hdr.tcp.ack,
|
|
|
|
|
hdr.tcp.psh,
|
|
|
|
|
hdr.tcp.rst,
|
|
|
|
|
hdr.tcp.syn,
|
|
|
|
|
hdr.tcp.fin,
|
|
|
|
|
hdr.tcp.window,
|
|
|
|
|
hdr.tcp.urgentPtr
|
|
|
|
|
},
|
|
|
|
|
hdr.tcp.checksum,
|
|
|
|
|
HashAlgorithm.csum16
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
update_checksum_with_payload(meta.chk_tcp_v6 == 1,
|
|
|
|
|
{
|
|
|
|
|
hdr.ipv6.src_addr,
|
|
|
|
|
hdr.ipv6.dst_addr,
|
|
|
|
|
meta.length_without_ip_header,
|
|
|
|
|
24w0,
|
|
|
|
|
hdr.ipv6.next_header,
|
|
|
|
|
|
|
|
|
|
// TCP header
|
|
|
|
|
hdr.tcp.src_port,
|
|
|
|
|
hdr.tcp.dst_port,
|
|
|
|
|
hdr.tcp.seqNo,
|
|
|
|
|
hdr.tcp.ackNo,
|
|
|
|
|
hdr.tcp.data_offset,
|
|
|
|
|
hdr.tcp.res,
|
|
|
|
|
hdr.tcp.cwr,
|
|
|
|
|
hdr.tcp.ece,
|
|
|
|
|
hdr.tcp.urg,
|
|
|
|
|
hdr.tcp.ack,
|
|
|
|
|
hdr.tcp.psh,
|
|
|
|
|
hdr.tcp.rst,
|
|
|
|
|
hdr.tcp.syn,
|
|
|
|
|
hdr.tcp.fin,
|
|
|
|
|
hdr.tcp.window,
|
|
|
|
|
hdr.tcp.urgentPtr
|
|
|
|
|
},
|
|
|
|
|
hdr.tcp.checksum,
|
|
|
|
|
HashAlgorithm.csum16);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|