forked from iovisor/bcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.p4
More file actions
74 lines (62 loc) · 1.11 KB
/
Copy pathsimple.p4
File metadata and controls
74 lines (62 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Routes a packet to an interface based on its IPv4 address
// Maintains a set of counters on the routing table
header_type ethernet_t {
fields {
dstAddr : 48;
srcAddr : 48;
etherType : 16;
}
}
header_type ipv4_t {
fields {
version : 4;
ihl : 4;
diffserv : 8;
totalLen : 16;
identification : 16;
flags : 3;
fragOffset : 13;
ttl : 8;
protocol : 8;
hdrChecksum : 16;
srcAddr : 32;
dstAddr: 32;
}
}
parser start {
return parse_ethernet;
}
header ethernet_t ethernet;
parser parse_ethernet {
extract(ethernet);
return select(latest.etherType) {
0x800 : parse_ipv4;
default: ingress;
}
}
action nop()
{}
action forward(port)
{
modify_field(standard_metadata.egress_port, port);
}
header ipv4_t ipv4;
parser parse_ipv4 {
extract(ipv4);
return ingress;
}
table routing {
reads {
ipv4.dstAddr: exact;
}
actions { nop; forward; }
size : 512;
}
counter cnt {
type: bytes;
direct: routing;
}
control ingress
{
apply(routing);
}