Carmelo Cascone | ca94bcf | 2017-10-27 14:16:59 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef __TABLE0__ |
| 18 | #define __TABLE0__ |
| 19 | |
| 20 | #include "headers.p4" |
| 21 | #include "defines.p4" |
| 22 | |
| 23 | control table0_control(inout headers_t hdr, |
| 24 | inout local_metadata_t local_metadata, |
| 25 | inout standard_metadata_t standard_metadata) { |
| 26 | |
| 27 | direct_counter(CounterType.packets_and_bytes) table0_counter; |
| 28 | |
| 29 | action set_next_hop_id(next_hop_id_t next_hop_id) { |
| 30 | local_metadata.next_hop_id = next_hop_id; |
| 31 | } |
| 32 | |
| 33 | table table0 { |
| 34 | key = { |
| 35 | standard_metadata.ingress_port : ternary; |
| 36 | hdr.ethernet.src_addr : ternary; |
| 37 | hdr.ethernet.dst_addr : ternary; |
| 38 | hdr.ethernet.ether_type : ternary; |
| 39 | hdr.ipv4.src_addr : ternary; |
| 40 | hdr.ipv4.dst_addr : ternary; |
| 41 | hdr.ipv4.protocol : ternary; |
| 42 | local_metadata.l4_src_port : ternary; |
| 43 | local_metadata.l4_dst_port : ternary; |
| 44 | } |
| 45 | actions = { |
| 46 | set_egress_port(standard_metadata); |
| 47 | send_to_cpu(standard_metadata); |
| 48 | set_next_hop_id(); |
| 49 | _drop(); |
| 50 | } |
| 51 | const default_action = _drop(); |
| 52 | counters = table0_counter; |
| 53 | } |
| 54 | |
| 55 | apply { |
| 56 | table0.apply(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | #endif |