blob: bc1e6a8dc37a0d884bb2bd686c72858525024019 (
plain)
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
43
44
45
46
47
48
|
use socket2::{Domain, Protocol, Socket, Type};
struct Init;
struct Master;
struct Backup;
impl Init {
fn new() -> Init {
Init {}
}
}
trait VRRPv2StateMachine {
fn next(&self) -> impl VRRPv2StateMachine;
}
impl VRRPv2StateMachine for Init {
fn next(&self) -> impl VRRPv2StateMachine {
Master {}
}
}
impl VRRPv2StateMachine for Master {
fn next(&self) -> impl VRRPv2StateMachine {
Backup {}
}
}
impl VRRPv2StateMachine for Backup {
fn next(&self) -> impl VRRPv2StateMachine {
Init {}
}
}
fn run() {
let sm = Init::new();
loop {
let _ = sm.next();
}
}
fn main() {
let res = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::from(112)));
let Ok(_sock) = res else {
eprintln!("Socket::new(): {}", res.err().unwrap());
std::process::exit(1);
};
}
|