pub struct UdpRelay { /* private fields */ }Expand description
Relays non-DNS UDP traffic between the guest and the real network.
Each unique (guest_src, guest_dst) pair gets a host-side UDP socket
and a tokio relay task. The poll loop calls relay_outbound() to
send guest datagrams; response frames are injected directly into
rx_ring.
Implementations§
Source§impl UdpRelay
impl UdpRelay
Sourcepub fn new(
shared: Arc<SharedState>,
gateway_mac: [u8; 6],
guest_mac: [u8; 6],
tokio_handle: Handle,
) -> Self
pub fn new( shared: Arc<SharedState>, gateway_mac: [u8; 6], guest_mac: [u8; 6], tokio_handle: Handle, ) -> Self
Build a new UDP relay.
§Arguments
shared- Stack-wide shared state used to inject response frames intorx_ringand wake the poll thread.gateway_mac- MAC address stamped as the source on synthesized response frames.guest_mac- MAC address stamped as the destination on synthesized response frames.tokio_handle- Runtime the per-session relay tasks are spawned on.
Sourcepub fn relay_outbound(
&mut self,
frame: &[u8],
src: SocketAddr,
guest_dst: SocketAddr,
host_dst: SocketAddr,
)
pub fn relay_outbound( &mut self, frame: &[u8], src: SocketAddr, guest_dst: SocketAddr, host_dst: SocketAddr, )
Relay an outbound UDP datagram from the guest.
§Arguments
frame- Raw ethernet frame captured from the guest.src- Guest source address; keys the session and becomes the destination on response frames.guest_dst- Destination the guest wrote on the datagram. Retained as the session key and the source IP on replies.host_dst- Address the host socket actually connects to. Usually equal toguest_dst; the caller substitutes loopback whenguest_dstmatches the gateway IP.
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Remove expired sessions.
Auto Trait Implementations§
impl !RefUnwindSafe for UdpRelay
impl !UnwindSafe for UdpRelay
impl Freeze for UdpRelay
impl Send for UdpRelay
impl Sync for UdpRelay
impl Unpin for UdpRelay
impl UnsafeUnpin for UdpRelay
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more