Skip to content

Commit

Permalink
Fix tests for neighbor endpoint state
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Molzer committed Feb 20, 2024
1 parent b81ade5 commit 2cd7c77
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ethox-iperf/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ fn main() {

let mut neighbors = [arp::Neighbor::default(); 1];
let mut routes = [ip::Route::new_ipv4_gateway(config.gateway.address()); 1];
let neighbors = arp::NeighborCache::new(&mut neighbors[..]);

let mut ip = ip::Endpoint::new(
Slice::One(config.host.into()),
ip::Routes::import(List::new_full(routes.as_mut().into())),
arp::NeighborCache::new(&mut neighbors[..]));
arp::Endpoint::new(neighbors));

println!("[+] Configured layers, communicating");

Expand Down
8 changes: 6 additions & 2 deletions ethox/src/layer/arp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ fn simple_arp() {
// No prior ARP cache entries needed.
let mut neighbors = [arp_layer::Neighbor::default(); 1];
let mut routes = [ip_layer::Route::unspecified(); 2];
let mut ip = ip_layer::Endpoint::new(ip::Cidr::new(IP_ADDR_HOST.into(), 24),
let arp = arp_layer::Endpoint::new(
arp_layer::NeighborCache::new(Slice::empty()));
let mut ip = ip_layer::Endpoint::new(
ip::Cidr::new(IP_ADDR_HOST.into(), 24),
// No routes necessary for local link.
ip_layer::Routes::new(&mut routes[..]),
arp_layer::NeighborCache::new(Slice::empty()));
arp,
);

let mut arp = arp_layer::Endpoint::new(arp_layer::NeighborCache::new(&mut neighbors[..]));

Expand Down
4 changes: 2 additions & 2 deletions ethox/src/layer/icmp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn answer_ping() {
let neighbors = {
let mut eth_cache = arp::NeighborCache::new(&mut neighbors[..]);
eth_cache.fill(IP_ADDR_OTHER.into(), MAC_ADDR_OTHER, None).unwrap();
eth_cache
arp::Endpoint::new(eth_cache)
};
let mut ip = [ip::Route::unspecified(); 2];
let mut ip = ip::Endpoint::new(Cidr::new(IP_ADDR_HOST.into(), 24),
Expand Down Expand Up @@ -72,7 +72,7 @@ fn queue_ping(nic: &mut Loopback<Vec<u8>>) {
let neighbors = {
let mut eth_cache = arp::NeighborCache::new(&mut neighbors[..]);
eth_cache.fill(IP_ADDR_HOST.into(), MAC_ADDR_HOST, None).unwrap();
eth_cache
arp::Endpoint::new(eth_cache)
};
let mut ip = ip::Endpoint::new(
Cidr::new(IP_ADDR_OTHER.into(), 24),
Expand Down
4 changes: 2 additions & 2 deletions ethox/src/layer/ip/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn simple_ipv4() {
let neighbors = {
let mut eth_cache = arp::NeighborCache::new(&mut neighbors[..]);
eth_cache.fill(IP_ADDR_DST.into(), MAC_ADDR_DST, None).unwrap();
eth_cache
arp::Endpoint::new(eth_cache)
};
let mut ip = [ip::Route::unspecified(); 2];
let mut ip = ip::Endpoint::new(Cidr::new(IP_ADDR_SRC.into(), 24),
Expand Down Expand Up @@ -82,7 +82,7 @@ fn simple_ipv6() {
let neighbors = {
let mut eth_cache = arp::NeighborCache::new(&mut neighbors[..]);
eth_cache.fill(IP_ADDR_DST.into(), MAC_ADDR_DST, None).unwrap();
eth_cache
arp::Endpoint::new(eth_cache)
};
let mut ip = [ip::Route::unspecified(); 2];
let mut ip = ip::Endpoint::new(Cidr::new(IP_ADDR_SRC.into(), 24),
Expand Down
2 changes: 1 addition & 1 deletion ethox/src/layer/udp/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn simple() {
let neighbors = {
let mut eth_cache = arp::NeighborCache::new(&mut neighbors[..]);
eth_cache.fill(IP_ADDR_DST.into(), MAC_ADDR_DST, None).unwrap();
eth_cache
arp::Endpoint::new(eth_cache)
};
let mut ip = [ip::Route::unspecified(); 2];
let mut ip = ip::Endpoint::new(Cidr::new(IP_ADDR_SRC.into(), 24),
Expand Down

0 comments on commit 2cd7c77

Please sign in to comment.