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

📄 eth.c.bak

📁 CP2201和51单片机实现ARP ICMP IP UDP协议
💻 BAK
字号:
#include "ne2000.h"
#include "arp.h"
#include "ip.h"
#include "cp2200.h"
#include <stdio.h>
extern union NetNode xdata myNode;
void eth_send (INT8U xdata * outbuf,union ethernet_address_type  hwaddr,INT16U proto_cal, INT16U len)
{
   INT8U i;
   ethernet_head xdata * eth;
   eth=(ethernet_head xdata *)outbuf;
   for(i=0;i<6;i++)
     {
    	eth->sourcenodeid[i]=myNode.node.mac[i];
        eth->destnodeid[i]=hwaddr.bytes[i];
     }
   eth->protocal=proto_cal;
  /* printf ("\neth  send \n");
   for(i=0;i<len+14;i++)
		{ 
		   if((i%10)==0)
           printf ("\n");
           printf ("%.2x", (unsigned int)outbuf[i]); 
           printf (" ");  
		}*/
  CP220x_Send(outbuf, len+14);

}
void eth_rcve(const INT8U xdata * inbuf)
{
     INT16U protol;
	 INT8U i;
     ethernet_head xdata * eth;
	union ethernet_address_type xdata rx_hwaddr;
	eth=(ethernet_head xdata * )inbuf;
     protol=eth->protocal;
	 for(i=0;i<6;i++)
	 rx_hwaddr.bytes[i]=eth->sourcenodeid[i];
         /* printf ("\nrecevied  eth\n");
		    	for(i=0;i<num_bytes;i++)
			     { if((i%10)==0)
                    printf ("\n");
            	    printf ("%.2x", (unsigned int)inbuf[i]); 
           	        printf (" ");  } */

      printf ("\n%.4x\n", protol); 
     switch(protol)
           {
             case ARP_PACKET:
             arp_rcve(inbuf);
             break;
             case IP_PACKET:
             ip_rcve(inbuf,rx_hwaddr);
             break;
             default:
             break;
           }
}
   

⌨️ 快捷键说明

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