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

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

?? scratchp.c

?? 嵌入式小型TCPIP協議棧
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Scratch Protocol for 'TCP/IP Lean' (c) Iosoft Ltd. 2000

This software is only licensed for distribution with the book 'TCP/IP Lean',
and may only be used for personal experimentation by the purchaser
of that book, on condition that this copyright notice is retained.
For commercial licensing, contact license@iosoft.co.uk

This is experimental software; use it entirely at your own risk. The author
offers no warranties of any kind, including its fitness for purpose. */

/*
** v0.01 JPB 28/10/99
** v0.02 JPB 1/11/99  Removed 'flags' from packet format
** v0.03 JPB 2/11/99  Reintroduced sequencing flags
** v0.04 JPB 3/11/99  Added SLIP support
** v0.05 JPB 4/11/99  Added config-file support
** v0.06 JPB 5/11/99  Revamped packet driver to support multiple classes
** v0.07 JPB 8/1/99   Updated packet format to use command string
** v0.08 JPB 8/1/99   Adapted Tx, Rx so txlen and rxlen include header length
** v0.09 JPB 9/11/99  Added sequencing
** v0.10 JPB 9/11/99  Added data queues
** v0.11 JPB 11/11/99 Improved sequence logic
** v0.12 JPB 12/11/99 Added circular buffer option to packet driver
** v0.13 JPB 15/11/99 Added network Tx and Rx circular buffers
** v0.14 JPB 16/11/99 Improved support for direct-drive of NE2000 card
** v0.15 JPB 16/11/99 Added SCRATCHE for use with DJGPP compiler
** v0.16 JPB 17/11/99 Fixed reentrancy problem on receive
** v0.17 JPB 18/11/99 Removed references to min() and max()
** v0.18 JPB 19/11/99 Completely revamped state machine
** v0.19 JPB 22/11/99 Added timeouts
** v0.20 JPB 23/11/99 Added WIN32 support
** v0.21 JPB 25/11/99 Fixed SLIP interface
** v0.22 JPB 26/11/99 Improved SCRATCHP state-machine
** v0.23 JPB 29/11/99 Added 'dir' command
** v0.24 JPB 30/11/99 Added 'get' and 'put'
** v0.25 JPB 1/12/99  Promoted 'seq' and 'ack' to 32-bit values
** v0.26 JPB 6/12/99  Added 3COM driver
** v0.27 JPB 30/12/99 Improved DJGPP compatibility - removed MAXPATH definition
** v0.28 JPB 6/4/00   Updated to use latest version of net drivers
** v0.29 JPB 13/8/00  Updated copyright notice
*/

#define VERSION "0.29"              /* This software version */

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>
#include <string.h>

/* Override the default circular buffer size used in TCPFS.H */
#define _CBUFFLEN_ 0x1000           /* Circ buffer size: MUST be power of 2 */

#include "ether.h"
#include "netutil.h"
#include "net.h"
#include "scratchp.h"

#define SCRATCHPVER 1               /* Protocol version number */
#define TESTLEN     SCRATCHPDLEN    /* Max size of 1 block of test data */
#define TESTBUFFLEN (TESTLEN*2)     /* Size of test data buffer */
#define TESTINC     1               /* Increment value for test data */
#define CFGFILE     "tcplean.cfg"   /* Default config filename */
#define NDIAGS      40              /* Number of diagnostic header entries */
#define DIAG_TX     1               /* Identifiers for diagnostic Tx, Rx hdrs */
#define DIAG_RX     2
#define ERRTIME     2               /* Error timeout in sec */
#define RETRIES     2               /* Number of error retries */
#define BLOCKLEN    255             /* Len of file xfer blk (excl. len byte) */
#define FILENAMELEN 40              /* Max length of get/put filename */

char cfgfile[MAXPATH+5]=CFGFILE;    /* Config filename */
BYTE testdata[TESTBUFFLEN];         /* Test data buffer */
LWORD testlen;
int txoff, rxoff;                   /* Tx, Rx offsets into test data */
GENFRAME genframe;                  /* Receive/transmit frame */
long txcount;                       /* Count of Rx bytes */
CBUFF txbuff={_CBUFFLEN_};          /* Circular buffer for transmit */
CBUFF rxbuff={_CBUFFLEN_};          /* Circular buffer for receive */
int statedebug, pktdebug, sigdebug; /* Flags to enable diagnostic printout */
char locid[IDLEN+1];                /* My (local) ident string */
char remid[IDLEN+1];                /* Remote node ident string */
BYTE remaddr[MACLEN];               /* Remote node address */
extern BYTE bcast[MACLEN];          /* Broadcast address */
char netcfg[40];                    /* Network config string */
int connstate;                      /* Network connection state */
int appstate;                       /* Application state */
char *connstates[]={STATENAMES};    /* Strings for connection states */
char *appstates[]={APPNAMES};       /* Diagnostic strings for states */
char *signames[] = {SIGNAMES};
BYTE apptemp[TESTLEN+1];            /* Temporary storage for app. data */
SCRATCHPHDR diaghdrs[NDIAGS];       /* Diagnostic storage of SCRATCHP headers */
int diagidx;                        /* Index into dignostic storage */
char kbuff[81];                     /* Keyboard buffer */
WORD errtimer, errcount;            /* Timer & counter for errors */
char *offon[] = {"off", "on"};      /* Off/on strings */
FILE *fhandle;                      /* File handle for GET and PUT */
char filename[FILENAMELEN+1];       /* File name for GET and PUT */
long filelen;                       /* File length for GET and PUT */
int breakflag;                      /* Flag to indicate ctrl-break pressed */

/* Prototypes */
int get_pkts(GENFRAME *nfp);
void prompt_user(void);
int do_scratchp(GENFRAME *nfp, int rxlen, int signal);
int do_apps(CBUFF *rxb, CBUFF *txb, int sig);
int do_dir(CBUFF *txb);
void newconnstate(int state);
void newappstate(int state);
void disp_sig(int sig);
int make_scratchp(GENFRAME *nfp, BYTE *dest, char *cmd, BYTE flags,
                  void *data, int dlen);
int make_scratchpds(GENFRAME *nfp, BYTE *dest, char *cmd, BYTE flags, char *str);
int put_scratchp(GENFRAME *nfp, WORD txlen);
int is_scratchp(GENFRAME *nfp, int len);
int swap_scratchp(GENFRAME *nfp);
void disp_scratchphdr(SCRATCHPHDR *sph);
void disp_scratchp(GENFRAME *nfp);
void dump_diags(void);
int read_cfg(char *fname);
int mygets(char *buff, int maxlen);

int main(int argc, char *argv[])
{
    char k, cmdkey=0;
    int i, keysig, connsig, sstep=0;
    WORD frametype, txlen=0;
    GENFRAME *nfp;

    printf("SCRATCHP v" VERSION "  ");      /* Sign on */
    if (!read_cfg(argc>1 ? argv[1] : 0))    /* Read config file */
    {
        printf("ERROR: invalid configuration file\n");
        exit(1);
    }
    printf("\n");                           /* Make random test data */
    for (i=0; i<TESTLEN; i++)
        testdata[i] = testdata[i+TESTLEN] = (BYTE)rand()&0xff;
    nfp = &genframe;                        /* Open net driver.. */
    nfp->g.dtype = frametype = open_net(netcfg);    /* ..get frame type */
    if (!frametype)
    {
        printf("ERROR: can't open network driver\n");
        exit(1);
    }
    else
    {
        newappstate(STATE_IDLE);            /* Set default states */
        newconnstate(APP_IDLE);
        timeout(&errtimer, 0);              /* Refresh timeout timer */
        while (!breakflag && cmdkey!='Q')   /* Main command loop.. */
        {
            txlen = keysig = connsig = 0;
            prompt_user();                  /* Prompt user on state change */
            if (sstep || kbhit())           /* If single-step or keypress..*/
            {
                k = getch();                /* ..get key */
                if (sstep)
                    timeout(&errtimer, 0);  /* If single-step, refresh timer */
                cmdkey = toupper(k);        /* Decode keystrokes.. */
                switch (cmdkey)             /* ..and generate signals */
                {
                case 'I':                   /* 'I': broadcast ident */
                    if (connstate != STATE_CONNECTED)
                        printf("Broadcast ident request\n");
                    keysig = SIG_USER_IDENT;
                    break;

                case 'O':                   /* 'O': open connection */
                    printf("Open connection: remote ident (RETURN if any)? ");
                    mygets(remid, IDLEN);
                    if (kbuff[0])
                        printf("Contacting '%s'..\n", remid);
                    else
                        printf("Contacting any node..\n");
                    keysig = SIG_USER_OPEN;
                    break;

                case 'D':                   /* 'D': directory */
                    printf("Directory of remote node\n");
                    if (connstate != STATE_CONNECTED)
                        printf("Error: not connected\n");
                    else
                        keysig = SIG_USER_DIR;
                    break;

                case 'E':                   /* 'E': echo data test */
                    if (connstate != STATE_CONNECTED)
                        printf("Error: not connected\n");
                    else
                    {
                        printf("Echo test\n");
                        keysig = SIG_USER_ECHO;
                    }
                    break;

                case 'G':                   /* 'G': get file from rmeote */
                    if (connstate != STATE_CONNECTED)
                        printf("Error: not connected\n");
                    else
                    {
                        printf("Filename to get? ");
                        if (mygets(filename, FILENAMELEN))
                            keysig = SIG_USER_GET;
                    }
                    break;

                case 'P':                   /* 'P': put file into remote */
                    if (connstate != STATE_CONNECTED)
                        printf("Error: not connected\n");
                    else
                    {
                        printf("Filename to put? ");
                        if (mygets(filename, FILENAMELEN))
                            keysig = SIG_USER_PUT;
                    }
                    break;

                case 'C':                   /* 'C': close connection */
                    printf("Closing connection..\n");
                    keysig = SIG_USER_CLOSE;
                    break;

                case 'S':                   /* 'S': single-step */
                    sstep = !sstep;
                    printf("Single-step %s\n", sstep ? "on" : "off");
                    break;

                case '?':                   /* '?': dump dignostic log */
                    printf("\n");
                    dump_diags();
                    break;
                }
            }                               /* Feed kbd signal to application */
            connsig = do_apps(&rxbuff, &txbuff, keysig);
            if (!connsig && connstate!=STATE_IDLE &&
                timeout(&errtimer, ERRTIME))/* If idle and timeout.. */
            {                               /* ..check error counter.. */
                if (errcount++ < RETRIES)
                    connsig = do_apps(&rxbuff, &txbuff, SIG_TIMEOUT);
                else                        /* ..signal 'timeout' or 'fail' */
                    connsig = do_apps(&rxbuff, &txbuff, SIG_FAIL);
            }                               /* Keep SCRATCHP alive */
            txlen = do_scratchp(nfp, 0, connsig);
            put_scratchp(nfp, txlen);       /* Transmit packet (if any) */
            txlen = get_pkts(nfp);          /* Check receive packets */
            put_scratchp(nfp, txlen);       /* Transmit response (if any) */
            poll_net(nfp->g.dtype);         /* Keep net drivers alive */
        }
        if (connstate)                      /* Shutdown: still connected? */
        {
            printf("Closing connection..");
            while (get_pkts(nfp))           /* Discard all receive packets.. */
                putchar(',');               /* ..then send 'stop' ..*/
            txlen = make_scratchp(nfp, remaddr, 0, FLAG_STOP, 0, 0);
            put_scratchp(nfp, txlen);
            while (get_pkts(nfp))           /* ..then discard any more.. */
                putchar('.');               /* (to ensure Tx buffer flushed) */
            putchar('\n');
            poll_net(nfp->g.dtype);         /* Keep net drivers alive */
        }
    }
    close_net(frametype);                   /* Close network drver */
    return(0);
}

/* Demultiplex incoming packets */
int get_pkts(GENFRAME *nfp)
{
    int rxlen, txlen=0;

    if ((rxlen=get_frame(nfp)) > 0)         /* If any packet received.. */
    {
        if (is_scratchp(nfp, rxlen))        /* If SCRATCHP.. */
        {
            swap_scratchp(nfp);                 /* ..do byte-swaps.. */
            txlen = do_scratchp(nfp, rxlen, 0); /* ..action it.. */
        }
    }                                       /* ..and maybe return a response */
    return(txlen);                          /* (using the same pkt buffer) */
}

/* Prompt user depending on connection & application states, & kbd signal */
void prompt_user(void)
{
    static int lastappstate=0, lastconnstate=-1;
    static long lastfilelen=0;

    if (lastfilelen != filelen)
        printf("%lu bytes     \r", filelen);
    lastfilelen = filelen;
    if (appstate != lastappstate)
    {
        if (appstate == APP_FILE_RECEIVER)
            printf("Receiving '%s'..\n", filename);
        if (appstate == APP_FILE_SENDER)
            printf("Sending '%s'..\n", filename);
        else if (lastappstate==APP_FILE_SENDER ||
                 lastappstate==APP_FILE_RECEIVER)
        {
            if (!filelen)
                printf("ERROR: file not found\n");
            else
                printf("%lu bytes transferred\n", filelen);
        }
        if (appstate == APP_ECHO_SERVER)
            printf("Echo server running... [C]lose connection?\n");
        else if (appstate == APP_ECHO_CLIENT)
            printf("Echo client running... [C]lose connection?\n");
        lastappstate = appstate;
    }
    else if (connstate != lastconnstate)
    {
        if (connstate == STATE_IDLE)
            printf("Connection closed: [I]dent, [O]pen, [Q]uit?\n");
        if (connstate == STATE_CONNECTED)
        {
            printf("Connected");
            if (*remid)
                printf(" to '%s'", remid);
            printf(": [D]ir [G]et [P]ut [E]cho [C]lose?\n");
        }
        lastconnstate = connstate;
    }
}

/* SCRATCHP connection state machine; given packet buffer and Rx len
** If Rx len is non-zero, process the incoming SCRATCHP packet,
** Otherwise, only check for state chamges or timeouts,
** Return non-zero packet length (incl. SCRATCHP hdr) if responding */
int do_scratchp(GENFRAME *nfp, int rxlen, int sig)
{
    WORD n, trylen, tx=0, txlen=0, crlen=0, dlen=0, txw;
    LWORD oldrx, rxw, acked=0;
    static LWORD txack;
    char *errstr=0, temps[22];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产sm最大网站| 国产亚洲欧美在线| 91丝袜高跟美女视频| 黑人精品欧美一区二区蜜桃 | 91黄色在线观看| av电影在线观看完整版一区二区| 日本怡春院一区二区| 亚洲与欧洲av电影| 中文字幕一区二区在线观看| 久久亚洲一级片| 精品日韩一区二区| 日韩女优电影在线观看| 欧美一区二区视频网站| 欧美日韩一级片在线观看| 91香蕉视频污在线| 成人av在线网| 91在线码无精品| 一本到不卡免费一区二区| 色老头久久综合| 欧美揉bbbbb揉bbbbb| 欧美卡1卡2卡| 欧美mv日韩mv国产网站| 久久亚洲欧美国产精品乐播 | 欧美va亚洲va在线观看蝴蝶网| 欧美日韩免费一区二区三区| 欧美日韩免费观看一区二区三区| 欧美日韩一二区| 日韩一级黄色片| 国产亚洲综合性久久久影院| 成人免费在线播放视频| 亚洲小说春色综合另类电影| 免费观看成人鲁鲁鲁鲁鲁视频| 国模冰冰炮一区二区| 国产传媒久久文化传媒| 色婷婷国产精品久久包臀| 日韩视频免费观看高清在线视频| 久久久久久久久久久久久夜| 亚洲色图一区二区三区| 美女任你摸久久| 91亚洲大成网污www| 久久网这里都是精品| 一区二区三区国产| 国产一区二区三区四区五区美女 | 欧美在线观看你懂的| 久久久久99精品国产片| 五月婷婷久久丁香| 成人毛片老司机大片| 欧美一区二区美女| 亚洲同性gay激情无套| 极品美女销魂一区二区三区免费| 色综合久久综合中文综合网| 欧美成人性战久久| 亚洲高清久久久| 91偷拍与自偷拍精品| 2023国产精华国产精品| 免费黄网站欧美| 欧美色偷偷大香| 一区二区三区中文字幕精品精品| 国产河南妇女毛片精品久久久| 精品伦理精品一区| 日韩在线播放一区二区| 欧美日韩第一区日日骚| 亚洲一区二区欧美日韩| 欧美在线色视频| 亚洲男人电影天堂| 色94色欧美sute亚洲线路一久| 中文字幕欧美一区| 91国内精品野花午夜精品| 一区二区激情视频| 欧美精品在线一区二区三区| 视频一区二区不卡| 91麻豆精品国产91久久久更新时间 | 中文字幕一区二区5566日韩| 高清免费成人av| 国产欧美一区二区精品忘忧草 | www.亚洲国产| 粉嫩av亚洲一区二区图片| 国产三级欧美三级日产三级99 | 久久久精品黄色| 91精品欧美一区二区三区综合在 | 丝袜诱惑制服诱惑色一区在线观看 | 日韩一区二区麻豆国产| 捆绑调教美女网站视频一区| 日韩一级免费一区| 国产在线国偷精品产拍免费yy| 国产日韩欧美高清在线| 99国产精品一区| 国产精品系列在线观看| 亚洲色图清纯唯美| 精品福利一二区| 欧美人与性动xxxx| 色婷婷综合中文久久一本| 日韩中文字幕亚洲一区二区va在线| 日本一区二区三区在线不卡| 色婷婷狠狠综合| 成人sese在线| 国产精品一二二区| 日韩中文字幕亚洲一区二区va在线| 国产精品久久久久久久久果冻传媒 | 欧美国产一区在线| 日韩免费电影网站| 欧美精品一二三区| 91福利资源站| 欧美午夜在线观看| 99热在这里有精品免费| 亚洲青青青在线视频| 久久久另类综合| 亚洲天堂中文字幕| 青青青伊人色综合久久| 美女视频黄a大片欧美| 国产一区二区视频在线| 国产一区二区三区视频在线播放| 久久国产日韩欧美精品| 麻豆成人91精品二区三区| 午夜不卡在线视频| 日本aⅴ免费视频一区二区三区| 亚洲永久精品国产| 丝袜美腿成人在线| 免费成人在线观看视频| 毛片不卡一区二区| 精品亚洲成a人| 高潮精品一区videoshd| 91在线观看地址| 欧美自拍丝袜亚洲| 51精品国自产在线| 欧美激情资源网| 亚洲国产成人91porn| 日韩福利电影在线观看| 狠狠色丁香久久婷婷综| 成人毛片视频在线观看| 欧美日韩精品一区二区天天拍小说 | 国产亚洲午夜高清国产拍精品| 国产精品第13页| 亚瑟在线精品视频| 国产一区二区三区精品欧美日韩一区二区三区 | 国产一区二区女| 99国产精品久久久久| 欧美日韩电影一区| 国产精品久久久久久久浪潮网站| 国产精品综合在线视频| 欧美人伦禁忌dvd放荡欲情| 国产精品国产自产拍高清av| 韩国午夜理伦三级不卡影院| 欧美私人免费视频| 亚洲精品国产a久久久久久| 国产精品77777| 精品乱人伦小说| 国产精品一区二区黑丝| 成人精品高清在线| 国产精品女上位| 老色鬼精品视频在线观看播放| 在线一区二区三区做爰视频网站| 欧美精品在线视频| 亚洲精品免费视频| 成人免费看视频| 国产亚洲精品久| 精久久久久久久久久久| 在线不卡a资源高清| 一区二区激情视频| 99精品久久只有精品| 久久午夜羞羞影院免费观看| 免费看精品久久片| 91精品国产综合久久福利软件| 最好看的中文字幕久久| 国产成人在线免费观看| 精品区一区二区| 久久精品国产久精国产爱| 欧美精品1区2区| 日本最新不卡在线| 日韩一区二区在线看| 精品一区免费av| 精品免费国产一区二区三区四区| 麻豆国产一区二区| wwww国产精品欧美| 国产精品一二三区| 亚洲私人影院在线观看| 色爱区综合激月婷婷| 亚洲一区二区三区精品在线| 91精品国产一区二区三区| 精品系列免费在线观看| 国产亚洲欧美一区在线观看| 国产成人一区在线| 国产精品国产三级国产aⅴ入口| eeuss鲁片一区二区三区 | 日韩三级视频在线看| 久久99国产精品成人| 678五月天丁香亚洲综合网| 久热成人在线视频| 国产精品久久久久国产精品日日| 91麻豆免费看片| 日本成人在线一区| 亚洲欧美日韩国产综合| 欧美一区二区啪啪| 99精品偷自拍| 日本伊人午夜精品| 一区二区在线观看免费视频播放 | 欧美一区二区三区的| 波多野结衣中文字幕一区| 免费在线视频一区| 日韩理论电影院|