📄 tftpmain.c
字号:
#include "../../inc/config.h"
#include "skbuff.h"
#include "eth.h"
#include "arp.h"
#include "ip.h"
#include "udp.h"
#include "utils.h"
#include "../../inc/board.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);
/* {
int i;
char *p = (char *)eth_hdr;
for(i=0; i<32; i++)
printf("%x,", p[i]);
printf("\n----%x", eth_hdr->h_proto);
}*/
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;
printf("Mini TFTP Server 1.0 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);
printf("Type 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('.');
TftpPutMark = 0;
}
}
}
#else
//void tftp_main(unsigned long addr, int dummy) {}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -