#[derive(Debug)]
pub struct AddressResolutionPacketProcessing<EINPDO: EthernetIncomingNetworkPacketDropObserver>
{
dropped_packet_reporting: Rc<EINPDO>,
our_valid_internet_protocol_version_4_host_addresses: Rc<OurValidInternetProtocolVersion4HostAddresses>,
}
impl<EINPDO: EthernetIncomingNetworkPacketDropObserver<ARPINPDR=AddressResolutionProtocolIncomingNetworkPacketDropReason>> Layer3PacketProcessing for AddressResolutionPacketProcessing<EINPDO>
{
type DropReason = AddressResolutionProtocolIncomingNetworkPacketDropReason;
type CheckSumsValidated = ();
#[inline(always)]
fn process<'lifetime>(&self, now: MonotonicMillisecondTimestamp, packet: impl EthernetIncomingNetworkPacket, layer_3_packet: &'lifetime Layer3Packet, layer_3_length: u16, ethernet_addresses: &'lifetime EthernetAddresses, _check_sum_validated_in_hardware: Self::CheckSumsValidated)
{
if unlikely!(AddressResolutionProtocolPacket::is_packet_length_too_short(layer_3_length))
{
drop!(now, PacketIsTooShort, ethernet_addresses, self, packet)
}
let address_resolution_protocol_packet: &'lifetime AddressResolutionProtocolPacket = layer_3_packet.as_type();
address_resolution_protocol_packet.process(now, packet, self, layer_3_length, ethernet_addresses)
}
}
impl<EINPDO: EthernetIncomingNetworkPacketDropObserver<ARPINPDR=AddressResolutionProtocolIncomingNetworkPacketDropReason>> AddressResolutionPacketProcessing<EINPDO>
{
#[inline(always)]
pub(crate) fn drop<'lifetime>(&self, now: MonotonicMillisecondTimestamp, reason: EINPDO::ARPINPDR, ethernet_addresses: &'lifetime EthernetAddresses, packet: impl EthernetIncomingNetworkPacket)
{
let reason = EthernetIncomingNetworkPacketDropReason::ProblematicAddressResolutionProtocolPacket
{
now,
ethernet_addresses,
reason,
};
self.dropped_packet_reporting.dropped_packet(reason);
packet.free_direct_contiguous_packet();
}
}
impl<EINPDO: EthernetIncomingNetworkPacketDropObserver> AddressResolutionPacketProcessing<EINPDO>
{
#[inline(always)]
pub(crate) fn is_internet_protocol_version_4_host_address_one_of_ours(&self, internet_protocol_version_4_host_address: InternetProtocolVersion4HostAddress) -> bool
{
self.our_valid_internet_protocol_version_4_host_addresses.is_internet_protocol_version_4_host_address_one_of_ours(internet_protocol_version_4_host_address)
}
#[inline(always)]
pub(crate) fn reply_to_probe<'ethernet_addresses>(&self, _packet: impl EthernetIncomingNetworkPacket, _ethernet_addresses: &'ethernet_addresses EthernetAddresses)
{
arp_unsupported!("replies to probes are not supported");
}
#[inline(always)]
pub(crate) fn reply_to_broadcast<'ethernet_addresses>(&self, _packet: impl EthernetIncomingNetworkPacket, _ethernet_addresses: &'ethernet_addresses EthernetAddresses)
{
arp_unsupported!("replies to broadcasts are not supported");
}
#[inline(always)]
pub(crate) fn add_to_address_resolution_cache(&self, _sender_hardware_address: &MediaAccessControlAddress, _sender_protocol_address: InternetProtocolVersion4HostAddress, packet: impl EthernetIncomingNetworkPacket)
{
arp_unsupported!("adding to resolution cache");
packet.free_direct_contiguous_packet();
}
#[inline(always)]
pub(crate) fn internet_protocol_version_4_host_address_conflict<'ethernet_addresses>(&self, _packet: impl EthernetIncomingNetworkPacket, _ethernet_addresses: &'ethernet_addresses EthernetAddresses)
{
arp_unsupported!("host address conflict");
}
}