mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
eth: process function
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#define _ETH_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <kernel/net.h>
|
||||
|
||||
typedef struct {
|
||||
uint8_t destination[6];
|
||||
@@ -12,4 +13,6 @@ typedef struct {
|
||||
#define ETH_PROTO_IP 0x0800
|
||||
#define ETH_PROTO_ARP 0x0806
|
||||
|
||||
void eth_process(netdev_t *netdev, void *buffer);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <kernel/eth.h>
|
||||
#include <hashtable.h>
|
||||
#include <mutex.h>
|
||||
#include <event.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
void *address;
|
||||
@@ -19,22 +22,11 @@ typedef struct {
|
||||
typedef struct netdev_t {
|
||||
mac_t mac;
|
||||
size_t mtu;
|
||||
hashtable_t arpcache;
|
||||
int (*allocdesc)(size_t requestedsize, netdesc_t *desc);
|
||||
int (*sendpacket)(struct netdev_t *_internal, netdesc_t desc, mac_t targetmac, int proto);
|
||||
} netdev_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t hwtype;
|
||||
uint16_t protocoltype;
|
||||
uint8_t hwlen;
|
||||
uint8_t ptlen;
|
||||
uint16_t opcode;
|
||||
uint8_t srchw[6];
|
||||
uint8_t srcpt[4];
|
||||
uint8_t dsthw[6];
|
||||
uint8_t dstpt[4];
|
||||
} __attribute__((packed)) arpframe_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t version_length;
|
||||
uint8_t servicetype_ecn;
|
||||
@@ -55,10 +47,20 @@ typedef struct {
|
||||
uint16_t checksum;
|
||||
} __attribute__((packed)) udpframe_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t port;
|
||||
uint32_t addr;
|
||||
} ipv4addr_t;
|
||||
|
||||
#define NET_BROADCAST_MAC (mac_t){.address = {0xff,0xff,0xff,0xff,0xff,0xff}}
|
||||
|
||||
#define MAC_EQUAL(m1,m2) (memcmp(m1, m2, sizeof(mac_t)) == 0)
|
||||
|
||||
#define IPV4_PROTO_UDP 0x11
|
||||
|
||||
void arp_init();
|
||||
void udp_init();
|
||||
void arp_process(netdev_t *netdev, void *buffer);
|
||||
int udp_allocdesc(netdev_t *netdev, size_t requestedsize, netdesc_t *desc);
|
||||
int udp_sendpacket(netdev_t *netdev, netdesc_t desc, uint32_t ip, uint16_t srcport, uint16_t dstport);
|
||||
int ipv4_allocdesc(netdev_t *netdev, size_t requestedsize, netdesc_t *desc);
|
||||
|
||||
Reference in New Issue
Block a user