blob: 27e1f8ad723450a7ceac093e5b6b6fc815ce9e30 [file] [log] [blame]
Carmelo Casconeca94bcf2017-10-27 14:16:59 -07001/*
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
23control 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
Keesjan Karsten23368892018-05-22 10:46:01 +000033 action send_to_cpu() {
34 standard_metadata.egress_spec = CPU_PORT;
35 }
36
37 action set_egress_port(port_t port) {
38 standard_metadata.egress_spec = port;
39 }
40
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070041 table table0 {
42 key = {
43 standard_metadata.ingress_port : ternary;
44 hdr.ethernet.src_addr : ternary;
45 hdr.ethernet.dst_addr : ternary;
46 hdr.ethernet.ether_type : ternary;
47 hdr.ipv4.src_addr : ternary;
48 hdr.ipv4.dst_addr : ternary;
49 hdr.ipv4.protocol : ternary;
50 local_metadata.l4_src_port : ternary;
51 local_metadata.l4_dst_port : ternary;
52 }
53 actions = {
Keesjan Karsten23368892018-05-22 10:46:01 +000054 set_egress_port;
55 send_to_cpu;
56 set_next_hop_id;
57 _drop;
Carmelo Casconeca94bcf2017-10-27 14:16:59 -070058 }
59 const default_action = _drop();
60 counters = table0_counter;
61 }
62
63 apply {
64 table0.apply();
65 }
66}
67
68#endif