-
Notifications
You must be signed in to change notification settings - Fork 3
/
bug7.p4
98 lines (82 loc) · 2.51 KB
/
bug7.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <tna.p4>
struct ingress_metadata_t {}
struct egress_metadata_t {}
header ethernet_t {
bit<48> dst_addr;
bit<48> src_addr;
bit<16> eth_type;
}
struct Headers {
ethernet_t eth_hdr;
}
struct Meta {
}
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 m, 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) {
action perform_action() {
ethernet_t simple_header = { 0, 0, 0};
simple_header = simple_header;
}
apply {
ig_tm_md.ucast_egress_port = 0;
perform_action();
perform_action();
}
}
// ---------------------------------------------------------------------------
// Ingress Deparser
// ---------------------------------------------------------------------------
control SwitchIngressDeparser(
packet_out pkt,
inout Headers hdr,
in ingress_metadata_t ig_md,
in ingress_intrinsic_metadata_for_deparser_t ig_dprsr_md) {
apply {
pkt.emit(hdr);
}
}
parser SwitchEgressParser(
packet_in pkt,
out Headers hdr,
out egress_metadata_t eg_md,
out egress_intrinsic_metadata_t eg_intr_md) {
state start {
pkt.extract(eg_intr_md);
transition accept;
}
}
control SwitchEgressDeparser(
packet_out pkt,
inout Headers hdr,
in egress_metadata_t eg_md,
in egress_intrinsic_metadata_for_deparser_t eg_intr_dprs_md) {
apply {
pkt.emit(hdr);
}
}
control SwitchEgress(
inout Headers hdr,
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 {}
}
Pipeline(SwitchIngressParser(),
ingress(),
SwitchIngressDeparser(),
SwitchEgressParser(),
SwitchEgress(),
SwitchEgressDeparser()) pipe;
Switch(pipe) main;