Add ARP tables and reply function
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user