Compare commits
No commits in common. "5950058c76d6b7a97bd9694c95380a3b8075464d" and "f3d4c79c0f52b296d9deb12cea7bdbd955442e8e" have entirely different histories.
5950058c76
...
f3d4c79c0f
20
src/main.rs
20
src/main.rs
@ -1,6 +1,4 @@
|
|||||||
use dhcproto::{
|
use dhcproto::{
|
||||||
Decodable,
|
|
||||||
Decoder,
|
|
||||||
Encodable,
|
Encodable,
|
||||||
Encoder,
|
Encoder,
|
||||||
v6::{
|
v6::{
|
||||||
@ -23,7 +21,7 @@ const DHCP_Relay_Agent_and_Server_port: u16 = 547;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let socket_addr = SocketAddrV6::new("fe80::e3cf:4290:9165:505d".parse().unwrap(), DHCP_Client_port, 0, scope_id);
|
let socket_addr = SocketAddrV6::new("::".parse().unwrap(), DHCP_Client_port, 0, scope_id);
|
||||||
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, scope_id);
|
||||||
@ -45,16 +43,8 @@ async fn main() {
|
|||||||
|
|
||||||
sock.send_to(&msg_buf, remote_addr).await.unwrap();
|
sock.send_to(&msg_buf, remote_addr).await.unwrap();
|
||||||
|
|
||||||
loop {
|
let mut buf = [0; 1024];
|
||||||
let mut recv_buf = [0; 1024];
|
let (len, recv_addr) = sock.recv_from(&mut buf).await.unwrap();
|
||||||
let (len, recv_addr) = sock.recv_from(&mut recv_buf).await.unwrap();
|
println!("{:?} bytes received from {:?}", len, recv_addr);
|
||||||
let recv_msg = Message::decode(&mut Decoder::new(&recv_buf)).unwrap();
|
println!("{}", &buf[..len].escape_ascii().to_string());
|
||||||
|
|
||||||
if recv_msg.xid() == msg.xid() {
|
|
||||||
println!("{:?} bytes received from {:?}", len, recv_addr);
|
|
||||||
println!("{}", &recv_buf[..len].escape_ascii().to_string());
|
|
||||||
println!("{}", &recv_msg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user