-
Notifications
You must be signed in to change notification settings - Fork 24
feat(net): add netlink route support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| use alloc::vec; | ||
| use core::task::Waker; | ||
| use core::{net::Ipv4Addr, task::Waker}; | ||
|
|
||
| use axpoll::PollSet; | ||
| use smoltcp::{ | ||
|
|
@@ -10,20 +10,22 @@ use smoltcp::{ | |
|
|
||
| use crate::{ | ||
| consts::{SOCKET_BUFFER_SIZE, STANDARD_MTU}, | ||
| device::Device, | ||
| device::{Device, DeviceFlags, DeviceType}, | ||
| }; | ||
|
|
||
| pub struct LoopbackDevice { | ||
| index: u32, | ||
| buffer: PacketBuffer<'static, ()>, | ||
| poll: PollSet, | ||
| } | ||
| impl LoopbackDevice { | ||
| pub fn new() -> Self { | ||
| pub fn new(index: u32) -> Self { | ||
| let buffer = PacketBuffer::new( | ||
| vec![PacketMetadata::EMPTY; SOCKET_BUFFER_SIZE], | ||
| vec![0u8; STANDARD_MTU * SOCKET_BUFFER_SIZE], | ||
| ); | ||
| Self { | ||
| index, | ||
| buffer, | ||
| poll: PollSet::new(), | ||
| } | ||
|
|
@@ -35,6 +37,26 @@ impl Device for LoopbackDevice { | |
| "lo" | ||
| } | ||
|
|
||
| fn get_type(&self) -> DeviceType { | ||
| DeviceType::LOOPBACK | ||
| } | ||
|
|
||
| fn get_flags(&self) -> DeviceFlags { | ||
| DeviceFlags::UP | DeviceFlags::LOOPBACK | DeviceFlags::RUNNING | ||
| } | ||
|
|
||
| fn get_index(&self) -> u32 { | ||
| self.index | ||
| } | ||
|
|
||
| fn ipv4_addr(&self) -> Option<Ipv4Addr> { | ||
| Some(Ipv4Addr::new(127, 0, 0, 1)) | ||
| } | ||
|
Comment on lines
+52
to
+54
|
||
|
|
||
| fn prefix_len(&self) -> Option<u8> { | ||
| Some(8) | ||
| } | ||
|
|
||
| fn recv(&mut self, buffer: &mut PacketBuffer<()>, _timestamp: Instant) -> bool { | ||
| self.buffer.dequeue().ok().is_some_and(|(_, rx_buf)| { | ||
| buffer | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_newwithoutcreatecurrently returnsVfsError::AlreadyExists, which implies the path exists even though this is just an invalid/meaningless flag combination (POSIX treatsO_EXCLas only meaningful withO_CREAT). ReturningInvalidInput(or implicitly enablingcreatewhencreate_newis set) would be more accurate.