| // Copyright (c) 2017, Google Inc. |
| // |
| // P4_16 specification for a ToR (top-of-rack) switch. |
| // Status: WORK IN PROGRESS |
| // Note: This code has not been tested and is expected to contain bugs. |
| |
| #include "parser.p4" |
| #include "class_id.p4" |
| #include "spoof_protection.p4" |
| #include "l3_fwd.p4" |
| #include "packetio.p4" |
| #include "punt.p4" |
| #include "vrf.p4" |
| #include "ipv4_checksum.p4" |
| |
| |
| control ingress_tor(inout parsed_packet_t hdr, |
| inout local_metadata_t local_metadata, |
| inout standard_metadata_t standard_metadata) { |
| apply { |
| if (hdr.packet_out.isValid()) { |
| packetio_ingress.apply(hdr, local_metadata, standard_metadata); |
| } |
| vrf.apply(hdr, local_metadata, standard_metadata); |
| class_id.apply(hdr, local_metadata, standard_metadata); |
| l3_fwd.apply(hdr, local_metadata, standard_metadata); |
| punt.apply(hdr, local_metadata, standard_metadata); |
| } |
| } // end ingress_tor |
| |
| control egress_tor(inout parsed_packet_t hdr, |
| inout local_metadata_t local_metadata, |
| inout standard_metadata_t standard_metadata) { |
| apply { |
| packetio_egress.apply(hdr, local_metadata, standard_metadata); |
| spoof_protection.apply(hdr, local_metadata, standard_metadata); |
| } |
| } |
| |
| V1Switch(pkt_parser(), verify_checksum(), ingress_tor(), egress_tor(), |
| compute_checksum(), pkt_deparser()) main; |