Use types for signalling expected action
This commit is contained in:
parent
da7fda57bf
commit
ea1873c14c
4 changed files with 33 additions and 12 deletions
|
|
@ -8,8 +8,9 @@
|
|||
typedef bit<48> mac_addr_t;
|
||||
typedef bit<32> ipv4_addr_t;
|
||||
typedef bit<128> ipv6_addr_t;
|
||||
typedef bit<9> port_t;
|
||||
typedef bit<9> port_t;
|
||||
typedef bit<16> mcast_t;
|
||||
typedef bit<8> task_t;
|
||||
|
||||
|
||||
const bit<16> TYPE_IPV4 = 0x0800;
|
||||
|
|
@ -31,6 +32,10 @@ const bit<8> ICMP6_NS = 135;
|
|||
const bit<8> ICMP6_NA = 136;
|
||||
|
||||
|
||||
const task_t TASK_ICMP6_NS = 1;
|
||||
const task_t TASK_ICMP6_GENERAL = 2;
|
||||
const task_t TASK_DEBUG = 3;
|
||||
|
||||
|
||||
header ethernet_t {
|
||||
mac_addr_t dst_addr;
|
||||
|
|
@ -106,6 +111,10 @@ header icmp_t {
|
|||
bit<32> rest;
|
||||
}
|
||||
|
||||
header cpu_t {
|
||||
port_t ingress_port;
|
||||
task_t task;
|
||||
}
|
||||
|
||||
struct headers {
|
||||
ethernet_t ethernet;
|
||||
|
|
@ -115,12 +124,11 @@ struct headers {
|
|||
udp_t udp;
|
||||
icmp6_t icmp6;
|
||||
icmp_t icmp;
|
||||
cpu_t cpu;
|
||||
}
|
||||
|
||||
struct metadata {
|
||||
bit<16> tcp_length;
|
||||
bit<16> ethertype; /* we use this, if we are cloning */
|
||||
bit<1> ether_modified;
|
||||
task_t task;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -75,6 +75,10 @@ parser MyParser(packet_in packet,
|
|||
|
||||
control MyDeparser(packet_out packet, in headers hdr) {
|
||||
apply {
|
||||
/* only if information is sent to the controller */
|
||||
packet.emit(hdr.cpu);
|
||||
|
||||
/* always */
|
||||
packet.emit(hdr.ethernet);
|
||||
|
||||
/* either */
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ control MyIngress(inout headers hdr,
|
|||
}
|
||||
|
||||
action controller_debug() {
|
||||
meta.ether_modified = 1;
|
||||
meta.ethertype = TYPE_DEBUG;
|
||||
meta.task = TASK_DEBUG;
|
||||
clone3(CloneType.I2E, 100, meta);
|
||||
}
|
||||
|
||||
action controller_reply() {
|
||||
action controller_reply(task_t task) {
|
||||
meta.task = task;
|
||||
clone3(CloneType.I2E, 100, meta);
|
||||
}
|
||||
|
||||
|
|
@ -203,7 +203,8 @@ control MyEgress(inout headers hdr,
|
|||
apply {
|
||||
// ingress clone
|
||||
if (standard_metadata.instance_type == 1 && meta.ether_modified == 1){
|
||||
hdr.ethernet.ethertype = meta.ethertype;
|
||||
hdr.cpu.setValid();
|
||||
hdr.cpu.task = meta.task;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -226,7 +227,6 @@ MyDeparser()
|
|||
// hdr.tcp.setValid();
|
||||
|
||||
|
||||
// hdr.cpu.setValid();
|
||||
// hdr.cpu.srcAddr = hdr.ethernet.srcAddr;
|
||||
// hdr.cpu.ingress_port = (bit<16>)meta.ingress_port;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue