-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbug35.p4
70 lines (57 loc) · 2.18 KB
/
bug35.p4
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
#include <tna.p4>
header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}
struct Headers {
ethernet_t eth_hdr;
}
struct ingress_metadata_t {
}
struct egress_metadata_t {
}
parser SwitchIngressParser(packet_in pkt, out Headers hdr, out ingress_metadata_t ig_md, out ingress_intrinsic_metadata_t ig_intr_md) {
state start {
pkt.extract(ig_intr_md);
pkt.advance(PORT_METADATA_SIZE);
transition parse_hdrs;
}
state parse_hdrs {
pkt.extract(hdr.eth_hdr);
transition accept;
}
}
control ingress(inout Headers h, inout ingress_metadata_t ig_md, in ingress_intrinsic_metadata_t ig_intr_md, in ingress_intrinsic_metadata_from_parser_t ig_prsr_md, inout ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md, inout ingress_intrinsic_metadata_for_tm_t ig_tm_md) {
bool decision = (8w1 ^ (bit<4>)h.eth_hdr.dst_addr ++ (bit<4>)h.eth_hdr.src_addr != 8w2);
apply {
ig_tm_md.ucast_egress_port = 0;
if (decision) {
h.eth_hdr.eth_type = 16w1;
} else {
h.eth_hdr.eth_type = 16w2;
}
}
}
control SwitchIngressDeparser(packet_out pkt, inout Headers h, in ingress_metadata_t ig_md, in ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md) {
apply {
pkt.emit(h);
}
}
parser SwitchEgressParser(packet_in pkt, out Headers h, out egress_metadata_t eg_md, out egress_intrinsic_metadata_t eg_intr_md) {
state start {
pkt.extract(eg_intr_md);
transition accept;
}
}
control SwitchEgress(inout Headers h, inout egress_metadata_t eg_md, in egress_intrinsic_metadata_t eg_intr_md, in egress_intrinsic_metadata_from_parser_t eg_intr_md_from_prsr, inout egress_intrinsic_metadata_for_deparser_t eg_intr_dprs_md, inout egress_intrinsic_metadata_for_output_port_t eg_intr_oport_md) {
apply {
}
}
control SwitchEgressDeparser(packet_out pkt, inout Headers h, in egress_metadata_t eg_md, in egress_intrinsic_metadata_for_deparser_t eg_intr_dprs_md) {
apply {
pkt.emit(h);
}
}
Pipeline(SwitchIngressParser(), ingress(), SwitchIngressDeparser(), SwitchEgressParser(), SwitchEgress(), SwitchEgressDeparser()) pipe;
Switch(pipe) main;