Remove function, because functions don't compile

This commit is contained in:
Nico Schottelius 2019-07-17 17:37:37 +02:00
commit 831d69fe9c
3 changed files with 138 additions and 65 deletions

View file

@ -56,17 +56,36 @@ action delta_udp_from_v4_to_v6()
{
delta_prepare();
bit<16> tmp = 0;
tmp = ones_complement_sum(hdr.udp.checksum, meta.v6sum);
hdr.udp.checksum = ones_complement_sum(tmp, 0xffff - meta.v6sum);
bit<17> tmp = (bit<17>) hdr.udp.checksum + (bit<17>) meta.v6sum;
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
hdr.udp.checksum = tmp;
}
action delta_tcp_from_v4_to_v6()
{
delta_prepare();
bit<16> tmp = 0;
tmp = ones_complement_sum(hdr.tcp.checksum, meta.v6sum);
hdr.tcp.checksum = ones_complement_sum(tmp, 0xffff - meta.v6sum);
bit<17> tmp = (bit<17>) hdr.tcp.checksum + (bit<17>) meta.v6sum;
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
tmp = tmp + (bit<17>) (0xffff - meta.v6sum);
if (tmp[16:16] == 1) {
tmp = tmp + 1;
tmp[16:16] = 0;
}
hdr.tcp.checksum = tmp;
}
action delta_ipv4_from_v6_to_v4()

View file

@ -238,18 +238,4 @@ struct metadata {
table_t table_id;
}
/* copied from
https://p4.org/p4-spec/docs/PSA-v1.1.0.html#appendix-internetchecksum-implementation
*/
bit<16> ones_complement_sum(in bit<16> x, in bit<16> y) {
bit<17> ret = (bit<17>) x + (bit<17>) y;
if (ret[16:16] == 1) {
ret = ret + 1;
}
return ret[15:0];
}
#endif