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

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

?? utility.c

?? linux下telnet服務端的源碼實現
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* Copyright (C) 1998,2001,2005 Free Software Foundation, Inc.   This file is part of GNU Inetutils.   GNU Inetutils is free software; you can redistribute it and/or modify   it under the terms of the GNU General Public License as published by   the Free Software Foundation; either version 2, or (at your option)   any later version.   GNU Inetutils is distributed in the hope that it will be useful,   but WITHOUT ANY WARRANTY; without even the implied warranty of   MERCHANTABILITY or FITNESS FOR PARTICULAR PURPOSE.  See the   GNU General Public License for more details.   You should have received a copy of the GNU General Public License   along with GNU Inetutils; see the file COPYING.  If not, write   to the Free Software Foundation, Inc., 51 Franklin Street,   Fifth Floor, Boston, MA 02110-1301 USA. */#define TELOPTS#define TELCMDS#define SLC_NAMES#include "telnetd.h"#include <stdarg.h>#ifdef HAVE_TERMIO_H# include <termio.h>#endif#if defined(AUTHENTICATION) || defined(ENCRYPTION)# include <libtelnet/misc.h># define NET_ENCRYPT net_encrypt#else# define NET_ENCRYPT()#endifstatic char netobuf[BUFSIZ+NETSLOP], *nfrontp, *nbackp;static char *neturg;    /* one past last byte of urgent data */#ifdef  ENCRYPTIONstatic char *nclearto;#endifstatic char ptyobuf[BUFSIZ+NETSLOP], *pfrontp, *pbackp;static char netibuf[BUFSIZ], *netip;static int ncc;static char ptyibuf[BUFSIZ], *ptyip;static int pcc;int not42;static intreadstream (int p, char *ibuf, int bufsize){#ifndef HAVE_STREAMSPTY  return read (p, ibuf, bufsize);#else  int flags = 0;  int ret = 0;  struct termios *tsp;  struct termio *tp;  struct iocblk *ip;  char vstop, vstart;  int ixon;  int newflow;  struct  strbuf strbufc, strbufd;  unsigned char ctlbuf[BUFSIZ];  static int flowstate = -1;   strbufc.maxlen = BUFSIZ;  strbufc.buf = (char *)ctlbuf;  strbufd.maxlen = bufsize-1;  strbufd.len = 0;  strbufd.buf = ibuf+1;  ibuf[0] = 0;  ret = getmsg(p, &strbufc, &strbufd, &flags);  if (ret < 0)  /* error of some sort -- probably EAGAIN */    return -1;  if (strbufc.len <= 0 || ctlbuf[0] == M_DATA)    {      /* data message */      if (strbufd.len > 0) /* real data */        return strbufd.len + 1;        /* count header char */      else        {          /* nothing there */          errno = EAGAIN;          return -1;        }    }  /*   * It's a control message.  Return 1, to look at the flag we set   */  switch (ctlbuf[0])    {    case M_FLUSH:      if (ibuf[1] & FLUSHW)        ibuf[0] = TIOCPKT_FLUSHWRITE;      return 1;    case M_IOCTL:      ip = (struct iocblk *) (ibuf+1);      switch (ip->ioc_cmd)        {        case TCSETS:        case TCSETSW:        case TCSETSF:          tsp = (struct termios *) (ibuf + 1 + sizeof(struct iocblk));          vstop = tsp->c_cc[VSTOP];          vstart = tsp->c_cc[VSTART];          ixon = tsp->c_iflag & IXON;          break;        case TCSETA:        case TCSETAW:        case TCSETAF:          tp = (struct termio *) (ibuf + 1 + sizeof(struct iocblk));          vstop = tp->c_cc[VSTOP];          vstart = tp->c_cc[VSTART];          ixon = tp->c_iflag & IXON;          break;        default:          errno = EAGAIN;          return -1;        }      newflow =  (ixon && (vstart == 021) && (vstop == 023)) ? 1 : 0;      if (newflow != flowstate)  /* it's a change */        {          flowstate = newflow;          ibuf[0] = newflow ? TIOCPKT_DOSTOP : TIOCPKT_NOSTOP;          return 1;        }    }  /* nothing worth doing anything about */  errno = EAGAIN;  return -1;#endif /* HAVE_STREAMSPTY */}/* ************************************************************************* *//* Net and PTY I/O functions */voidio_setup (){  pfrontp = pbackp = ptyobuf;  nfrontp = nbackp = netobuf;#ifdef  ENCRYPTION  nclearto = 0;#endif   netip = netibuf;  ptyip = ptyibuf;}voidset_neturg (){  neturg = nfrontp - 1;}/* net-buffers */voidnet_output_byte (int c){  *nfrontp++ = c;}intnet_output_data (const char *format,...){  va_list args;  size_t remaining, ret;  va_start (args, format);  remaining = BUFSIZ - (nfrontp - netobuf);  /* try a netflush() if the room is too low */  if (strlen (format) > remaining || BUFSIZ / 4 > remaining)    {      netflush ();      remaining = BUFSIZ - (nfrontp - netobuf);    }  ret = vsnprintf (nfrontp, remaining, format, args);  nfrontp += ((ret < remaining - 1) ? ret : remaining - 1);  va_end (args);  return ret;}intnet_output_datalen (const void *buf, size_t l){  size_t remaining;  remaining = BUFSIZ - (nfrontp - netobuf);  if (remaining < l)    {      netflush ();      remaining = BUFSIZ - (nfrontp - netobuf);    }  if (remaining < l)    return -1;  memmove (nfrontp, buf, l);  nfrontp += l;  return (int) l;}intnet_input_level (){  return ncc;}intnet_output_level (){  return nfrontp - nbackp;}intnet_buffer_is_full (){  return (&netobuf[BUFSIZ] - nfrontp) < 2;}intnet_get_char (int peek){  if (peek)    return *netip;  else if (ncc > 0)    {      ncc--;      return *netip++ & 0377;    }}intnet_read (){  ncc = read (net, netibuf, sizeof (netibuf));  if (ncc < 0 && errno == EWOULDBLOCK)    ncc = 0;  else if (ncc == 0)    {      syslog (LOG_INFO, "telnetd:  peer died");      cleanup(0);    }  else if (ncc > 0)    {      netip = netibuf;      DEBUG(debug_report,1,	    debug_output_data ("td: netread %d chars\r\n", ncc));      DEBUG(debug_net_data,1,	  	    printdata("nd", netip, ncc));    }  return ncc;}/* PTY buffer functions */intpty_buffer_is_full (){  return (&ptyobuf[BUFSIZ] - pfrontp) < 2;}voidpty_output_byte (int c){  *pfrontp++ = c;}	     voidpty_output_datalen (const void *data, size_t len){  if ((&ptyobuf[BUFSIZ] - pfrontp) > len)    ptyflush ();  memcpy (pfrontp, data, len);  pfrontp += len;}intpty_input_level (){  return pcc;}intpty_output_level (){  return pfrontp - pbackp;}voidptyflush(){  int n;    if ((n = pfrontp - pbackp) > 0)    {      DEBUG(debug_report, 1,	    debug_output_data ("td: ptyflush %d chars\r\n", n));      DEBUG(debug_pty_data, 1,	    printdata("pd", pbackp, n));      n = write(pty, pbackp, n);    }  if (n < 0)    {      if (errno == EWOULDBLOCK || errno == EINTR)	return;      cleanup(0);    }  pbackp += n;  if (pbackp == pfrontp)    pbackp = pfrontp = ptyobuf;}intpty_get_char (int peek){  if (peek)    return *ptyip;  else if (pcc > 0)    {      pcc--;      return *ptyip++ & 0377;    }}intpty_input_putback (const char *str, size_t len){  if (len > &ptyibuf[BUFSIZ] - ptyip)    len = &ptyibuf[BUFSIZ] - ptyip;  strncpy (ptyip, str, len);  pcc += len;}intpty_read (){  pcc = readstream (pty, ptyibuf, BUFSIZ);  if (pcc < 0      && (errno == EWOULDBLOCK #ifdef	EAGAIN	  || errno == EAGAIN #endif	  || errno == EIO))     pcc = 0;  ptyip = ptyibuf;  DEBUG(debug_report,1,	debug_output_data ("ptyread %d chars\r\n", pcc));  DEBUG(debug_pty_data,1,	  	printdata("pty", ptyip, pcc));  return pcc;}/* ************************************************************************* *//* io_drain () *    *   *	A small subroutine to flush the network output buffer, get some data * from the network, and pass it through the telnet state machine.  We * also flush the pty input buffer (by dropping its data) if it becomes * too full. */voidio_drain (){  DEBUG(debug_report, 1, debug_output_data("td: ttloop\r\n"));  if (nfrontp - nbackp > 0)     netflush (); again:  ncc = read (net, netibuf, sizeof netibuf);  if (ncc < 0)    {      if (errno == EAGAIN)	{	  syslog (LOG_INFO, "ttloop: retrying");	  goto again;	}      syslog (LOG_INFO, "ttloop:  read: %m\n");      exit (1);    }  else if (ncc == 0)    {      syslog (LOG_INFO, "ttloop:  peer died: %m\n");      exit (1);    }  DEBUG(debug_report, 1,	debug_output_data ("td: ttloop read %d chars\r\n", ncc));  netip = netibuf;  telrcv ();			/* state machine */  if (ncc > 0)    {      pfrontp = pbackp = ptyobuf;      telrcv ();    }}  /* end of ttloop *//* * Check a descriptor to see if out of band data exists on it. *//* int	s; socket number */intstilloob (int s){  static struct timeval timeout = { 0 };  fd_set excepts;  int value;  do    {      FD_ZERO (&excepts);      FD_SET (s, &excepts);      value = select (s+1, (fd_set *)0, (fd_set *)0, &excepts, &timeout);    }  while (value == -1 && errno == EINTR);  if (value < 0)    fatalperror (pty, "select");  return FD_ISSET (s, &excepts);}/* * nextitem() *   *	Return the address of the next "item" in the TELNET data * stream.  This will be the address of the next character if * the current address is a user data character, or it will * be the address of the character following the TELNET command * if the current address is a TELNET IAC ("I Am a Command") * character. */char *nextitem (char *current){  if ((*current&0xff) != IAC)     return current+1;  switch (*(current+1)&0xff)    {    case DO:    case DONT:    case WILL:    case WONT:	return current+3;	    case SB:		/* loop forever looking for the SE */      {	register char *look = current+2;	for (;;) 	  if ((*look++&0xff) == IAC	      && (*look++&0xff) == SE) 	    return look;	      default:	return current+2;      }    }}  /* end of nextitem *//* * netclear() *   *	We are about to do a TELNET SYNCH operation.  Clear * the path to the network. *   *	Things are a bit tricky since we may have sent the first * byte or so of a previous TELNET command into the network. * So, we have to scan the network buffer from the beginning * until we are up to where we want to be. *   *	A side effect of what we do, just to keep things * simple, is to clear the urgent data pointer.  The principal * caller should be setting the urgent data pointer AFTER calling * us in any case. */#define	wewant(p) \  ((nfrontp > p) && ((*p&0xff) == IAC) && \   ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))voidnetclear (){  register char *thisitem, *next;  char *good;  #ifdef	ENCRYPTION  thisitem = nclearto > netobuf ? nclearto : netobuf;#else	/* ENCRYPTION */  thisitem = netobuf;#endif	/* ENCRYPTION */  while ((next = nextitem (thisitem)) <= nbackp)    thisitem = next;  /* Now, thisitem is first before/at boundary. */#ifdef	ENCRYPTION  good = nclearto > netobuf ? nclearto : netobuf;#else	/* ENCRYPTION */  good = netobuf;	/* where the good bytes go */#endif	/* ENCRYPTION */  while (nfrontp > thisitem)    {      if (wewant (thisitem))	{	  int length;	  for (next = thisitem; wewant (next) && nfrontp > next;	       next = nextitem(next))	    ;	  length = next - thisitem;	  memmove (good, thisitem, length);	  good += length;	  thisitem = next;	}      else	{	  thisitem = nextitem (thisitem);	}    }  nbackp = netobuf;  nfrontp = good;		/* next byte to be sent */  neturg = 0;}  /* end of netclear *//* *  netflush *		Send as much data as possible to the network, *	handling requests for urgent data. */voidnetflush (){  int n;    if ((n = nfrontp - nbackp) > 0)    {      NET_ENCRYPT ();      /*       * if no urgent data, or if the other side appears to be an       * old 4.2 client (and thus unable to survive TCP urgent data),       * write the entire buffer in non-OOB mode.       */      if (!neturg || !not42) 	n = write (net, nbackp, n);	/* normal write */      else	{	  n = neturg - nbackp;	  /*	   * In 4.2 (and 4.3) systems, there is some question about	   * what byte in a sendOOB operation is the "OOB" data.	   * To make ourselves compatible, we only send ONE byte	   * out of band, the one WE THINK should be OOB (though	   * we really have more the TCP philosophy of urgent data	   * rather than the Unix philosophy of OOB data).	   */	  if (n > 1) 	    n = send (net, nbackp, n-1, 0);	/* send URGENT all by itself */	  else 	    n = send (net, nbackp, n, MSG_OOB);	/* URGENT data */	}    }  if (n < 0)    {      if (errno == EWOULDBLOCK || errno == EINTR)	return;      cleanup (0);    }    nbackp += n;#ifdef	ENCRYPTION  if (nbackp > nclearto)    nclearto = 0;#endif	/* ENCRYPTION */  if (nbackp >= neturg)    neturg = 0;  if (nbackp == nfrontp)    {      nbackp = nfrontp = netobuf;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产精品影院| 国产精品白丝jk黑袜喷水| 亚洲欧洲www| 亚洲欧洲国产专区| 欧美aaaaaa午夜精品| 日本免费新一区视频| 黄色资源网久久资源365| 成人av集中营| 91网站最新地址| 欧美日韩一区二区电影| 欧美一区二区精美| 国产嫩草影院久久久久| 亚洲午夜视频在线| 99精品视频在线观看| 欧美一区二区三区在| 久久久精品中文字幕麻豆发布| 中文字幕中文字幕一区二区| 石原莉奈一区二区三区在线观看| 麻豆91在线观看| 色哦色哦哦色天天综合| 久久久噜噜噜久久中文字幕色伊伊| 亚洲欧美日韩国产综合在线| 麻豆成人综合网| 欧美一区二区视频在线观看2020 | 久久综合九色综合欧美就去吻| 久久综合久久久久88| 婷婷亚洲久悠悠色悠在线播放| 成人性生交大片免费| 久久一区二区三区国产精品| 三级在线观看一区二区 | 日韩三级视频中文字幕| 一区二区三区成人| 91久久精品一区二区| 亚洲日本在线看| 91免费看视频| 亚洲综合激情网| 欧美日韩国产片| 久久精品国产99国产精品| 欧美区视频在线观看| 美女视频网站久久| 久久午夜国产精品| 成人国产精品免费网站| 国产精品久久久久久户外露出| 成人综合婷婷国产精品久久蜜臀 | 青草av.久久免费一区| 欧美一区三区四区| 国产福利一区二区| 国产精品久久久久久久久免费相片| 国产99久久久国产精品免费看| 国产精品二三区| 69成人精品免费视频| 国产精品91xxx| 亚洲chinese男男1069| 久久亚洲私人国产精品va媚药| 99久久免费视频.com| 全部av―极品视觉盛宴亚洲| 中文字幕av一区二区三区高| 在线观看91精品国产麻豆| 国产99久久久国产精品免费看| 亚洲高清一区二区三区| 欧美—级在线免费片| 精品少妇一区二区| 欧美一级生活片| 欧美日韩国产乱码电影| 色综合天天性综合| 高清不卡在线观看av| 国产精品123| 久久精品久久综合| 另类综合日韩欧美亚洲| 图片区日韩欧美亚洲| 亚洲第一成年网| 一区二区在线观看免费视频播放| 国产嫩草影院久久久久| 欧美高清在线一区二区| 国产三级精品三级在线专区| 久久久久97国产精华液好用吗| 91精品国产综合久久精品app | 精品国产污污免费网站入口 | 94-欧美-setu| 欧美在线观看你懂的| 欧美日韩一卡二卡| 69堂亚洲精品首页| 国产精品污污网站在线观看| 激情文学综合插| 日韩制服丝袜av| 成人aaaa免费全部观看| 欧美色中文字幕| 久久久亚洲精华液精华液精华液| 久久久久久97三级| 亚洲高清在线精品| 国产99久久久精品| 91精品国产综合久久香蕉麻豆| 国产亚洲一区二区在线观看| 亚洲色图一区二区三区| 国产在线日韩欧美| 欧美精品三级日韩久久| 亚洲国产成人91porn| 成人国产一区二区三区精品| 日韩欧美一区二区免费| 亚洲午夜精品在线| 在线视频欧美区| 亚洲天堂av一区| 在线观看三级视频欧美| 成人免费视频在线观看| 不卡免费追剧大全电视剧网站| www一区二区| 成人一区在线观看| 亚洲人精品午夜| 色综合久久久久久久久久久| 亚洲三级免费观看| 欧美三级中文字| 蜜桃在线一区二区三区| 日韩精品一区在线| 国产69精品久久777的优势| 久久精品欧美日韩| 一本色道久久综合亚洲91| 亚洲一区二区三区四区中文字幕| 欧美色涩在线第一页| 麻豆国产精品官网| 欧美激情在线一区二区| va亚洲va日韩不卡在线观看| 亚洲一二三区不卡| 26uuu色噜噜精品一区二区| 国产aⅴ综合色| 日本在线播放一区二区三区| 久久久亚洲午夜电影| 色婷婷国产精品久久包臀| 日欧美一区二区| 国产精品久久久一本精品| 日韩一区二区中文字幕| 91一区一区三区| 国产精品一品视频| 天天色综合天天| 亚洲另类一区二区| 欧美激情一区三区| 国产亚洲欧美一区在线观看| 欧美在线色视频| 91美女片黄在线| 成人av免费在线观看| 从欧美一区二区三区| 国产一区 二区 三区一级| 久久99精品一区二区三区| 亚洲va天堂va国产va久| 一区二区三区四区激情 | 久久综合久色欧美综合狠狠| 一区二区三区欧美亚洲| av电影在线观看不卡| 亚洲成av人片在www色猫咪| 日韩欧美在线不卡| 久久国产综合精品| 这里是久久伊人| 九九视频精品免费| 亚洲免费观看高清完整版在线| 色综合久久精品| 精品亚洲国内自在自线福利| 日日摸夜夜添夜夜添国产精品| 国产精品久久久久久亚洲毛片| 国产精品免费av| 亚洲国产aⅴ成人精品无吗| 亚洲综合色网站| 亚洲午夜久久久久久久久电影网| 日韩黄色免费电影| 国产精品456| 97精品国产露脸对白| 欧美精品免费视频| 国产精品美女久久久久久2018| 综合在线观看色| 美女精品自拍一二三四| 风间由美中文字幕在线看视频国产欧美| 国产馆精品极品| 在线精品视频小说1| 欧美一级欧美三级| 一区av在线播放| 成人app下载| 精品人在线二区三区| 亚洲乱码国产乱码精品精的特点 | 日韩毛片一二三区| 国产不卡一区视频| 日韩午夜在线观看| 一区二区三区精品视频在线| 国内精品自线一区二区三区视频| 欧美日韩国产首页| 亚洲电影第三页| 国产不卡一区视频| 国产精品国产a级| 成人丝袜18视频在线观看| 日韩精品一区二区三区老鸭窝| 一区二区三区日韩精品| 成人黄页在线观看| 亚洲免费高清视频在线| 成人小视频在线| 亚洲一区二区三区四区在线| 91色九色蝌蚪| 亚洲精品免费在线| 一本大道久久a久久精品综合| 久久久久88色偷偷免费| 国产成人aaa| 一区二区日韩电影| 精品国产凹凸成av人导航| 国产精品77777|