Add ARP tables and reply function

This commit is contained in:
Mark
2020-03-20 12:52:30 +02:00
parent 1be037f3c6
commit 425dbdc114
8 changed files with 108 additions and 2 deletions
+3
View File
@@ -4,6 +4,9 @@
#define ARP_H_ETH 1
#define ARP_P_IP 0x0800
#define ARP_OP_REQUEST 1
#define ARP_OP_REPLY 2
struct arp_frame {
uint16_t htype;
uint16_t ptype;
+3
View File
@@ -11,5 +11,8 @@ struct eth_frame {
uint16_t ethertype;
} __attribute__((packed));
struct netdev;
struct packet;
void eth_handle_frame(struct packet *p);
int eth_send_wrapped(struct netdev *src, const uint8_t *dst, uint16_t et, void *data, size_t len);
+3 -1
View File
@@ -6,6 +6,7 @@
#define IF_T_ETH 1
struct netdev;
struct arp_ent;
typedef int (*netdev_send_func_t) (struct netdev *, const void *, size_t);
@@ -17,7 +18,8 @@ struct netdev {
uint32_t flags;
int type;
// TODO: arp table here?
// ARP entry list
struct arp_ent *arp_ent_head;
netdev_send_func_t send;
+8
View File
@@ -9,6 +9,14 @@
void strmac(char *dst, const uint8_t *hw);
static inline uint32_t ntohl(uint32_t w) {
uint8_t *s = (uint8_t *)&w;
return (uint32_t) (s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
}
static inline uint16_t ntohs(uint16_t w) {
return (w >> 8) | (w << 8);
}
static inline uint16_t htons(uint16_t w) {
return (w >> 8) | (w << 8);
}