integrate netpfga/p4 generic
This commit is contained in:
parent
3dc7e98d4b
commit
ff1688e3b2
13 changed files with 213 additions and 896 deletions
|
|
@ -2,15 +2,7 @@
|
|||
#ifndef PARSERS_P4
|
||||
#define PARSERS_P4
|
||||
|
||||
#include <core.p4>
|
||||
#include <v1model.p4>
|
||||
|
||||
#include "headers.p4"
|
||||
|
||||
parser MyParser(packet_in packet,
|
||||
out headers hdr,
|
||||
inout metadata meta,
|
||||
inout standard_metadata_t standard_metadata) {
|
||||
/* to be included into the parser block */
|
||||
|
||||
state start {
|
||||
meta.chk_icmp = 0;
|
||||
|
|
@ -21,6 +13,8 @@ parser MyParser(packet_in packet,
|
|||
meta.chk_udp_v4 = 0;
|
||||
meta.chk_tcp_v6 = 0;
|
||||
meta.chk_tcp_v4 = 0;
|
||||
meta.v4sum = 0;
|
||||
meta.v6sum = 0;
|
||||
|
||||
packet.extract(hdr.ethernet);
|
||||
transition select(hdr.ethernet.ethertype){
|
||||
|
|
@ -74,7 +68,6 @@ parser MyParser(packet_in packet,
|
|||
transition accept;
|
||||
}
|
||||
|
||||
|
||||
/* Leaf */
|
||||
state tcp {
|
||||
packet.extract(hdr.tcp);
|
||||
|
|
@ -86,11 +79,6 @@ parser MyParser(packet_in packet,
|
|||
transition accept;
|
||||
}
|
||||
|
||||
// state icmp6 {
|
||||
// packet.extract(hdr.icmp6);
|
||||
// transition accept;
|
||||
// }
|
||||
|
||||
state icmp {
|
||||
packet.extract(hdr.icmp);
|
||||
transition accept;
|
||||
|
|
@ -101,36 +89,5 @@ parser MyParser(packet_in packet,
|
|||
transition accept;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
************************ D E P A R S E R *******************************
|
||||
*************************************************************************/
|
||||
|
||||
control MyDeparser(packet_out packet, in headers hdr) {
|
||||
apply {
|
||||
/* always */
|
||||
packet.emit(hdr.ethernet);
|
||||
|
||||
/* only if information is sent to the controller */
|
||||
packet.emit(hdr.cpu);
|
||||
|
||||
/* either */
|
||||
packet.emit(hdr.ipv4);
|
||||
packet.emit(hdr.ipv6);
|
||||
packet.emit(hdr.arp);
|
||||
|
||||
/* either */
|
||||
packet.emit(hdr.tcp);
|
||||
packet.emit(hdr.udp);
|
||||
packet.emit(hdr.icmp);
|
||||
|
||||
/* might be more than one subtype */
|
||||
packet.emit(hdr.icmp6);
|
||||
packet.emit(hdr.icmp6_na_ns);
|
||||
packet.emit(hdr.icmp6_option_link_layer_addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue