/* Copyright 2017 VMware, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include #include header ethernet_t { bit<48> dstAddr; bit<48> srcAddr; bit<16> etherType; } header H { bit<8> a; bit<8> b; } struct Parsed_packet { ethernet_t eth; H h; } struct Metadata { } control deparser(packet_out packet, in Parsed_packet hdr) { apply { packet.emit(hdr); } } parser p(packet_in pkt, out Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { state start { pkt.extract(hdr.eth); transition parse_h; } state parse_h { pkt.extract(hdr.h); transition accept; } } void do_something(inout bit<8> val) { if (val == 0) { val = 8w1; return; } val = 8w2; return; } control ingress(inout Parsed_packet h, inout Metadata m, inout standard_metadata_t sm) { apply { do_something(h.h.b); } } control egress(inout Parsed_packet hdr, inout Metadata meta, inout standard_metadata_t stdmeta) { apply {} } control vrfy(inout Parsed_packet hdr, inout Metadata meta) { apply {} } control update(inout Parsed_packet hdr, inout Metadata meta) { apply {} } V1Switch(p(), vrfy(), ingress(), egress(), update(), deparser()) main;