⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icmp.c

📁 Pic Nic 16f877/18f452控制 rtl8019as 原代码
💻 C
字号:
/*
 * icmp.c
 *
 * ICMP Response Routines
 *
 */

void icmpResponse() {

   int16 prev_chksum;
   int8 i, j;

   //Prepare Ethernet Packet
   load_ethernet_header();   // Load MAC source and destination addresses

   //Prepare IP header and send it to the NIC
   load_IP_header(60, ICMP); // load IP header
   chksum=0;

   //Write the ICMP Type in the NIC transmit Buffer
   outportw(NIC_DATA, (int16)icmp_code);  // Type = 0 (echo reply)

   //Compute Checksum and write it to NIC
   calc_chksum (icmp_identifier);
   calc_chksum (icmp_sequence);

   for (i=0; i<32; i+=2) {
      calc_chksum (make16(Buffer[i],Buffer[i+1]));
   }

   outportw(NIC_DATA, ~chksum);

   //Write final details to nic and send the icmp answer
   outportw(NIC_DATA,icmp_identifier);
   outportw(NIC_DATA,icmp_sequence);

   writeNicTxBuffer(Buffer, 32);
   sendPacket(74);

   lcd_pos_xy(16,1);
   printf(lcd_escreve, "I");

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -