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