-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Add some netif/nib processing
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "riot-wrappers-test-networkproperties" | ||
version = "0.1.0" | ||
authors = ["Christian Amsüss <[email protected]>"] | ||
edition = "2021" | ||
publish = false | ||
|
||
[lib] | ||
crate-type = ["staticlib"] | ||
|
||
[profile.release] | ||
panic = "abort" | ||
|
||
[dependencies] | ||
riot-wrappers = { path = "../..", features = [ "set_panic_handler", "panic_handler_format" ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# name of your application | ||
APPLICATION = riot-wrappers-test-networkproperties | ||
BOARD ?= native | ||
APPLICATION_RUST_MODULE = riot_wrappers_test_networkproperties | ||
BASELIBS += $(APPLICATION_RUST_MODULE).module | ||
FEATURES_REQUIRED += rust_target | ||
|
||
# This may not be a GNRC netdev in all cases; when it is not, the test will | ||
# break, and that will be the time to split it. So far, also IPv6 support can | ||
# just be assumed. (Really, anyone writing an IoT application without IPv6 | ||
# support may want to look into Cobol). | ||
USEMODULE += netdev_default | ||
USEMODULE += auto_init_gnrc_netif | ||
USEMODULE += gnrc_ipv6_default | ||
# This is an easy way to visibly populate entries into the neighbor cache: ping | ||
# the RIOT instance. | ||
USEMODULE += gnrc_icmpv6_echo | ||
|
||
USEMODULE += ztimer_msec | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#![no_std] | ||
|
||
use riot_wrappers::println; | ||
use riot_wrappers::riot_main; | ||
|
||
riot_main!(main); | ||
|
||
fn main() { | ||
use riot_wrappers::ztimer::*; | ||
|
||
let msec = Clock::msec(); | ||
|
||
loop { | ||
for netif in riot_wrappers::gnrc::Netif::all() { | ||
println!( | ||
"Netif at PID {:?} with link-layer addr {:?}", | ||
netif.pid(), | ||
netif.l2addr() | ||
); | ||
for addr in &netif.ipv6_addrs().unwrap() { | ||
println!("- Address {:?}", addr); | ||
} | ||
} | ||
|
||
println!("Cache entries:"); | ||
for cache_entry in riot_wrappers::gnrc::nib::NcEntry::all() { | ||
println!( | ||
"- on interface {:?}: {:02x?} <=> {:?}, router? {:?}, NUD {:?}, AR {:?}", | ||
cache_entry.iface(), | ||
cache_entry.l2addr(), | ||
cache_entry.ipv6_addr(), | ||
cache_entry.is_router(), | ||
cache_entry.nud_state(), | ||
cache_entry.ar_state() | ||
); | ||
} | ||
println!(""); | ||
|
||
msec.sleep(Ticks(300)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import sys | ||
from testrunner import run | ||
|
||
def test(child): | ||
# Cant' make any predictions about network addresses, but showing them | ||
# should not crash. | ||
for _ in range(3): | ||
child.expect("Netif at ") | ||
child.expect("Cache entries") | ||
|
||
if __name__ == "__main__": | ||
sys.exit(run(test)) |