我有以下客户端 IPMI ping 程序:
pub fn ping(host: &String) -> Result<(), String> {
let socket = UdpSocket::bind("0.0.0.0:0").expect("Unable to bind to host");
let mut udp_payload: Vec<u8> = vec![];
// WRITE RMCP header
// WRITE ASF Ping header
let mut retry_count = 3;
while retry_count > 0 {
match socket.send_to(udp_payload.as_slice(), host) {
Ok(_) => trace!("Successfully sent ping packet"),
Err(_) => {
trace!("Unable to send ping packet retrying");
retry_count -= 1;
continue;
}
}
trace!("Sent ping pkt");
let mut buffer = [0u8; 1500];
match socket.recv_from(&mut buffer) {
Ok((amt, source)) => {
trace!("Got {} a pong response from {}", amt, source);
// Verify RMCP and ASF Pong headers
return Ok(());
}
Err(err) => {
trace!("Did not receive a Pong response, so retrying {}", err);
retry_count = retry_count - 1;
continue;
}
}
}
Err(format!("IPMI ping failed"))
}
我在运行上述功能时进行了数据包捕获。我看到正在发送 ping 数据包并从服务器接收到 pong 响应,但该recv_from
函数永远不会返回。