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

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

?? tftpd.c

?? tftp-1.0源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/**********************************************************Date: 		OCT 28th, 2006Project :	NET4900 Project: tftpd.c TFTP ServerProgramers:	Craig HolmesReza Rahmanian File:		TFTP Server (main)Purpose:	A TFTP server that will accept a connections from		a client and transefet files.Notes:		Here we are using the sendto and recvfrom		functions so the server and client can exchange data.***********************************************************************//* Include our header which contains libaries and defines */#include "tftp.h"/* Function prototypes */void tsend (char *, struct sockaddr_in, char *, int);void tget (char *, struct sockaddr_in, char *, int);int isnotvaliddir (char *);void usage (void);/* default values which can be controlled by command line */int debug = 0;char path[64] = "/tmp/";int port = 69;unsigned short int ackfreq = 1;int datasize = 512;intmain (int argc, char **argv){    /*local variables */    extern char *optarg;    int sock, n, client_len, pid, status, opt, tid;    char opcode, *bufindex, filename[196], mode[12];    struct sockaddr_in server, client;	/*the address structure for both the server and client */    /* All of the following deals with command line switches */    while ((opt = getopt (argc, argv, "dh:p:P:a:s:")) != -1)	/* this function is handy */    {        switch (opt)        {            case 'p':		/* path (opt required) */                if (!isnotvaliddir (optarg))                {                    printf                        ("Sorry, you specified an invalid/non-existant directory. Make sure the directory exists.\n");                    return 0;                }                strncpy (path, optarg, sizeof (path) - 1);                break;            case 'd':		/* debug mode (no opts) */                debug = 1;                break;            case 'P':		/* Port (opt required) */                port = atoi (optarg);                break;            case 'a':		/* ack frequency (opt required) */                ackfreq = atoi (optarg);                if (ackfreq > MAXACKFREQ)                {                    printf                        ("Sorry, you specified an ack frequency higher than the maximum allowed (Requested: %d Max: %d)\n",                         ackfreq, MAXACKFREQ);                    return 0;                }                else if (ackfreq == 0)                {                    printf ("Sorry, you have to ack sometime.\n");                    return 0;                }                break;            case 's':		/* File chunk size (opt required) */                datasize = atoi (optarg);                if (datasize > MAXDATASIZE)                {                    printf                        ("Sorry, you specified a data size higher than the maximum allowed (Requested: %d Max: %d)\n",                         datasize, MAXDATASIZE);                    return 0;                }                break;            case 'h':		/* Help (no opts) */                usage ();                return (0);                break;            default:		/* everything else */                usage ();                return (0);                break;        }    }    /* Done dealing with switches */    /*Create the socket, a -1 will show us an error */    if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)    {        printf ("Server Socket could not be created");        return 0;    }    /*set the address values for the server */    server.sin_family = AF_INET;	/*address family for TCP and UDP */    server.sin_addr.s_addr = htonl (INADDR_ANY);	/*use any address */    server.sin_port = htons (port);	/*pick a free port */    /*Bind the socket */    if (bind (sock, (struct sockaddr *) &server, sizeof (server)) < 0)    {        printf            ("Server bind failed. Server already running? Proper permissions?\n");        return (2);    }    if (!debug)    {        pid = fork ();        if (pid != 0)		/* if pid != 0 then we are the parent */        {            if (pid == -1)            {                printf ("Error: Fork failed!\n");                return 0;            }            else            {                printf ("Daemon Successfully forked (pid: %d)\n", pid);                return 1;            }        }    }    else    {        printf            ("tftpd server is running in debug mode and will not fork. \nMulti-threaded mode disabled.\nServer is bound to port %d and awaiting connections\nfile path: %s\n",             ntohs (server.sin_port), path);    }    /*endless loop to get connections from the client */    while (1)    {        client_len = sizeof (client);	/*get the length of the client */        memset (buf, 0, BUFSIZ);	/*clear the buffer */        /*the fs message */        n = 0;        while (errno == EAGAIN || n == 0)	/* This loop is required because on linux we have to acknowledge complete children with waitpid. Ugh. */        {            waitpid (-1, &status, WNOHANG);            n =                recvfrom (sock, buf, BUFSIZ, MSG_DONTWAIT,                        (struct sockaddr *) &client,                        (socklen_t *) & client_len);            if (n < 0 && errno != EAGAIN)            {                printf ("The server could not receive from the client");                return 0;            }            usleep (1000);        }        if (debug)            printf ("Connection from %s, port %d\n",                    inet_ntoa (client.sin_addr), ntohs (client.sin_port));        bufindex = buf;		//start our pointer going        if (bufindex++[0] != 0x00)        {			//first TFTP packet byte needs to be null. Once the value is taken increment it.            if (debug)                printf ("Malformed tftp packet.\n");            return 0;        }        tid = ntohs (client.sin_port);	/* record the tid */        opcode = *bufindex++;	//opcode is in the second byte.        if (opcode == 1 || opcode == 2)	// RRQ or WRQ. The only two really valid packets on port 69        {            strncpy (filename, bufindex, sizeof (filename) - 1);	/* Our pointer has been nudged along the recieved string so the first char is the beginning of the filename. This filename is null deliimited so we can use the str family of functions */            bufindex += strlen (filename) + 1;	/* move the pointer to after the filename + null byte in the string */            strncpy (mode, bufindex, sizeof (mode) - 1);	/* like the filename, we are at the beginning of the null delimited mode */            bufindex += strlen (mode) + 1;	/* move pointer... */            if (debug)                printf ("opcode: %x filename: %s packet size: %d mode: %s\n", opcode, filename, n, mode);	/*show the message to the server */        }        else        {            if (debug)                printf ("opcode: %x size: %d \n", opcode, sizeof (n));	/*show the message to the server */        }        switch (opcode)		/* case one and two are valid on port 69 or server port... no other codes are */        {            case 1:                if (debug)                {                    printf ("Opcode indicates file read request\n");                    tsend (filename, client, mode, tid);                }                else                {                    pid = fork ();                    if (pid == 0)                    {		/* if we are pid != 0 then we are the parent */                        tsend (filename, client, mode, tid);                        exit (1);                    }                }                break;            case 2:                if (debug)                {                    printf ("Opcode indicates file write request\n");                    tget (filename, client, mode, tid);                }                else                {                    pid = fork ();                    if (pid == 0)	/* if we are pid != 0 then we are the parent */                    {                        tget (filename, client, mode, tid);                        exit (1);                    }                }                break;            default:                if (debug)                    printf ("Invalid opcode detected. Ignoring packet.");                break;        }			//end of while    }}voidtget (char *pFilename, struct sockaddr_in client, char *pMode, int tid){    /* local variables */    int sock, len, client_len, opcode, i, j, n, flag = 1;    unsigned short int count = 0, rcount = 0;    unsigned char filebuf[MAXDATASIZE + 1];    unsigned char packetbuf[MAXDATASIZE + 12];    extern int errno;    char filename[128], mode[12], fullpath[196], *bufindex, ackbuf[512];    struct sockaddr_in data;    FILE *fp;			/* pointer to the file we will be getting */    strcpy (filename, pFilename);	//copy the pointer to the filename into a real array    strcpy (mode, pMode);		//same as above    if (debug)        printf ("branched to file receive function\n");    if ((sock = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)	//startup a socket    {        printf ("Server reconnect for getting did not work correctly\n");        return;    }    if (!strncasecmp (mode, "octet", 5) && !strncasecmp (mode, "netascii", 8))	/* these two are the only modes we accept */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产三级国产专播品爱网| 欧美亚洲一区二区在线| 久久久亚洲精品石原莉奈| 韩国女主播一区| 欧美激情一区二区三区四区| 成人app网站| 夜色激情一区二区| 欧美日韩一区二区三区视频| 日韩成人午夜精品| 久久亚洲一区二区三区四区| 岛国精品在线观看| 国产精品高潮呻吟久久| 色www精品视频在线观看| 亚洲成在人线免费| 欧美va日韩va| 大胆亚洲人体视频| 亚洲高清不卡在线观看| 日韩精品在线网站| av在线播放不卡| 亚洲一本大道在线| 久久青草欧美一区二区三区| av在线不卡免费看| 天天影视涩香欲综合网| 久久蜜桃av一区精品变态类天堂| 99久久99久久综合| 天堂av在线一区| 国产欧美日本一区二区三区| 欧美亚洲日本国产| 国产一区二区在线看| 一区二区三区精品在线观看| 欧美一级在线视频| 99精品欧美一区| 美女精品一区二区| 亚洲免费观看高清完整版在线观看熊 | 色综合欧美在线| 免费的成人av| 亚洲精品国产高清久久伦理二区| 日韩欧美一区二区不卡| 91视频在线看| 国产最新精品精品你懂的| 一区二区三区丝袜| 国产欧美日韩三区| 欧美一区二区啪啪| 一本到不卡免费一区二区| 国产一区在线精品| 色综合视频在线观看| 国产一区二区在线观看视频| 亚洲第一av色| 亚洲人xxxx| 国产午夜精品久久久久久久| 欧美剧情片在线观看| 色诱视频网站一区| caoporm超碰国产精品| 国产一区啦啦啦在线观看| 日韩影院免费视频| 国产精品沙发午睡系列990531| 精品久久免费看| 91精品国产入口| 欧美日韩精品系列| 欧美亚洲禁片免费| 一本色道综合亚洲| 91视频com| 99精品黄色片免费大全| 成人网页在线观看| 国产精品一色哟哟哟| 欧美日韩久久不卡| 91丨porny丨蝌蚪视频| 成av人片一区二区| 国产91富婆露脸刺激对白| 国产一区二区免费视频| 久久电影国产免费久久电影| 美女视频免费一区| 麻豆中文一区二区| 久久精品国产在热久久| 美女诱惑一区二区| 奇米综合一区二区三区精品视频| 首页亚洲欧美制服丝腿| 香蕉加勒比综合久久| 亚洲电影中文字幕在线观看| 亚洲国产视频一区二区| 亚洲成国产人片在线观看| 亚洲一二三四在线| 亚洲国产欧美一区二区三区丁香婷| 亚洲免费视频中文字幕| 亚洲精品国产a| 亚洲第一精品在线| 亚洲aⅴ怡春院| 婷婷国产v国产偷v亚洲高清| 视频一区二区欧美| 美腿丝袜一区二区三区| 九色综合国产一区二区三区| 国产乱人伦偷精品视频免下载| 国产成人午夜精品5599 | 久久久噜噜噜久噜久久综合| 精品卡一卡二卡三卡四在线| 久久青草国产手机看片福利盒子 | 日韩你懂的在线播放| 精品三级在线看| 欧美高清在线视频| 一区二区三区四区乱视频| 亚洲一区免费在线观看| 日本视频在线一区| 国产老妇另类xxxxx| 本田岬高潮一区二区三区| 色天天综合久久久久综合片| 51精品视频一区二区三区| 久久午夜色播影院免费高清 | 日韩三级伦理片妻子的秘密按摩| 精品免费视频一区二区| 欧美激情综合在线| 亚洲精品国产视频| 日本特黄久久久高潮| 成人免费视频一区二区| 91极品美女在线| 精品日韩在线观看| 最新日韩av在线| 日韩成人一级大片| 不卡区在线中文字幕| 欧美久久一区二区| 国产精品亲子乱子伦xxxx裸| 亚洲国产成人精品视频| 国产精品综合一区二区| 欧美三级蜜桃2在线观看| 精品蜜桃在线看| 一区二区三区精品视频| 国产精品中文字幕日韩精品| 欧美亚洲一区二区在线| 国产精品色在线观看| 日韩精品免费专区| av亚洲产国偷v产偷v自拍| 日韩欧美一级二级三级久久久| 中文字幕一区二区三| 毛片av中文字幕一区二区| 91在线看国产| 久久这里只有精品视频网| 亚洲国产欧美在线人成| 波多野结衣亚洲一区| 日韩免费一区二区| 亚洲自拍偷拍欧美| 成人网在线播放| 久久综合九色综合97婷婷 | 亚洲天堂免费在线观看视频| 理论片日本一区| 欧美日韩精品免费观看视频 | 欧美自拍偷拍一区| 国产亚洲精品福利| 裸体一区二区三区| 欧美日韩精品一区二区| ㊣最新国产の精品bt伙计久久| 国产精品一级黄| 日韩精品综合一本久道在线视频| 亚洲第一会所有码转帖| 91免费精品国自产拍在线不卡| 国产欧美精品一区二区色综合朱莉| 美女一区二区视频| 欧美精品国产精品| 五月婷婷另类国产| 欧美亚洲国产一区二区三区| 亚洲精品日韩综合观看成人91| 成人免费不卡视频| 欧美激情一区三区| 风间由美性色一区二区三区| 久久精品欧美日韩| 国产一区二区女| 国产欧美综合在线| 国产精品一卡二卡| 国产色产综合产在线视频| 国产999精品久久久久久| 2020国产精品自拍| 国产高清不卡一区| 国产日本一区二区| 成人少妇影院yyyy| 亚洲啪啪综合av一区二区三区| 色香蕉成人二区免费| 亚洲视频综合在线| 91黄色免费版| 日韩国产精品久久久久久亚洲| 91精品黄色片免费大全| 久久国产精品免费| 久久精品一区二区| 国产传媒久久文化传媒| 国产精品人人做人人爽人人添| 91女神在线视频| 亚洲成在人线免费| 日韩精品中文字幕在线不卡尤物| 国产精品资源在线观看| 欧美韩日一区二区三区| jlzzjlzz欧美大全| 亚洲国产欧美日韩另类综合| 日韩一级完整毛片| 成人一区二区三区视频在线观看 | 色系网站成人免费| 三级一区在线视频先锋 | 国产福利不卡视频| 亚洲欧美在线观看| 欧美一三区三区四区免费在线看| 麻豆久久久久久久| 国产精品久久看| 欧美日韩日日摸| 国产乱子伦视频一区二区三区 |