60 lines
No EOL
1.5 KiB
Text
60 lines
No EOL
1.5 KiB
Text
#ifndef NICO_ARP
|
|
#define NICO_ARP
|
|
|
|
|
|
/********************** ARP ***********************************/
|
|
|
|
action arp_reply(mac_addr_t mac_addr) {
|
|
/* swap */
|
|
ipv4_addr_t ipv4_src = hdr.arp.dst_ipv4_addr;
|
|
ipv4_addr_t ipv4_dst = hdr.arp.src_ipv4_addr;
|
|
|
|
/* swap/add */
|
|
mac_addr_t mac_src = mac_addr;
|
|
mac_addr_t mac_dst = hdr.arp.src_mac_addr;
|
|
|
|
/* fill the ethernet header */
|
|
hdr.ethernet.dst_addr = mac_dst;
|
|
hdr.ethernet.src_addr = mac_src;
|
|
|
|
/* fill the arp header */
|
|
hdr.arp.dst_mac_addr = mac_dst;
|
|
hdr.arp.src_mac_addr = mac_src;
|
|
|
|
/* swapping */
|
|
hdr.arp.dst_ipv4_addr = ipv4_dst;
|
|
hdr.arp.src_ipv4_addr = ipv4_src;
|
|
|
|
hdr.arp.opcode = ARP_REPLY;
|
|
}
|
|
|
|
table v4_arp {
|
|
key = {
|
|
hdr.ethernet.dst_addr: exact;
|
|
hdr.arp.opcode: exact;
|
|
hdr.arp.dst_ipv4_addr: lpm;
|
|
}
|
|
actions = {
|
|
controller_debug_table_id;
|
|
arp_reply;
|
|
NoAction;
|
|
}
|
|
size = ICMP6_TABLE_SIZE;
|
|
default_action = controller_debug_table_id(TABLE_ARP);
|
|
}
|
|
|
|
table v4_arp_egress {
|
|
key = {
|
|
hdr.arp.dst_ipv4_addr: lpm;
|
|
}
|
|
actions = {
|
|
controller_debug_table_id;
|
|
set_egress_port;
|
|
NoAction;
|
|
}
|
|
size = ICMP6_TABLE_SIZE;
|
|
default_action = controller_debug_table_id(TABLE_ARP_EGRESS);
|
|
}
|
|
|
|
|
|
#endif |