1
0
mirror of https://github.com/danog/libdvb.git synced 2024-11-30 04:19:00 +01:00
libdvb/examples/netinfo.rs
2022-03-19 22:08:33 +01:00

29 lines
712 B
Rust

use {
anyhow::{bail, Context, Result},
libdvb::NetDevice,
};
fn main() -> Result<()> {
let mut args = std::env::args().skip(1);
let adapter = match args.next() {
Some(v) => v.parse::<u32>().context("adapter number")?,
None => bail!("adapter number not defined"),
};
let device = match args.next() {
Some(v) => v.parse::<u32>().context("device number")?,
None => 0,
};
let dev = NetDevice::open(adapter, device)?;
let interface = dev.add_if(0, libdvb::net::sys::DVB_NET_FEEDTYPE_MPE)?;
println!("Interface: {}", &interface);
let mac = interface.get_mac();
println!("MAC: {}", &mac);
dev.remove_if(interface)?;
Ok(())
}