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

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

?? moncmd.c

?? umon bootloader source code, support mips cpu.
?? C
字號:
/** \file moncmd.c:
 *	\brief The guts of the moncmd UDP client.
 *	\author Ed Sutter esutter@lucent.com
 *
 *	This tool is used to support simple UDP communication between a host and
 *	a target running MicroMonitor.  The target is listening on port 
 *	IPPORT_MONCMD (777) for incoming command strings just as they would be
 *	seen if typed in at the RS-232 console port.  When the monitor receives
 *	this, it processes the string through the same mechanism as the console.
 *	The only addition is that all output is copied to the sender of the UDP
 *	packet (one line at a time).  Once the command has been processed, the
 *	final packet returned to the sender is a packet of size 1 with the data
 *	being zero.  This is what tells moncmd that the command has completed
 *	on the target.
 *
 *	\attention
 *	This code is part of a boot-monitor package developed as a generic base
 *	platform for embedded system designs.  As such, it is likely to be
 *	distributed to various projects beyond the control of the original
 *	author.  Please notify the author of any enhancements made or bugs found
 *	so that all may benefit from the changes.  In addition, notification back
 *	to the author will allow the new user to pick up changes that may have
 *	been made by other users after this version of the code was distributed.
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <signal.h>
#include <errno.h>
#ifdef BUILD_WITH_VCC
#include <windows.h>
#include <winsock2.h>
#else
#include <netdb.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif

#include "moncmd.h"

#ifdef BUILD_WITH_VCC
#define sleep(n) Sleep(n*1000)
#define SOCKET_INVALID(s)	(s == INVALID_SOCKET)
#else
#define SOCKET_INVALID(s)	(s < 0)
#endif

typedef unsigned char uchar;

extern	void err(char *);

/** \var char *thisProgname
 *	\brief String containing the value of argv[0] when the program was
 *	\brief executed.
 */
char *thisProgname;
				
/**	\var char *msgString
 *	\brief Pointer to the message that this program is 
 *	\brief to send to the target host.
 */
char *msgString;

/**	\var char *targetHost
 *	\brief Ip address or DNS name of host that this
 *	\brief program is to communicate with.
 */
char *targetHost;

/**	\var int retryFlag
 *	\brief If set, then the program will retry.
 */
int	retryFlag;


/**	\var int retryCount
 *	\brief Running total number of retries.
 */
int	retryCount;

/**	\var int quietMode
 *	\brief If set, then don't output status message at
 *	\brief the end of the program.
 */
int	quietMode;

/**	\var int	interactiveMode
 *	\brief If set, then moncmd runs similar to netcat, in
 *	\brief an interactive mode where each line typed is passed
 *	\brief to the target.
 */
int	interactiveMode;

/**	\var int	multirespMode
 *	\brief If set, then it is possible that more than one
 *	\brief target will respond, so don't quit after one
 *	\brief response is received.
 */
int	multirespMode;

/**	\var int waitTime
 *	\brief This is the amount of time that program will
 *	\brief wait for a response prior to giving up.
 */
int waitTime;

/**	\var int	socketFd
 *	\brief File descriptor of the open socket used to
 *	\brief communicate with the target host.
 */
int	socketFd;

/** \var int verbose
 *	\brief Set for more verbosity.
 */
int verbose;

/**	\var int	cmdRcvd
 *	\brief Set if the command has been received by the target, but no
 *	\brief additional response has been received.
 */
int	cmdRcvd;

/**	\var int binMode
 *	\brief If set, then moncmd is sending/receiving binary.
 */
int binMode;

/** \var struct sockaddr_in targetAddr
 *	\brief This structure is used to hold the socket
 *	\brief address info related to the target host.
 */
struct sockaddr_in targetAddr;

#ifdef BUILD_WITH_VCC
WSADATA WsaData;
DWORD	tid = (DWORD)0;
HANDLE	tHandle;
#else
pthread_attr_t attr;
pthread_t tid = (pthread_t)0;
#endif

/** \fn void Giveup(int sig)
 *	\brief This function is called if the alarm worker determines that
 *	\brief it is time to call it quits.
 */
void
Giveup(int sig)
{
	if (!quietMode) {
		if (cmdRcvd) {
			fprintf(stderr,
				"\n%s timeout: command received but not completed.\n",
				thisProgname);
		}
		else {
			fprintf(stderr,"\n%s timeout: command not received.\n",
				thisProgname);
		}
	}
	else {
							/* If quiteMode is set, then we just exit with */
		exit(EXIT_SUCCESS);	/* success because the user chooses to ignore */
							/* the error. */
	}

	if (cmdRcvd)
		exit(EXIT_CMP_TIMEOUT);
	else
		exit(EXIT_ACK_TIMEOUT);
}

/**	\var int	AlarmCount
 *	\brief If allowed to decrement to zero, the program gives up.
 */
int	AlarmCount;

/** \fn DWORD WINAPI AlarmWorker(LPVOID notused)
 *	\brief This is a thread that is created to provide a timeout if moncmd
 *	\brief does not receive a response within a specified amount of time.
 *  \brief For Cygwin, when the alarmworker times out, it sends a SIGUSR1
 *  \brief signal to the main process so that the recvfrom() call is 
 *  \brief interrupted.
 */
#ifdef BUILD_WITH_VCC
DWORD WINAPI AlarmWorker(LPVOID notused)
#else
void * AlarmWorker(void *notused)
#endif
{
	while(1) {
		sleep(1);
		if (AlarmCount) {
			if (AlarmCount == 1) {
				if ((retryFlag) && (!cmdRcvd)) {
					retryCount++;
					if (verbose)
						fprintf(stderr,"Retry %d: <%s> to %s...\n",
							retryCount, msgString,targetHost);
					if (sendto(socketFd,msgString,(int)strlen(msgString)+1,0,
					    (struct sockaddr *)&targetAddr,sizeof(targetAddr))<0) {
						close(socketFd);
						err("re-sendto failed");
					}
					AlarmCount = waitTime+1;
				}
				else
#ifdef BUILD_WITH_VCC
					Giveup(0);
#else
					kill(0,SIGUSR1);	/* Interrupt the recvfrom below */
					pthread_exit(0);
#endif
			}
			AlarmCount--;
		}
	}
	return(0);
}

#ifndef BUILD_WITH_VCC
/* This handler doesn't have to do anything except "exist".  The
 * purpose of this SIGUSR1 signal is to interrupt the recvfrom() call.
 */
void
handler(int sig)
{
}
#endif

/**	\fn int do_moncmd(char *hostname, char *command_to_monitor, short portnum)
 *	\param hostname Name or IP of target.
 *	\param command_to_monitor String to be sent to the target.
 *	\param portnum UDP port number to use.
 *	\brief Open a socket and send the command to the specified port of the
 *	\brief specified host.  Wait for a response if necessary.
 */
int
do_moncmd(char *hostname, char *command_to_monitor, short portnum)
{
	int	i, lasterr;
	int	msglen;
	unsigned long	inaddr;
	struct	hostent	*hp, host_info;
	char	rcvmsg[4096*4], cmdline[128];

#ifdef BUILD_WITH_VCC
	if (WSAStartup (0x0101, &WsaData) == SOCKET_ERROR)
		err("WSAStartup Failed");
#endif

	cmdRcvd = 0;
	retryCount = 0;
	targetHost = hostname;

	/* Accept target name as string or internet dotted-decimal address:
	 */
	memset((char *)&targetAddr,0,sizeof(struct sockaddr));
	if ((inaddr = inet_addr(targetHost)) != INADDR_NONE) {
		memcpy((char *)&targetAddr.sin_addr,(char *)&inaddr,sizeof(inaddr));
		host_info.h_name = NULL;
	}
	else {
		hp = gethostbyname(targetHost);
		if (hp == NULL)
			err("gethostbyname failed");
		host_info = *hp;
		memcpy((char *)&targetAddr.sin_addr,hp->h_addr,hp->h_length);
	}
	targetAddr.sin_family = AF_INET;
	targetAddr.sin_port = htons(portnum);

	socketFd = socket(AF_INET,SOCK_DGRAM,0);

	if (SOCKET_INVALID(socketFd))
		err("socket failed");

	do {
		if (interactiveMode) {
			do {
				gets(cmdline);
				command_to_monitor = cmdline;
			} while (strlen(command_to_monitor) == 0);
		}

		if (verbose)
			printf("Sending <%s> to %s...\n",command_to_monitor,targetHost);

		msgString = command_to_monitor;
		if (sendto(socketFd,msgString,(int)strlen(msgString)+1,0,
		    (struct sockaddr *)&targetAddr,sizeof(targetAddr)) < 0) {
			close(socketFd);
			err("sendto failed");
		}

		/* If the -w option says that wait time is zero, then don't bother
		 * waiting for a response, just return here.
		 */
		if (waitTime <= 0) {
			close(socketFd);
			return(EXIT_SUCCESS);
		}

		AlarmCount = waitTime;
#ifdef BUILD_WITH_VCC
		if (tid == (DWORD)0) {
			tHandle = CreateThread(NULL,0,AlarmWorker,(LPVOID)0,0,&tid);
#else
		if (tid == (pthread_t)0) {
			pthread_attr_init(&attr);
			pthread_attr_setstacksize(&attr,0x8000);
			pthread_create(&tid,&attr,AlarmWorker,(void *)0);
			signal(SIGUSR1,handler);
#endif
		}

		while(1) {
			int	j;
	
			/* Wait for incoming message: */
			msglen = sizeof(struct sockaddr);
			i = recvfrom(socketFd,rcvmsg,sizeof(rcvmsg),0,
				(struct sockaddr *)&targetAddr,&msglen);

			if (i == 0) {
				fprintf(stderr,"Connection closed\n");
				close(socketFd);
				exit(EXIT_ERROR);
			}
			else if (SOCKET_INVALID(i)) {
				//perror("socket invalid");
				close(socketFd);
				Giveup(0);
			}
			else  {
				/* Each time something is received, restart the timeout.
		 		 */
				AlarmCount = waitTime;
			}

			/* If ANY response is received from the target, then the command
			 * was received...
			 */
			cmdRcvd = 1;

			/* If size is 1 and 1st byte is 0 assume that's the target
			 * saying "I'm done".
			 */
			if ((i==1) && (rcvmsg[0] == 0)) {
				if (multirespMode)
					continue;
				break;
			}

			/* Print the received message:
			 */
			for(j=0;j<i;j++)
				putchar(rcvmsg[j]);
			fflush(stdout);
		}
	} while (interactiveMode);

	AlarmCount = 0;
	close(socketFd);
	return(EXIT_SUCCESS);
}

/**	\fn void moncmd_init(char *progname)
 *	\brief Initialize globals at startup
 *	\param progname Value of argv[0] at startup.
 */
void
moncmd_init(char *progname)
{
	thisProgname = progname;
	binMode = 0;
	waitTime = 10;
	verbose = 0;
	multirespMode = 0;
	interactiveMode = 0;
	retryFlag = quietMode = 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
麻豆成人久久精品二区三区小说| 日韩午夜在线播放| 国产亚洲综合av| 国内精品在线播放| 久久精品日产第一区二区三区高清版 | 欧美国产97人人爽人人喊| 懂色中文一区二区在线播放| 欧美激情一区二区三区蜜桃视频 | 毛片不卡一区二区| 久久精品国产一区二区三区免费看 | 精品欧美黑人一区二区三区| 国产91精品欧美| 成人a免费在线看| 天天综合天天做天天综合| 日韩视频在线观看一区二区| 精品人伦一区二区色婷婷| 国产亚洲成av人在线观看导航| 国产日韩欧美激情| 日韩一级二级三级精品视频| 欧美第一区第二区| 欧美日韩国产在线播放网站| 狠狠色综合播放一区二区| 国产一区二区在线视频| 一个色综合av| 国产精品麻豆欧美日韩ww| 3d动漫精品啪啪1区2区免费| 91猫先生在线| 国产风韵犹存在线视精品| 美女网站色91| 成人性生交大片| 国产伦理精品不卡| 99精品热视频| 99精品一区二区三区| 欧美性感一区二区三区| 不卡一区二区在线| 在线播放欧美女士性生活| 欧美性生活久久| 精品国产露脸精彩对白 | 日韩高清一区在线| 亚洲综合图片区| 亚洲欧美影音先锋| 欧美国产乱子伦| 亚洲成av人片| 婷婷久久综合九色综合伊人色| 国产精品正在播放| 成人网男人的天堂| 欧美一级艳片视频免费观看| 91精品国产一区二区三区蜜臀 | 制服丝袜在线91| 国产精品私房写真福利视频| 日韩高清不卡在线| 色综合久久综合| 色综合欧美在线| 日本一区二区三区在线不卡| 视频一区视频二区中文| 久久国产麻豆精品| 欧美精品一卡二卡| 一区二区三区小说| 99久久精品免费看| 久久精品视频在线看| 韩国一区二区视频| 欧美一区二区三区四区视频| 亚洲精品国产成人久久av盗摄| 一区二区三区在线视频免费观看| 国产凹凸在线观看一区二区| 欧美一级夜夜爽| 日本麻豆一区二区三区视频| 欧美三级资源在线| 亚洲精品一区二区三区香蕉 | 精品粉嫩超白一线天av| 日本伊人精品一区二区三区观看方式| 91黄色免费版| 日韩欧美中文字幕精品| 日韩激情在线观看| 欧美一区日本一区韩国一区| 一区二区三区中文免费| 欧美自拍偷拍午夜视频| 7777精品久久久大香线蕉| 亚洲一区在线观看免费 | 欧美一级免费观看| 亚洲第一会所有码转帖| 欧美日韩精品三区| 日韩av电影天堂| 精品三级av在线| 国产a久久麻豆| 国产日韩亚洲欧美综合| 成人av影视在线观看| 久久精品夜色噜噜亚洲a∨| 国产乱子轮精品视频| 久久久久久97三级| 亚洲成人资源网| 日韩一区二区在线看| 久久精品国产网站| 国产女主播一区| 色视频成人在线观看免| 爽好久久久欧美精品| 91精品国产综合久久久久久漫画| 另类小说一区二区三区| 精品国产免费一区二区三区香蕉| 国产白丝精品91爽爽久久| 亚洲欧洲国产日韩| 欧美一区三区四区| 成人激情黄色小说| 午夜精品免费在线| 久久精品免费在线观看| 欧美怡红院视频| 国产精品一区二区久激情瑜伽 | 九九热在线视频观看这里只有精品| 一本到三区不卡视频| 日日夜夜一区二区| 日本一区二区三区免费乱视频 | 国产精品二三区| 成人精品国产免费网站| 亚洲无线码一区二区三区| 91成人免费在线| 国产综合久久久久久鬼色| 亚洲男帅同性gay1069| av色综合久久天堂av综合| 久久久无码精品亚洲日韩按摩| 91在线精品一区二区三区| 热久久免费视频| 日韩一区二区视频| 91亚洲精品乱码久久久久久蜜桃| 视频一区二区三区在线| 中文字幕一区免费在线观看| 欧美一区日韩一区| 欧美综合色免费| av不卡免费电影| 国产在线精品免费| 视频一区视频二区中文字幕| 亚洲人成7777| 国产精品亲子伦对白| 精品国产乱码久久久久久浪潮| 欧美色精品天天在线观看视频| 高清不卡在线观看av| 激情欧美日韩一区二区| 日韩一区精品字幕| 亚洲成人资源在线| 亚洲主播在线观看| 国产精品乱码一区二三区小蝌蚪| 精品国产凹凸成av人导航| 欧美日韩的一区二区| 色哟哟国产精品免费观看| www.欧美日韩| www.日韩在线| 色综合婷婷久久| 婷婷综合五月天| 亚洲午夜久久久| 亚洲综合色噜噜狠狠| 一区二区在线看| 亚洲伊人伊色伊影伊综合网| 一区二区三区在线免费播放| 亚洲最新在线观看| 亚洲自拍偷拍欧美| 婷婷久久综合九色综合绿巨人| 亚洲成人激情av| 日韩中文字幕一区二区三区| 日本系列欧美系列| 久久黄色级2电影| 国产毛片一区二区| 高清成人在线观看| 色综合天天性综合| 欧美亚洲愉拍一区二区| 欧美日韩一区二区三区免费看 | 九九精品一区二区| 激情六月婷婷综合| 成人av网在线| 在线观看视频一区二区| 欧美丰满少妇xxxxx高潮对白| 欧美色综合天天久久综合精品| 欧美专区在线观看一区| 555夜色666亚洲国产免| 精品国产污污免费网站入口 | 欧美影视一区在线| 日韩一区二区在线观看视频| 国产欧美一区二区精品性色| 国产精品第四页| 午夜欧美在线一二页| 国产综合色产在线精品| 91在线无精精品入口| 日韩免费观看高清完整版在线观看 | 在线观看视频一区二区| 精品日韩成人av| 亚洲人成人一区二区在线观看| 日本成人在线不卡视频| 成人午夜又粗又硬又大| 欧美天堂一区二区三区| 久久综合资源网| 日韩一级大片在线观看| 国产精品久久久久桃色tv| 亚洲成人www| 国产精品一二二区| 91免费精品国自产拍在线不卡| 欧美日韩精品欧美日韩精品| 中文字幕av在线一区二区三区| 亚洲一区av在线| 成人一区在线观看| 日韩一区二区中文字幕| 夜夜精品视频一区二区| 国产一区二区精品久久99|