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

📄 tftpmain.c

📁 本软件是ARMSYS44B0-P开发板的自举程序(BOIS)
💻 C
字号:
/****************************************************************
 *		ARMSYS7 S3C44B0X developer's notes						*  
 ****************************************************************

 1. 2005.5.17::
 
 ***************************************************************/

#include "..\inc\config.h"
#include "..\inc\utils.h"
#include "..\inc\board.h"
#include "..\inc\tftp\skbuff.h"
#include "..\inc\tftp\eth.h"
#include "..\inc\tftp\ip.h"
#include "..\inc\tftp\udp.h"
#include "..\inc\tftp\arp.h"


#ifdef	TFTP_DOWNLOAD_SUPPORT

char TftpLoadEnd;
char TftpPutBegin;
char TftpPutMark;

int net_handle(void)
{
	struct sk_buff *skb;
	struct ethhdr *eth_hdr;		
	
	skb = alloc_skb(ETH_FRAME_LEN);

	if (eth_rcv(skb) != -1) 
	{

		eth_hdr = (struct ethhdr *)(skb->data);					
		skb_pull(skb, ETH_HLEN);

		if (ntohs(eth_hdr->h_proto) == ETH_P_ARP)
			arp_rcv_packet(skb);

		else if(ntohs(eth_hdr->h_proto) == ETH_P_IP)						
		 	ip_rcv_packet(skb);
	 	
	}

	free_skb(skb);

	return 0;
}

//#include "params.h"

void tftp_main(U32 addr, U32 give_ip)
{
	unsigned char eth_addr[ETH_ALEN];
	unsigned char *s = (unsigned char *)&give_ip;
	int i=0;	
	
	printf("Mini TFTP Server 1.1 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);		
	printf("Example: tftp -i %d.%d.%d.%d put filename at the host PC\n", s[3], s[2], s[1], s[0]);
	puts("Press ESC key to exit\n");

	eth_init();
	if(eth_lnk_stat())
		return;
		
	eth_get_addr(eth_addr);		
//	arp_init();
	ip_init(give_ip);
	udp_init();
		
	arp_add_entry(eth_addr, give_ip);	

	TftpLoadEnd  = 0;
	TftpPutMark  = 0;
	TftpPutBegin = 0;
	
	while ((getkey()!=ESC_KEY)&&!TftpLoadEnd) 
	{		
		net_handle();
		if(TftpPutBegin) 
		{
			puts("Starting the TFTP download...\n");
			TftpPutBegin = 0;
		}
		if(TftpPutMark) 
		{
			//putch('.');
			printf("%3d,",i++);
			TftpPutMark = 0;
			if((i%10)==0)
				printf("\n");	
			
		}
	}
}


#endif

⌨️ 快捷键说明

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