blob: 6f02e28528cb84f967e09a8269e9347fbb21cb75 [file] [log] [blame]
Carmelo Cascone837e6452017-07-19 20:35:22 -04001#ifndef PACKET_IO
2#define PACKET_IO
3
4control PacketIoIngressControl(inout headers_t hdr, inout standard_metadata_t standard_metadata) {
5 apply {
6 if (hdr.packet_out.isValid()) {
7 standard_metadata.egress_spec = hdr.packet_out.egress_port;
8 }
9 }
10}
11
12control PacketIoEgressControl(inout headers_t hdr, inout standard_metadata_t standard_metadata) {
13 apply {
14 hdr.packet_out.setInvalid();
15 if (standard_metadata.egress_spec == CPU_PORT) {
16 hdr.packet_in.setValid();
17 hdr.packet_in.ingress_port = standard_metadata.ingress_port;
18 }
19 }
20}
21
22#endif