home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckcnet.h < prev    next >
C/C++ Source or Header  |  2020-01-01  |  42KB  |  1,467 lines

  1. /* ckcnet.h -- Symbol and macro definitions for C-Kermit network support */
  2.  
  3. /*
  4.   Author: Frank da Cruz <fdc@columbia.edu>
  5.   Columbia University Academic Information Systems, New York City.
  6.  
  7.   Copyright (C) 1985, 2005,
  8.     Trustees of Columbia University in the City of New York.
  9.     All rights reserved.  See the C-Kermit COPYING.TXT file or the
  10.     copyright text in the ckcmai.c module for disclaimer and permissions.
  11. */
  12. #ifndef CKCNET_H
  13. #define CKCNET_H
  14.  
  15. /* Network types */
  16.  
  17. #define NET_NONE 0                      /* None */
  18. #define NET_TCPB 1                      /* TCP/IP Berkeley (socket) */
  19. #define NET_TCPA 2                      /* TCP/IP AT&T (streams) */
  20. #define NET_SX25 3                      /* SUNOS SunLink X.25 */
  21. #define NET_DEC  4                      /* DECnet */
  22. #define NET_VPSI 5                      /* VAX PSI */
  23. #define NET_PIPE 6                      /* LAN Manager Named Pipe */
  24. #define NET_VX25 7                      /* Stratus VOS X.25 */
  25. #define NET_BIOS 8                      /* IBM NetBios */
  26. #define NET_SLAT 9                      /* Meridian Technologies' SuperLAT */
  27. #define NET_FILE 10                     /* Read from a file */
  28. #define NET_CMD  11                     /* Read from a sub-process */
  29. #define NET_DLL  12                     /* Load a DLL for use as comm channel*/
  30. #define NET_IX25 13                     /* IBM AIX 4.1 X.25 */
  31. #define NET_HX25 14                     /* HP-UX 10 X.25 */
  32. #define NET_PTY  15                     /* Pseudoterminal */
  33. #define NET_SSH  16                     /* SSH */
  34.  
  35. #ifdef OS2                              /* In OS/2, only the 32-bit */
  36. #ifndef __32BIT__                       /* version gets NETBIOS */
  37. #ifdef CK_NETBIOS
  38. #undef CK_NETBIOS
  39. #endif /* CK_NETBIOS */
  40. #endif /* __32BIT__ */
  41. #endif /* OS2 */
  42.  
  43. #ifdef _M_PPC
  44. #ifdef SUPERLAT
  45. #undef SUPERLAT
  46. #endif /* SUPERLAT */
  47. #endif /* _M_PPC */
  48.  
  49. #ifdef NPIPE                            /* For items in common to */
  50. #define NPIPEORBIOS                     /* Named Pipes and NETBIOS */
  51. #endif /* NPIPE */
  52. #ifdef CK_NETBIOS
  53. #ifndef NPIPEORBIOS
  54. #define NPIPEORBIOS
  55. #endif /* NPIPEORBIOS */
  56. #endif /* CK_NETBIOS */
  57.  
  58. /* Network virtual terminal protocols (for SET HOST connections) */
  59. /* FTP, HTTP and SSH have their own stacks                       */
  60.  
  61. #define NP_DEFAULT    255
  62. #define NP_NONE         0               /* None (async) */
  63. #define NP_TELNET       1               /* TCP/IP telnet */
  64. #define NP_VTP          2               /* ISO Virtual Terminal Protocol */
  65. #define NP_X3           3               /* CCITT X.3 */
  66. #define NP_X28          4               /* CCITT X.28 */
  67. #define NP_X29          5               /* CCITT X.29 */
  68. #define NP_RLOGIN       6               /* TCP/IP Remote login */
  69. #define NP_KERMIT       7               /* TCP/IP Kermit */
  70. #define NP_TCPRAW       8               /* TCP/IP Raw socket */
  71. #define NP_TCPUNK       9               /* TCP/IP Unknown */
  72. #define NP_SSL         10               /* TCP/IP SSLv23 */
  73. #define NP_TLS         11               /* TCP/IP TLSv1 */
  74. #define NP_SSL_TELNET  12               /* TCP/IP Telnet over SSLv23 */
  75. #define NP_TLS_TELNET  13               /* TCP/IP Telnet over TLSv1 */
  76. #define NP_K4LOGIN     14               /* TCP/IP Kerberized remote login */
  77. #define NP_EK4LOGIN    15               /* TCP/IP Encrypted Kerberized ... */
  78. #define NP_K5LOGIN     16               /* TCP/IP Kerberized remote login */
  79. #define NP_EK5LOGIN    17               /* TCP/IP Encrypted Kerberized ... */
  80. #define NP_K5U2U       18               /* TCP/IP Kerberos 5 User to User */
  81. #define NP_CTERM       19               /* DEC CTERM */
  82. #define NP_LAT         20               /* DEC LAT */
  83. #define NP_SSL_RAW     21        /* SSL with no Telnet permitted */
  84. #define NP_TLS_RAW     22        /* TLS with no Telnet permitted */
  85.  
  86. /* others here... */
  87.  
  88. #ifdef CK_SSL
  89. #define IS_TELNET()      (nettype == NET_TCPB && (ttnproto == NP_TELNET \
  90.                          || ttnproto == NP_SSL_TELNET \
  91.                          || ttnproto == NP_TLS_TELNET \
  92.                          || ttnproto == NP_KERMIT))
  93. #else /* CK_SSL */
  94. #define IS_TELNET()      (nettype == NET_TCPB && (ttnproto == NP_TELNET \
  95.                          || ttnproto == NP_KERMIT))
  96. #endif /* CK_SSL */
  97.  
  98. #ifdef CK_KERBEROS
  99. #ifdef KRB5
  100. #ifdef KRB4
  101. #define IS_RLOGIN()      (nettype == NET_TCPB && (ttnproto == NP_RLOGIN \
  102.                          || ttnproto == NP_K5LOGIN \
  103.                          || ttnproto == NP_EK5LOGIN \
  104.                          || ttnproto == NP_K4LOGIN \
  105.                          || ttnproto == NP_EK4LOGIN \
  106.                          ))
  107. #else /* KRB4 */
  108. #define IS_RLOGIN()      (nettype == NET_TCPB && (ttnproto == NP_RLOGIN \
  109.                          || ttnproto == NP_K5LOGIN \
  110.                          || ttnproto == NP_EK5LOGIN \
  111.                          ))
  112. #endif /* KRB4 */
  113. #else /* KRB5 */
  114. #ifdef KRB4
  115. #define IS_RLOGIN()      (nettype == NET_TCPB && (ttnproto == NP_RLOGIN \
  116.                          || ttnproto == NP_K4LOGIN \
  117.                          || ttnproto == NP_EK4LOGIN \
  118.                          ))
  119. #else /* KRB4 */
  120. KERBEROS defined without either KRB4 or KRB5
  121. #endif /* KRB4 */
  122. #endif /* KRB5 */
  123. #else /* CK_KERBEROS */
  124. #define IS_RLOGIN()      (nettype == NET_TCPB && (ttnproto == NP_RLOGIN))
  125. #endif /* CK_KERBEROS */
  126.  
  127. #define IS_SSH()         (nettype == NET_SSH)
  128.  
  129. /* RLOGIN Modes */
  130. #define    RL_RAW     0                 /*  Do Not Process XON/XOFF */
  131. #define    RL_COOKED  1                 /*  Do Process XON/XOFF */
  132.  
  133. /* Encryption types */
  134.  
  135. #define CX_NONE    999
  136.  
  137. #ifdef ENCTYPE_ANY
  138. #define CX_AUTO ENCTYPE_ANY
  139. #else
  140. #define CX_AUTO 0
  141. #endif /* ENCTYPE_ANY */
  142.  
  143. #ifdef ENCTYPE_DES_CFB64
  144. #define CX_DESC64 ENCTYPE_DES_CFB64
  145. #else
  146. #define CX_DESC64 1
  147. #endif /* ENCTYPE_DES_CFB64 */
  148.  
  149. #ifdef ENCTYPE_DES_OFB64
  150. #define CX_DESO64 ENCTYPE_DES_OFB64
  151. #else
  152. #define CX_DESO64 2
  153. #endif /* ENCTYPE_DES_OFB64 */
  154.  
  155. #ifdef ENCTYPE_DES3_CFB64
  156. #define CX_DES3C64 ENCTYPE_DES3_CFB64
  157. #else
  158. #define CX_DES3C64 3
  159. #endif /* ENCTYPE_DES_CFB64 */
  160.  
  161. #ifdef ENCTYPE_DES3_OFB64
  162. #define CX_DESO64 ENCTYPE_DES3_OFB64
  163. #else
  164. #define CX_DES3O64 4
  165. #endif /* ENCTYPE_DES_OFB64 */
  166.  
  167. #ifdef ENCTYPE_CAST5_40_CFB64
  168. #define CX_C540C64 ENCTYPE_CAST5_40_CFB64
  169. #else
  170. #define CX_C540C64 8
  171. #endif /* ENCTYPE_CAST5_40_CFB64 */
  172.  
  173. #ifdef ENCTYPE_CAST5_40_OFB64
  174. #define CX_C540O64 ENCTYPE_CAST5_40_OFB64
  175. #else
  176. #define CX_C540O64 9
  177. #endif /* ENCTYPE_CAST5_40_OFB64 */
  178.  
  179. #ifdef ENCTYPE_CAST128_CFB64
  180. #define CX_C128C64 ENCTYPE_CAST128_CFB64
  181. #else
  182. #define CX_C128C64 10
  183. #endif /* ENCTYPE_CAST128_CFB64 */
  184.  
  185. #ifdef ENCTYPE_CAST128_OFB64
  186. #define CX_C128O64 ENCTYPE_CAST128_OFB64
  187. #else
  188. #define CX_C128O64 11
  189. #endif /* ENCTYPE_CAST128_OFB64 */
  190.  
  191. /* Basic network function prototypes, common to all. */
  192.  
  193. _PROTOTYP( int netopen, (char *, int *, int) );
  194. _PROTOTYP( int netclos, (void) );
  195. _PROTOTYP( int netflui, (void) );
  196. _PROTOTYP( int nettchk, (void) );
  197. _PROTOTYP( int netxchk, (int) );
  198. _PROTOTYP( int netbreak, (void) );
  199. _PROTOTYP( int netinc, (int) );
  200. _PROTOTYP( int netxin, (int, CHAR *) );
  201. _PROTOTYP( int nettol, (CHAR *, int) );
  202. _PROTOTYP( int nettoc, (CHAR) );
  203. /*
  204.   SunLink X.25 support by Marcello Frutig, Catholic University,
  205.   Rio de Janeiro, Brazil, 1990.
  206.  
  207.   Maybe this can be adapted to VAX PSI and other X.25 products too.
  208. */
  209. #ifndef SUNOS4                          /* Only valid for SUNOS4 */
  210. #ifndef SOLARIS
  211. #ifdef SUNX25
  212. #undef SUNX25
  213. #endif /* SUNX25 */
  214. #endif /* SOLARIS */
  215. #endif /* SUNOS4 */
  216.  
  217. #ifdef STRATUSX25
  218. #define ANYX25
  219. #define MAX_USER_DATA 128 /* SUN defines this in a header file, I believe. */
  220. #endif /* STRATUSX25 */
  221.  
  222. #ifdef SUNX25
  223. #define ANYX25
  224. #endif /* SUNX25 */
  225.  
  226. #ifdef IBMX25                           /* AIX 4.1 X.25 */
  227. #ifndef AIX41
  228. #undef IBMX25
  229. #else /* AIX41 */
  230. #define ANYX25
  231. #define MAX_USER_DATA NPI_MAX_DATA      /* used for buffer sizes */
  232. #endif /* AIX41 */
  233. #endif /* IBMX25 */
  234.  
  235. #ifdef HPX25                            /* HP-UX 10.* X.25 */
  236. #ifndef HPUX10
  237. #undef HPX25
  238. #else /* HPUX10 */
  239. #define ANYX25
  240. #endif /* HPUX10 */
  241. #endif /* HPX25 */
  242.  
  243. #ifdef ANYX25
  244. #ifndef NETCONN                         /* ANYX25 implies NETCONN */
  245. #define NETCONN
  246. #endif /* NETCONN */
  247.  
  248. #define MAXPADPARMS                22   /* Number of PAD parameters */
  249. #define MAXCUDATA                  12   /* Max length of X.25 call user data */
  250. #define X29PID                      1   /* X.29 protocol ID */
  251. #define X29PIDLEN                   4   /* X.29 protocol ID length */
  252.  
  253. #define X29_SET_PARMS               2
  254. #define X29_READ_PARMS              4
  255. #define X29_SET_AND_READ_PARMS      6
  256. #define X29_INVITATION_TO_CLEAR     1
  257. #define X29_PARAMETER_INDICATION    0
  258. #define X29_INDICATION_OF_BREAK     3
  259. #define X29_ERROR                   5
  260.  
  261. #define INVALID_PAD_PARM            1
  262.  
  263. #define PAD_BREAK_CHARACTER         0
  264.  
  265. #define PAD_ESCAPE                  1
  266. #define PAD_ECHO                    2
  267. #define PAD_DATA_FORWARD_CHAR       3
  268. #define PAD_DATA_FORWARD_TIMEOUT    4
  269. #define PAD_FLOW_CONTROL_BY_PAD     5
  270. #define PAD_SUPPRESSION_OF_SIGNALS  6
  271. #define PAD_BREAK_ACTION            7
  272. #define PAD_SUPPRESSION_OF_DATA     8
  273. #define PAD_PADDING_AFTER_CR        9
  274. #define PAD_LINE_FOLDING           10
  275. #define PAD_LINE_SPEED             11
  276. #define PAD_FLOW_CONTROL_BY_USER   12
  277. #define PAD_LF_AFTER_CR            13
  278. #define PAD_PADDING_AFTER_LF       14
  279. #define PAD_EDITING                15
  280. #define PAD_CHAR_DELETE_CHAR       16
  281. #define PAD_BUFFER_DELETE_CHAR     17
  282. #define PAD_BUFFER_DISPLAY_CHAR    18
  283.  
  284. #define MAXIX25 MAX_USER_DATA*7
  285. #define MAXOX25 MAX_USER_DATA
  286. #endif /* ANYX25 */
  287.  
  288. #ifdef SUNX25
  289. #ifdef SOLARIS25                        /* and presumably SunLink 9.xx */
  290. #include <fcntl.h>
  291. #include <errno.h>
  292. #include <sys/ioccom.h>
  293. #include <sys/types.h>
  294. #include <sys/socket.h>
  295. #include <sys/sockio.h>
  296. #include <sundev/syncstat.h>
  297. #include <netx25/x25_pk.h>
  298. #include <netx25/x25_ctl.h>
  299. #include <netx25/x25_ioctl.h>
  300. #else
  301. #include <sys/ioctl.h>                  /* X.25 includes, Sun only */
  302. #include <sys/systm.h>
  303. #ifndef SOLARIS
  304. #include <sys/mbuf.h>
  305. #endif /* SOLARIS */
  306. #include <sys/socket.h>
  307. #include <sys/protosw.h>
  308. #ifdef SOLARIS
  309. #include <sys/sockio.h>
  310. #else
  311. #include <sys/domain.h>
  312. #endif /* SOLARIS */
  313. #include <sys/socketvar.h>
  314. #include <net/if.h>
  315. #include <sundev/syncstat.h>
  316. #include <netx25/x25_pk.h>
  317. #include <netx25/x25_ctl.h>
  318. #include <netx25/x25_ioctl.h>
  319. #endif /* SOLARIS25 */
  320. #endif /* SUNX25 */
  321.  
  322. #ifdef ANYX25
  323.  
  324. #ifdef IBMX25                           /* X.25 includes, AIX only */
  325. #include <fcntl.h>
  326. #include <sys/twtypes.h>
  327. #include <sys/twlib.h>
  328.  
  329. #include <sys/stream.h>
  330. #include <stropts.h>
  331.  
  332. #define NPI_20                          /* required to include the whole NPI */
  333. #include <sys/npi_20.h>
  334. #include <sys/npiapi.h>
  335. #include <sys/pktintf.h>
  336.  
  337. #include <odmi.h>                       /* required for access to the ODM   */
  338. #include <sys/cfgodm.h>                 /* database, needed to find out the */
  339.                                         /* local NUA. see x25local_nua()    */
  340.  
  341.  
  342. /* IBM X25 NPI generic primitive type */
  343. typedef union N_npi_ctl_t {
  344.     ulong               PRIM_type;              /* generic primitive type */
  345.     char                buffer[NPI_MAX_CTL];    /* maximum primitive size */
  346.     N_bind_ack_t        bind_ack;
  347.     N_bind_req_t        bind_req;
  348.     N_conn_con_t        conn_con;
  349.     N_conn_ind_t        conn_ind;
  350.     N_conn_req_t        conn_req;
  351.     N_conn_res_t        conn_res;
  352.     N_data_req_t        data_req;
  353.     N_data_ind_t        data_ind;
  354.     N_discon_ind_t      discon_ind;
  355.     N_discon_req_t      discon_req;
  356.     N_error_ack_t       error_ack;
  357.     N_exdata_ind_t      exdata_ind;
  358.     N_info_ack_t        info_ack;
  359.     N_ok_ack_t          ok_ack;
  360.     N_reset_con_t       reset_con;
  361.     N_reset_req_t       reset_req;
  362.     N_reset_ind_t       reset_ind;
  363. } N_npi_ctl_t;
  364.  
  365. /* some extra definitions to help out */
  366. typedef char    x25addr_t[45];          /* max 40 defined by CCITT */
  367. typedef char    N_npi_data_t[NPI_MAX_DATA];
  368.  
  369. /* fd or server waiting for connections, used by netclos and netopen */
  370. extern int x25serverfd;
  371.  
  372. #endif /* IBMX25 */
  373.  
  374. #ifdef HPX25                            /* X.25 includes, HP-UX only */
  375. #include <x25/ccittproto.h>
  376. #include <x25/x25.h>
  377. #include <x25/x25addrstr.h>
  378. #include <x25/x25codes.h>
  379. #include <x25/x25hd_ioctl.h>
  380. #include <x25/x25ioctls.h>
  381. #include <x25/x25str.h>
  382. #include <sys/ioctl.h>
  383. #endif /* HPX25 */
  384.  
  385. /* C-Kermit X.3 / X.25 / X.29 / X.121 support functions */
  386.  
  387. /* (riehm: this list of functions isn't quite right for AIX) */
  388.  
  389. _PROTOTYP( int shopad, (int) );
  390. _PROTOTYP( int shox25, (int) );
  391. _PROTOTYP( VOID initpad, (void) );
  392. _PROTOTYP( VOID setpad, (CHAR *, int) );
  393. _PROTOTYP( VOID readpad, (CHAR *, int, CHAR *) );
  394. _PROTOTYP( int qbitpkt, (CHAR *, int) );
  395. _PROTOTYP( VOID setqbit, (void) );
  396. _PROTOTYP( VOID resetqbit, (void) );
  397. _PROTOTYP( VOID breakact, (void) );
  398. _PROTOTYP( int pkx121, (char *, CHAR *) );
  399. _PROTOTYP( SIGTYP x25oobh, (int) );
  400. _PROTOTYP( int x25diag, (void) );
  401. _PROTOTYP( int x25intr, (char) );
  402. _PROTOTYP( int x25reset, (char, char) );
  403. _PROTOTYP( int x25clear, (void) );
  404. _PROTOTYP( int x25stat, (void) );
  405. _PROTOTYP( int x25in, (int, CHAR *) );
  406. _PROTOTYP( int setpadp, (void) );
  407. _PROTOTYP( int setx25, (void) );
  408. _PROTOTYP( int x25xin, (int, CHAR *) );
  409. _PROTOTYP( int x25inl, (CHAR *, int, int, CHAR) );
  410.  
  411. #ifdef IBMX25
  412.                                         /* setup x25 */
  413. _PROTOTYP( ulong x25bind, (int, char *, char *, int, int, int, ulong) );
  414. _PROTOTYP( int x25call, (int, char *, char *) ); /* connect to remote */
  415. _PROTOTYP( int x25unbind, (int) );      /* disconnect */
  416. _PROTOTYP( char *x25prim, (int) );      /* display primitives */
  417. _PROTOTYP( int x25local_nua, (char *) ); /* find local NUA */
  418. #endif /* IBMX25 */
  419.  
  420. #endif /* ANYX25 */
  421.  
  422. /* CMU-OpenVMS/IP */
  423.  
  424. #ifdef CMU_TCPIP                        /* CMU_TCPIP implies TCPSOCKET */
  425. #ifndef TCPSOCKET
  426. #define TCPSOCKET
  427. #endif /* TCPSOCKET */
  428. #ifndef TCPIPLIB
  429. #define TCPIPLIB
  430. #endif /* TCPIPLIB */
  431. #endif /* CMU_TCPIP */
  432.  
  433. /* DEC TCP/IP for (Open)VMS, previously known as UCX */
  434.  
  435. #ifdef DEC_TCPIP                        /* DEC_TCPIP implies TCPSOCKET */
  436. #ifndef TCPSOCKET
  437. #define TCPSOCKET
  438. #endif /* TCPSOCKET */
  439. #ifndef TCPIPLIB
  440. #define TCPIPLIB
  441. #endif /* TCPIPLIB */
  442. #endif /* DEC_TCPIP */
  443.  
  444. /* SRI/TGV/Cisco/Process MultiNet, TCP/IP for VAX/VMS */
  445.  
  446. #ifdef MULTINET                         /* MULTINET implies TCPSOCKET */
  447. #ifndef TCPSOCKET
  448. #define TCPSOCKET
  449. #endif /* TCPSOCKET */
  450. #ifndef TCPIPLIB
  451. #define TCPIPLIB
  452. #endif /* TCPIPLIB */
  453. #ifndef TGVORWIN                        /* MULTINET and WINTCP */
  454. #define TGVORWIN                        /* share a lot of code... */
  455. #endif /* TGVORWIN */
  456. #endif /* MULTINET */
  457.  
  458. /* Wollongong TCP/IP for VAX/VMS */
  459.  
  460. #ifdef WINTCP                           /* WINTCP implies TCPSOCKET */
  461. #ifndef TCPSOCKET
  462. #define TCPSOCKET
  463. #endif /* TCPSOCKET */
  464. #ifndef TCPIPLIB
  465. #define TCPIPLIB
  466. #endif /* TCPIPLIB */
  467. #ifndef TGVORWIN                        /* WINTCP and MULTINET */
  468. #define TGVORWIN                        /* share a lot of code... */
  469. #endif /* TGVORWIN */
  470. #endif /* WINTCP */
  471.  
  472. /* Wollongong TCP/IP for AT&T Sys V */
  473.  
  474. #ifdef WOLLONGONG                       /* WOLLONGONG implies TCPSOCKET */
  475. #ifndef TCPSOCKET                       /* Don't confuse WOLLONGONG */
  476. #define TCPSOCKET                       /* (which is for UNIX) with */
  477. #endif /* TCPSOCKET */                  /* WINTCP, which is for VMS! */
  478. #endif /* WOLLONGONG */
  479.  
  480. #ifdef EXCELAN                          /* EXCELAN implies TCPSOCKET */
  481. #ifndef TCPSOCKET
  482. #define TCPSOCKET
  483. #endif /* TCPSOCKET */
  484. #endif /* EXCELAN */
  485.  
  486. #ifdef INTERLAN                         /* INTERLAN implies TCPSOCKET */
  487. #ifndef TCPSOCKET
  488. #define TCPSOCKET
  489. #endif /* TCPSOCKET */
  490. #endif /* INTERLAN */
  491.  
  492. #ifdef BEBOX
  493. #ifndef TCPSOCKET
  494. #define TCPSOCKET
  495. #endif /* TCPSOCKET */
  496. #ifndef TCPIPLIB
  497. #define TCPIPLIB
  498. #endif /* TCPIPLIB */
  499. #define socket_errno    h_errno
  500. #define socket_read(x,y,z)      recv(x,y,sizeof(char),z)
  501. #define socket_write(x,y,z)     send(x,y,sizeof(char),z)
  502. #define socket_ioctl    ioctl
  503. #define socket_close(x)         closesocket(x)
  504. #ifndef FIONBIO
  505. #define FIONBIO 2
  506. #endif /* FIONBIO */
  507. #ifndef FIONREAD
  508. #define FIONREAD       1
  509. #endif /* FIONREAD */
  510. #ifndef SIOCATMARK
  511. #define SIOCATMARK     3
  512. #endif /* SIOCATMARK */
  513. #endif /* BEBOX */
  514.  
  515. #ifdef COMMENT /* no longer used but might come in handy again later... */
  516. /*
  517.   CK_READ0 can (and should) be defined if and only if:
  518.   (a) read(fd,&x,0) can be used harmlessly on a TCP/IP socket connection.
  519.   (b) read(fd,&x,0) returns 0 if the connection is up, -1 if it is down.
  520. */
  521. #ifndef CK_READ0
  522. #ifdef TCPSOCKET
  523. #ifdef SUNOS41                          /* It works in SunOS 4.1 */
  524. #define CK_READ0
  525. #else
  526. #ifdef NEXT                             /* and NeXTSTEP */
  527. #define CK_READ0
  528. #endif /* NEXT */
  529. #endif /* SUNOS41 */
  530. #endif /* TCPSOCKET */
  531. #endif /* CK_READ0 */
  532. #endif /* COMMENT */
  533.  
  534. /* Telnet protocol */
  535.  
  536. #ifdef TCPSOCKET                        /* TCPSOCKET implies TNCODE */
  537. #ifndef TNCODE                          /* Which means... */
  538. #define TNCODE                          /* Compile in telnet code */
  539. #endif /* TNCODE */
  540.  
  541. /*
  542.    Platforms where we must call gethostname(buf,len) and then
  543.    gethostbyname(buf) to get local IP address, rather than calling
  544.    gethostbyname("").
  545. */
  546. #ifndef CKGHNLHOST
  547. #ifdef datageneral
  548. #define CKGHNLHOST
  549. #else
  550. #ifdef SOLARIS
  551. #define CKGHNLHOST
  552. #else
  553. #ifdef SUNOS4
  554. #define CKGHNLHOST
  555. #else
  556. #ifdef UNIXWARE
  557. #define CKGHNLHOST
  558. #else
  559. #ifdef SINIX
  560. #define CKGHNLHOST
  561. #endif /* SINIX */
  562. #endif /* UNIXWARE */
  563. #endif /* SUNOS4 */
  564. #endif /* SOLARIS */
  565. #endif /* datageneral */
  566. #endif /* CKGHNLHOST */
  567.  
  568. #ifndef RLOGCODE                        /* What about Rlogin? */
  569. #ifndef NORLOGIN
  570. /*
  571.   Rlogin can be enabled only for UNIX versions that have both SIGURG
  572.   (SCO doesn't) and CK_TTGWSIZ (OSF/1 doesn't), so we don't assume that
  573.   any others have these without verifying first.  Not that it really makes
  574.   much difference since you can only use Rlogin if you are root...
  575. */
  576. #ifdef SUNOS41
  577. #define RLOGCODE
  578. #else
  579. #ifdef SOLARIS
  580. #define RLOGCODE
  581. #else
  582. #ifdef HPUX9
  583. #define RLOGCODE
  584. #else
  585. #ifdef HPUX10
  586. #define RLOGCODE
  587. #else
  588. #ifdef OSF40
  589. #define RLOGCODE
  590. #else
  591. #ifdef NEXT
  592. #define RLOGCODE
  593. #else
  594. #ifdef AIX41
  595. #define RLOGCODE
  596. #else
  597. #ifdef UNIXWARE
  598. #define RLOGCODE
  599. #else
  600. #ifdef IRIX51
  601. #define RLOGCODE
  602. #else
  603. #ifdef IRIX60
  604. #define RLOGCODE
  605. #else
  606. #ifdef QNX
  607. #define RLOGCODE
  608. #else
  609. #ifdef __linux__
  610. #define RLOGCODE
  611. #else
  612. #ifdef BSD44
  613. #define RLOGCODE
  614. #endif /* BSD44 */
  615. #endif /* __linux__ */
  616. #endif /* QNX */
  617. #endif /* IRIX60 */
  618. #endif /* IRIX51 */
  619. #endif /* UNIXWARE */
  620. #endif /* AIX41 */
  621. #endif /* NEXT */
  622. #endif /* OSF40 */
  623. #endif /* HPUX10 */
  624. #endif /* HPUX9 */
  625. #endif /* SOLARIS */
  626. #endif /* SUNOS41 */
  627. #endif /* NORLOGIN */
  628. #ifdef VMS                              /* VMS */
  629. #define RLOGCODE
  630. #endif /* VMS */
  631. #endif /* RLOGCODE */
  632. #endif /* TCPSOCKET */
  633.  
  634. #ifdef TNCODE
  635. /*
  636.   Telnet local-echo buffer, used for saving up user data that can't be
  637.   properly displayed and/or evaluated until pending Telnet negotiations are
  638.   complete.  TTLEBUF is defined for platforms (like UNIX) where net i/o is
  639.   done by the same routines that do serial i/o (in which case the relevant
  640.   code goes into the ck?tio.c module, in the ttinc(), ttchk(), etc, routines);
  641.   NETLETBUF is defined for platforms (like VMS) that use different APIs for
  642.   network and serial i/o, and enables the copies of the same routines that
  643.   are in ckcnet.c.
  644. */
  645. #ifndef TTLEBUF
  646. #ifdef UNIX
  647. #define TTLEBUF
  648. #else
  649. #ifdef datageneral
  650. #define TTLEBUF
  651. #endif /* datageneral */
  652. #endif /* UNIX */
  653. #endif /* TTLEBUF */
  654.  
  655. #ifndef NETLEBUF
  656. #ifdef VMS
  657. #define NETLEBUF
  658. #endif /* VMS */
  659. #endif /* NETLEBUF */
  660. #endif /* TNCODE */
  661.  
  662. #ifdef SUNX25                           /* SUNX25 implies TCPSOCKET */
  663. #ifndef TCPSOCKET                       /* But doesn't imply TNCODE */
  664. #define TCPSOCKET
  665. #endif /* TCPSOCKET */
  666. #endif /* SUNX25 */
  667.  
  668. #ifndef TCPSOCKET
  669. #ifndef NO_DNS_SRV
  670. #define NO_DNS_SRV
  671. #endif /* NO_DNS_SRV */
  672. #endif /* TCPSOCKET */
  673.  
  674. /* This is another TCPSOCKET section... */
  675.  
  676. #ifdef TCPSOCKET
  677. #ifndef NETCONN                         /* TCPSOCKET implies NETCONN */
  678. #define NETCONN
  679. #endif /* NETCONN */
  680.  
  681. #ifndef NO_DNS_SRV
  682. #ifdef NOLOCAL
  683. #define NO_DNS_SRV
  684. #endif /* NOLOCAL */
  685. #ifdef OS2ONLY
  686. #define NO_DNS_SRV
  687. #endif /* OS2ONLY */
  688. #ifdef NT
  689. #ifdef _M_PPC
  690. #define NO_DNS_SRV
  691. #endif /* _M_DNS */
  692. #endif /* NO_DNS_SRV */
  693. #ifdef VMS
  694. #define NO_DNS_SRV
  695. #endif /* VMS */
  696. #ifdef STRATUS
  697. #define NO_DNS_SRV
  698. #endif /* STRATUS */
  699. #ifdef datageneral
  700. #define NO_DNS_SRV
  701. #endif /* datageneral */
  702. #ifdef ultrix
  703. #define NO_DNS_SRV
  704. #endif /* ultrix */
  705. #ifdef NEXT
  706. #define NO_DNS_SRV
  707. #endif /* NEXT */
  708. #endif /* NO_DNS_SRV */
  709.  
  710. #ifndef CK_DNS_SRV                      /* Use DNS SRV records to determine */
  711. #ifndef NO_DNS_SRV                      /* host and ports */
  712. #define CK_DNS_SRV
  713. #endif /* NO_DNS_SRV */
  714. #endif /* CK_DNS_SRV */
  715.  
  716. #ifndef NOLISTEN                        /* select() is required to support */
  717. #ifndef SELECT                          /* incoming connections. */
  718. #ifndef VMS
  719. #ifndef OS2
  720. #define NOLISTEN
  721. #endif /* OS2 */
  722. #endif /* VMS */
  723. #endif /* SELECT */
  724. #endif /* NOLISTEN */
  725.  
  726. /* BSD sockets library header files */
  727.  
  728. #ifdef VMS
  729. /*
  730.   Because bzero() and bcopy() are not portable among VMS versions,
  731.   or compilers, or TCP/IP products, etc.
  732. */
  733. #ifndef bzero
  734. #define bzero(s,n) memset(s,0,n)
  735. #endif /* bzero */
  736. #ifndef bcopy
  737. #define bcopy(h,a,l) memcpy(a,h,l)
  738. #endif /* bcopy */
  739. #endif /* VMS */
  740.  
  741. #ifdef UNIX                             /* UNIX section */
  742.  
  743. #ifdef SVR4
  744. /*
  745.   These suggested by Rob Healey, rhealey@kas.helios.mn.org, to avoid
  746.   bugs in Berkeley compatibility library on Sys V R4 systems, but untested
  747.   by me (fdc).  Remove this bit if it gives you trouble.
  748.   (Later corrected by Marc Boucher <mboucher@iro.umontreal.ca> because
  749.   bzero/bcopy are not argument-compatible with memset/memcpy|memmove.)
  750. */
  751. #ifndef bzero
  752. #define bzero(s,n) memset(s,0,n)
  753. #endif
  754. #ifdef SOLARIS
  755. #ifdef SUNX25
  756. #undef bzero
  757. /*
  758.   WOULD YOU BELIEVE... That the Solaris X.25 /opt/SUNWcomm/lib/libsockx25
  759.   library references bzero, even though the use of bzero is forbidden in
  760.   Solaris?  Look for the function definition in ckcnet.c.
  761. */
  762. _PROTOTYP( void bzero, (char *, int) );
  763. #endif /* SUNX25 */
  764. #ifndef bcopy
  765. #define bcopy(h,a,l) memcpy(a,h,l)
  766. #endif
  767. #else
  768. #ifndef bcopy
  769. #define bcopy(h,a,l) memmove(a,h,l)
  770. #endif
  771. #endif /* SOLARIS */
  772. #else /* !SVR4 */
  773. #ifdef PTX                              /* Sequent DYNIX PTX 1.3 */
  774. #ifndef bzero
  775. #define bzero(s,n) memset(s,0,n)
  776. #endif
  777. #ifndef bcopy
  778. #define bcopy(h,a,l) memcpy(a,h,l)
  779. #endif
  780. #endif /* PTX */
  781. #endif /* SVR4 */
  782.  
  783. #ifdef INTERLAN                         /* Racal-Interlan TCP/IP */
  784. #include <interlan/socket.h>
  785. #include <interlan/il_types.h>
  786. #include <interlan/telnet.h>
  787. #include <interlan/il_errno.h>
  788. #include <interlan/in.h>
  789. #include <interlan/telnet.h>            /* Why twice ? ? ? */
  790. #else /* Not Interlan */
  791. #ifdef BEBOX
  792. #include <socket.h>
  793. #else /* Not BEBOX */                   /* Normal BSD TCP/IP library */
  794. #ifdef COMMENT
  795. #ifndef HPUX
  796. #include <arpa/telnet.h>
  797. #endif /* HPUX */
  798. #endif /* COMMENT */
  799. #ifdef SCO234
  800. #include <sys/errno.tcp.h>
  801. #include <sys/types.tcp.h>
  802. #endif /* SCO234 */
  803. #include <sys/socket.h>
  804. #ifdef WOLLONGONG
  805. #include <sys/in.h>
  806. #else
  807. #include <netinet/in.h>
  808. #ifndef SV68R3V6                /* (maybe this should be SVR3 in general) */
  809. #include <netinet/tcp.h>        /* Added June 2001 */
  810. #endif /* SV68R3V6 */
  811. #endif /* WOLLONGONG */
  812. #endif /* BEBOX */
  813. #endif /* INTERLAN */
  814.  
  815. #ifndef EXCELAN
  816. #include <netdb.h>
  817. #ifndef INTERLAN
  818. #ifdef WOLLONGONG
  819. #define minor                           /* Do not include <sys/macros.h> */
  820. #include <sys/inet.h>
  821. #else
  822. #ifndef OXOS
  823. #ifndef HPUX
  824. #ifndef BEBOX
  825. #include <arpa/inet.h>
  826. #endif /* BEBOX */
  827. #endif /* HPUX */
  828. #else /* OXOS */
  829. /* In too many releases of X/OS, <arpa/inet.h> declares inet_addr() as
  830.  * ``struct in_addr''.  This is definitively wrong, and could cause
  831.  * core dumps.  Instead of including that bad file, inet_addr() is
  832.  * correctly declared here.  Of course, all the declarations done there
  833.  * has been copied here.
  834.  */
  835. unsigned long inet_addr();
  836. char    *inet_ntoa();
  837. struct  in_addr inet_makeaddr();
  838. unsigned long inet_network();
  839. #endif /* OXOS */
  840. #endif /* WOLLONGONG */
  841. #endif /* INTERLAN */
  842. #endif /* EXCELAN */
  843.  
  844. #ifdef EXCELAN                          /* Excelan TCP/IP */
  845. #ifndef bzero
  846. #define bzero(s,n) memset(s,0,n)
  847. #endif /* bzero */
  848. #ifndef bcopy
  849. #define bcopy(h,a,l) memcpy(a,h,l)
  850. #endif /* bcopy */
  851. #include <ex_errno.h>
  852. #endif /* EXCELAN */
  853.  
  854. #ifdef I386IX                           /* Interactive Sys V R3 network. */
  855. /* #define TELOPTS */                   /* This might need defining. */
  856. #define ORG_NLONG ENAMETOOLONG          /* Resolve conflicting symbols */
  857. #undef ENAMETOOLONG                     /* in <errno.h> and <net/errno.h> */
  858. #define ORG_NEMPTY ENOTEMPTY
  859. #undef ENOTEMPTY
  860. #include <net/errno.h>
  861. #undef ENAMETOOLONG
  862. #define ENAMETOOLONG ORG_NLONG
  863. #undef ENOTEMPTY
  864. #define ENOTEMPTY ORG_NEMPTY
  865. #include <netinet/tcp.h>                /* for inet_addr() */
  866. #endif /* I386IX */
  867. /*
  868.   Data type of the inet_addr() function...
  869.   We define INADDRX if it is of type struct inaddr.
  870.   If it is undefined, unsigned long is assumed.
  871.   Look at <arpa/inet.h> to find out.  The following known cases are
  872.   handled here.  Other systems that need it can be added here, or else
  873.   -DINADDRX can be included in the CFLAGS on the cc command line.
  874. */
  875. #ifndef NOINADDRX
  876. #ifdef DU2                              /* DEC Ultrix 2.0 */
  877. #define INADDRX
  878. #endif /* DU2 */
  879. #endif /* NOINADDRX */
  880.  
  881. #else /* Not UNIX */
  882.  
  883. #ifdef VMS                              /* (Open)VMS section */
  884.  
  885. #ifdef MULTINET                         /* TGV MultiNet */
  886. /*
  887.   In C-Kermit 7.0 Beta.08 we started getting scads of compile time warnings
  888.   in Multinet builds: "blah" is implicitly declared as a function, where blah
  889.   is socket_read/write/close, ntohs, htons, getpeername, accept, select, etc.
  890.   I have no idea why -- these routines are declared in the header files below,
  891.   and the includes haven't changed.  The executable still seems to work OK.
  892.   Messing with the order of the following includes is disastrous.
  893. */
  894. #ifdef MULTINET_NO_PROTOTYPES
  895. #undef MULTINET_NO_PROTOTYPES
  896. #endif /* MULTINET_NO_PROTOTYPES */
  897.  
  898. #ifdef  __cplusplus
  899. #undef  __cplusplus
  900. #endif /*  __cplusplus */
  901.  
  902. #include "multinet_root:[multinet.include]errno.h"
  903. #include "multinet_root:[multinet.include.sys]types.h"
  904. #include "multinet_root:[multinet.include.sys]socket.h"
  905. #include "multinet_root:[multinet.include]netdb.h"
  906. #include "multinet_root:[multinet.include.netinet]in.h"
  907. #include "multinet_root:[multinet.include.arpa]inet.h"
  908. #include "multinet_root:[multinet.include.sys]ioctl.h"
  909.  
  910. #ifdef COMMENT
  911. /*
  912.   No longer needed because now bzero/bcopy are macros defined as
  913.   memset/memmove in all VMS builds.
  914. */
  915. /*
  916.   We should be able to pick these up from <strings.h> but it's
  917.   not portable between VAXC and DECC.  And even with DECC 5.x we have a
  918.   difference between VAX and Alpha.  We get warnings here on the VAX
  919.   with DECC 5.6-003 but they are not fatal.
  920. */
  921. #ifndef __DECC_VER
  922. #ifndef bzero
  923. _PROTOTYP( void bzero, (char *, int) );
  924. #endif /* bzero */
  925. #ifndef bcopy
  926. _PROTOTYP( void bcopy, (char *, char *, int) );
  927. #endif /* bcopy */
  928. #endif /* __DECC_VER */
  929. #endif /* COMMENT */
  930.  
  931. #ifdef __DECC
  932. /*
  933.    If compiling under DEC C the socket calls must not be prefixed with
  934.    DECC$.  This is done by using the compiler switch /Prefix=Ansi_C89.
  935.    However, this causes some calls that should be prefixed to not be
  936.    (which I think is a bug in the compiler - I've been told these calls
  937.    are present in ANSI compilers).  At any rate, such calls are fixed
  938.    here by explicitly prefixing them.
  939. */
  940. #ifdef COMMENT
  941. /*
  942.    But this causes errors with VMS 6.2 / DEC C 5.3-006 / MultiNet 4.0A on
  943.    a VAX (but not on an Alpha).  So now what happens if we skip doing this?
  944. */
  945. #define close decc$close
  946. #define alarm decc$alarm
  947. #endif /* COMMENT */
  948. #endif /* __DECC */
  949.  
  950. #else /* Not MULTINET */
  951.  
  952. #ifdef WINTCP                           /* WIN/TCP = PathWay for VMS */
  953. #ifdef OLD_TWG
  954. #include "twg$tcp:[netdist.include.sys]errno.h"
  955. #include "twg$tcp:[netdist.include.sys]types2.h" /* avoid some duplicates */
  956. #else
  957. #include "twg$tcp:[netdist.include]socket_aliases.h"
  958. #include <errno.h>
  959. #include "twg$tcp:[netdist.include.sys]types.h"
  960. #endif /* OLD_TWG */
  961. #include "twg$tcp:[netdist.include.sys]socket.h"
  962. #include "twg$tcp:[netdist.include]netdb.h"
  963. #include "twg$tcp:[netdist.include.sys]domain.h"
  964. #include "twg$tcp:[netdist.include.sys]protosw.h"
  965. #include "twg$tcp:[netdist.include.netinet]in.h"
  966. #include "twg$tcp:[netdist.include.arpa]inet.h"
  967. #include "twg$tcp:[netdist.include.sys]ioctl.h"
  968.  
  969. #else /* Not WINTCP */
  970.  
  971. #ifdef DEC_TCPIP
  972. #ifdef UCX50
  973. #ifndef IF_DOT_H
  974. #define IF_DOT_H
  975. #endif /*  IF_DOT_H */
  976. #endif /* UCX50 */
  977.  
  978. #ifdef IF_DOT_H
  979. #include <if.h>                         /* Needed to put up u_int typedef */
  980. #else
  981. #ifdef NEEDUINT
  982. typedef unsigned int u_int;
  983. #endif /* NEEDUINT */
  984. #endif /* IF_DOT_H */
  985.  
  986. #include <in.h>
  987. #include <netdb.h>
  988. #include <socket.h>
  989. #include "ckvioc.h"
  990. #define socket_errno errno
  991.  
  992. #ifdef COMMENT
  993. /*
  994.   No longer needed because now bzero/bcopy are macros defined as
  995.   memset/memmove in all VMS builds.
  996. */
  997. /*
  998.   Translation: In <strings.h>, which exists only for DECC >= 5.2, bzero()
  999.   and bcopy() are declared only for OpenVMS >= 7.0.  This still might need
  1000.   adjustment for DECC 5.0 and higher.
  1001. */
  1002. #ifdef __DECC_VER
  1003. #ifdef VMSV70
  1004. /*
  1005.   Note: you can't use "#if (__VMS_VER>=70000000)" because that is not
  1006.   portable and kills non-VMS builds.
  1007. */
  1008. #include <strings.h>
  1009. #else
  1010. #ifndef bzero
  1011. #define bzero(s,n) memset(s,0,n)
  1012. #endif
  1013. #ifndef bcopy
  1014. #define bcopy(h,a,l) memmove(a,h,l)
  1015. #endif
  1016. #endif /* VMSV70 */
  1017. #else
  1018. #ifndef bzero
  1019. #define bzero(s,n) memset(s,0,n)
  1020. #endif
  1021. #ifndef bcopy
  1022. #define bcopy(h,a,l) memmove(a,h,l)
  1023. #endif
  1024. #endif /* __DECC_VER */
  1025. #endif /* COMMENT */
  1026.  
  1027. #define socket_read     read
  1028. #define socket_write    write
  1029. #define socket_ioctl    ioctl
  1030. #define socket_close    close
  1031.  
  1032. #ifdef __DECC
  1033. int ioctl (int d, int request, void *argp);
  1034. #else
  1035. int ioctl (int d, int request, char *argp);
  1036. #endif /* DECC */
  1037. /*
  1038.   UCX supports select(), but does not provide the needed symbol and
  1039.   structure definitions in any header file, so ...
  1040. */
  1041. #include <types.h>
  1042. #ifndef NBBY
  1043. /*-
  1044.  * Copyright (c) 1982, 1986, 1991, 1993
  1045.  *      The Regents of the University of California.  All rights reserved.
  1046.  *
  1047.  * Redistribution and use in source and binary forms, with or without
  1048.  * modification, are permitted provided that the following conditions
  1049.  * are met:
  1050.  * 1. Redistributions of source code must retain the above copyright
  1051.  *    notice, this list of conditions and the following disclaimer.
  1052.  * 2. Redistributions in binary form must reproduce the above copyright
  1053.  *    notice, this list of conditions and the following disclaimer in the
  1054.  *    documentation and/or other materials provided with the distribution.
  1055.  * 3. All advertising materials mentioning features or use of this software
  1056.  *    must display the following acknowledgement:
  1057.  *      This product includes software developed by the University of
  1058.  *      California, Berkeley and its contributors.
  1059.  * 4. Neither the name of the University nor the names of its contributors
  1060.  *    may be used to endorse or promote products derived from this software
  1061.  *    without specific prior written permission.
  1062.  *
  1063.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1064.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1065.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1066.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1067.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1068.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1069.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1070.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1071.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1072.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1073.  * SUCH DAMAGE.
  1074.  *
  1075.  *      @(#)types.h     8.1 (Berkeley) 6/2/93
  1076.  */
  1077.  
  1078. #define NBBY    8               /* number of bits in a byte */
  1079.  
  1080. /*
  1081.  * Select uses bit masks of file descriptors in longs.  These macros
  1082.  * manipulate such bit fields (the filesystem macros use chars).
  1083.  * FD_SETSIZE may be defined by the user, but the default here should
  1084.  * be enough for most uses.
  1085.  */
  1086. #ifndef FD_SETSIZE
  1087. #define FD_SETSIZE      256
  1088. #endif
  1089.  
  1090. typedef long    fd_mask;
  1091. #define NFDBITS (sizeof(fd_mask) * NBBY)        /* bits per mask */
  1092.  
  1093. #ifndef howmany
  1094. #define howmany(x, y)   (((x)+((y)-1))/(y))
  1095. #endif
  1096.  
  1097. typedef struct fd_set {
  1098.         fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  1099. } fd_set;
  1100.  
  1101. #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  1102. #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  1103. #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  1104. #define FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
  1105. #define FD_ZERO(p)      bzero(p, sizeof(*(p)))
  1106. #endif /* !NBBY */
  1107.  
  1108. #else  /* Not DEC_TCPIP */
  1109.  
  1110. #ifdef CMU_TCPIP
  1111. #include <types.h>
  1112. #include <in.h>
  1113. #include <netdb.h>
  1114. #include <socket.h>
  1115. #include <inet.h>
  1116. #include <ioctl.h>
  1117. #include "ckvioc.h"
  1118. #define socket_errno errno
  1119.  
  1120. /*
  1121.  * Routines supplied in LIBCMU.OLB
  1122.  */
  1123. #define socket_ioctl    ioctl
  1124. #define socket_read     cmu_read
  1125. #define socket_write    cmu_write
  1126. #define socket_close    cmu_close
  1127.  
  1128. #endif /* CMU_TCPIP */
  1129. #endif /* DEC_TCPIP */
  1130. #endif /* WINTCP */
  1131. #endif /* MULTINET */
  1132.  
  1133. #else /* Not VMS */
  1134.  
  1135. #ifdef OS2
  1136. #include "ckonet.h"
  1137. #ifndef NT
  1138. #include <nerrno.h>
  1139. #endif
  1140. #endif /* OS2 */
  1141.  
  1142. #ifdef STRATUS  /* Stratus VOS using OS TCP/IP products S235, S236, S237 */
  1143. #include <tcp_socket.h>
  1144. /* This gets used some places when TCPSOCKET is defined. */
  1145. /* OS TCP provides bzero(), but not bcopy()... go figure. */
  1146. #define bcopy(s,d,z) memcpy(d,s,z)
  1147. #endif /* STRATUS */
  1148.  
  1149. #ifdef OSK
  1150. #ifndef OSKXXC
  1151. #include <inet/in.h>
  1152. #include <inet/netdb.h>
  1153. #include <inet/socket.h>
  1154. #else
  1155. #include <INET/in.h>
  1156. #include <INET/netdb.h>
  1157. #include <INET/socket.h>
  1158. #endif /* OSKXXC */
  1159. #ifndef bzero
  1160. #define bzero(s,n) memset(s,0,n)
  1161. #endif
  1162. #ifndef bcopy
  1163. #define bcopy(h,a,l) memcpy(a,h,l)
  1164. #endif
  1165. typedef char * caddr_t; /* core address type */
  1166. #endif /* OSK */
  1167.  
  1168. #endif /* VMS */
  1169. #endif /* UNIX */
  1170. #endif /* TCPSOCKET */
  1171.  
  1172. #ifdef TCPSOCKET
  1173. #ifndef NOHADDRLIST
  1174. #ifndef HADDRLIST
  1175. #ifdef SUNOS41
  1176. #define HADDRLIST
  1177. #endif /* SUNOS41 */
  1178. #ifdef SOLARIS
  1179. #define HADDRLIST
  1180. #endif /* SOLARIS */
  1181. #ifdef LINUX
  1182. #define HADDRLIST
  1183. #endif /* LINUX */
  1184. #ifdef AIXRS
  1185. #define HADDRLIST
  1186. #endif /* AIXRS */
  1187. #ifdef HPUX
  1188. #define HADDRLIST
  1189. #endif /* HPUX */
  1190. #ifdef IRIX
  1191. #define HADDRLIST
  1192. #endif /* IRIX */
  1193. #ifdef I386IX
  1194. #define HADDRLIST
  1195. #endif /* I386IX */
  1196. #endif /* HADDRLIST */
  1197. /* A system that defines h_addr as h_addr_list[0] should be HADDRLIST */
  1198. #ifndef HADDRLIST
  1199. #ifdef h_addr
  1200. #define HADDRLIST
  1201. #endif /* h_addr */
  1202. #endif /* HADDRLIST */
  1203. #endif /* NOHADDRLIST */
  1204. #endif /* TCPSOCKET */
  1205.  
  1206. #ifdef TNCODE                           /* If we're compiling telnet code... */
  1207. #ifndef IKS_OPTION
  1208. #ifndef STRATUS
  1209. #define IKS_OPTION
  1210. #endif /* STRATUS */
  1211. #endif /* IKS_OPTION */
  1212. #include "ckctel.h"
  1213. #else
  1214. extern int sstelnet;
  1215. #ifdef IKSD
  1216. #undef IKSD
  1217. #endif /* IKSD */
  1218. #ifndef NOIKSD
  1219. #define NOIKSD
  1220. #endif /* NOIKSD */
  1221. #ifdef IKS_OPTION
  1222. #undef IKS_OPTION
  1223. #endif /* IKS_OPTION */
  1224. #endif /* TNCODE */
  1225.  
  1226. #ifndef NOTCPOPTS
  1227. /*
  1228.   Automatically define NOTCPOPTS for configurations where they can't be
  1229.   used at runtime or cause too much trouble at compile time.
  1230. */
  1231. #ifdef CMU_TCPIP                        /* CMU/Tek */
  1232. #define NOTCPOPTS
  1233. #endif /* CMU_TCPIP */
  1234. #ifdef MULTINET                         /* Multinet on Alpha */
  1235. #ifdef __alpha
  1236. #define NOTCPOPTS
  1237. #endif /* __alpha */
  1238. #endif /* MULTINET */
  1239. #endif /* NOTCPOPTS */
  1240.  
  1241. #ifdef NOTCPOPTS
  1242. #ifdef TCP_NODELAY
  1243. #undef TCP_NODELAY
  1244. #endif /* TCP_NODELAY */
  1245. #ifdef SO_LINGER
  1246. #undef SO_LINGER
  1247. #endif /* SO_LINGER */
  1248. #ifdef SO_KEEPALIVE
  1249. #undef SO_KEEPALIVE
  1250. #endif /* SO_KEEPALIVE */
  1251. #ifdef SO_SNDBUF
  1252. #undef SO_SNDBUF
  1253. #endif /* SO_SNDBUF */
  1254. #ifdef SO_RCVBUF
  1255. #undef SO_RCVBUF
  1256. #endif /* SO_RCVBUF */
  1257. #endif /* NOTCPOPTS */
  1258.  
  1259. /* This function is declared even when TCPSOCKET is not available */
  1260. _PROTOTYP( char * ckgetpeer, (VOID));
  1261.  
  1262. #ifdef TCPSOCKET
  1263. #ifdef SOL_SOCKET
  1264. #ifdef TCP_NODELAY
  1265. _PROTOTYP( int no_delay, (int, int) );
  1266. #endif /* TCP_NODELAY */
  1267. #ifdef SO_KEEPALIVE
  1268. _PROTOTYP( int keepalive, (int, int) ) ;
  1269. #endif /* SO_KEEPALIVE */
  1270. #ifdef SO_LINGER
  1271. _PROTOTYP( int ck_linger, (int, int, int) ) ;
  1272. #endif /* SO_LINGER */
  1273. #ifdef SO_SNDBUF
  1274. _PROTOTYP( int sendbuf,(int, int) ) ;
  1275. #endif /* SO_SNDBUF */
  1276. #ifdef SO_RCVBUF
  1277. _PROTOTYP( int recvbuf, (int, int) ) ;
  1278. #endif /* SO_RCVBUF */
  1279. #ifdef SO_DONTROUTE
  1280. _PROTOTYP(int dontroute, (int, int));
  1281. #endif /* SO_DONTROUTE */
  1282. #endif /* SOL_SOCKET */
  1283. _PROTOTYP( int getlocalipaddr, (VOID));
  1284. _PROTOTYP( int getlocalipaddrs, (char *,int,int));
  1285. _PROTOTYP( char * ckgetfqhostname,(char *));
  1286. _PROTOTYP( struct hostent * ck_copyhostent,(struct hostent *));
  1287. _PROTOTYP( char * ckname2addr, (char *));
  1288. _PROTOTYP( char * ckaddr2name, (char *));
  1289.  
  1290. /* AIX */
  1291.  
  1292. #ifdef AIXRS
  1293. #ifndef TCP_NODELAY
  1294. #define TCP_NODELAY 0x1
  1295. #endif /* TCP_NODELAY */
  1296. #ifndef TCP_MAXSEG
  1297. #define TCP_MAXSEG 0x2
  1298. #endif /* TCP_MAXSEG */
  1299. #ifndef TCP_KEEPALIVE
  1300. #define TCP_KEEPALIVE 0x8
  1301. #endif /* TCP_KEEPALIVE */
  1302. #endif /* AIXRS */
  1303. #endif /* TCPSOCKET */
  1304.  
  1305. #ifdef RLOGCODE
  1306. #ifndef CK_TTGWSIZ
  1307. SORRY_RLOGIN_REQUIRES_TTGWSIZ_see_ckcplm.doc
  1308. #endif /* CK_TTGWSIZ */
  1309. #endif /* RLOGCODE */
  1310.  
  1311. #ifdef CK_NAWS
  1312. #ifndef CK_TTGWSIZ
  1313. SORRY_CK_NAWS_REQUIRES_TTGWSIZ_see_ckcplm.doc
  1314. #endif /* CK_TTGWSIZ */
  1315. #endif /* CK_NAWS */
  1316.  
  1317. #ifndef PF_INET
  1318. #ifdef  AF_INET
  1319. #define PF_INET AF_INET
  1320. #endif /* AF_INET */
  1321. #endif /* PF_INET */
  1322.  
  1323. #ifndef IPPORT_ECHO
  1324. #define IPPORT_ECHO 7
  1325. #endif /* IPPORT_ECHO */
  1326.  
  1327. #ifdef CK_KERBEROS
  1328. #ifdef RLOGCODE
  1329. _PROTOTYP(int ck_krb_rlogin,(CHAR *, int, CHAR *, CHAR *, CHAR *,
  1330.                               struct sockaddr_in *,
  1331.                               struct sockaddr_in *, int, int));
  1332. #endif /* RLOGCODE */
  1333. #endif /* CK_KERBEROS */
  1334.  
  1335. _PROTOTYP( VOID ini_kerb, ( void ) );   /* Kerberos initialization routine */
  1336. _PROTOTYP( int doauth, (int) );         /* AUTHENTICATE action routine */
  1337.  
  1338. #ifdef CK_DNS_SRV
  1339. _PROTOTYP(int locate_srv_dns,(char *host, char *service,
  1340.                               char *protocol, struct sockaddr **addr_pp,
  1341.                               int *naddrs));
  1342. #endif /* CK_DNS_SRV */
  1343.  
  1344. #ifndef NOHTTP
  1345. _PROTOTYP(int http_open, (char *, char *, int, char *, int, char *));
  1346. _PROTOTYP(int http_reopen, (VOID));
  1347. _PROTOTYP(int http_close, (VOID));
  1348. _PROTOTYP(int http_get, (char *,char **,char *,char *,char,char *,char *,
  1349.                          int));
  1350. _PROTOTYP(int http_head, (char *,char **,char *,char *,char,char *,char *,
  1351.                           int));
  1352. _PROTOTYP(int http_put, (char *,char **,char *,char *,char *,char,char *,
  1353.                          char *, char *, int));
  1354. _PROTOTYP(int http_delete, (char *,char **,char *,char *,char,char *));
  1355. _PROTOTYP(int http_connect, (int, char *,char **,char *,char *,char,char *));
  1356. _PROTOTYP(int http_post, (char *,char **,char *,char *,char *,char,char *,
  1357.                   char *,char *, int));
  1358. _PROTOTYP(int http_index, (char *,char **,char *,char *,char,char *,char *,
  1359.                            int));
  1360. _PROTOTYP(int http_inc, (int));
  1361. _PROTOTYP(int http_isconnected, (void));
  1362.  
  1363. extern char * tcp_http_proxy;           /* Name[:port] of http proxy server */
  1364. extern int    tcp_http_proxy_errno;     /* Return value from server */
  1365. extern char * tcp_http_proxy_user;      /* Name of user for authentication */
  1366. extern char * tcp_http_proxy_pwd;       /* Password of user */
  1367. #endif /* NOHTTP */
  1368.  
  1369. #ifdef TCPSOCKET
  1370.  
  1371. /* Type needed as 5th argument (length) to get/setsockopt() */
  1372.  
  1373. #ifdef TRU64
  1374. /* They say it themselves - this does not conform to standards */
  1375. #define socklen_t int
  1376. #else
  1377. #ifdef HPUX
  1378. #define socklen_t int
  1379. #endif    /* HPUX */
  1380. #endif    /* TRU64 */
  1381.  
  1382. #ifndef SOCKOPT_T
  1383. #ifdef CK_64BIT
  1384. #define SOCKOPT_T socklen_t
  1385. #endif    /* CK_64BIT */
  1386. #endif    /* SOCKOPT_T */
  1387.  
  1388. #ifndef SOCKOPT_T
  1389. #define SOCKOPT_T int
  1390. #ifdef AIX42
  1391. #undef SOCKOPT_T
  1392. #define SOCKOPT_T unsigned long
  1393. #else
  1394. #ifdef PTX
  1395. #undef SOCKOPT_T
  1396. #define SOCKOPT_T size_t
  1397. #else
  1398. #ifdef NT
  1399. #undef SOCKOPT_T
  1400. #define SOCKOPT_T int
  1401. #else /* NT */
  1402. #ifdef UNIXWARE
  1403. #undef SOCKOPT_T
  1404. #define SOCKOPT_T size_t
  1405. #else /* UNIXWARE */
  1406. #ifdef VMS
  1407. #ifdef DEC_TCPIP
  1408. #ifdef __DECC_VER
  1409. #undef SOCKOPT_T
  1410. #define SOCKOPT_T size_t
  1411. #endif /* __DECC_VER */
  1412. #endif /* DEC_TCPIP */
  1413. #endif /* VMS */
  1414. #endif /* UNIXWARE */
  1415. #endif /* NT */
  1416. #endif /* PTX */
  1417. #endif /* AIX42 */
  1418. #endif /* SOCKOPT_T */
  1419.  
  1420. /* Ditto for getsockname() */
  1421.  
  1422. #ifndef GSOCKNAME_T
  1423. #ifdef CK_64BIT
  1424. #define GSOCKNAME_T socklen_t
  1425. #endif    /* CK_64BIT */
  1426. #endif    /* GSOCKNAME_T */
  1427.  
  1428. #ifndef GSOCKNAME_T
  1429. #define GSOCKNAME_T int
  1430. #ifdef PTX
  1431. #undef GSOCKNAME_T
  1432. #define GSOCKNAME_T size_t
  1433. #else
  1434. #ifdef AIX42                            /* size_t in 4.2++, int in 4.1-- */
  1435. #undef GSOCKNAME_T
  1436. #define GSOCKNAME_T size_t
  1437. #else
  1438. #ifdef UNIXWARE
  1439. #undef GSOCKNAME_T
  1440. #define GSOCKNAME_T size_t
  1441. #else
  1442. #ifdef VMS
  1443. #ifdef DEC_TCPIP
  1444. #ifdef __DECC_VER
  1445. #undef GSOCKNAME_T
  1446. #define GSOCKNAME_T size_t
  1447. #endif /* __DECC_VER */
  1448. #endif /* DEC_TCPIP */
  1449. #endif /* VMS */
  1450. #endif /* UNIXWARE */
  1451. #endif /* AIX41 */
  1452. #endif /* PTX */
  1453. #endif /* GSOCKNAME_T */
  1454.  
  1455. #endif /* TCPSOCKET */
  1456.  
  1457. #ifdef MACOSX10
  1458. #ifdef bcopy
  1459. #undef bcopy
  1460. #endif
  1461. #ifdef bzero
  1462. #undef bzero
  1463. #endif
  1464. #endif /* MACOSX10 */
  1465.  
  1466. #endif /* CKCNET_H */
  1467.