ProtocolStackManager

Struct ProtocolStackManager 

Source
pub struct ProtocolStackManager {
    stacks: RwLock<BTreeMap<SocketDomain, Arc<dyn ProtocolStack>>>,
}
Expand description

Protocol stack manager

Manages registered protocol stacks and routes packets to appropriate stacks.

Fields§

§stacks: RwLock<BTreeMap<SocketDomain, Arc<dyn ProtocolStack>>>

Registered protocol stacks by domain

Implementations§

Source§

impl ProtocolStackManager

Source

pub const fn new() -> Self

Create a new protocol stack manager

Source

pub fn register_stack(&self, stack: Arc<dyn ProtocolStack>)

Register a protocol stack

§Arguments
  • stack - Protocol stack implementation to register
§Example
let tcp_ip_stack = Arc::new(TcpIpStack::new());
protocol_stack_manager.register_stack(tcp_ip_stack);
Source

pub fn get_stack(&self, domain: SocketDomain) -> Option<Arc<dyn ProtocolStack>>

Get a protocol stack for a specific domain

§Arguments
  • domain - Socket domain (Inet, Inet6, etc.)
§Returns

The protocol stack for this domain, or None if not registered

Source

pub fn process_packet(&self, packet: &DevicePacket) -> Result<(), SocketError>

Process an incoming packet

Routes the packet to the appropriate protocol stack based on packet type.

§Arguments
  • packet - Raw packet from network device
§Errors

Returns an error if no protocol stack can handle the packet

Source

pub fn get_all_statistics(&self) -> Vec<(String, ProtocolStackStats)>

Get statistics for all protocol stacks

Trait Implementations§

Source§

impl Default for ProtocolStackManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for ProtocolStackManager

§

impl !RefUnwindSafe for ProtocolStackManager

§

impl Send for ProtocolStackManager

§

impl Sync for ProtocolStackManager

§

impl Unpin for ProtocolStackManager

§

impl !UnwindSafe for ProtocolStackManager

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.