?? tftpmain.c
字號:
#include "config.h"
#include "44blib.h"
#include "skbuff.h"
#include "eth.h"
#include "arp.h"
#include "ip.h"
#include "udp.h"
#include "utils.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++)
Uart_Printf("%x,", p[i]);
Uart_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;
Uart_Printf("Mini TFTP Server 1.0 (IP : %d.%d.%d.%d PORT: %d)\n", s[3], s[2], s[1], s[0], TFTP);
Uart_Printf("Type tftp -i %d.%d.%d.%d put filename at the host PC\n", s[3], s[2], s[1], s[0]);
Uart_Printf("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 ((Uart_GetKey()!=ESC_KEY)&&!TftpLoadEnd) {
net_handle();
if(TftpPutBegin) {
Uart_Printf("Starting the TFTP download...\n");
TftpPutBegin = 0;
}
if(TftpPutMark) {
Uart_SendByte('.');
TftpPutMark = 0;
}
}
}
#else
//void tftp_main(unsigned long addr, int dummy) {}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -