+headers +parsers [udp, icmp, icmp6]
This commit is contained in:
parent
8bc292564e
commit
214ccd4479
3 changed files with 49 additions and 3 deletions
|
@ -66,7 +66,8 @@
|
|||
**** See time table above
|
||||
*** Additional features queue (to be discussed)
|
||||
**** TODO Offset based translation (v4->v6) -> same as range (?)
|
||||
****
|
||||
**** TODO IP address learning (v6/v4) for real life switch?
|
||||
|
||||
** Thesis documentation
|
||||
*** Motivation
|
||||
TBD
|
||||
|
|
|
@ -76,11 +76,35 @@ header tcp_t{
|
|||
bit<16> urgentPtr;
|
||||
}
|
||||
|
||||
header udp_t {
|
||||
bit<16> src_port;
|
||||
bit<16> dst_port;
|
||||
bit<16> payload_length;
|
||||
bit<16> checksum;
|
||||
}
|
||||
|
||||
header icmp6_t {
|
||||
bit<8> type;
|
||||
bit<8> code;
|
||||
bit<16> checksum;
|
||||
}
|
||||
|
||||
header icmp_t {
|
||||
bit<8> type;
|
||||
bit<8> code;
|
||||
bit<16> checksum;
|
||||
bit<32> rest;
|
||||
}
|
||||
|
||||
|
||||
struct headers {
|
||||
ethernet_t ethernet;
|
||||
ipv4_t ipv4;
|
||||
ipv6_t ipv6;
|
||||
tcp_t tcp;
|
||||
udp_t udp;
|
||||
icmp6_t icmp6;
|
||||
icmp_t icmp;
|
||||
}
|
||||
|
||||
struct metadata {
|
||||
|
|
|
@ -26,7 +26,10 @@ parser MyParser(packet_in packet,
|
|||
meta.tcp_length = hdr.ipv4.totalLen - 16w20;
|
||||
|
||||
transition select(hdr.ipv4.protocol){
|
||||
TYPE_TCP: tcp;
|
||||
PROTO_TCP: tcp;
|
||||
PROTO_UDP: udp;
|
||||
PROTO_ICMP: icmp;
|
||||
|
||||
default: accept;
|
||||
}
|
||||
}
|
||||
|
@ -36,16 +39,34 @@ parser MyParser(packet_in packet,
|
|||
meta.tcp_length = hdr.ipv6.payload_length;
|
||||
|
||||
transition select(hdr.ipv6.next_header){
|
||||
TYPE_TCP: tcp;
|
||||
PROTO_TCP: tcp;
|
||||
PROTO_UDP: udp;
|
||||
PROTO_ICMP6: icmp6;
|
||||
default: accept;
|
||||
}
|
||||
}
|
||||
|
||||
/* Leaf */
|
||||
state tcp {
|
||||
packet.extract(hdr.tcp);
|
||||
transition accept;
|
||||
}
|
||||
|
||||
state udp {
|
||||
packet.extract(hdr.udp);
|
||||
transition accept;
|
||||
}
|
||||
|
||||
state icmp6 {
|
||||
packet.extract(hdr.icmp6);
|
||||
transition accept;
|
||||
}
|
||||
|
||||
state icmp {
|
||||
packet.extract(hdr.icmp);
|
||||
transition accept;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
|
|
Loading…
Reference in a new issue