亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tftpd.c

?? windows wm5 下的bootloader代碼
?? C
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Module Name:  
    tftpd.c
    
Abstract:  
    This contains the TFTP server (daemon) routines for the
	bootloader.  For the most part, these operate on top of the udp.c
	module.  There are some global data structures that are shared with
	the tftp.c module.
    
Functions:


Notes: 

--*/
#include <windows.h>
#include <udp.h>
#include <tftp.h>

TFtpdServerRegistryEntry TFtpdServerRegistry[MAX_TFTP_SERVER_PROCS];
BOOL  bDoLaunch = FALSE;  

// Holds address of last TFTP download peer
EDBG_ADDR TftpPeerAddr = {0};

extern BYTE TFTPFrameBuffer[];

void EbootInitTFtpd( void ) {

	int i;

	for( i = 0; i < MAX_TFTP_SERVER_PROCS; i++ )
		TFtpdServerRegistry[i].fInUse = 0;
}


int __cdecl tolower(int c) {
	return ((c>='A') && (c<='Z')) ? (c-'A'+'a') : c;
}


// This function is called to associate a callback function with a given TFTP file name.
//  When a packet arrives that specifies the given file name, the callback will be called.
//  The requested operation is given, either TFTPD_OPEN, TFTPD_READ, TFTPD_WRITE, or TFTPD_DESTROY
//  and a pointer to a data buffer is given along with it.  The amount of valid data in the buffer is stored in
//  cwLength.  The amount of data cannot exceed 512 bytes, and in fact, must always be 512 bytes unless this is
//  the last packet that will be transferred over the link. If the number of data bytes is < 512 the link
//  is closing.
// The file name used for the associated link is also passed, allowing a single routine to act as a server for
//  multiple files.  The callback should not return until either all the data has been written to or taken from
//  the buffer because the buffer will later be destroyed.  It should then return 0 to indicate that there are no
//  errors and the link may continue.  If an error exists, the callback should return non-zero and the link will
//  be destroyed.
// When calling the TFtpServerRegister() routine, it will return 0 if the callback was successfully registered,
//	or non-zero if there are no more registration slots available.
UINT16 EbootTFtpdServerRegister( char *pszFileName, TFtpdCallBackFunc pfCallBack ) {

	int i;

    if ((strlen(pszFileName) + 1) > MAX_TFTP_FILENAME) return 1;

	for( i = 0; i < MAX_TFTP_SERVER_PROCS; i++ )
		if (TFtpdServerRegistry[i].fInUse == 0)
			break;
	if (i == MAX_TFTP_SERVER_PROCS)
		return 1;

	TFtpdServerRegistry[i].fInUse = 1;
	strcpy( TFtpdServerRegistry[i].szFileName, pszFileName );
	TFtpdServerRegistry[i].pfCallBack = pfCallBack;
	return 0;
}



// A server process can call this routine if it wants to remove itself as a server for the given file name
void EbootTFtpdServerUnRegister( char *pszFileName ) {

	int i;

	for( i = 0; i < MAX_TFTP_SERVER_PROCS; i++ )
		if (!strcmp( TFtpdServerRegistry[i].szFileName, pszFileName ))
			break;
	if (i != MAX_TFTP_SERVER_PROCS) {
		TFtpdServerRegistry[i].fInUse = 0;
		// Make sure to kill all links associated with this server
		for( i = 0; i < MAX_TFTP_LINKS; i++ )
			if (TFtpLinks[i].State != TFTP_STATE_IDLE && TFtpLinks[i].pfCallBack == TFtpdServerRegistry[i].pfCallBack)
				TFtpKillLink( (UINT16)i, TFTP_ERROR_FILENOTFOUND, "Server Process Has UnRegistered Itself" );
	}

}



// This routine generates a pseudo random sequence using a 16-bit LFSR.  These are used as source ports
//  for the TFTP protocol.  Note that because XOR was used, 0 is a dead value and will never be
//  returned.  The value of all 1's can be made the dead value if XNOR is used.
UINT16 GenerateSrcPort( void ) {

	static UINT16 wLastValue = 1;
	UINT16 wTempValue;
	int i;

	// Loop here until we get a value that isn't in use
	do {
		// For a 16-bit LFSR shifting to the left, I'll take bits 15,14,12,3
		wTempValue = 0xD008 & wLastValue;
		// Now XOR those bits together to get the bit shifted in on the right
		wTempValue ^= (wTempValue >> 12);
		wTempValue ^= (wTempValue >> 2);
		wTempValue ^= (wTempValue >> 1);

		// Shift it and OR in the new bit
		wLastValue = (wLastValue << 1) | (wTempValue & 0x0001);

		// Now compare the new value in wLastValue against all the source ports that are in use
		// Also keep us out of the normal well known port range
		for( i = 0; i < MAX_TFTP_LINKS; i++ )
			if (wLastValue < htons(1024) || (TFtpLinks[i].State != TFTP_STATE_IDLE && TFtpLinks[i].SrcAddr.wPort == wLastValue))
				break;
	}
	while(i != MAX_TFTP_LINKS);

	return wLastValue;
}



// This routine is called when a packet arrives to form a new server link.  It will then attempt
//  to determine if there is a callback procedure associated with that file name, and
//  if so, it will then call that process with the TFTPD_OPEN command.  If all goes well, the 
//  routine returns 0.  If there is an error, it will return non-zero.  The slot number that
//  is to be used for this link in the TFtpLinks[] table is passed in so that the callback
//  function pointer can be initialized for the link.  This is done to avoid the overhead of
//  looking up the callback address for every succeeding packet.
UINT16 TFtpdFormNewLink( EDBG_ADDR *pMyAddr, BYTE *pFrameBuffer, UINT16 iLinkSlot, UINT16 *pwMsg ) {

	char *pszParse;
	int i;

	// Convert both the strings to lower case so that the comparisons here will be case insensitive
	pszParse = (char *)(pwMsg + 1);
	for( i = 0; i < 2; pszParse++ ) {
		if (*pszParse == '\0')
			i++;
		*pszParse = tolower(*pszParse);
	}

	// Make sure we have a server process registered for this file name
	for( i = 0; i < MAX_TFTP_SERVER_PROCS; i++ )
		if (!strcmp( TFtpdServerRegistry[i].szFileName, (char *)(pwMsg + 1) ))
			break;
	if (i == MAX_TFTP_SERVER_PROCS) {
		EdbgOutputDebugString( "No Server Process Associated With File Name %s\r\n", (char *)(pwMsg + 1) );
		return 1;
		}
	else {
		// Go ahead and fill out the link record so that I can call TFtpKillLink() if I have too.
		nNumTFtpLinksInUse++;
		TFtpLinks[iLinkSlot].pfCallBack = TFtpdServerRegistry[i].pfCallBack;
		strcpy( TFtpLinks[iLinkSlot].szFileName, (char *)(pwMsg + 1) );
		TFtpLinks[iLinkSlot].wBlockNumber = 0;

		TFtpLinks[iLinkSlot].SrcAddr = *pMyAddr;
		TFtpLinks[iLinkSlot].SrcAddr.wPort = GenerateSrcPort();
		SrcAddrFromFrame( &(TFtpLinks[iLinkSlot].DestAddr), pFrameBuffer );
		// gmd - store address in global so we can filter out EDBG commands from
		// other hosts.
		memcpy(&TftpPeerAddr, &(TFtpLinks[iLinkSlot].DestAddr), sizeof(EDBG_ADDR));
        
		EdbgOutputDebugString( "Locked Down Link %d\r\n", iLinkSlot );
		EdbgOutputDebugString( "Src IP %s Port %H   ",
			inet_ntoa( TFtpLinks[iLinkSlot].SrcAddr.dwIP ), ntohs(TFtpLinks[iLinkSlot].SrcAddr.wPort));
		EdbgOutputDebugString( "Dest IP %s Port %H\r\n",
			inet_ntoa( TFtpLinks[iLinkSlot].DestAddr.dwIP ), ntohs(TFtpLinks[iLinkSlot].DestAddr.wPort) );

		// See if this is a read request
		if (ntohs(*((UINT16 *)pwMsg)) == 1) {
			TFtpLinks[iLinkSlot].DataDir = O2HLink;
			TFtpLinks[iLinkSlot].State = TFTP_STATE_XFER_BUSY;
		}
		// Otherwise it should be a write request
		else if (ntohs(*((UINT16 *)pwMsg)) == 2) {
			TFtpLinks[iLinkSlot].DataDir = H2OLink;
			TFtpLinks[iLinkSlot].State = TFTP_STATE_XFER_WAIT;
		}
		else {
			TFtpLinks[iLinkSlot].State = TFTP_STATE_XFER_WAIT;
			TFtpKillLink( iLinkSlot, TFTP_ERROR_ILLEGALOPERATION, "Illegal TFTP Operation - Read/Write Req Expected" );
			return 2;
		}

		// Make sure they are using binary transfer mode
		if (strcmp( "octet", (char *)(pwMsg + 1) + strlen((char *)(pwMsg + 1)) + 1 )) {
			TFtpKillLink( iLinkSlot, TFTP_ERROR_ACCESSVIOLATION, "You must access files in binary mode." );
			return 3;
		}

		// Now we will inform the server process of the new link and send any appropriate data/acknowledge back.
		//  Also, errors can be generated down there that could terminate the link.
		TFtpdCallBack( iLinkSlot, TFTPD_OPEN );
	}

	return 0;
}



void TFtpdCallBack( UINT16 iLinkSlot, TFtpdCallBackOps Operation ) {

	char *pszErrorMsg;

	switch(Operation) {

		case TFTPD_OPEN:
			// Call open to give the callback a chance to initialize
			if (TFtpLinks[iLinkSlot].pfCallBack( TFtpLinks[iLinkSlot].szFileName, TFTPD_OPEN, NULL, NULL, &pszErrorMsg )) {
				TFtpKillLink( iLinkSlot, TFTP_ERROR_FILENOTFOUND, pszErrorMsg );
				return;
			}
			// If it's for a Read request we need to respond with data, recursively call ourselves
			if (TFtpLinks[iLinkSlot].DataDir == O2HLink) {
				TFtpdCallBack( iLinkSlot, TFTPD_READ );
				return;
			}
			// If it's for a Write request, we need to respond with an acknowledge
			else {
				*((UINT16 *)TFtpLinks[iLinkSlot].Buffer) = htons(4);
				// This block number should be 0
				*((UINT16 *)TFtpLinks[iLinkSlot].Buffer + 1) = htons(TFtpLinks[iLinkSlot].wBlockNumber);
				TFtpLinks[iLinkSlot].cwMsgLen = 4;
			}
			break;
		case TFTPD_READ:
			// We need to send a data packet back
			*((UINT16 *)TFtpLinks[iLinkSlot].Buffer) = htons(3);
			TFtpLinks[iLinkSlot].wBlockNumber++;
			*((UINT16 *)TFtpLinks[iLinkSlot].Buffer + 1) = htons(TFtpLinks[iLinkSlot].wBlockNumber);
			if (TFtpLinks[iLinkSlot].pfCallBack( TFtpLinks[iLinkSlot].szFileName, TFTPD_READ,
			TFtpLinks[iLinkSlot].Buffer + 4, &(TFtpLinks[iLinkSlot].cwMsgLen), &pszErrorMsg ) ) {
				TFtpKillLink( iLinkSlot, TFTP_ERROR_ACCESSVIOLATION, pszErrorMsg );
				return;
			}
			// Add in length for the control words
			TFtpLinks[iLinkSlot].cwMsgLen += 4;
			TFtpLinks[iLinkSlot].State = TFTP_STATE_XFER_WAIT;
			break;
		case TFTPD_WRITE:
			// We need to process the data and send an acknowledge back
			*((UINT16 *)TFtpLinks[iLinkSlot].Buffer) = htons(4);
			*((UINT16 *)TFtpLinks[iLinkSlot].Buffer + 1) = htons(TFtpLinks[iLinkSlot].wBlockNumber);
			TFtpLinks[iLinkSlot].cwMsgLen -= 4;
			if (TFtpLinks[iLinkSlot].pfCallBack( TFtpLinks[iLinkSlot].szFileName, TFTPD_WRITE,
			TFtpLinks[iLinkSlot].Buffer + 4, &(TFtpLinks[iLinkSlot].cwMsgLen), &pszErrorMsg ) ) {
				TFtpKillLink( iLinkSlot, TFTP_ERROR_ACCESSVIOLATION, pszErrorMsg );
				return;
			}
			// The acknowledge length is just the control words
			TFtpLinks[iLinkSlot].cwMsgLen = 4;
			TFtpLinks[iLinkSlot].State = TFTP_STATE_XFER_WAIT;
			break;
		case TFTPD_DESTROY:
			// Just tell them that it's dead and return
			TFtpLinks[iLinkSlot].pfCallBack( TFtpLinks[iLinkSlot].szFileName, TFTPD_DESTROY, NULL, NULL, &pszErrorMsg );
			return;

	} // switch(Operation)

	// Send the packet back to the host
	EbootSendUDP(TFTPFrameBuffer, &(TFtpLinks[iLinkSlot].DestAddr), &(TFtpLinks[iLinkSlot].SrcAddr),
                 TFtpLinks[iLinkSlot].Buffer, TFtpLinks[iLinkSlot].cwMsgLen );
	TFtpLinks[iLinkSlot].cwRetries = 0;
	TFtpLinks[iLinkSlot].tLastTransmit = OEMEthGetSecs();

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美乱妇15p| 日韩精品影音先锋| 国产毛片精品国产一区二区三区| 亚洲高清免费在线| 午夜视频一区二区三区| 亚洲成人免费影院| 美女视频网站黄色亚洲| 麻豆精品新av中文字幕| 国产乱码精品一区二区三区五月婷 | 亚洲欧美日韩国产一区二区三区| 欧美国产97人人爽人人喊| 国产欧美日韩三级| 亚洲欧美一区二区在线观看| 亚洲三级在线免费| 亚洲香肠在线观看| 免费国产亚洲视频| 国产成人啪免费观看软件| 国产精品一区二区黑丝| 成人性视频免费网站| 91同城在线观看| 欧美日韩小视频| 337p粉嫩大胆噜噜噜噜噜91av| 国产日韩精品一区二区三区| 一区二区在线免费观看| 日韩一区精品字幕| 国产精品18久久久久久久久久久久| 成人午夜精品在线| 欧美三级在线视频| 亚洲精品在线观看视频| 成人免费一区二区三区视频| 日日摸夜夜添夜夜添精品视频| 激情图片小说一区| 91视频在线观看免费| 欧美一区二区三区免费| 日本一区二区高清| 亚洲成人一区在线| 成人禁用看黄a在线| 在线不卡一区二区| 国产精品国产三级国产普通话三级| 亚洲国产一区视频| 成人中文字幕合集| 欧美精品精品一区| 综合色中文字幕| 九一九一国产精品| 欧美性大战xxxxx久久久| 国产午夜精品美女毛片视频| 五月天精品一区二区三区| 国产成人综合在线观看| 6080午夜不卡| 亚洲一区免费在线观看| 成人黄色国产精品网站大全在线免费观看 | 欧美videos中文字幕| 中文字幕一区二区三区不卡在线 | 亚洲图片自拍偷拍| 成人免费视频一区| 精品国产1区二区| 日韩av一级片| 欧美精品亚洲一区二区在线播放| 国产精品亲子伦对白| 狠狠狠色丁香婷婷综合激情| 91精品国产综合久久久久| 亚洲男帅同性gay1069| 不卡一区在线观看| 欧美国产日韩亚洲一区| 久久99热99| 日韩免费观看高清完整版| 天天综合色天天| 欧美精品在线一区二区三区| 一区二区三区免费看视频| 成人av免费在线| 国产精品国产三级国产三级人妇| 国产一区 二区| 国产日韩欧美不卡在线| 国产大陆亚洲精品国产| 欧美精彩视频一区二区三区| 国产麻豆精品视频| 欧美经典一区二区三区| 成人午夜av在线| 国产精品久久久久久久浪潮网站| 国产白丝网站精品污在线入口| 久久九九久精品国产免费直播| 精品一区二区三区的国产在线播放| 91精品国产综合久久精品| 奇米影视一区二区三区| 亚洲精品在线观看网站| 福利电影一区二区| 亚洲视频小说图片| 欧美少妇xxx| 精品一区二区三区香蕉蜜桃| wwwwxxxxx欧美| av成人老司机| 亚洲福中文字幕伊人影院| 欧美一区二区福利在线| 国产乱码精品一区二区三区忘忧草| 国产色产综合产在线视频| 99久久精品国产网站| 亚洲成人激情av| 精品国产精品网麻豆系列| 99久久综合色| 日韩综合小视频| 久久久不卡网国产精品二区 | 日韩成人一区二区| 久久久久亚洲综合| 91福利精品第一导航| 久久国产精品无码网站| 国产精品国产三级国产aⅴ入口| 欧美在线一二三| 国产伦理精品不卡| 亚洲一区在线免费观看| 精品国产露脸精彩对白| 色偷偷久久一区二区三区| 美女网站视频久久| 亚洲黄色小视频| 久久嫩草精品久久久精品一| 色综合咪咪久久| 久国产精品韩国三级视频| 亚洲精品老司机| 精品久久久久久综合日本欧美| 91美女在线观看| 国内精品伊人久久久久av影院 | 欧美精品欧美精品系列| 福利电影一区二区三区| 琪琪久久久久日韩精品| 中文字幕亚洲区| 久久久五月婷婷| 91精品国产麻豆国产自产在线| 99在线精品视频| 国产福利电影一区二区三区| 视频一区视频二区中文| 亚洲免费av在线| 国产精品亲子乱子伦xxxx裸| 久久夜色精品一区| 91麻豆精品国产91久久久资源速度 | 欧美午夜理伦三级在线观看| 国产成人自拍高清视频在线免费播放| 一区二区三区在线免费播放| 亚洲国产经典视频| www成人在线观看| 欧美成人一区二区三区在线观看| 在线免费av一区| 一本大道久久精品懂色aⅴ| 国产91精品精华液一区二区三区 | 国产精品午夜春色av| 久久免费精品国产久精品久久久久| 欧美久久一二区| 欧美三级在线视频| 欧美日韩在线播放一区| 欧洲精品中文字幕| 在线精品视频免费观看| 在线观看日韩av先锋影音电影院| 91蝌蚪porny九色| 一本色道a无线码一区v| 日本丶国产丶欧美色综合| 99re这里只有精品6| 91玉足脚交白嫩脚丫在线播放| 成人免费三级在线| gogogo免费视频观看亚洲一| 国产精品一二三四五| 国产成人免费高清| 99视频有精品| 色综合久久天天| 欧美日韩国产成人在线免费| 欧美精品vⅰdeose4hd| 欧美一卡二卡三卡四卡| 日韩一区二区三区精品视频| 日韩精品一区二区三区四区| 精品av久久707| 欧美高清在线一区| 一区二区欧美在线观看| 日韩专区欧美专区| 国产精品99久久久久久宅男| hitomi一区二区三区精品| 色婷婷一区二区| 日韩一区二区在线看| 久久久不卡网国产精品二区| 国产精品无人区| 亚洲自拍另类综合| 蜜臀av一级做a爰片久久| 国产伦理精品不卡| 欧美在线观看视频一区二区三区| 欧美疯狂性受xxxxx喷水图片| 精品国产污网站| 一区二区三区中文字幕在线观看| 午夜精品久久久久久久| 国产一区不卡精品| 欧美三级三级三级爽爽爽| 337p日本欧洲亚洲大胆精品| 一区二区三区中文字幕电影 | 懂色av一区二区三区蜜臀| 欧美午夜精品一区二区蜜桃| 久久综合中文字幕| 伊人一区二区三区| 国产一区二区成人久久免费影院| 一本到一区二区三区| 久久在线观看免费| 亚洲第一久久影院| 成人h动漫精品| 精品欧美一区二区在线观看| 亚洲一线二线三线视频| 成人性色生活片|