Carmelo Cascone | 837e645 | 2017-07-19 20:35:22 -0400 | [diff] [blame] | 1 | #ifndef PACKET_IO |
| 2 | #define PACKET_IO |
| 3 | |
| 4 | control 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 | |
| 12 | control 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 |