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

📄 arp.c

📁 dsp 的内核编程在此呢
💻 C
字号:
/*---------------------------------------------------------- 
主要实现IP协议和ARP协议。当DSP接收到正确的以太网数据包以后,
调用check_packet函数处理。如果是ARP请求,则发送一个ARP应答;
如果是ARP应答,则把对方的IP地址和以太网地址放到ARP缓存中;
如果是IP包,则调用IP处理模块处理,接收数据。
-----------------------------------------------------------*/

#include "Ethernet.h"
#include "ARP.h"
#include "IP.h"
#include "TCP.h"

/*---------------- check_packe function works---------------------- 
  arp: CMPM *(databuf.ethernetpkt.protocol),#0x0608;
  make a judgement whether it is a ARP protocal CALL arp_process;
 -----------------------------------------------------------------*/
int arp_check_packet(EthernetPkt *pEthernet)
{
 if(pEthernet->Protocal==0x0608)
 {
    return 1;
 }
 else 
    return 0;  
}

int arp_process(EthernetPkt *pEthernet)
{
   /*--如果是ARP请求,则发送一个ARP应答.--*/
    //respond();     
   
   /*--如果是ARP应答,则把对方的IP地址和以太网地址放到ARP缓存中--*/
      
   /* arp_process:接收ARP请求后,封装好ARP数据报 */
   
    /*Ip: CMPM *(databuf.ethernet.protocol),#0x0008;
     判断协议类型是否为IP协议  CC ip_process,TC ; */
       
    /* 若为IP协议,调用IP协议处理模块 */
    
    /* ST #taskfree,*(task) ;设置空闲任务指针 B taskfree ;跳转到空闲任务 */
    
    /*--Ip: CMPM *(databuf.ethernet.protocol),#0x0008;判断协议类型是否为IP协议
  CC ip_process,TC ;若为IP协议,调用IP协议处理模块--*/

   if(ip_check_packet(pEthernet)==1)
   {
      ip_process(pEthernet);
      return;
   }
   else
   {
      return;
   }
   
   /* 调用send_packet函数完成发送

⌨️ 快捷键说明

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