/*#include "platform.h" #include "eth.h" #include "ip.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" /* ========================================================================== přišel ICMP datagram => odpovíme argument: len - complet length *buffer - pointer tu packet buffer */ void icmp (unsigned int len, unsigned char *buff) { unsigned int txbuf; struct ICMP_header *icmp; icmp = (struct ICMP_header *)&buff[34]; eth (buff); // vygenerujem ethernet hlavičku (výměna MAC adres) ip (buff); // vygenerujem ip hlavičku (výměna ip adres) icmp->ICMP_type = ICMP_REPLY; // odpovíme stejným typem icmp->ICMP_code = 0; icmp->ICMP_checksumByte += HTONS(ICMP_ECHO << 8); // kontrolní součet if (icmp->ICMP_checksumByte < HTONS(ICMP_ECHO<<8)) icmp->ICMP_checksumByte++; if (!nic_tx_alloc(&txbuf)) return; // zapíšeme buffer do ENC netbuf_wr_seek(txbuf, NB_SEEK_SET); netbuf_write(buff, len); netbuf_close(); nic_tx(len); // vyšleme buffer }