Skip to content

Commit d8c1428

Browse files
feat(kernel): make DNS resolution work properly
* Add the loopback device * Create the /etc/resolv.conf file, where the entry is the default SLIRP DNS server address. * Add sock_send() for Unix sockets. * On socket(), create the inode with name <{type}_socket> instead of just <socket> which makes debugging easier. * Add some assertions that I will deal with later :) Signed-off-by: Anhad Singh <[email protected]>
1 parent e9077a0 commit d8c1428

File tree

12 files changed

+195
-73
lines changed

12 files changed

+195
-73
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ $ lldb
3636
(lldb)
3737
````
3838

39-
Check out the docs for your debugger for information about how to use the debugger.
39+
Check out the docs for your debugger for information about how to use the debugger.
40+
41+
`./aero.py -- -netdev user,id=spider -device e1000,netdev=spider,id=ck_nic0 -object filter-dump,id=spider,netdev=spider,file=qemulog.log`

base-files/etc/resolv.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nameserver 10.0.2.3

src/Cargo.lock

Lines changed: 48 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/aero_kernel/src/net/arp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ impl Cache {
7676
}
7777

7878
fn request(&mut self, ip: Ipv4Addr, packet: RawPacket) {
79+
if ip == Ipv4Addr::LOOPBACK {
80+
panic!()
81+
}
82+
7983
if self.0.get_mut(&ip).is_some() {
8084
todo!()
8185
} else {

src/aero_kernel/src/net/loopback.rs

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (C) 2021-2023 The Aero Project Developers.
2+
//
3+
// This file is part of The Aero Project.
4+
//
5+
// Aero is free software: you can redistribute it and/or modify
6+
// it under the terms of the GNU General Public License as published by
7+
// the Free Software Foundation, either version 3 of the License, or
8+
// (at your option) any later version.
9+
//
10+
// Aero is distributed in the hope that it will be useful,
11+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
// GNU General Public License for more details.
14+
//
15+
// You should have received a copy of the GNU General Public License
16+
// along with Aero. If not, see <https://www.gnu.org/licenses/>.
17+
18+
//! Loopback device.
19+
20+
use alloc::boxed::Box;
21+
use alloc::sync::Arc;
22+
use crabnet::data_link::MacAddr;
23+
use crabnet::network::Ipv4Addr;
24+
25+
use crate::utils::dma::DmaAllocator;
26+
27+
use super::{NetworkDevice, NetworkDriver, RecvPacket};
28+
29+
pub struct Loopback;
30+
31+
impl NetworkDriver for Loopback {
32+
fn send(&self, _packet: Box<[u8], DmaAllocator>) {
33+
todo!()
34+
}
35+
36+
fn recv(&self) -> RecvPacket {
37+
todo!()
38+
}
39+
40+
fn recv_end(&self, _packet_id: usize) {
41+
todo!()
42+
}
43+
44+
#[inline]
45+
fn mac(&self) -> MacAddr {
46+
// TODO: What should this really be?
47+
MacAddr::NULL
48+
}
49+
}
50+
51+
lazy_static::lazy_static! {
52+
pub static ref LOOPBACK: Arc<NetworkDevice> = (|| {
53+
let device = Arc::new(NetworkDevice::new(Arc::new(Loopback)));
54+
55+
device.set_ip(Ipv4Addr::LOOPBACK);
56+
device.set_subnet_mask(Ipv4Addr::new(255, 0, 0, 0));
57+
58+
device
59+
})();
60+
}

0 commit comments

Comments
 (0)