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

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

?? tftputil.c

?? 在ARM7和UC/OSII的平臺上實現了GPS自動報站的功能,涉及GPS模塊LEA_4S的驅動,位置速尋算法,語音芯片ISD4004的錄放音驅動,LED頁面管理等等.從啟動代碼到操作系統的移植以及到業
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*   tftputil.c

   Copyright 1998-1999 by InterNiche Technologies, Inc. All rights reserved.
   Copyright 1995 by NetPort Software.
   Copyright 1986 by Carnegie Mellon
   Copyright 1984 by the Massachusetts Institute of Technology
*/

#include "tftpport.h"

#include "tftp.h"

/* internal routine */
static void check_state(struct tfconn * cn);

struct tfconn * tftp_conns = NULL;   /* list of active connections */

int ntftps = 0;   /* number of connections */

/* Setup a TFTP connection block. */

struct tfconn * 
tfmkcn(void)
{
struct tfconn * cn;

   cn = (struct tfconn *)TFC_ALLOC(sizeof(struct tfconn));
   if(!cn)
      return NULL;

   ntftps++;
   cn->next = tftp_conns;   /* add this tfconn to list */
   tftp_conns = cn;

   cn->tf_srtt = cn->tf_rt = TPS/2;   /* init round trip timer with large-ish guess */
   if (cn->tf_rt > TF_MAXTMO)
      cn->tf_rt = TF_MAXTMO;
   if (cn->tf_rt < TF_MINTMO)
      cn->tf_rt = TF_MINTMO;
   cn->tf_NR_last = 1;   /* fake last packet Number retrys */

   return cn;
}


/* Cleanup routine called when done */

void
tfcleanup(struct tfconn *cn)
{
struct tfconn * tmp, * last;

   /* unlink cn from list */
   tmp = tftp_conns;
   last = NULL;
   while(tmp)   /* traverse list, looking of cn to free */
   {
      if(tmp == cn)
      {
         if(last)   /* unlink from list */
            last->next = tmp->next;
         else   /* was first in list, fix list pointer */
            tftp_conns = tmp->next;
         break;
      }
      last = tmp;
      tmp = tmp->next;
   }
   if(!tmp)   /* connection not in master list? */
   {
      dtrap("tftputil 1\n");   /* serious prog error..... */
   }

   if(cn->tf_fd != NULL)
      vfclose(cn->tf_fd);
   if(cn->tf_outbuf.data)
      tftp_udpfree(cn);
   if(cn->tf_conn != 0)
      tftp_udpclose(cn->tf_conn);

   TFC_FREE(cn);
   ntftps--;
}


void 
tftptmo(struct tfconn * cn)
{
TFTPBUF p;

   cn->tf_tmo++;
   /* if we have more tries... */
   if((cn->tf_tries == 0) || (--cn->tf_tries))
   {
   int e;

      cn->tf_rsnd++;
      cn->tf_NR++;
      /* do the actual retry. Don't use tf_write() since it will re-init 
         the round trip & retry count values. */
      p = &cn->tf_outbuf;
      e = tftp_udpsend(cn, p->data, cn->tf_lastlen);
      if(e < 0)
      {
         if (cn->callback)
         {
            if (e == ENP_NOBUFFER)
               cn->callback(TFC_BUFFER, cn, "UDP alloc failed");
            else
               cn->callback(TFC_UDPSEND, cn, "UDP send failed");
         }
         tfkill(cn);    /* UDP send error, kill tftp session */
      }
      else  /* udp retry packet sent OK */
      {
         cn->tf_rt <<= 1;      /* double round trip est. */
         if (cn->tf_rt > TF_MAXTMO)
            cn->tf_rt = TF_MAXTMO;
         cn->tf_tick = cticks + cn->tf_rt;   /* set time to do next retry */
      }
   }
   else 
   {
      cn->tf_state = TIMEOUT;
   }
}

/* tf_good() - called to do timing calcs after good receives */

void
tf_good(struct tfconn * cn)
{
unsigned long trt;

   trt = cticks - cn->tf_sent;  /*  Measured round trip time  */
   /* set smoothed round trip time based on measured */
   if((cn->tf_srtt > trt) && (cn->tf_srtt > 1))
      cn->tf_srtt--;
   else if((cn->tf_srtt) < trt)
      cn->tf_srtt++;
   /* set the retry time: experimental algorithm: */
   trt = trt + cn->tf_srtt + 1;
   if (trt < TF_MINTMO)
      cn->tf_rt = TF_MINTMO;
   else if (trt > TF_MAXTMO)
      cn->tf_rt = TF_MAXTMO;
   else
      cn->tf_rt = trt;

   cn->tf_NR_last = cn->tf_NR;
   cn->tf_NR = 0;
}



/* tfdodata() - Process a data packet received for TFTP connection cn.
Handle out of sequence blocks and check on block length. If a block
is way to short (len < tftp header size) send back an error message
and abort the transfer. If the block is less than 512 bytes long, shut 
down the transfer; we're done. Otherwise, just write it to disk (if necessary).

Returns TRUE if OK, FALSE if error.
*/

int /* BOOL */
tfdodata(struct tfconn * cn,
   TFTPBUF p,
   unsigned len)
{
char * data;
struct tfdata *ptfdat;

   if(len < 4) 
   {
      tfsnderr(cn, ERRTXT, "Bad len (too short)");
      if (cn->callback)
         cn->callback(TFC_BADLEN, cn, "short data from peer");
      tfkill(cn);
      return FALSE;
   }

   if(cn->tf_state != DATAWAIT)
   {
      tfsnderr(cn, ERRTXT, "Rcvd unexpected data block");
      return FALSE;
   }

   /* point to tftp header at front of */
   ptfdat = (struct tfdata *) p->data;
   len -= 4;   /* subtract length of header from data */

   if(htons(ptfdat->tf_block) != cn->tf_expected)
   {

   /*   We got a retransmission of a packet we have already tried to
   ACK.  If we retransmit the ACK, and the old ACK finally gets through also,
   our correspondent will resend the next data block, and we will do the same
   thing for it, on through to the end of the file.  So we shouldn't retransmit
   the ACK until we are convinced that the first one was actually lost.  We will
   become convinced if our own timeout waiting for the next data packet
   expires.  */

      cn->tf_ous++;   
      return FALSE;
   }
   tf_good(cn);   /* adjust timer values */

   cn->tf_size += len;
   cn->tf_flen = len;

   /* write UDP data into file */
   data = ptfdat->tf_data;
   if((int)vfwrite(data, 1, len, cn->tf_fd) != (int)len)
   {
      tf_full(cn);
      return FALSE;
   }
   
   /* Send the ack & move to next state */
   tfsndack(cn);
   if(len == NORMLEN) 
      cn->tf_state = DATAWAIT;
   else    /* sub-normal len (less than 512) indicates end of file */
      cn->tf_state = RCVLASTDATA;

   cn->tf_expected++;
   return TRUE;
}

/*  Handle disk full condition by sending error packet and killing
    this connection.  */
void
tf_full(struct tfconn *cn)
{
   tfsnderr(cn, DISKFULL, " ");
   tfkill(cn);   
   if(cn->callback)
       cn->callback(TFC_DISKFULL, cn, tferrors[DISKFULL] );
}

/* Send an error packet. If the code is nonzero, put it in the packet.
   Otherwise, copy the text into the packet. */

char * tferrors[] = 
{
   "See text",
   "File not found",
   "Access violation",
   "Disk full",
   "Illegal TFTP operation",
   "Unknown transfer ID",
   "File already exists",
   "No such user"
};

void
tfsnderr(struct tfconn * cn,
   unsigned code,
   char *text)
{
unsigned len;
struct tferr *perr;

   len = sizeof(struct tferr)-2;

   tftp_udpbuffer(cn, sizeof(struct tfack) );
   if(cn->tf_outbuf.data == NULL)
      return;

   perr = (struct tferr *)(cn->tf_outbuf.data);
   perr->tf_op = htons(TF_ERROR);
   perr->tf_code = htons(code);

   if(code == ERRTXT)
   {
      strcpy(perr->tf_err, text);
      len += strlen(text)+1;
   }
   else
   {
      strcpy(perr->tf_err, tferrors[code]);
      len += strlen(tferrors[code]) + 1;
   }
   tftp_udpsend(cn, perr, len);
   tftp_udpfree(cn);    /* free now, there are no retrys on these */
}

/* Process an incoming error packet */

void
tfdoerr(struct tfconn *cn, TFTPBUF p, unsigned len)
{
struct tferr * perr;
int tferror;   /* tftp protocol error */
char * errtxt;   /* text of/for error */

   /* if connection is dead, don't worry about this... */
   if(cn->tf_state == DEAD || cn->tf_state == TERMINATED)
      return;

   tfkill(cn);

   perr = (struct tferr *) p->data;   /* overlay tftp error packet struct */
   tferror = htons(perr->tf_code);      /* get tftp error code (see rfc) */
   if(tferror > 0 && tferror < 8)      /* check for known range of errors */
      errtxt = tferrors[tferror];      /* get text from array if known error */
   else   /* not know error, try to extract text from tftp packet */
   {
      errtxt = perr->tf_err;
      if(*errtxt <= ' ' || *errtxt & 0x80 || (strlen(errtxt) > 100))   /* make sure it's printable */
         errtxt = "bogus tftp error text";
   }
   if(cn->callback)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.亚洲精品| 欧美日韩精品一区二区三区蜜桃 | 亚洲一区av在线| 日韩欧美久久久| 99久久99久久久精品齐齐| 日韩高清不卡在线| 综合自拍亚洲综合图不卡区| 91精品久久久久久久91蜜桃| 91在线视频观看| 国产乱国产乱300精品| 性做久久久久久| 日韩毛片视频在线看| 日韩欧美一区二区在线视频| 色婷婷av一区二区三区大白胸| 麻豆精品视频在线观看视频| 亚洲一区二区视频| 中文字幕一区不卡| 国产视频一区二区在线| 日韩一级二级三级精品视频| 欧美午夜一区二区| 日本丶国产丶欧美色综合| 丰满少妇久久久久久久| 久久91精品国产91久久小草| 三级在线观看一区二区| 亚洲永久精品大片| 一区二区三区在线视频免费观看| 国产精品国产三级国产aⅴ入口| 欧美不卡视频一区| 欧美一区二区三区婷婷月色| 欧美性大战久久| 欧美伊人久久大香线蕉综合69| 波多野结衣在线一区| 国产真实乱偷精品视频免| 美女一区二区视频| 久久成人久久鬼色| 麻豆国产欧美一区二区三区| 日产精品久久久久久久性色| 三级不卡在线观看| 日韩在线播放一区二区| 无吗不卡中文字幕| 性欧美大战久久久久久久久| 午夜电影网一区| 日韩国产高清影视| 麻豆freexxxx性91精品| 麻豆精品在线播放| 国产精品 欧美精品| 国产精品香蕉一区二区三区| 国产一区二区看久久| 久久99精品久久只有精品| 国内国产精品久久| 成人激情免费电影网址| 99re6这里只有精品视频在线观看| youjizz国产精品| 91免费看视频| 欧美午夜影院一区| 欧美一二三四区在线| 精品国产第一区二区三区观看体验| 欧美一区二区三区四区久久| 亚洲精品一区二区在线观看| 久久久精品免费观看| 国产精品国产a| 亚洲在线观看免费视频| 日本成人在线网站| 国产精品一二三四区| 95精品视频在线| 欧美日本免费一区二区三区| 日韩精品影音先锋| 亚洲国产精品99久久久久久久久| 中文字幕一区二区三区在线不卡| 亚洲综合精品自拍| 极品尤物av久久免费看| 99久久久免费精品国产一区二区| 欧美在线|欧美| 日韩免费视频线观看| 亚洲欧洲一区二区三区| 亚洲3atv精品一区二区三区| 麻豆精品久久久| 91啪在线观看| 日韩精品一区二区三区中文不卡 | 日本午夜精品视频在线观看| 久久99国产精品久久| 99久久免费视频.com| 欧美一区二区性放荡片| 国产精品伦理一区二区| 五月天一区二区| 国产成人精品午夜视频免费| 欧美图区在线视频| 久久久99久久| 日韩国产欧美在线播放| 成人av在线一区二区三区| 欧美卡1卡2卡| 亚洲天堂2014| 韩国成人精品a∨在线观看| 在线观看一区二区精品视频| 久久精品亚洲乱码伦伦中文 | 亚洲h在线观看| 福利一区二区在线| 欧美一区二区三区在线电影| 亚洲蜜桃精久久久久久久| 久久91精品久久久久久秒播| 欧美在线一二三四区| 国产欧美一区二区精品久导航 | 日韩欧美国产系列| 亚洲欧美经典视频| 国产成人久久精品77777最新版本| 欧美欧美欧美欧美首页| 国产精品欧美一级免费| 久久99久久精品| 欧美精品一卡二卡| 亚洲免费观看高清完整版在线观看 | 综合欧美亚洲日本| 国产精品99精品久久免费| 5月丁香婷婷综合| 亚洲乱码中文字幕综合| 成人精品在线视频观看| 精品国产a毛片| 免费黄网站欧美| 精品视频一区三区九区| 亚洲欧美另类在线| 99久久国产免费看| 亚洲国产高清aⅴ视频| 国产一区二区在线观看免费| 欧美一区二区三区视频免费| 亚洲国产综合人成综合网站| 色综合久久精品| 国产精品久久久久桃色tv| 国产成人亚洲精品狼色在线 | 国产亚洲精品中文字幕| 久久国产精品色婷婷| 日韩欧美精品三级| 人人爽香蕉精品| 欧美一级高清片| 麻豆精品一二三| 精品毛片乱码1区2区3区| 麻豆精品一区二区三区| 精品国产一区二区国模嫣然| 奇米在线7777在线精品 | 久久久噜噜噜久久中文字幕色伊伊| 日韩有码一区二区三区| 91.com在线观看| 日韩精品免费专区| 宅男在线国产精品| 久久国产生活片100| www国产精品av| 国产一区二区三区免费播放| 欧美精品一区二区三区很污很色的 | 国产另类ts人妖一区二区| 日本一区二区三区在线观看| 国产黑丝在线一区二区三区| 国产精品久久久久毛片软件| 成人av电影在线| 亚洲综合男人的天堂| 日韩一区二区在线观看视频播放| 免费在线视频一区| 久久久综合九色合综国产精品| 成人小视频在线观看| 亚洲日本免费电影| 欧美日本韩国一区| 精品一区免费av| 国产精品污污网站在线观看| 色综合久久中文字幕| 三级影片在线观看欧美日韩一区二区| 91精品国产色综合久久不卡蜜臀 | 午夜一区二区三区在线观看| 这里只有精品视频在线观看| 久久99精品久久久久久久久久久久 | 日韩欧美国产三级| 国产99久久久国产精品潘金 | 丝袜a∨在线一区二区三区不卡| 91精品麻豆日日躁夜夜躁| 国产盗摄女厕一区二区三区| 亚洲欧美视频在线观看| 91精品黄色片免费大全| 国产aⅴ精品一区二区三区色成熟| 亚洲精品高清在线| 欧美sm美女调教| 91视频免费观看| 日本欧美肥老太交大片| 国产精品二三区| 欧美一区二区三区四区五区 | 一区二区中文字幕在线| 3751色影院一区二区三区| 高清不卡一二三区| 日韩av电影一区| 亚洲三级在线看| 精品国内二区三区| 91精品1区2区| 国产精品一区2区| 日韩电影网1区2区| 亚洲日穴在线视频| 久久综合狠狠综合久久综合88| 欧美在线观看18| 不卡的av在线播放| 韩日av一区二区| 亚洲第一精品在线| 亚洲日本免费电影| 国产欧美一区二区精品性色| 91精品国产综合久久精品图片| 色综合久久中文字幕综合网| 国产精华液一区二区三区|