Skip to content

Commit

Permalink
Complete gARP
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-weqe committed Jul 29, 2024
1 parent 06106f4 commit 8ddc171
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions holo-vrrp/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ pub struct InterfaceSys {
pub ifindex: Option<u32>,
// Interface IPv4 addresses.
pub addresses: BTreeSet<Ipv4Network>,
// interface Mac Address
pub mac_address: Vec<u8>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -129,11 +131,14 @@ impl Interface {
target_proto_address: addr.ip().octets()
};

let mut mac_arr: &mut [u8; 6] = &mut [0u8; 6];
let mut mac_addr: &mut [u8; 6] = &mut [0u8; 6];
for (idx, item) in self.system.mac_address.iter().enumerate() {
mac_addr[idx] = *item;
}
let eth_frame = EthernetFrame {
ethertype: 0x806,
dst_mac: [0xff; 6],
src_mac: *mac_arr
src_mac: *mac_addr
};
let _ = network::send_packet_arp(
&self.net.socket_arp,
Expand Down
2 changes: 1 addition & 1 deletion holo-vrrp/src/southbound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn process_iface_update(

iface.system.flags = msg.flags;
iface.system.ifindex = Some(msg.ifindex);

iface.system.mac_address = msg.mac_address;
// TODO: trigger protocol event?
}

Expand Down

0 comments on commit 8ddc171

Please sign in to comment.