socket_set.rs 515 B

12345678910111213141516171819202122232425
  1. use super::netdev::AnyNetDevice;
  2. use alloc::{collections::BTreeSet, sync::Arc};
  3. use core::marker::PhantomData;
  4. use smoltcp::{iface::SocketHandle, socket::AnySocket, wire::IpAddress};
  5. pub struct BoundSocket {
  6. address: IpAddress,
  7. port: u16,
  8. handle: SocketHandle,
  9. net_device: Arc<dyn AnyNetDevice>,
  10. }
  11. pub enum Socket {
  12. Unbound,
  13. Bound(Arc<BoundSocket>),
  14. }
  15. pub struct SocketSet<T>
  16. where
  17. T: for<'a> AnySocket<'a>,
  18. {
  19. sockets: BTreeSet<Arc<BoundSocket>>,
  20. _phantom: PhantomData<T>,
  21. }