feat: fleshed out handling a new connection

This commit is contained in:
Andrew Rioux
2023-09-02 16:58:25 -04:00
parent d7a0deba0c
commit cda6388596
6 changed files with 81 additions and 24 deletions

View File

@@ -328,7 +328,7 @@ impl<T: Activated> Interface<T> {
struct ListenHandler<'a, F>
where
F: Fn(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
F: FnMut(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
{
packet_handler: F,
break_on_fail: bool,
@@ -344,14 +344,14 @@ impl<T: NotListening> Interface<T> {
packet_count: i32,
) -> (Option<error::Error>, i32)
where
F: Fn(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
F: FnMut(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
{
unsafe extern "C" fn cback<F>(
user: *mut libc::c_void,
header: *const ffi::PktHeader,
data: *const u8,
) where
F: Fn(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
F: FnMut(&Interface<DevListening>, packets::EthernetPkt) -> error::Result<bool>,
{
let info = &mut *(user as *mut ListenHandler<F>);