-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheaders.p4
More file actions
148 lines (124 loc) · 3.33 KB
/
headers.p4
File metadata and controls
148 lines (124 loc) · 3.33 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*************************************************************************
************* C O N S T A N T S A N D T Y P E S *******************
*************************************************************************/
enum bit<16> ether_type_t {
TPID = 0x8100,
IPV4 = 0x0800,
ARP = 0x0806
}
enum bit<8> ip_proto_t {
ICMP = 1,
IGMP = 2,
TCP = 6,
UDP = 17
}
struct ports {
bit<16> sp;
bit<16> dp;
}
type bit<48> mac_addr_t;
/*************************************************************************
*********************** H E A D E R S *********************************
*************************************************************************/
/* Define all the headers the program will recognize */
/* The actual sets of headers processed by each gress can differ */
/*********************** P A C K E T H E A D E R S ************************/
/* Standard ethernet header */
header ethernet_h {
mac_addr_t dst_addr;
mac_addr_t src_addr;
ether_type_t ether_type;
}
header vlan_tag_h {
bit<3> pcp;
bit<1> cfi;
bit<12> vid;
ether_type_t ether_type;
}
header arp_h {
bit<16> htype;
bit<16> ptype;
bit<8> hlen;
bit<8> plen;
bit<16> opcode;
mac_addr_t hw_src_addr;
bit<32> proto_src_addr;
mac_addr_t hw_dst_addr;
bit<32> proto_dst_addr;
}
header ipv4_h {
bit<4> version;
bit<4> ihl;
bit<6> diffserv;
bit<2> ecn;
bit<16> total_len;
bit<16> identification;
bit<3> flags;
bit<13> frag_offset;
bit<8> ttl;
bit<8> protocol;
bit<16> hdr_checksum;
bit<32> src_addr;
bit<32> dst_addr;
}
header icmp_h {
bit<16> type_code;
bit<16> checksum;
}
header igmp_h {
bit<16> type_code;
bit<16> checksum;
}
header tcp_h {
bit<16> src_port;
bit<16> dst_port;
bit<32> seq_no;
bit<32> ack_no;
bit<4> data_offset;
bit<4> res;
bit<8> flags;
bit<16> window;
bit<16> checksum;
bit<16> urgent_ptr;
}
header udp_h {
bit<16> src_port;
bit<16> dst_port;
bit<16> len;
bit<16> checksum;
}
/*********************** I N G R E S S H E A D E R S ************************/
struct my_ingress_headers_t{
ethernet_h ethernet;
arp_h arp;
vlan_tag_h[2] vlan_tag;
ipv4_h ipv4;
icmp_h icmp;
igmp_h igmp;
tcp_h tcp;
udp_h udp;
}
/****** G L O B A L I N G R E S S M E T A D A T A *********/
struct my_ingress_metadata_t {
bit<32> ll;
bit<16> ecmp_select;
}
/*********************** E G R E S S H E A D E R S ************************/
struct my_egress_headers_t {
ethernet_h ethernet;
arp_h arp;
vlan_tag_h[2] vlan_tag;
ipv4_h ipv4;
icmp_h icmp;
igmp_h igmp;
tcp_h tcp;
udp_h udp;
}
/******** G L O B A L E G R E S S M E T A D A T A *********/
struct my_egress_metadata_t {
/* ECN */
bit<1> exceeded_ecn_marking_threshold;
bit<8> cc_mode;
bit<8> dcqcn_random_number;
bit<8> dcqcn_prob_output;
}