eth: process function

This commit is contained in:
Matheus
2024-03-30 18:40:25 -03:00
parent 52ab80bc9a
commit 0a96bcf68d
4 changed files with 48 additions and 13 deletions
+29
View File
@@ -0,0 +1,29 @@
#include <kernel/net.h>
#include <kernel/eth.h>
#include <logging.h>
// runs on dpc context, called by the individual driver dpcs on a receive.
void eth_process(netdev_t *netdev, void *buffer) {
ethframe_t *frame = buffer;
mac_t dst, src;
memcpy(&dst, &frame->destination, sizeof(mac_t));
memcpy(&src, &frame->source, sizeof(mac_t));
mac_t broadcast = NET_BROADCAST_MAC;
// check if packet is for our machine or a broadcast. if neither, do nothing
if (!(MAC_EQUAL(&dst, &netdev->mac) || MAC_EQUAL(&dst, &broadcast)))
return;
printf("our machine!\n");
void *nextbuff = (void *)((uintptr_t)buffer + sizeof(ethframe_t));
switch (be_to_cpu_w(frame->type)) {
case ETH_PROTO_IP:
break;
case ETH_PROTO_ARP:
arp_process(netdev, nextbuff);
break;
}
}
+1
View File
@@ -1,4 +1,5 @@
#include <kernel/net.h>
#include <kernel/eth.h>
#include <arch/cpu.h>
#include <logging.h>