Adding P4 cheat cheet and its latex source files. (#201)
This commit is contained in:
23
utils/cheat_sheet_src/src/adv_parsing.txt
Normal file
23
utils/cheat_sheet_src/src/adv_parsing.txt
Normal file
@@ -0,0 +1,23 @@
|
||||
// common defns for IPv4 and IPv6
|
||||
header ip46_t {
|
||||
bit<4> version;
|
||||
bit<4> reserved;
|
||||
}
|
||||
|
||||
// header stack parsing
|
||||
state parse_labels {
|
||||
packet.extract(hdr.labels.next);
|
||||
transition select(hdr.labels.last.bos) {
|
||||
0: parse_labels; // create loop
|
||||
1: guess_labels_payload;
|
||||
}
|
||||
}
|
||||
|
||||
// lookahead parsing
|
||||
state guess_labels_payload {
|
||||
transition select(packet.lookahead<ip46_t>().version) {
|
||||
4 : parse_inner_ipv4;
|
||||
6 : parse_inner_ipv6;
|
||||
default : parse_inner_ethernet;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user