#[derive(Debug, Copy, Clone)]
pub enum AddressResolutionProtocolAddressConflictState
{
YetToSendProbe
{
send_first_probe_at: Seconds,
},
Probing
{
subsequent_probes_left_to_send: u8,
probe_interval: Seconds,
first_probe_sent_at: Seconds,
},
Announcing
{
first_probe_sent_at: Seconds,
subsequent_announcements_left_to_send: u8,
},
DefendingAddressConflict
{
last_conflicting_packet_acted_on_at: Seconds,
},
Conflicted,
}
impl AddressResolutionProtocolAddressConflictState
{
const PROBE_WAIT: Seconds = x;
const PROBE_MIN: Seconds = x;
const PROBE_MAX: Seconds = x;
const ANNOUNCE_WAIT: Seconds = x;
const DEFEND_INTERVAL: Seconds = x;
#[inline(always)]
pub(crate) fn progress(&mut self)
{
use self::AddressResolutionProtocolAddressConflictState::*;
match *self
{
YetToSendProbe { send_first_probe_at } =>
{
if send_first_probe_at >= Self::current_time()
{
AddressResolutionProtocolPacket::send_arp_probe(packet, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX);
let probe_interval = thrd_rng().range(XXXXXXXXXXXXXXXX);
*self = Probing
{
subsequent_probes_left_to_send: x,
probe_interval,
first_probe_sent_at: send_first_probe_at,
}
}
}
}
}
#[inline(always)]
pub(crate) fn internet_protocol_version_4_host_address_conflict(&mut self, packet: PacketBuffer, packet_processing: &PacketProcessing)
{
use self::AddressResolutionProtocolAddressConflictState::*;
match *self
{
YetToSendProbe { .. } => drop!(XXX, packet_processing, packet),
Probing { first_probe_sent_at, .. } =>
{
let current_time = Self::current_time();
if first_probe_sent_at + Self::ANNOUNCE_WAIT < current_time
{
*self = Conflicted;
}
}
Announcing { first_probe_sent_at } =>
{
let current_time = Self::current_time();
if first_probe_sent_at + Self::ANNOUNCE_WAIT < current_time
{
*self = Conflicted;
}
}
DefendingAddressConflict { ref mut last_conflicting_packet_acted_on_at } =>
{
let current_time = Self::current_time();
if *last_conflicting_packet_acted_on_at + Self::DEFEND_INTERVAL < current_time
{
*last_conflicting_packet_acted_on_at = current_time;
AddressResolutionProtocolPacket::send_arp_announcement(packet, XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX);
}
else
{
drop!(XXX, packet_processing, packet)
}
}
Conflicted => drop!(XXX, packet_processing, packet)
}
}
#[inline(always)]
fn current_time() -> Seconds
{
XXXX
}
}