Wait for DHCP response with a matching transaction id
This commit is contained in:
parent
c613f7bc48
commit
5950058c76
18
src/main.rs
18
src/main.rs
@ -45,10 +45,16 @@ async fn main() {
|
||||
|
||||
sock.send_to(&msg_buf, remote_addr).await.unwrap();
|
||||
|
||||
let mut recv_buf = [0; 1024];
|
||||
let (len, recv_addr) = sock.recv_from(&mut recv_buf).await.unwrap();
|
||||
println!("{:?} bytes received from {:?}", len, recv_addr);
|
||||
println!("{}", &recv_buf[..len].escape_ascii().to_string());
|
||||
let recv_msg = Message::decode(&mut Decoder::new(&recv_buf)).unwrap();
|
||||
println!("{}", &recv_msg);
|
||||
loop {
|
||||
let mut recv_buf = [0; 1024];
|
||||
let (len, recv_addr) = sock.recv_from(&mut recv_buf).await.unwrap();
|
||||
let recv_msg = Message::decode(&mut Decoder::new(&recv_buf)).unwrap();
|
||||
|
||||
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