Compare commits

...

4 Commits

Author SHA1 Message Date
57e94d576a Remove obsolete scope_id constant 2024-08-24 14:42:01 +02:00
8f9895bfaa Remove unused constant 2024-08-24 14:41:13 +02:00
4857491882 Make constants uppercase 2024-08-24 14:40:49 +02:00
c061b83d09 Remove unnecessary mutable 2024-08-24 14:37:50 +02:00

View File

@ -19,12 +19,9 @@ use std::{
}; };
use tokio::net::UdpSocket; use tokio::net::UdpSocket;
const scope_id: u32 = 15; const ALL_DHCP_RELAY_AGENTS_AND_SERVERS: &str = "ff02::1:2";
const duid: [u8; 4] = [0x13, 0x37, 0x23, 0x42]; const DHCP_CLIENT_PORT: u16 = 546;
const DHCP_RELAY_AGENT_AND_SERVER_PORT: u16 = 547;
const All_DHCP_Relay_Agents_and_Servers: &str = "ff02::1:2";
const DHCP_Client_port: u16 = 546;
const DHCP_Relay_Agent_and_Server_port: u16 = 547;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
@ -52,13 +49,13 @@ async fn main() {
let selected_address = ipv6_link_local_addresses.next() let selected_address = ipv6_link_local_addresses.next()
.expect("No IPv6 link local address assigned to this interface"); .expect("No IPv6 link local address assigned to this interface");
let socket_addr = SocketAddrV6::new(selected_address.ip(), DHCP_Client_port, 0, selected_interface.index.clone()); let socket_addr = SocketAddrV6::new(selected_address.ip(), DHCP_CLIENT_PORT, 0, selected_interface.index.clone());
let sock = UdpSocket::bind(socket_addr).await.unwrap(); let sock = UdpSocket::bind(socket_addr).await.unwrap();
let remote_addr = SocketAddrV6::new(All_DHCP_Relay_Agents_and_Servers.parse().unwrap(), DHCP_Relay_Agent_and_Server_port, 0, scope_id); let remote_addr = SocketAddrV6::new(ALL_DHCP_RELAY_AGENTS_AND_SERVERS.parse().unwrap(), DHCP_RELAY_AGENT_AND_SERVER_PORT, 0, selected_interface.index.clone());
let mut msg = Message::new(MessageType::InformationRequest); let mut msg = Message::new(MessageType::InformationRequest);
let mut msg_opts = msg.opts_mut(); let msg_opts = msg.opts_mut();
//msg_opts.insert(DhcpOption::ClientId(Vec::from(duid))); //msg_opts.insert(DhcpOption::ClientId(Vec::from(duid)));
msg_opts.insert(DhcpOption::ElapsedTime(0)); msg_opts.insert(DhcpOption::ElapsedTime(0));
msg_opts.insert(DhcpOption::ORO(ORO { opts: vec![ msg_opts.insert(DhcpOption::ORO(ORO { opts: vec![