Skip to content

Commit

Permalink
initialize basic socket
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-weqe committed Jun 21, 2024
1 parent 8632fcb commit 5c65f68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions holo-vrrp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ serde_with.workspace = true
tokio.workspace = true
tracing.workspace = true
yang2.workspace = true
socket2.workspace = true
capctl.workspace = true

holo-northbound = { path = "../holo-northbound" }
holo-protocol = { path = "../holo-protocol" }
Expand All @@ -41,3 +43,5 @@ workspace = true
[features]
default = []
testing = []


18 changes: 17 additions & 1 deletion holo-vrrp/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@
// SPDX-License-Identifier: MIT
//

// TODO
use libc::ETH_P_ALL;
use socket2::{Socket, Domain, Type, Protocol};
use capctl::caps;
use holo_utils::capabilities;

fn socket() -> Result<Socket, std::io::Error> {
let socket = capabilities::raise(|| {
Socket::new(
Domain::IPV4,
Type::RAW,
Some(Protocol::from(112))
)
})?;

socket.set_broadcast(true);
Ok(socket)
}

0 comments on commit 5c65f68

Please sign in to comment.