File: error_packet.rs

package info (click to toggle)
rust-neli 0.7.1-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 456 kB
  • sloc: makefile: 2
file content (21 lines) | stat: -rw-r--r-- 738 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use std::error::Error;

use neli::{
    consts::socket::NlFamily, err::RouterError, router::synchronous::NlRouter, utils::Groups,
};

fn main() -> Result<(), Box<dyn Error>> {
    // Create a socket and connect to generic netlink.
    let (sock, _) = NlRouter::connect(NlFamily::Generic, None, Groups::empty())?;
    // Attempt to resolve a multicast group that should not exist.
    let error = sock.resolve_nl_mcast_group("not_a", "group");
    match error {
        Ok(_) => panic!("Should not succeed"),
        Err(RouterError::Nlmsgerr(e)) => {
            // Should be packet that caused error
            println!("{e:?}");
        }
        Err(_) => panic!("Should not return any error other than NlError"),
    };
    Ok(())
}