-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
385 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
mod medium; | ||
pub use medium::*; | ||
|
||
mod device; | ||
pub use device::*; | ||
|
||
mod addrs_storage; | ||
pub use addrs_storage::*; | ||
mod prelude; | ||
pub use prelude::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use auip_pkt::{layer2, layer3}; | ||
|
||
use crate::{Medium, Result}; | ||
|
||
pub trait Device { | ||
fn send(&mut self, buffer: &[u8]) -> Result<()>; | ||
|
||
fn recv(&mut self) -> Result<Option<&[u8]>>; | ||
|
||
fn medium(&self) -> Medium; | ||
} | ||
|
||
pub trait AddrsStorage { | ||
fn set_mac_addr(&mut self, addr: layer2::Address); | ||
|
||
fn mac_addr(&self) -> &layer2::Address; | ||
|
||
fn add_ip_addr(&mut self, addr: layer3::Cidr) -> Result<()>; | ||
|
||
fn del_ip_addr(&mut self, addr: layer3::Cidr); | ||
|
||
fn ip_addrs(&self) -> &[layer3::Cidr]; | ||
} | ||
|
||
pub trait Layer3PacketStorage { | ||
type Layer3PacketBytes; | ||
|
||
fn get(&self, idx: usize) -> Option<&layer3::Packet<Self::Layer3PacketBytes>>; | ||
|
||
fn get_mut(&mut self, idx: usize) -> Option<&mut layer3::Packet<Self::Layer3PacketBytes>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use auip_pkt::layer3; | ||
|
||
use crate::{FixedBytes, Layer3PacketStorage}; | ||
|
||
pub struct FixedLayer3PacketStorage<const MTU: usize, const LEN: usize> { | ||
pub packets: [layer3::Packet<FixedBytes<MTU>>; LEN], | ||
} | ||
|
||
impl<const MTU: usize, const LEN: usize> Layer3PacketStorage | ||
for FixedLayer3PacketStorage<MTU, LEN> | ||
{ | ||
type Layer3PacketBytes = FixedBytes<MTU>; | ||
|
||
fn get(&self, idx: usize) -> Option<&layer3::Packet<Self::Layer3PacketBytes>> { | ||
if self.packets.len() < idx { | ||
Some(&self.packets[idx]) | ||
} else { | ||
None | ||
} | ||
} | ||
|
||
fn get_mut(&mut self, idx: usize) -> Option<&mut layer3::Packet<Self::Layer3PacketBytes>> { | ||
if self.packets.len() < idx { | ||
Some(&mut self.packets[idx]) | ||
} else { | ||
None | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,10 @@ | ||
mod fixed_addrs; | ||
pub use fixed_addrs::*; | ||
|
||
#[cfg(feature = "alloc")] | ||
mod dynamic_addrs; | ||
#[cfg(feature = "alloc")] | ||
pub use dynamic_addrs::*; | ||
|
||
mod fixed_l3ps; | ||
pub use fixed_l3ps::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
pub struct FixedBytes<const LEN: usize>(pub [u8; LEN]); | ||
|
||
impl<const LEN: usize> AsRef<[u8]> for FixedBytes<LEN> { | ||
fn as_ref(&self) -> &[u8] { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl<const LEN: usize> AsMut<[u8]> for FixedBytes<LEN> { | ||
fn as_mut(&mut self) -> &mut [u8] { | ||
&mut self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.