blob: 69fd45f318356bb4b16036b3434216f3bf53f119 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <stdint.h>
#include "eth.h"
#include "inet.h"
#include "arp.h"
#include "ipv4.h"
#include "lib/string/string.h"
#include "netdev.h"
void net_incoming(struct netdev *netdev, struct eth_hdr *hdr)
{
if(hdr->ethertype==htons(ETH_P_ARP))arp_incoming(netdev,hdr);
if(hdr->ethertype==htons(ETH_P_IPV4))ipv4_incoming(netdev,hdr);
}
void netdev_transmit(struct netdev *dev, struct eth_hdr *hdr, uint16_t ethertype, int len, unsigned char *dst)
{
hdr->ethertype = htons(ethertype);
memcpy(hdr->smac, dev->hwaddr, 6);
memcpy(hdr->dmac, dst, 6);
len += sizeof(struct eth_hdr);
dev->transmit(hdr,len);
}
|