1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#[macro_use]
extern crate bitflags;
extern crate byteorder;
extern crate libc;
use std::io;
mod netlink;
use netlink::Socket;
pub type Error = io::Error;
const NAME: &str = "IPVS";
#[derive(Debug)]
pub struct Client {
sock: Socket,
family: i32,
}
impl Client {
pub fn new() -> Result<Client, Error> {
let mut sock = Socket::new()?;
let family = sock.resolve_family(NAME)?;
let client = Client { sock, family };
Ok(client)
}
pub fn family(&self) -> i32 {
self.family
}
pub fn flush(&mut self) -> Result<(), Error> {
self.sock.send(netlink::FlushFrame)
}
}