Parse down to icmp6_na_ns
This commit is contained in:
parent
7db850a731
commit
f79033c0c9
4 changed files with 272 additions and 220 deletions
|
|
@ -37,7 +37,7 @@ const task_t TASK_ICMP6_GENERAL = 2;
|
|||
const task_t TASK_DEBUG = 3;
|
||||
const task_t TASK_ICMP6_REPLY = 4;
|
||||
|
||||
|
||||
/* 48+48+16 = 112 */
|
||||
header ethernet_t {
|
||||
mac_addr_t dst_addr;
|
||||
mac_addr_t src_addr;
|
||||
|
|
@ -60,7 +60,10 @@ header ipv4_t {
|
|||
ipv4_addr_t dst_addr;
|
||||
}
|
||||
|
||||
/* https://en.wikipedia.org/wiki/IPv6_packet */
|
||||
/*
|
||||
https://en.wikipedia.org/wiki/IPv6_packet
|
||||
64 + 256 = 320
|
||||
*/
|
||||
header ipv6_t {
|
||||
bit<4> version;
|
||||
bit<8> traffic_class;
|
||||
|
|
@ -105,12 +108,25 @@ header icmp6_t {
|
|||
bit<16> checksum;
|
||||
}
|
||||
|
||||
/*
|
||||
https://tools.ietf.org/html/rfc4861#section-4.4
|
||||
*/
|
||||
header icmp6_na_ns_t {
|
||||
bit<1> router;
|
||||
bit<1> solicitated;
|
||||
bit<1> override;
|
||||
bit<29> reserved;
|
||||
ipv6_addr_t target_addr;
|
||||
}
|
||||
|
||||
header icmp_t {
|
||||
bit<8> type;
|
||||
bit<8> code;
|
||||
bit<16> checksum;
|
||||
bit<32> rest;
|
||||
}
|
||||
|
||||
|
||||
header cpu_t {
|
||||
task_t task;
|
||||
bit<16> ingress_port;
|
||||
|
|
@ -123,9 +139,10 @@ struct headers {
|
|||
ipv6_t ipv6;
|
||||
tcp_t tcp;
|
||||
udp_t udp;
|
||||
icmp6_t icmp6;
|
||||
icmp_t icmp;
|
||||
cpu_t cpu;
|
||||
icmp6_t icmp6;
|
||||
icmp6_na_ns_t icmp6_na_ns;
|
||||
}
|
||||
|
||||
struct metadata {
|
||||
|
|
|
|||
|
|
@ -46,17 +46,20 @@ parser MyParser(packet_in packet,
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
state icmp6 {
|
||||
packet.extract(hdr.icmp6);
|
||||
transition select(hdr.ipv6.next_header){
|
||||
ICMP6_NS:
|
||||
ICMP6_NS: icmp6_neighbor_solicitation;
|
||||
default: accept;
|
||||
}
|
||||
}
|
||||
state icmp6_neighbor_solicitation {
|
||||
|
||||
} */
|
||||
state icmp6_neighbor_solicitation {
|
||||
packet.extract(hdr.icmp6_na_ns);
|
||||
transition accept;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Leaf */
|
||||
state tcp {
|
||||
|
|
@ -69,10 +72,10 @@ parser MyParser(packet_in packet,
|
|||
transition accept;
|
||||
}
|
||||
|
||||
state icmp6 {
|
||||
packet.extract(hdr.icmp6);
|
||||
transition accept;
|
||||
}
|
||||
// state icmp6 {
|
||||
// packet.extract(hdr.icmp6);
|
||||
// transition accept;
|
||||
// }
|
||||
|
||||
state icmp {
|
||||
packet.extract(hdr.icmp);
|
||||
|
|
@ -101,7 +104,10 @@ control MyDeparser(packet_out packet, in headers hdr) {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ control MyIngress(inout headers hdr,
|
|||
standard_metadata.mcast_grp = mcast_grp;
|
||||
}
|
||||
|
||||
action icmp6_neighbor_solicitation(ipv6_addr_t addr) {
|
||||
action icmp6_neighbor_solicitation(ipv6_addr_t addr, mac_addr_t hwaddr) {
|
||||
/* egress = ingress */
|
||||
standard_metadata.egress_spec = standard_metadata.ingress_port;
|
||||
|
||||
|
|
@ -50,6 +50,16 @@ control MyIngress(inout headers hdr,
|
|||
hdr.ipv6.src_addr = addr;
|
||||
hdr.icmp6.type = ICMP6_NA;
|
||||
|
||||
/* ether + ipv6 + icmp6 */
|
||||
ipv6_addr_t tgt_addr =
|
||||
|
||||
truncate((bit<32>)(112 + 320 + 32)/8);
|
||||
hdr.icmp6_na.setValid();
|
||||
|
||||
hdr.icmp6_na.solicitated = 1;
|
||||
hdr.icmp6_na.override = 1;
|
||||
|
||||
|
||||
/* checksum trigger / content */
|
||||
meta.do_cksum = 1;
|
||||
meta.cast_length = (bit<32>) hdr.ipv6.payload_length;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue