#include "netdev.h" #include "net_sys.h" #include #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); }