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