From 96b10b2d6ee92e884fa34924358f158c55afb101 Mon Sep 17 00:00:00 2001 From: Sunil Nimmagadda Date: Thu, 12 Dec 2024 15:24:05 +0530 Subject: Join VRRP multicast group. --- src/main.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index bc1e6a8..ed61942 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use socket2::{Domain, Protocol, Socket, Type}; +use std::net::Ipv4Addr; struct Init; struct Master; @@ -41,8 +42,16 @@ fn run() { fn main() { let res = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::from(112))); - let Ok(_sock) = res else { + let Ok(sock) = res else { eprintln!("Socket::new(): {}", res.err().unwrap()); std::process::exit(1); }; + let res = sock.join_multicast_v4( + &Ipv4Addr::new(224, 0, 0, 18), + &Ipv4Addr::UNSPECIFIED, + ); + let Ok(_) = res else { + eprintln!("join_multicast_v4(): {}", res.err().unwrap()); + std::process::exit(1); + }; } -- cgit v1.2.3