use net_types::ip::{Ipv4, Ipv6};
use netstack3_base::{
AnyDevice, CounterContext, DeviceIdContext, InstantBindingsTypes, ReferenceNotifiers,
RngContext, TimerBindingsTypes, TracingContext,
};
use netstack3_datagram as datagram;
use netstack3_device::ethernet::{EthernetDeviceId, EthernetLinkDevice, EthernetWeakDeviceId};
use netstack3_device::{self as device, DeviceId, DeviceLayerTypes, WeakDeviceId};
use netstack3_filter::{FilterBindingsContext, FilterBindingsTypes};
use netstack3_icmp_echo::{IcmpEchoBindingsContext, IcmpEchoBindingsTypes, IcmpEchoStateContext};
use netstack3_ip::device::{
IpDeviceBindingsContext, IpDeviceConfigurationContext, IpDeviceConfigurationHandler,
IpDeviceIpExt,
};
use netstack3_ip::icmp::{IcmpBindingsContext, IcmpBindingsTypes};
use netstack3_ip::multicast_forwarding::{
MulticastForwardingBindingsContext, MulticastForwardingBindingsTypes,
MulticastForwardingStateContext,
};
use netstack3_ip::nud::{NudBindingsContext, NudContext};
use netstack3_ip::raw::{
RawIpSocketMapContext, RawIpSocketStateContext, RawIpSocketsBindingsContext,
RawIpSocketsBindingsTypes,
};
use netstack3_ip::socket::IpSocketContext;
use netstack3_ip::{self as ip, IpLayerBindingsContext, IpLayerContext, IpLayerIpExt};
use netstack3_tcp::{self as tcp, TcpBindingsContext, TcpBindingsTypes, TcpContext};
use netstack3_udp::{self as udp, UdpBindingsContext, UdpBindingsTypes, UdpCounters};
use crate::TimerId;
pub trait IpExt: BaseIpExt + datagram::DualStackIpExt<OtherVersion: BaseIpExt> {}
impl<I> IpExt for I where I: BaseIpExt + datagram::DualStackIpExt<OtherVersion: BaseIpExt> {}
pub trait BaseIpExt:
IpLayerIpExt
+ IpDeviceIpExt
+ netstack3_base::IcmpIpExt
+ ip::device::IpDeviceIpExt
+ tcp::DualStackIpExt
+ datagram::DualStackIpExt
{
}
impl<I> BaseIpExt for I where
I: ip::IpLayerIpExt
+ IpDeviceIpExt
+ netstack3_base::IcmpIpExt
+ ip::device::IpDeviceIpExt
+ tcp::DualStackIpExt
+ datagram::DualStackIpExt
{
}
pub trait CoreContext<I, BC>:
udp::StateContext<I, BC>
+ CounterContext<UdpCounters<I>>
+ TcpContext<I, BC>
+ IcmpEchoStateContext<I, BC>
+ ip::icmp::IcmpStateContext
+ IpLayerContext<I, BC>
+ NudContext<I, EthernetLinkDevice, BC>
+ IpDeviceConfigurationContext<I, BC>
+ IpDeviceConfigurationHandler<I, BC>
+ IpSocketContext<I, BC>
+ DeviceIdContext<AnyDevice, DeviceId = DeviceId<BC>, WeakDeviceId = WeakDeviceId<BC>>
+ DeviceIdContext<
EthernetLinkDevice,
DeviceId = EthernetDeviceId<BC>,
WeakDeviceId = EthernetWeakDeviceId<BC>,
> + RawIpSocketMapContext<I, BC>
+ RawIpSocketStateContext<I, BC>
+ MulticastForwardingStateContext<I, BC>
where
I: IpExt,
BC: IpBindingsContext<I>,
{
}
impl<I, BC, O> CoreContext<I, BC> for O
where
I: IpExt,
BC: IpBindingsContext<I>,
O: udp::StateContext<I, BC>
+ CounterContext<UdpCounters<I>>
+ TcpContext<I, BC>
+ IcmpEchoStateContext<I, BC>
+ ip::icmp::IcmpStateContext
+ IpLayerContext<I, BC>
+ NudContext<I, EthernetLinkDevice, BC>
+ IpDeviceConfigurationContext<I, BC>
+ IpDeviceConfigurationHandler<I, BC>
+ IpSocketContext<I, BC>
+ DeviceIdContext<AnyDevice, DeviceId = DeviceId<BC>, WeakDeviceId = WeakDeviceId<BC>>
+ DeviceIdContext<
EthernetLinkDevice,
DeviceId = EthernetDeviceId<BC>,
WeakDeviceId = EthernetWeakDeviceId<BC>,
> + RawIpSocketMapContext<I, BC>
+ RawIpSocketStateContext<I, BC>
+ MulticastForwardingStateContext<I, BC>,
{
}
pub trait BindingsTypes:
InstantBindingsTypes
+ DeviceLayerTypes
+ TcpBindingsTypes
+ FilterBindingsTypes
+ IcmpEchoBindingsTypes
+ IcmpBindingsTypes
+ MulticastForwardingBindingsTypes
+ RawIpSocketsBindingsTypes
+ UdpBindingsTypes
+ TimerBindingsTypes<DispatchId = TimerId<Self>>
{
}
impl<O> BindingsTypes for O where
O: InstantBindingsTypes
+ DeviceLayerTypes
+ TcpBindingsTypes
+ FilterBindingsTypes
+ IcmpEchoBindingsTypes
+ IcmpBindingsTypes
+ MulticastForwardingBindingsTypes
+ RawIpSocketsBindingsTypes
+ UdpBindingsTypes
+ TimerBindingsTypes<DispatchId = TimerId<Self>>
{
}
pub trait IpBindingsContext<I: IpExt>:
BindingsTypes
+ RngContext
+ UdpBindingsContext<I, DeviceId<Self>>
+ TcpBindingsContext
+ FilterBindingsContext
+ IcmpBindingsContext
+ IcmpEchoBindingsContext<I, DeviceId<Self>>
+ MulticastForwardingBindingsContext<I, DeviceId<Self>>
+ RawIpSocketsBindingsContext<I, DeviceId<Self>>
+ IpDeviceBindingsContext<I, DeviceId<Self>>
+ IpLayerBindingsContext<I, DeviceId<Self>>
+ NudBindingsContext<I, EthernetLinkDevice, EthernetDeviceId<Self>>
+ device::DeviceLayerEventDispatcher
+ device::socket::DeviceSocketBindingsContext<DeviceId<Self>>
+ ReferenceNotifiers
+ TracingContext
+ 'static
{
}
impl<I, BC> IpBindingsContext<I> for BC
where
I: IpExt,
BC: BindingsTypes
+ RngContext
+ UdpBindingsContext<I, DeviceId<Self>>
+ TcpBindingsContext
+ FilterBindingsContext
+ IcmpBindingsContext
+ IcmpEchoBindingsContext<I, DeviceId<Self>>
+ MulticastForwardingBindingsContext<I, DeviceId<Self>>
+ RawIpSocketsBindingsContext<I, DeviceId<Self>>
+ IpDeviceBindingsContext<I, DeviceId<Self>>
+ IpLayerBindingsContext<I, DeviceId<Self>>
+ NudBindingsContext<I, EthernetLinkDevice, EthernetDeviceId<Self>>
+ device::DeviceLayerEventDispatcher
+ device::socket::DeviceSocketBindingsContext<DeviceId<Self>>
+ ReferenceNotifiers
+ TracingContext
+ 'static,
{
}
pub trait BindingsContext: IpBindingsContext<Ipv4> + IpBindingsContext<Ipv6> {}
impl<BC> BindingsContext for BC where BC: IpBindingsContext<Ipv4> + IpBindingsContext<Ipv6> {}