Introduce sub-control for renaming variables

This commit is contained in:
Nico Schottelius 2019-07-24 11:22:32 +02:00
parent 89161e260e
commit 327d0b70f9

View file

@ -60,17 +60,18 @@ parser TopParser(
/********************************************************************************
* Main
*/
control TopPipe(
inout Parsed_packet p,
inout user_metadata_t user_metadata,
*/
control RealMain(
inout Parsed_packet hdr,
inout user_metadata_t meta,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
action swap_eth_addresses() {
EthAddr_t temp = p.ethernet.dstAddr;
p.ethernet.dstAddr = p.ethernet.srcAddr;
p.ethernet.srcAddr = temp;
EthAddr_t temp = hdr.ethernet.dstAddr;
hdr.ethernet.dstAddr = hdr.ethernet.srcAddr;
hdr.ethernet.srcAddr = temp;
/* set egress port */
sume_metadata.dst_port = sume_metadata.src_port;
@ -93,12 +94,12 @@ control TopPipe(
}
action do_nothing() {
EthAddr_t temp = p.ethernet.dstAddr;
EthAddr_t temp = hdr.ethernet.dstAddr;
}
table lookup_table {
key = {
p.ethernet.dstAddr: exact;
hdr.ethernet.dstAddr: exact;
}
actions = {
@ -116,6 +117,19 @@ control TopPipe(
}
}
control TopPipe(
inout Parsed_packet p,
inout user_metadata_t user_metadata,
inout digest_data_t digest_data,
inout sume_metadata_t sume_metadata) {
RealMain() realmain;
apply {
realmain.apply(p, user_metadata, digest_data, sume_metadata);
}
}
/********************************************************************************
* Deparser
*/