⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ckcnet.c

📁 C-Kermit源码。是使用串口/Modem和网络通讯的程序
💻 C
📖 第 1 页 / 共 5 页
字号:
char *cknetv = "Network support, 7.0.194, 30 Dec 1999";/*  C K C N E T  --  Network support  *//*  Copyright (C) 1985, 1999,    Trustees of Columbia University in the City of New York.    All rights reserved.  See the C-Kermit COPYING.TXT file or the    copyright text in the ckcmai.c module for disclaimer and permissions.*//*  REMINDER: Any changes made to this file that other modules depend must  also be made to cklnet.c (for VOS) until such time as cklnet.c and this  module are merged back together.  NOTE TO CONTRIBUTORS: This file, and all the other shared (ckc and cku)  C-Kermit source files, must be compatible with C preprocessors that support  only #ifdef, #else, #endif, #define, and #undef.  Please do not use #if,  logical operators, or other preprocessor features in this module.  Also,  don't use any ANSI C constructs except within #ifdef CK_ANSIC..#endif.  Authors:  Frank da Cruz (fdc@columbia.edu),    Columbia University Academic Information Systems, New York City.  Jeffrey E Altman (jaltman@columbia.edu) -- OS/2 & Windows and a lot more.    netopen() routine for TCP/IP originally by Ken Yap, Rochester University    (ken@cs.rochester.edu) (no longer at that address).  Missing pieces for Excelan sockets library from William Bader.  Telnet protocol by Frank da Cruz and Jeffrey Altman.  Rlogin protocol by Jeffrey Altman.  SSL support adapted by Jeffrey Altman from work done by    Tim Hudson <tjh@cryptosoft.com> +61 7 32781581  TLS support by Jeffrey Altman.  HTTP support by Jeffrey Altman.  TGV MultiNet code by Frank da Cruz.  MultiNet code adapted to WIN/TCP by Ray Hunter of TWG.  MultiNet code adapted to DEC TCP/IP by Lee Tibbert of DEC and Frank da Cruz.  TCP/IP support adapted to IBM TCP/IP 1.2.1,2.0 for OS/2 by Kai Uwe Rommel.  CMU-OpenVMS/IP modifications by Mike O'Malley, Digital (DEC).  X.25 support by Marcello Frutig, Catholic University,    Rio de Janeiro, Brazil (frutig@rnp.impa.br) with fixes from    Stefaan Eeckels, Eurokom, Luxembourg.    David Lane added support for Stratus X.25 1996.    Stephen Riehm added support for IBM AIX X.25 in April 1998.  Other contributions as indicated in the code.*/#define CKCNET_C#include "ckcsym.h"#include "ckcdeb.h"#include "ckcker.h"#ifdef I386IX                           /* Has to come before ckcnet.h in */#include <errno.h>                      /* this version, but after in others */#endif /* I386IX */#include "ckcnet.h"                     /* which includes ckctel.h */#ifdef CK_SSL#include "ck_ssl.h"#endif /* CK_SSL */#ifdef CK_DNS_SRV#ifdef OS2#ifdef NT#include <wshelper.h>#else /* NT *//* !Error OS/2 does not support DNS Service Records. */#endif /* NT */#else /* OS2 */#include <arpa/inet.h>#include <arpa/nameser.h>#include <resolv.h>#ifndef PS2AIX10#ifndef BSD4#include <netdb.h>#endif /* BSD4 */#endif /* PS2AIX10 */#endif /* OS2 */#ifndef T_SRV#define T_SRV 33#endif /* T_SRV *//* for old Unixes and friends ... */#ifndef MAXHOSTNAMELEN#define MAXHOSTNAMELEN 64#endif /* MAXHOSTNAMELEN */#define MAX_DNS_NAMELEN (15*(MAXHOSTNAMELEN + 1)+1)#endif /* CK_DNS_SRV */#ifdef NOLOCAL#ifdef TCPIPLIB#undef TCPIPLIB#endif /* TCPIPLIB */#endif /* NOLOCAL */#ifndef NOMHHOST#ifdef datageneral#define NOMHHOST#else#ifdef HPUX5WINTCP#define NOMHHOST#endif /* HPUX5WINTCP */#endif /* datageneral */#endif /* NOMHHOST */#ifdef INADDRX  struct in_addr inaddrx;#endif /* INADDRX */int ttnet = NET_NONE;                   /* Network type */int ttnproto = NP_DEFAULT;              /* Network virtual terminal protocol *//* 0 = don't lowercase username for Rlogin/Telnet protocol *//* nonzero = do lowercase it.  Add a SET command if necessary... */#ifdef VMSint ck_lcname = 1;#elseint ck_lcname = 0;#endif /* VMS */extern int                              /* External variables */  duplex, debses, seslog, sessft, wasclosed,  ttyfd, quiet, msgflg, what, nettype, ttmdm;#ifdef NETCONN/* Don't need any of this if there is no network support. *//*  NETLEBUF is (must be) defined for those platforms that call this  module to do network i/o (e.g. netinc(), nettchk(), etc) rather  than doing it themselves (ttinc(), ttchk(), etc).  In this case  the Telnet local-echo buffers and routines are defined and referenced  here, rather than in the ck?tio.c module.*/#ifdef NETLEBUF#define LEBUFSIZ 4096int ttpush = -1, le_data = 0;           /* These are seen from outside */static CHAR le_buf[LEBUFSIZ];           /* These are used internally */static int le_start = 0, le_end = 0;int tt_push_inited = 0;#endif /* NETLEBUF */#ifdef CK_SOCKS                         /* SOCKS Internet relay package */#ifdef CK_SOCKS5                        /* SOCKS 5 */#define accept  SOCKSaccept#define bind    SOCKSbind#define connect SOCKSconnect#define getsockname SOCKSgetsockname#define listen SOCKSlisten#else  /* Not SOCKS 5 */#define accept  Raccept#define bind    Rbind#define connect Rconnect#define getsockname Rgetsockname#define listen Rlisten#endif /* CK_SOCKS5 */#endif /* CK_SOCKS */#ifdef DEC_TCPIP#include <time.h>#include <inet.h>#endif /* DEC_TCPIP *//* Also see ckcnet.h -- hmmm, why don't we always include inet.h? */#ifdef HPUX#ifndef HPUX7                           /* HPUX 7.00 doesn't have it */#include <arpa/inet.h>                  /* For inet_ntoa() prototype */#endif /* HPUX7 */#endif /* HPUX */#ifdef CMU_TCPIP#include <time.h>#endif /* CMU_TCPIP */#ifdef DCLTIMEVAL                       /* UnixWare 7 */struct timeval {                        /* And define these ourselves. */    long tv_sec;                        /* (see comments in ckutio.c) */    long tv_usec;};struct timezone {    int tz_minuteswest;    int tz_dsttime;};#endif /* DCLTIMEVAL */#ifdef WINTCP#include <setjmp.h>#include <signal.h>#include <sys/time.h>/*  The WIN/TCP code path is the same as that for MultiNet.  Only the routine names have changed ...*/#define socket_read     netread#define socket_ioctl    ioctl#define socket_write    netwrite#define socket_close    netclose#ifdef OLD_TWG                         /* some routines have evolved */        extern int vmserrno, uerrno;#define socket_errno    uerrno#define socket_perror   perror         /* which uses errno, not uerrno! */#else#define socket_errno    errno#define socket_perror   win$perror#endif /* OLD_TWG */#else /* Not WINTCP */#ifdef OSF13#ifdef CK_ANSIC#ifdef _NO_PROTO#undef _NO_PROTO#endif /* _NO_PROTO */#endif /* CK_ANSIC */#endif /* OSF13 */#ifndef I386IX#include <errno.h>                      /* Already included above */#endif /* I386IX */#include <signal.h>                     /* Everybody needs this */#ifdef ZILOG                            /* Zilog has different name for this */#include <setret.h>#else#include <setjmp.h>#endif /* ZILOG */#endif /* WINTCP */#ifdef datageneral                      /* Data General AOS/VS */#include <:usr:include:vs_tcp_errno.h>#include <:usr:include:sys:vs_tcp_types.h>#ifdef SELECT/*  NOTE: This can be compiled and linked OK with SELECT defined  but it doesn't work at all.  Anybody who cares and knows how  to fix it, feel free.*/#include <:usr:include:sys:vs_tcp_time.h>#endif /* SELECT */#include <:usr:include:sys:socket.h>#include <:usr:include:netinet:in.h>#include <:usr:include:netdb.h>#endif /* datageneral */#ifndef socket_errno#define socket_errno errno#endif /* socket_errno */#ifdef TNCODEextern int tn_deb;#endif /* TNCODE */int tcp_rdns =                          /* Reverse DNS lookup */#ifdef DEC_TCPIP_OLD    SET_OFF                             /* Doesn't seem to work in UCX */#else     SET_AUTO#endif /* DEC_TCPIP */      ;#ifdef CK_DNS_SRVint tcp_dns_srv = SET_OFF;#endif /* CK_DNS_SRV */#ifdef RLOGCODE#ifdef TCPIPLIB_PROTOTYP( static VOID rlog_oob, (CHAR *, int) );#else_PROTOTYP( static SIGTYP rlogoobh, ( int ) );#endif /* TCPIPLIB */_PROTOTYP( static int rlog_ini, (CHAR *, int,                                 struct sockaddr_in *,                                 struct sockaddr_in *) );int rlog_mode = RL_COOKED;int rlog_stopped = 0;#endif /* RLOGCODE */#ifndef NOICPextern int doconx;                      /* CONNECT-class command active */#endif /* NOICP */#ifdef IBMX25/* This variable should probably be generalised for true client/server * support - ie: the fd of the listening server, accepted calls should * be forked or at least handled via a second fd (for IBM's X.25 - * ttyfd always holds the active fd - ie the server becomes inactive * as long as a client is connected, and becomes active again when the * connection is closed) */int x25serverfd = 0;            /* extern in ckcnet.h */int x25seqno = 0;               /* Connection sequence number */int x25lastmsg = -1;            /* A cheapskate's state table */#define X25_CLOSED      0       /* Default state: no connection, no STREAM */#define X25_SETUP       1       /* X.25 has been set up (no connection) */#define X25_CONNECTED   2       /* X.25 connection has been established */int x25_state = X25_CLOSED;     /* Default state */#endif /* IBMX25 */#ifndef DEBUG#define deblog 0#endif /* DEBUG */#ifdef CK_NAWS                          /* Negotiate About Window Size */#ifdef RLOGCODE_PROTOTYP( int rlog_naws, (void) );#endif /* RLOGCODE */#endif /* CK_NAWS */#ifdef OS2                              /* For terminal type name string */#include "ckuusr.h"#ifndef NT#include <os2.h>#undef COMMENT#endif /* NT */#include "ckocon.h"extern int tt_type, max_tt;extern struct tt_info_rec tt_info[];extern char ttname[];#else#ifdef CK_AUTHENTICATION#include "ckuusr.h"#endif /* CK_AUTHENTICATION */#endif /* OS2 */#ifdef CK_AUTHENTICATION#include "ckuath.h"#endif /* CK_AUTHENTICATION */#include "ckcsig.h"#ifndef OS2                             /* For timeout longjumps */static ckjmpbuf njbuf;#endif /* OS2 */#define NAMECPYL 100                    /* Local copy of hostname */char namecopy[NAMECPYL];                /* Referenced by ckctel.c */char ipaddr[20] = { '\0' };             /* Global copy of IP address */char myipaddr[20] = { '\0' };           /* Global copy of my IP address */unsigned long myxipaddr = 0L;           /* Ditto as a number */#endif /* NETCONN */char *tcp_address = NULL;               /* Preferred IP Address */extern char uidbuf[];                   /* User ID buffer */extern char pwbuf[];                    /* Password buffer */#ifdef OS2extern int tt_rows[], tt_cols[];extern int tt_status;#else /* OS2 */extern int tt_rows, tt_cols;            /* Everybody has this */#endif /* OS2 */extern int cmd_cols, cmd_rows;#ifdef STREAMING                        /* Use blocking writes for streaming */extern int streaming;#endif /* STREAMING */#ifdef NTextern int WSASafeToCancel;int win95selectbug = 0;                 /* For TCP/IP stacks whose select() *//* always fails on write requests such as Cisco and Quarterdeck */#define stricmp _stricmp#endif /* NT */#ifndef NOTCPOPTS/* Skip all this if NOTCPOPTS specified. */#ifdef SOL_SOCKET#ifdef TCP_NODELAYint tcp_nodelay = 0;                    /* Nagle algorithm TCP_NODELAY */#endif /* TCP_NODELAY */#ifdef SO_DONTROUTEint tcp_dontroute = 0;#endif /* SO_DONTROUTE */#ifdef SO_LINGERint tcp_linger  = 0;                    /* SO_LINGER */int tcp_linger_tmo = 0;                 /* SO_LINGER timeout */#endif /* SO_LINGER */#ifdef HPUX                             /* But the data structures */#ifndef HPUX8                           /* needed for linger are not */#ifndef HPUX9                           /* defined in HP-UX versions */#ifndef HPUX10                          /* prior to 8.00. */#ifdef SO_LINGER#undef SO_LINGER#endif /* SO_LINGER */#endif /* HPUX10 */#endif /* HPUX9 */#endif /* HPUX8 */#endif /* HPUX */#ifndef SO_OOBINLINE                    /* Hopefully only HP-UX 7.0 */#define SO_OOBINLINE 0x0100#endif /* SO_OOBINLINE */#ifndef TCPSNDBUFSIZ#ifdef VMS#ifdef __alpha#define TCPSNDBUFSIZ 16384#endif /* __alpha */#endif /* VMS */#endif /* TCPSNDBUFSIZ */#ifndef TCPSNDBUFSIZ#define TCPSNDBUFSIZ -1#endif /* TCPSNDBUFSIZ */#ifdef SO_SNDBUFint tcp_sendbuf = TCPSNDBUFSIZ;#endif /* SO_SNDBUF */#ifdef SO_RCVBUFint tcp_recvbuf = -1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -