?? main.c
字號:
#include "types.h"
#include "bios.h"
#include "skbuff.h"
#include "eth.h"
#include "arp.h"
#include "ip.h"
#include "udp.h"
#include "console.h"
#include "utils.h"
int startup_mode;int startup_param;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;
}
int timeout_handle(void)
{
static int timeout = 0; timeout++;
if (timeout < 5000) return 0; timeout = 0;
return 0;
}
int _main(unsigned long ip, unsigned long mode, unsigned long param)
{ unsigned char eth_addr[ETH_ALEN]; unsigned char *s = (unsigned char *)&ip; int timeout = 0;
console_init();
printf("Mini TFTP Server 1.0 (IP : %d.%d.%d.%d) - ", s[3], s[2], s[1], s[0]);
startup_mode = mode; startup_param = param; switch (startup_mode) { case BOOT_LOAD_PROGRAM: printf("Load Program (HEX)\r\n"); break; case BOOT_UPDATE_BIOS: printf("Update BIOS\r\n"); break; case BOOT_UPDATE_SYSPARAMETERS: printf("Update System Parameters\r\n"); break; case BOOT_UPDATE_PARTITIONTABLE: printf("Update Partition Table\r\n"); break; case BOOT_UPDATE_PARTITION: printf("Update Partition %d\r\n", startup_param + 1); break; case BOOT_UPDATE_FIRMWARE: printf("Update Firmware\r\n"); break; default: break; } printf("Usage (Windows 2000/XP) :\r\n"); printf(" tftp -i %d.%d.%d.%d put <filename>\r\n\r\n", s[3], s[2], s[1], s[0]);
eth_init();
eth_get_addr(eth_addr); arp_init(); ip_init(ip); udp_init(); arp_add_entry(eth_addr, ip);
while (1) {
net_handle(); timeout_handle(); if (kbhit() && (getch() == KEY_ESC)) break; } return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -