File: error_packet.rs

package info (click to toggle)
rust-neli 0.7.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 484 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 768 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
22
23
use std::error::Error;

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

fn main() -> Result<(), Box<dyn Error>> {
    env_logger::init();

    // 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(e) => panic!("Should not return any error other than NlError: {e}"),
    };
    Ok(())
}