blob: 1177891168c8fc709d8a66c07aad92775c9c49d5 (
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
25
26
27
|
#include "netdev.h"
#include "net_sys.h"
#include <stdint.h>
#include "eth.h"
#include "inet.h"
#include "arp.h"
#include "ipv4.h"
void net_incoming(struct netdev *netdev, struct eth_hdr *hdr)
{
klog("frame incoming: type [0x%04x]",hdr->ethertype);
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);
}
|