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

📄 main.c

📁 This a naive implementation of BOOTP/TFTPBOOT, the protocols to use to bootstrap a computer through
💻 C
字号:
/*	Copyright 2001, 2002 Georges Menie (www.menie.org)	This file is part of Tftpnaive.    Tftpnaive is free software; you can redistribute it and/or modify    it under the terms of the GNU Lesser General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    Tftpnaive is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU Lesser General Public License for more details.    You should have received a copy of the GNU Lesser General Public License    along with Tftpnaive; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#include "tftpnaive.h"#include "baselib.h"#include "timer.h"#if TFTPNAIVE_TIMEREQUESTstatic void getTime (){	int ts, h, m, s;		/* send a timestamp request to the TFTP server,	 * to get it's GMT time of the day */	if (tftp_req) {		if ((ts = netTimestampRequest (tftp_req->server)) != 0) {			ts = (ts + 500) / 1000;	/* round to secs */			h = (ts / 3600) % 24;			m = (ts / 60) % 60;			s = ts % 60;			setTime (h, m, s);			printf ("GMT time is %d:%d:%d\n", h, m, s);		}	}}#endifint main (void){	int error;	timerInit ();	/* initialize the network chip, loop until it's ready */	while ((error = netUp ()) != 0) {		if (error != ERR_LINK)			printf ("Network interface init failed: code %d\n", error);		else			printf ("No network, cable problem ?\n");		usleep (1000000);	}	while (1) {		/* request an IP address through BOOTP */		netRequestIP ();#if TFTPNAIVE_TIMEREQUEST		getTime ();#endif		/* bootstrap using TFTP */		if (netBoot () == 0)			break;	}	/* shutdown the network chip */	netDown ();	/* if the download is successfull and	 * a start address has been given, jump to it	 */	if (tftp_req && tftp_req->sts > 0 && tftp_req->strtf) {		jump ((void *) tftp_req->strt);		/* not reached */	}	return 0;}

⌨️ 快捷键说明

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