net: loopback device

This commit is contained in:
Matheus
2024-04-09 22:24:03 -03:00
parent ee3e9a9da9
commit a79b6240ed
5 changed files with 72 additions and 3 deletions
+6 -3
View File
@@ -168,9 +168,11 @@ int ipv4_sendpacket(void *buffer, size_t packetsize, uint32_t ip, int proto, net
if (entry.netdev == NULL)
return 0; // if a packet can't be routed to anywhere just pretend it was sent somewhere
int error = arp_lookup(entry.netdev, entry.gateway ? entry.gateway : ip, &mac);
if (error)
return error;
if (entry.netdev->doarp) {
int error = arp_lookup(entry.netdev, entry.gateway ? entry.gateway : ip, &mac);
if (error)
return error;
}
netdev = entry.netdev;
} else {
@@ -207,4 +209,5 @@ void ipv4_init() {
MUTEX_INIT(&routingtablelock);
routingtable = alloc(sizeof(routingentry_t));
__assert(routingtable);
__assert(ipv4_addroute(loopback_device(), 0x7f000001, 0, 0xff000000, 10000) == 0);
}