Replace switch in action with multiple if's

p4c --target bmv2 --arch v1model --std p4-16 "../p4src/static-mapping.p4" -o "/home/p4/master-thesis/p4src"
../p4src/static-mapping.p4(60): error: SwitchStatement: switch statements not allowed in actions
        switch(hdr.icmp6.type) {
        ^^^^^^
This commit is contained in:
Nico Schottelius 2019-03-27 18:05:59 +01:00
commit 7d9e9e1cfd
2 changed files with 15 additions and 3 deletions

View file

@ -57,9 +57,11 @@ control MyIngress(inout headers hdr,
hdr.icmp.setValid();
hdr.ipv4.protocol = PROTO_ICMP; // overwrite generic same protocol assumption
switch(hdr.icmp6.type) {
ICMP6_ECHO_REQUEST: { hdr.icmp.type = ICMP_ECHO_REQUEST; }
ICMP6_ECHO_REPLY: { hdr.icmp.type = ICMP_ECHO_REPLY; }
if(hdr.icmp6.type == ICMP6_ECHO_REQUEST) {
hdr.icmp.type = ICMP_ECHO_REQUEST;
}
if(hdr.icmp6.type == ICMP6_ECHO_REPLY) {
hdr.icmp.type = ICMP_ECHO_REPLY;
}
/* trigger checksumming */