Skip to content

Commit 6bc7dc4

Browse files
committed
Add MINIMAL_RETRANS_DURATION_SECS constant
1 parent 06f863d commit 6bc7dc4

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

crates/lib-dhcp/src/constants.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
pub const DHCP_MAGIC_COOKIE_ARR: [u8; 4] = [99, 130, 83, 99];
2-
pub const DHCP_MINIMUM_LEGAL_MAX_MESSAGE_SIZE: u16 = 576;
3-
pub const DHCP_MAGIC_COOKIE: u32 = 1_669_485_411;
4-
pub const DHCP_MIN_MSG_SIZE: usize = 300;
5-
pub const DHCP_SERVER_PORT: u16 = 67;
6-
pub const DHCP_CLIENT_PORT: u16 = 68;
1+
pub const MINIMUM_LEGAL_MAX_MESSAGE_SIZE: u16 = 576;
2+
pub const MIN_MSG_SIZE: usize = 300;
3+
4+
pub const SERVER_PORT: u16 = 67;
5+
pub const CLIENT_PORT: u16 = 68;
6+
7+
pub const MAGIC_COOKIE_ARR: [u8; 4] = [99, 130, 83, 99];
8+
pub const MAGIC_COOKIE: u32 = 1_669_485_411;
9+
10+
pub const MINIMAL_RETRANS_DURATION_SECS: u32 = 60;
711

812
pub const HARDWARE_ADDR_TYPE_ETHERNET: u8 = 1;
913
pub const HARDWARE_ADDR_LEN_ETHERNET: u8 = 6;

crates/lib-dhcp/src/server/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl Server {
5050
// Wait until the socket is readable, this can produce a false positive
5151
socket.readable().await?;
5252

53-
let mut buf = [0u8; constants::DHCP_MINIMUM_LEGAL_MAX_MESSAGE_SIZE as usize];
53+
let mut buf = [0u8; constants::MINIMUM_LEGAL_MAX_MESSAGE_SIZE as usize];
5454
let (len, addr) = match socket.recv_from(&mut buf).await {
5555
Ok(result) => result,
5656
Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => {

crates/lib-dhcp/src/types/message.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Readable for Message {
141141
let file = buf.read_vec(128)?;
142142

143143
match buf.peekn::<4>() {
144-
Some(m) if m == constants::DHCP_MAGIC_COOKIE_ARR => buf.skipn(4)?,
144+
Some(m) if m == constants::MAGIC_COOKIE_ARR => buf.skipn(4)?,
145145
Some(_) => return Err(MessageError::BufferError(BufferError::InvalidData)),
146146
None => return Err(MessageError::BufferError(BufferError::BufTooShort)),
147147
};
@@ -198,7 +198,7 @@ impl Writeable for Message {
198198
n += self.file.write::<E>(buf)?;
199199

200200
// Write magic cookie
201-
n += buf.write(constants::DHCP_MAGIC_COOKIE_ARR);
201+
n += buf.write(constants::MAGIC_COOKIE_ARR);
202202

203203
n += self.options.write::<E>(buf)?;
204204

0 commit comments

Comments
 (0)