pub struct Net { /* private fields */ }Implementations§
Source§impl Net
impl Net
pub fn new() -> Self
Sourcepub fn with_config(cfg: KernelConfig) -> Self
pub fn with_config(cfg: KernelConfig) -> Self
cfg is applied to every host added later.
Sourcepub fn add_host<A: ToIpAddrs>(&mut self, addrs: A) -> HostId
pub fn add_host<A: ToIpAddrs>(&mut self, addrs: A) -> HostId
Register a host. addrs accepts hostnames (auto-allocated to
192.168.x.x on first sight, idempotent on reuse) or literal
IPs. Loopback (127.0.0.1, ::1) is implicit — do not pass it.
Panics if an address is already claimed by another host, or
if loopback is passed explicitly. The first host added becomes
current.
Sourcepub fn lookup(&mut self, name: &str) -> IpAddr
pub fn lookup(&mut self, name: &str) -> IpAddr
Resolve name to its registered IP, allocating if unseen.
Mirrors the name resolution used by Net::add_host and the
shim’s hostname-aware socket addrs.
pub fn host_ids(&self) -> impl Iterator<Item = HostId> + '_
Sourcepub fn rule(&mut self, rule: impl Rule)
pub fn rule(&mut self, rule: impl Rule)
Install a rule for the life of the Net. Use this when the
rule is part of the test’s fixed setup (symmetric latency,
permanent packet filter, etc). For rules that only apply to
a phase of the test, use the guard-returning rule free
function from inside the sim instead.
Sourcepub fn enter(self) -> EnterGuard
pub fn enter(self) -> EnterGuard
Panics if another Net is already installed on this thread.