/*#include "platform.h" #include "arp.h" #include "enc28j60.h" #include "eth.h"*/ #include "platform.h" #include "eth.h" #include "enc28j60.h" #include "ap.h" #include "arp.h" #include "icmp.h" #include "ip.h" #include "udp.h" #include "stdlib.h" #include "globals.h" /* ========================================================================== Receive ARP packet and send response */ void arp (unsigned int len, unsigned char *buff) { unsigned char a; unsigned int txbuf; struct ARP_header *arp; arp = (struct ARP_header *)&buff[21]; if ((Checkbroadcast() || Checkmymac() ) && Check_my_ip_arp()) { // check broadcast MAC and my IP eth(buff); // create response arp->Opcode = OP_REPLY; for (a = 0; a < 6; a++) { // swap arp_mac address arp->ARP_destMac[a] = arp->ARP_sourceMac[a]; arp->ARP_sourceMac[a] = mymac[a]; } for (a = 0; a < 4; a++) { // swap arp_ip address arp->ARP_destIp[a] = arp->ARP_sourceIp[a]; arp->ARP_sourceIp[a] = myip[a]; } if (!nic_tx_alloc(&txbuf)) return; // write buffer to chip netbuf_wr_seek(txbuf, NB_SEEK_SET); netbuf_write(buff, len); netbuf_close(); nic_tx(len); // send //uart_send("vyslan ARP paket"); } } /* ========================================================================== Check my IP address in ARP packet */ unsigned char Check_my_ip_arp (void) { if (buffer[38] == myip[0] && buffer[39] == myip[1] && buffer[40] == myip[2] && buffer[41] == myip[3]) { return 1; } return 0; }