home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / cku201.zip / ckcnet.h < prev    next >
C/C++ Source or Header  |  2001-12-26  |  40KB  |  1,414 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, 2001,
  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. #define bzero(s,n) memset(s,0,n)
  748. #ifdef SOLARIS
  749. #ifdef SUNX25
  750. #undef bzero
  751. /*
  752.   WOULD YOU BELIEVE... That the Solaris X.25 /opt/SUNWcomm/lib/libsockx25
  753.   library references bzero, even though the use of bzero is forbidden in
  754.   Solaris?  Look for the function definition in ckcnet.c.
  755. */
  756. _PROTOTYP( void bzero, (char *, int) );
  757. #endif /* SUNX25 */
  758. #define bcopy(h,a,l) memcpy(a,h,l)
  759. #else
  760. #define bcopy(h,a,l) memmove(a,h,l)
  761. #endif /* SOLARIS */
  762. #else /* !SVR4 */
  763. #ifdef PTX                /* Sequent DYNIX PTX 1.3 */
  764. #define bzero(s,n) memset(s,0,n)
  765. #define bcopy(h,a,l) memcpy(a,h,l)
  766. #endif /* PTX */
  767. #endif /* SVR4 */
  768.  
  769. #ifdef INTERLAN                /* Racal-Interlan TCP/IP */
  770. #include <interlan/socket.h>
  771. #include <interlan/il_types.h>
  772. #include <interlan/telnet.h>
  773. #include <interlan/il_errno.h>
  774. #include <interlan/in.h>
  775. #include <interlan/telnet.h>        /* Why twice ? ? ? */
  776. #else /* Not Interlan */
  777. #ifdef BEBOX
  778. #include <socket.h>
  779. #else /* Not BEBOX */            /* Normal BSD TCP/IP library */
  780. #ifdef COMMENT
  781. #ifndef HPUX
  782. #include <arpa/telnet.h>
  783. #endif /* HPUX */
  784. #endif /* COMMENT */
  785. #ifdef SCO234
  786. #include <sys/errno.tcp.h>
  787. #include <sys/types.tcp.h>
  788. #endif /* SCO234 */
  789. #include <sys/socket.h>
  790. #ifdef WOLLONGONG
  791. #include <sys/in.h>
  792. #else
  793. #include <netinet/in.h>
  794. #ifndef SV68R3V6        /* (maybe this should be SVR3 in general) */
  795. #include <netinet/tcp.h>    /* Added June 2001 */
  796. #endif /* SV68R3V6 */
  797. #endif /* WOLLONGONG */
  798. #endif /* BEBOX */
  799. #endif /* INTERLAN */
  800.  
  801. #ifndef EXCELAN
  802. #include <netdb.h>
  803. #ifndef INTERLAN
  804. #ifdef WOLLONGONG
  805. #define minor                /* Do not include <sys/macros.h> */
  806. #include <sys/inet.h>
  807. #else
  808. #ifndef OXOS
  809. #ifndef HPUX
  810. #ifndef BEBOX
  811. #include <arpa/inet.h>
  812. #endif /* BEBOX */
  813. #endif /* HPUX */
  814. #else /* OXOS */
  815. /* In too many releases of X/OS, <arpa/inet.h> declares inet_addr() as
  816.  * ``struct in_addr''.  This is definitively wrong, and could cause
  817.  * core dumps.  Instead of including that bad file, inet_addr() is
  818.  * correctly declared here.  Of course, all the declarations done there
  819.  * has been copied here.
  820.  */
  821. unsigned long inet_addr();
  822. char    *inet_ntoa();
  823. struct    in_addr inet_makeaddr();
  824. unsigned long inet_network();
  825. #endif /* OXOS */
  826. #endif /* WOLLONGONG */
  827. #endif /* INTERLAN */
  828. #endif /* EXCELAN */
  829.  
  830. #ifdef EXCELAN                /* Excelan TCP/IP */
  831. #ifndef bzero
  832. #define bzero(s,n) memset(s,0,n)
  833. #endif /* bzero */
  834. #ifndef bcopy
  835. #define bcopy(h,a,l) memcpy(a,h,l)
  836. #endif /* bcopy */
  837. #include <ex_errno.h>
  838. #endif /* EXCELAN */
  839.  
  840. #ifdef I386IX                /* Interactive Sys V R3 network. */
  841. /* #define TELOPTS */            /* This might need defining. */
  842. #define ORG_NLONG ENAMETOOLONG        /* Resolve conflicting symbols */
  843. #undef ENAMETOOLONG            /* in <errno.h> and <net/errno.h> */
  844. #define ORG_NEMPTY ENOTEMPTY
  845. #undef ENOTEMPTY
  846. #include <net/errno.h>
  847. #undef ENAMETOOLONG
  848. #define ENAMETOOLONG ORG_NLONG
  849. #undef ENOTEMPTY
  850. #define ENOTEMPTY ORG_NEMPTY
  851. #include <netinet/tcp.h>        /* for inet_addr() */
  852. #endif /* I386IX */
  853. /*
  854.   Data type of the inet_addr() function...
  855.   We define INADDRX if it is of type struct inaddr.
  856.   If it is undefined, unsigned long is assumed.
  857.   Look at <arpa/inet.h> to find out.  The following known cases are
  858.   handled here.  Other systems that need it can be added here, or else
  859.   -DINADDRX can be included in the CFLAGS on the cc command line.
  860. */
  861. #ifndef NOINADDRX
  862. #ifdef DU2                /* DEC Ultrix 2.0 */
  863. #define INADDRX
  864. #endif /* DU2 */
  865. #endif /* NOINADDRX */
  866.  
  867. #else /* Not UNIX */
  868.  
  869. #ifdef VMS                /* (Open)VMS section */
  870.  
  871. #ifdef MULTINET                /* TGV MultiNet */
  872. /*
  873.   In C-Kermit 7.0 Beta.08 we started getting scads of compile time warnings
  874.   in Multinet builds: "blah" is implicitly declared as a function, where blah
  875.   is socket_read/write/close, ntohs, htons, getpeername, accept, select, etc.
  876.   I have no idea why -- these routines are declared in the header files below,
  877.   and the includes haven't changed.  The executable still seems to work OK.
  878.   Messing with the order of the following includes is disastrous.
  879. */
  880. #ifdef MULTINET_NO_PROTOTYPES
  881. #undef MULTINET_NO_PROTOTYPES
  882. #endif /* MULTINET_NO_PROTOTYPES */
  883.  
  884. #ifdef  __cplusplus
  885. #undef  __cplusplus
  886. #endif /*  __cplusplus */
  887.  
  888. #include "multinet_root:[multinet.include]errno.h"
  889. #include "multinet_root:[multinet.include.sys]types.h"
  890. #include "multinet_root:[multinet.include.sys]socket.h"
  891. #include "multinet_root:[multinet.include]netdb.h"
  892. #include "multinet_root:[multinet.include.netinet]in.h"
  893. #include "multinet_root:[multinet.include.arpa]inet.h"
  894. #include "multinet_root:[multinet.include.sys]ioctl.h"
  895.  
  896. #ifdef COMMENT
  897. /*
  898.   No longer needed because now bzero/bcopy are macros defined as
  899.   memset/memmove in all VMS builds.
  900. */
  901. /*
  902.   We should be able to pick these up from <strings.h> but it's
  903.   not portable between VAXC and DECC.  And even with DECC 5.x we have a
  904.   difference between VAX and Alpha.  We get warnings here on the VAX
  905.   with DECC 5.6-003 but they are not fatal.
  906. */
  907. #ifndef __DECC_VER
  908. #ifndef bzero
  909. _PROTOTYP( void bzero, (char *, int) );
  910. #endif /* bzero */
  911. #ifndef bcopy
  912. _PROTOTYP( void bcopy, (char *, char *, int) );
  913. #endif /* bcopy */
  914. #endif /* __DECC_VER */
  915. #endif /* COMMENT */
  916.  
  917. #ifdef __DECC
  918. /*
  919.    If compiling under DEC C the socket calls must not be prefixed with
  920.    DECC$.  This is done by using the compiler switch /Prefix=Ansi_C89.
  921.    However, this causes some calls that should be prefixed to not be
  922.    (which I think is a bug in the compiler - I've been told these calls
  923.    are present in ANSI compilers).  At any rate, such calls are fixed
  924.    here by explicitly prefixing them.
  925. */
  926. #ifdef COMMENT
  927. /*
  928.    But this causes errors with VMS 6.2 / DEC C 5.3-006 / MultiNet 4.0A on
  929.    a VAX (but not on an Alpha).  So now what happens if we skip doing this?
  930. */
  931. #define close decc$close
  932. #define alarm decc$alarm
  933. #endif /* COMMENT */
  934. #endif /* __DECC */
  935.  
  936. #else /* Not MULTINET */
  937.  
  938. #ifdef WINTCP                /* WIN/TCP = PathWay for VMS */
  939. #ifdef OLD_TWG
  940. #include "twg$tcp:[netdist.include.sys]errno.h"
  941. #include "twg$tcp:[netdist.include.sys]types2.h" /* avoid some duplicates */
  942. #else
  943. #include "twg$tcp:[netdist.include]socket_aliases.h"
  944. #include <errno.h>
  945. #include "twg$tcp:[netdist.include.sys]types.h"
  946. #endif /* OLD_TWG */
  947. #include "twg$tcp:[netdist.include.sys]socket.h"
  948. #include "twg$tcp:[netdist.include]netdb.h"
  949. #include "twg$tcp:[netdist.include.sys]domain.h"
  950. #include "twg$tcp:[netdist.include.sys]protosw.h"
  951. #include "twg$tcp:[netdist.include.netinet]in.h"
  952. #include "twg$tcp:[netdist.include.arpa]inet.h"
  953. #include "twg$tcp:[netdist.include.sys]ioctl.h"
  954.  
  955. #else /* Not WINTCP */
  956.  
  957. #ifdef DEC_TCPIP
  958. #ifdef UCX50
  959. #ifndef IF_DOT_H
  960. #define IF_DOT_H
  961. #endif /*  IF_DOT_H */
  962. #endif /* UCX50 */
  963.  
  964. #ifdef IF_DOT_H
  965. #include <if.h>                /* Needed to put up u_int typedef */
  966. #else
  967. #ifdef NEEDUINT
  968. typedef unsigned int u_int;
  969. #endif /* NEEDUINT */
  970. #endif /* IF_DOT_H */
  971.  
  972. #include <in.h>
  973. #include <netdb.h>
  974. #include <socket.h>
  975. #include "ckvioc.h"
  976. #define socket_errno errno
  977.  
  978. #ifdef COMMENT
  979. /*
  980.   No longer needed because now bzero/bcopy are macros defined as
  981.   memset/memmove in all VMS builds.
  982. */
  983. /*
  984.   Translation: In <strings.h>, which exists only for DECC >= 5.2, bzero()
  985.   and bcopy() are declared only for OpenVMS >= 7.0.  This still might need
  986.   adjustment for DECC 5.0 and higher.
  987. */
  988. #ifdef __DECC_VER
  989. #ifdef VMSV70
  990. /*
  991.   Note: you can't use "#if (__VMS_VER>=70000000)" because that is not
  992.   portable and kills non-VMS builds.
  993. */
  994. #include <strings.h>
  995. #else
  996. #define bzero(s,n) memset(s,0,n)
  997. #define bcopy(h,a,l) memmove(a,h,l)
  998. #endif /* VMSV70 */
  999. #else
  1000. #define bzero(s,n) memset(s,0,n)
  1001. #define bcopy(h,a,l) memmove(a,h,l)
  1002. #endif /* __DECC_VER */
  1003. #endif /* COMMENT */
  1004.  
  1005. #define socket_read     read
  1006. #define socket_write     write
  1007. #define socket_ioctl    ioctl
  1008. #define socket_close    close
  1009.  
  1010. #ifdef __DECC
  1011. int ioctl (int d, int request, void *argp);
  1012. #else
  1013. int ioctl (int d, int request, char *argp);
  1014. #endif /* DECC */
  1015. /*
  1016.   UCX supports select(), but does not provide the needed symbol and
  1017.   structure definitions in any header file, so ...
  1018. */
  1019. #include <types.h>
  1020. #ifndef NBBY
  1021. /*-
  1022.  * Copyright (c) 1982, 1986, 1991, 1993
  1023.  *    The Regents of the University of California.  All rights reserved.
  1024.  *
  1025.  * Redistribution and use in source and binary forms, with or without
  1026.  * modification, are permitted provided that the following conditions
  1027.  * are met:
  1028.  * 1. Redistributions of source code must retain the above copyright
  1029.  *    notice, this list of conditions and the following disclaimer.
  1030.  * 2. Redistributions in binary form must reproduce the above copyright
  1031.  *    notice, this list of conditions and the following disclaimer in the
  1032.  *    documentation and/or other materials provided with the distribution.
  1033.  * 3. All advertising materials mentioning features or use of this software
  1034.  *    must display the following acknowledgement:
  1035.  *    This product includes software developed by the University of
  1036.  *    California, Berkeley and its contributors.
  1037.  * 4. Neither the name of the University nor the names of its contributors
  1038.  *    may be used to endorse or promote products derived from this software
  1039.  *    without specific prior written permission.
  1040.  *
  1041.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  1042.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1043.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1044.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  1045.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1046.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1047.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1048.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1049.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1050.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1051.  * SUCH DAMAGE.
  1052.  *
  1053.  *    @(#)types.h    8.1 (Berkeley) 6/2/93
  1054.  */
  1055.  
  1056. #define    NBBY    8        /* number of bits in a byte */
  1057.  
  1058. /*
  1059.  * Select uses bit masks of file descriptors in longs.  These macros
  1060.  * manipulate such bit fields (the filesystem macros use chars).
  1061.  * FD_SETSIZE may be defined by the user, but the default here should
  1062.  * be enough for most uses.
  1063.  */
  1064. #ifndef    FD_SETSIZE
  1065. #define    FD_SETSIZE    256
  1066. #endif
  1067.  
  1068. typedef long    fd_mask;
  1069. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  1070.  
  1071. #ifndef howmany
  1072. #define    howmany(x, y)    (((x)+((y)-1))/(y))
  1073. #endif
  1074.  
  1075. typedef    struct fd_set {
  1076.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  1077. } fd_set;
  1078.  
  1079. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  1080. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  1081. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  1082. #define    FD_COPY(f, t)    bcopy(f, t, sizeof(*(f)))
  1083. #define    FD_ZERO(p)    bzero(p, sizeof(*(p)))
  1084. #endif /* !NBBY */
  1085.  
  1086. #else  /* Not DEC_TCPIP */
  1087.  
  1088. #ifdef CMU_TCPIP
  1089. #include <types.h>
  1090. #include <in.h>
  1091. #include <netdb.h>
  1092. #include <socket.h>
  1093. #include <inet.h>
  1094. #include <ioctl.h>
  1095. #include "ckvioc.h"
  1096. #define socket_errno errno
  1097. #ifdef COMMENT
  1098. /* This is now done above for all VMS builds */
  1099. #define bzero(s,n) memset(s,0,n)
  1100. #define bcopy(h,a,l) memmove(a,h,l)
  1101. #endif /* COMMENT */
  1102.  
  1103. /*
  1104.  * Routines supplied in LIBCMU.OLB
  1105.  */
  1106. #define socket_ioctl    ioctl
  1107. #define socket_read     cmu_read
  1108. #define socket_write     cmu_write
  1109. #define socket_close    cmu_close
  1110.  
  1111. #endif /* CMU_TCPIP */
  1112. #endif /* DEC_TCPIP */
  1113. #endif /* WINTCP */
  1114. #endif /* MULTINET */
  1115.  
  1116. #else /* Not VMS */
  1117.  
  1118. #ifdef OS2
  1119. #include "ckonet.h"
  1120. #ifndef NT
  1121. #include <nerrno.h>
  1122. #endif
  1123. #endif /* OS2 */
  1124.  
  1125. #ifdef STRATUS  /* Stratus VOS using OS TCP/IP products S235, S236, S237 */
  1126. #include <tcp_socket.h>
  1127. /* This gets used some places when TCPSOCKET is defined. */
  1128. /* OS TCP provides bzero(), but not bcopy()... go figure. */
  1129. #define bcopy(s,d,z) memcpy(d,s,z)
  1130. #endif /* STRATUS */
  1131.  
  1132. #ifdef OSK
  1133. #ifndef OSKXXC
  1134. #include <inet/in.h>
  1135. #include <inet/netdb.h>
  1136. #include <inet/socket.h>
  1137. #else
  1138. #include <INET/in.h>
  1139. #include <INET/netdb.h>
  1140. #include <INET/socket.h>
  1141. #endif /* OSKXXC */
  1142. #define bzero(s,n) memset(s,0,n)
  1143. #define bcopy(h,a,l) memcpy(a,h,l)
  1144. typedef char * caddr_t; /* core address type */
  1145. #endif /* OSK */
  1146.  
  1147. #endif /* VMS */
  1148. #endif /* UNIX */
  1149. #endif /* TCPSOCKET */
  1150.  
  1151. #ifdef TCPSOCKET
  1152. #ifndef NOHADDRLIST
  1153. #ifndef HADDRLIST
  1154. #ifdef SUNOS41
  1155. #define HADDRLIST
  1156. #endif /* SUNOS41 */
  1157. #ifdef SOLARIS
  1158. #define HADDRLIST
  1159. #endif /* SOLARIS */
  1160. #ifdef LINUX
  1161. #define HADDRLIST
  1162. #endif /* LINUX */
  1163. #ifdef AIXRS
  1164. #define HADDRLIST
  1165. #endif /* AIXRS */
  1166. #ifdef HPUX
  1167. #define HADDRLIST
  1168. #endif /* HPUX */
  1169. #ifdef IRIX
  1170. #define HADDRLIST
  1171. #endif /* IRIX */
  1172. #ifdef I386IX
  1173. #define HADDRLIST
  1174. #endif /* I386IX */
  1175. #endif /* HADDRLIST */
  1176. /* A system that defines h_addr as h_addr_list[0] should be HADDRLIST */
  1177. #ifndef HADDRLIST
  1178. #ifdef h_addr
  1179. #define HADDRLIST
  1180. #endif /* h_addr */
  1181. #endif /* HADDRLIST */
  1182. #endif /* NOHADDRLIST */
  1183. #endif /* TCPSOCKET */
  1184.  
  1185. #ifdef TNCODE                /* If we're compiling telnet code... */
  1186. #ifndef IKS_OPTION
  1187. #ifndef STRATUS
  1188. #define IKS_OPTION
  1189. #endif /* STRATUS */
  1190. #endif /* IKS_OPTION */
  1191. #include "ckctel.h"
  1192. #else
  1193. extern int sstelnet;
  1194. #ifdef IKSD
  1195. #undef IKSD
  1196. #endif /* IKSD */
  1197. #ifndef NOIKSD
  1198. #define NOIKSD
  1199. #endif /* NOIKSD */
  1200. #ifdef IKS_OPTION
  1201. #undef IKS_OPTION
  1202. #endif /* IKS_OPTION */
  1203. #endif /* TNCODE */
  1204.  
  1205. #ifndef NOTCPOPTS
  1206. /*
  1207.   Automatically define NOTCPOPTS for configurations where they can't be
  1208.   used at runtime or cause too much trouble at compile time.
  1209. */
  1210. #ifdef CMU_TCPIP            /* CMU/Tek */
  1211. #define NOTCPOPTS
  1212. #endif /* CMU_TCPIP */
  1213. #ifdef MULTINET                /* Multinet on Alpha */
  1214. #ifdef __alpha
  1215. #define NOTCPOPTS
  1216. #endif /* __alpha */
  1217. #endif /* MULTINET */
  1218. #endif /* NOTCPOPTS */
  1219.  
  1220. #ifdef NOTCPOPTS
  1221. #ifdef TCP_NODELAY
  1222. #undef TCP_NODELAY
  1223. #endif /* TCP_NODELAY */
  1224. #ifdef SO_LINGER
  1225. #undef SO_LINGER
  1226. #endif /* SO_LINGER */
  1227. #ifdef SO_KEEPALIVE
  1228. #undef SO_KEEPALIVE
  1229. #endif /* SO_KEEPALIVE */
  1230. #ifdef SO_SNDBUF
  1231. #undef SO_SNDBUF
  1232. #endif /* SO_SNDBUF */
  1233. #ifdef SO_RCVBUF
  1234. #undef SO_RCVBUF
  1235. #endif /* SO_RCVBUF */
  1236. #endif /* NOTCPOPTS */
  1237.  
  1238. /* This function is declared even when TCPSOCKET is not available */
  1239. _PROTOTYP( char * ckgetpeer, (VOID));
  1240.  
  1241. #ifdef TCPSOCKET
  1242. #ifdef SOL_SOCKET
  1243. #ifdef TCP_NODELAY
  1244. _PROTOTYP( int no_delay, (int, int) );
  1245. #endif /* TCP_NODELAY */
  1246. #ifdef SO_KEEPALIVE
  1247. _PROTOTYP( int keepalive, (int, int) ) ;
  1248. #endif /* SO_KEEPALIVE */
  1249. #ifdef SO_LINGER
  1250. _PROTOTYP( int ck_linger, (int, int, int) ) ;
  1251. #endif /* SO_LINGER */
  1252. #ifdef SO_SNDBUF
  1253. _PROTOTYP( int sendbuf,(int, int) ) ;
  1254. #endif /* SO_SNDBUF */
  1255. #ifdef SO_RCVBUF
  1256. _PROTOTYP( int recvbuf, (int, int) ) ;
  1257. #endif /* SO_RCVBUF */
  1258. #ifdef SO_DONTROUTE
  1259. _PROTOTYP(int dontroute, (int, int));
  1260. #endif /* SO_DONTROUTE */
  1261. #endif /* SOL_SOCKET */
  1262. _PROTOTYP( int getlocalipaddr, (VOID));
  1263. _PROTOTYP( int getlocalipaddrs, (char *,int,int));
  1264. _PROTOTYP( char * ckgetfqhostname,(char *));
  1265. _PROTOTYP( struct hostent * ck_copyhostent,(struct hostent *));
  1266. _PROTOTYP( char * ckname2addr, (char *));
  1267. _PROTOTYP( char * ckaddr2name, (char *));
  1268.  
  1269. /* AIX */
  1270.  
  1271. #ifdef AIXRS
  1272. #ifndef TCP_NODELAY
  1273. #define TCP_NODELAY 0x1
  1274. #endif /* TCP_NODELAY */
  1275. #ifndef TCP_MAXSEG
  1276. #define TCP_MAXSEG 0x2
  1277. #endif /* TCP_MAXSEG */
  1278. #ifndef TCP_KEEPALIVE
  1279. #define TCP_KEEPALIVE 0x8
  1280. #endif /* TCP_KEEPALIVE */
  1281. #endif /* AIXRS */
  1282. #endif /* TCPSOCKET */
  1283.  
  1284. #ifdef RLOGCODE
  1285. #ifndef CK_TTGWSIZ
  1286. SORRY_RLOGIN_REQUIRES_TTGWSIZ_see_ckcplm.doc
  1287. #endif /* CK_TTGWSIZ */
  1288. #endif /* RLOGCODE */
  1289.  
  1290. #ifdef CK_NAWS
  1291. #ifndef CK_TTGWSIZ
  1292. SORRY_CK_NAWS_REQUIRES_TTGWSIZ_see_ckcplm.doc
  1293. #endif /* CK_TTGWSIZ */
  1294. #endif /* CK_NAWS */
  1295.  
  1296. #ifndef PF_INET
  1297. #ifdef  AF_INET
  1298. #define PF_INET AF_INET
  1299. #endif /* AF_INET */
  1300. #endif /* PF_INET */
  1301.  
  1302. #ifndef IPPORT_ECHO
  1303. #define IPPORT_ECHO 7
  1304. #endif /* IPPORT_ECHO */
  1305.  
  1306. #ifdef CK_KERBEROS
  1307. #ifdef RLOGCODE
  1308. _PROTOTYP(int ck_krb_rlogin,(CHAR *, int, CHAR *, CHAR *, CHAR *,
  1309.                               struct sockaddr_in *,
  1310.                               struct sockaddr_in *, int, int));
  1311. #endif /* RLOGCODE */
  1312. #endif /* CK_KERBEROS */
  1313.  
  1314. _PROTOTYP( VOID ini_kerb, ( void ) );   /* Kerberos initialization routine */
  1315. _PROTOTYP( int doauth, (int) );         /* AUTHENTICATE action routine */
  1316.  
  1317. #ifdef CK_DNS_SRV
  1318. _PROTOTYP(int locate_srv_dns,(char *host, char *service,
  1319.                   char *protocol, struct sockaddr **addr_pp,
  1320.                   int *naddrs));
  1321. #endif /* CK_DNS_SRV */
  1322.  
  1323. #ifndef NOHTTP
  1324. _PROTOTYP(int http_open, (char *, char *, int, char *, int));
  1325. _PROTOTYP(int http_reopen, (VOID));
  1326. _PROTOTYP(int http_close, (VOID));
  1327. _PROTOTYP(int http_get, (char *,char **,char *,char *,char,char *,char *,
  1328.              int));
  1329. _PROTOTYP(int http_head, (char *,char **,char *,char *,char,char *,char *,
  1330.               int));
  1331. _PROTOTYP(int http_put, (char *,char **,char *,char *,char *,char,char *,
  1332.              char *, char *, int));
  1333. _PROTOTYP(int http_delete, (char *,char **,char *,char *,char,char *));
  1334. _PROTOTYP(int http_connect, (int, char *,char **,char *,char *,char,char *));
  1335. _PROTOTYP(int http_post, (char *,char **,char *,char *,char *,char,char *,
  1336.           char *,char *, int));
  1337. _PROTOTYP(int http_index, (char *,char **,char *,char *,char,char *,char *,
  1338.                int));
  1339.  
  1340. extern char * tcp_http_proxy;           /* Name[:port] of http proxy server */
  1341. extern int    tcp_http_proxy_errno;     /* Return value from server */
  1342. extern char * tcp_http_proxy_user;      /* Name of user for authentication */
  1343. extern char * tcp_http_proxy_pwd;       /* Password of user */
  1344. #endif /* NOHTTP */
  1345.  
  1346. #ifdef TCPSOCKET
  1347.  
  1348. /* Type needed as 5th argument (length) to get/setsockopt() */
  1349.  
  1350. #ifndef SOCKOPT_T
  1351. #define SOCKOPT_T int
  1352. #ifdef AIX42
  1353. #undef SOCKOPT_T
  1354. #define SOCKOPT_T unsigned long
  1355. #else
  1356. #ifdef PTX
  1357. #undef SOCKOPT_T
  1358. #define SOCKOPT_T size_t
  1359. #else
  1360. #ifdef NT
  1361. #undef SOCKOPT_T
  1362. #define SOCKOPT_T int
  1363. #else /* NT */
  1364. #ifdef UNIXWARE
  1365. #undef SOCKOPT_T
  1366. #define SOCKOPT_T size_t
  1367. #else /* UNIXWARE */
  1368. #ifdef VMS
  1369. #ifdef DEC_TCPIP
  1370. #ifdef __DECC_VER
  1371. #undef SOCKOPT_T
  1372. #define SOCKOPT_T size_t
  1373. #endif /* __DECC_VER */
  1374. #endif /* DEC_TCPIP */
  1375. #endif /* VMS */
  1376. #endif /* UNIXWARE */
  1377. #endif /* NT */
  1378. #endif /* PTX */
  1379. #endif /* AIX42 */
  1380. #endif /* SOCKOPT_T */
  1381.  
  1382. /* Ditto for getsockname() */
  1383.  
  1384. #ifndef GSOCKNAME_T
  1385. #define GSOCKNAME_T int
  1386. #ifdef PTX
  1387. #undef GSOCKNAME_T
  1388. #define GSOCKNAME_T size_t
  1389. #else
  1390. #ifdef AIX42                            /* size_t in 4.2++, int in 4.1-- */
  1391. #undef GSOCKNAME_T
  1392. #define GSOCKNAME_T size_t
  1393. #else
  1394. #ifdef UNIXWARE
  1395. #undef GSOCKNAME_T
  1396. #define GSOCKNAME_T size_t
  1397. #else
  1398. #ifdef VMS
  1399. #ifdef DEC_TCPIP
  1400. #ifdef __DECC_VER
  1401. #undef GSOCKNAME_T
  1402. #define GSOCKNAME_T size_t
  1403. #endif /* __DECC_VER */
  1404. #endif /* DEC_TCPIP */
  1405. #endif /* VMS */
  1406. #endif /* UNIXWARE */
  1407. #endif /* AIX41 */
  1408. #endif /* PTX */
  1409. #endif /* GSOCKNAME_T */
  1410.  
  1411. #endif /* TCPSOCKET */
  1412.  
  1413. #endif /* CKCNET_H */
  1414.