ckcnet.h 42 KB

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