nwprot.pp 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  1. {
  2. Netware Server Imports for FreePascal, contains definitions for the
  3. netware server protocol library
  4. Initial Version 2003/02/23 Armin ([email protected] or [email protected])
  5. The C-NDK and Documentation can be found here:
  6. http://developer.novell.com
  7. This program is distributed in the hope that it will be useful,but WITHOUT
  8. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  9. FITNESS FOR A PARTICULAR PURPOSE.
  10. Do not blame Novell if there are errors in this file, instead
  11. contact me and i will se what i can do.
  12. This module is untested, for the socket functions please use winsock
  13. }
  14. unit nwprot;
  15. interface
  16. {$mode objfpc}
  17. {$packrecords C}
  18. const
  19. O_RDONLY = $0000;
  20. O_WRONLY = $0001;
  21. O_RDWR = $0002;
  22. O_ACCMODE = $0003;
  23. O_APPEND = $0010;
  24. O_CREAT = $0020;
  25. O_TRUNC = $0040;
  26. O_EXCL = $0080;
  27. O_TEXT = $0100;
  28. O_BINARY = $0200;
  29. O_NDELAY = $0400;
  30. O_NOCTTY = $0800;
  31. O_NONBLOCK = O_NDELAY;
  32. {-ip_route.h-------------------------------------------------------------------}
  33. // dont know where the symbols came from, may be TCPIP.NLM, for now we
  34. // define 'clib'
  35. { total size of an IP address in bytes }
  36. const
  37. IP_ADDR_SZ = 4;
  38. type
  39. Pip_addr = ^Tip_addr;
  40. Tip_addr = record
  41. case longint of
  42. 0 : ( ip_array : array[0..(IP_ADDR_SZ)-1] of byte );
  43. 1 : ( ip_short : array[0..(IP_ADDR_SZ DIV 2)-1] of word );
  44. 2 : ( ip_long : dword );
  45. end;
  46. const
  47. SNPA_MX = 10; // maximum address mapping size is that largest we currently use
  48. // Simple IP interface information block --
  49. type
  50. Pip_if_info = ^Tip_if_info;
  51. Tip_if_info = record
  52. ifi_local_addr : Tip_addr; // interface's IP address
  53. ifi_net_mask : Tip_addr; // Netmask
  54. ifi_broadcast : Tip_addr; // Broadcast
  55. end;
  56. // Extended IP interface information block
  57. Pip_extended_if_info = ^Tip_extended_if_info;
  58. Tip_extended_if_info = record
  59. iex_signature : dword; // API signature
  60. iex_version : dword; // API version
  61. iex_length : dword; // bufsize
  62. iex_flags : dword;
  63. iex_if_id : dword; // Interface-ID
  64. iex_timestamp : dword; // creation time
  65. iex_local_addr : Tip_addr; // IP Address
  66. iex_net_mask : Tip_addr; // Netmask
  67. iex_broadcast : Tip_addr; // Broadcast Address
  68. iex_packet_mx : dword; // max out packet size
  69. iex_packet_opt : dword; // optimum packet size
  70. iex_reasm_mx : dword; // maximum reassembled packet
  71. iex_net_type : longint; // Network type
  72. iex_board_num : dword; // ODLI voardnumber
  73. iex_our_snpa : array[0..(SNPA_MX)-1] of byte; // SNPA for interface
  74. end;
  75. function IPExtendedIFInfo(info_pt:Pip_extended_if_info):longint;cdecl;external 'clib' name 'IPExtendedIFInfo';
  76. function IPExtendedIFInfo(var info_t:Tip_extended_if_info):longint;cdecl;external 'clib' name 'IPExtendedIFInfo';
  77. function IPGetIFInfo(if_info_pt:Pip_if_info):longint;cdecl;external 'clib' name 'IPGetIFInfo';
  78. function IPGetIFInfo(var if_info_t:Tip_if_info):longint;cdecl;external 'clib' name 'IPGetIFInfo';
  79. function IPGetLocalAddr(last_addr:dword):dword;cdecl;external 'clib' name 'IPGetLocalAddr';function IPGetLocalAddrIncludingAux(last_addr:dword):dword;cdecl;external 'clib' name 'IPGetLocalAddrIncludingAux';
  80. {-netdb.h----------------------------------------------------------------------}
  81. // Macros mapping the standard 4.3BSD names are not implemented in pascal
  82. {
  83. $Abstract:
  84. Standard definitions for accessing the socket interface's network
  85. database in Novell's NetWare 386 TCP/IP. Since process context is
  86. limited in NetWare 386, we need to play some games to provide context
  87. to the database.
  88. $
  89. $Implementation Notes:
  90. The actual NetWare 386 TCP/IP routines take an additional parameter
  91. to provide them a block for maintaining context. The normal routines
  92. are actually macros which call the context aware routines.
  93. One modification is required for porting an NLM the NetWare 386
  94. versions of the database routines: a context block must be defined.
  95. This is done by using the macro NETDB_DEFINE_CONTEXT in any one
  96. module linked into the NLM.
  97. If the preprocessor symbol NOT_NETWARE_386 is defined, this becomes
  98. the standard netdb.h from 4.3BSD for use in more typical environments.
  99. $
  100. The HOSTS database macros (i.e. gethostxxx) have the capability to
  101. evaluate either to the routines that access just the local /etc/hosts
  102. file (i.e. NWgethostxxx), or else the routines that automatically access
  103. a combination of local file, DNS, and NIS (i.e. NetDBgethostxxx). The
  104. former case is the way previous SDK usage of the macro was implemented.
  105. The latter case is a newer option that utilizes network name services
  106. transparent to the NLM, but it requires NETDB.NLM (which is also provided
  107. in this SDK). NETDB.NLM is an extension to TCP/IP and may be freely
  108. distributed with your product.
  109. The developer may choose which routines to use by directly calling the
  110. routines desired (either NWgethostxxx or NetDBgethostxxx). If the macros
  111. are used, then the macros will call the local-file-only versions of the
  112. calls (i.e. NWgethostxxx) unless the symbol NETDB_USE_INTERNET is
  113. defined below. If you wish to use the internet name services such as
  114. NIS or DNS in addition to the local hosts file for host access, then this
  115. symbol must be defined (either here or in your source file).
  116. }
  117. {$define NETDB_USE_INTERNET}
  118. const
  119. HOST_NOT_FOUND = 1;
  120. TRY_AGAIN = 2;
  121. NO_RECOVERY = 3;
  122. NO_ADDRESS = 4;
  123. { Structures returned by network
  124. data base library. All addresses
  125. are supplied in host order, and
  126. returned in network order (suitable
  127. for use in system calls). }
  128. { define h_addr h_addr_list[0] /* address, for backward compatiblity */ }
  129. type
  130. Phostent = ^Thostent;
  131. Thostent = record
  132. h_name : Pchar; // official name of host
  133. h_aliases : ^Pchar; // alias list
  134. h_addrtype : longint;
  135. h_length : longint; // length of address
  136. h_addr_list : ^Pchar; // list of addresses from name server
  137. end;
  138. // Assumption here is that a network number fits in 32 bits -- probably a poor one.
  139. Pnetent = ^Tnetent;
  140. Tnetent = record
  141. n_name : Pchar; // official name of net
  142. n_aliases : ^Pchar; // alias list
  143. n_addrtype : longint;
  144. n_net : dword;
  145. n_mask : dword; // Netmask, Novell extension
  146. end;
  147. Pservent = ^Tservent;
  148. Tservent = record
  149. s_name : Pchar; // official service name
  150. s_aliases : ^Pchar; // alias list
  151. s_port : longint; // portnumber
  152. s_proto : Pchar; // protocol to use
  153. end;
  154. Pprotoent = ^Tprotoent;
  155. Tprotoent = record
  156. p_name : Pchar; // official protocol name
  157. p_aliases : ^Pchar;
  158. p_proto : longint;
  159. end;
  160. // var h_errno : longint;cvar;external;
  161. const
  162. SCRATCHBUFSIZE = 1024;
  163. MAXALIASES = 10;
  164. MAXALIASSIZE = 64;
  165. MAXNAMESIZE = 64;
  166. MAXADDRSIZE = 19;
  167. MAXHOSTADDR = 1;
  168. { Special Novell structure for providing context in the otherwise
  169. context-free NetWare 386 environment. The applications SHOULD NOT
  170. access this structure ! }
  171. type
  172. Pnwsockent = ^Tnwsockent;
  173. Tnwsockent = record
  174. nse_hostctx : pointer; // PFILE;
  175. nse_netctx : pointer; // PFILE;
  176. nse_protoctx : pointer; // PFILE;
  177. nse_servctx : pointer; // PFILE;
  178. nse_h_errno : longint;
  179. nse_sockent_un : record
  180. case longint of
  181. 0 : ( nsu_hst : Thostent );
  182. 1 : ( nsu_net : Tnetent );
  183. 2 : ( nsu_proto : Tprotoent );
  184. 3 : ( nsu_serv : Tservent );
  185. end;
  186. nse_scratch : array[0..(SCRATCHBUFSIZE)-1] of char;
  187. end;
  188. { Declare the context block. The client must supply the actual
  189. block by placing NETDB_DEFINE_CONTEXT in one of the C modules
  190. in the link. }
  191. // var nwSocketCtx : longint;cvar;external;
  192. { ------------------------------------------------------------------------
  193. Host file examination
  194. ------------------------------------------------------------------------ }
  195. { Local-file-only routines }
  196. function NWgethostbyname(nwsktctx:Pnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyname';
  197. function NWgethostbyname(var nwsktctx:Tnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyname';
  198. function NWgethostbyaddr(nwsktctx:Pnwsockent; addr:Pchar; length:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyaddr';
  199. function NWgethostbyaddr(var nwsktctx:Tnwsockent; addr:Pchar; length:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyaddr';
  200. function NWgethostent(nwsktctx:Pnwsockent):Phostent;cdecl;external {'tcpip'} name 'NWgethostent';
  201. function NWgethostent(var nwsktctx:Tnwsockent):Phostent;cdecl;external {'tcpip'} name 'NWgethostent';
  202. procedure NWsethostent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsethostent';
  203. procedure NWsethostent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsethostent';
  204. procedure NWendhostent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendhostent';
  205. procedure NWendhostent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendhostent';
  206. { Internet Name Service routines }
  207. {
  208. NetDBgethostbyname() -- returns the host entry (struct hostent ) given
  209. the name of a host.
  210. The local file sys:/etc/hosts is consulted first to see if the entry
  211. exists there. If so, then that is returned. If not, then if DNS is
  212. installed on the machine, it will be consulted to perform the lookup.
  213. If the host still is not found, then NIS will be consulted if at all
  214. possible.
  215. This function returns NULL when an error occurs. The integer
  216. nwsktent->nse_h_errno can be checked to determine the nature of the
  217. error.
  218. The integer nwsktent->nse_h_errno can have the following values:
  219. HOST_NOT_FOUND No such host exists.
  220. If the NetDBgethostbyname function succeeds, it will return a pointer
  221. to a structure of type struct hostent.
  222. Syntax:
  223. struct hostent NetDBgethostbyname(struct nwsockent nwsktent,
  224. char name);
  225. nwskent: Points to a context block.
  226. name: Official name of the host.
  227. Returns:
  228. A pointer to the appropriate struct hostent if any that matches.
  229. NULL if no match found.
  230. }
  231. function NetDBgethostbyname(nwskent:Pnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyname';
  232. function NetDBgethostbyname(var nwskent:Tnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyname';
  233. {
  234. NetDBgethostbyaddr() -- returns the host entry (struct hostent ) given
  235. the address of a host.
  236. The local file sys:/etc/hosts is consulted first to see if the entry
  237. exists there. If so, then that is returned. If not, then if DNS is
  238. installed on the machine, it will be consulted to perform the lookup.
  239. If the host still is not found, then NIS will be consulted if at all
  240. possible.
  241. This function returns NULL when an error occurs. The integer
  242. nwsktent->nse_h_errno can be checked to determine the nature of the
  243. error.
  244. The integer nwsktent->nse_h_errno can have the following values:
  245. HOST_NOT_FOUND No such host exists.
  246. If the NetDBgethostbyaddr function succeeds, it will return a pointer
  247. to a structure of type struct hostent.
  248. Syntax:
  249. struct hostent NetDBgethostbyaddr(struct nwsockent nwskent,
  250. char addr, int len, int type);
  251. nwsktent: (Input) Points to a context block.
  252. addr: (Input) Internet address of the host.
  253. len: (Input) Length of the Internet address, in bytes.
  254. type: (Input) Value corresponding to the type of Internet
  255. address. Currently, the type is always AF_INET.
  256. Returns:
  257. A pointer to the appropriate struct hostent if any that matches.
  258. NULL if no match found.
  259. }
  260. function NetDBgethostbyaddr(nwsktent:Pnwsockent; addr:Pchar; len:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyaddr';
  261. function NetDBgethostbyaddr(var nwsktent:Tnwsockent; addr:Pchar; len:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyaddr';
  262. {
  263. NetDBgethostent() -- returns the next sequential entry from the
  264. SYS:ETC/HOSTS file, opening the file it it is not already open. Once
  265. the local file is depleted, all of the NIS host entries will be
  266. retrieved until those are depleted.
  267. Note that there may be duplicate entries in the local and NIS databases.
  268. The caller should handle these appropriately.
  269. This function returns NULL when an error occurs. The integer
  270. nwsktent->nse_h_errno can be checked to determine the nature of the
  271. error.
  272. The integer nwsktent->nse_h_errno can have the following values:
  273. HOST_NOT_FOUND No more hosts exist in either SYS:ETC/HOSTS or
  274. NIS.
  275. Syntax:
  276. struct hostent NetDBgethostent(struct nwsockent nwsktent,
  277. short ploc);
  278. nwsktent: (Input) Points to a context block.
  279. ploc: (Output) If non-NULL, this short will indicate if this
  280. entry is from the local sys:etc/hosts file (NETDB_LOC_LOCAL)
  281. or from the NIS database (NETDB_LOC_NIS).
  282. Pass in NULL if you're not interested in this information.
  283. Returns:
  284. A pointer to the next host entry if the function is successful.
  285. NULL if no more entries or an error occurred.
  286. }
  287. function NetDBgethostent(nwsktent:Pnwsockent; ploc:Psmallint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostent';
  288. function NetDBgethostent(var nwsktent:Tnwsockent; ploc:Psmallint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostent';
  289. {
  290. NetDBsethostent() -- rewinds the SYS:ETC/HOSTS file if the file is
  291. already open. This call guarantees that the next call to
  292. NetDBgethostent() will return the FIRST record in the local hosts file,
  293. regardless of whether the LAST call returned an entry from the local
  294. file or from NIS.
  295. If the stayopen flag is set (nonzero), the SYS:ETC/HOSTS file is NOT
  296. closed after each call made to NetDBgethostbyname() or
  297. NetDBgethostbyaddr().
  298. Syntax:
  299. void NetDBsethostent(struct nwsockent nwsktent, int stayopen);
  300. nwsktent: (Input) Points to a context block.
  301. stayopen: (Input) If nonzero, causes SYS:ETC/HOSTS to remain open
  302. after a call to NetDBgethostbyname() or
  303. NetDBgethostbyaddr().
  304. Returns:
  305. Nothing.
  306. }
  307. procedure NetDBsethostent(nwsktent:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NetDBsethostent';
  308. procedure NetDBsethostent(var nwsktent:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NetDBsethostent';
  309. {
  310. NetDBendhostent() -- closes the SYS:ETC/HOSTS file. Also ends access
  311. to the NIS database. After this call, the next call to
  312. NetDBgethostent() will be from the beginning of the local file again.
  313. Syntax:
  314. void NetDBendhostent(struct nwsockent nwsktent);
  315. nwsktent: (Input) Points to a context block.
  316. Returns:
  317. Nothing.
  318. }
  319. procedure NetDBendhostent(nwsktent:Pnwsockent);cdecl;external {'tcpip'} name 'NetDBendhostent';
  320. procedure NetDBendhostent(var nwsktent:Tnwsockent);cdecl;external {'tcpip'} name 'NetDBendhostent';
  321. {
  322. NetDBgethostname() -- this gets the current machine's host name into the
  323. passed in buffer (if it is large enough).
  324. This will use the local hosts file if it exists, otherwise it will then
  325. try both DNS and NIS if available in order to get the official name of
  326. our own machine.
  327. Syntax:
  328. int NetDBgethostname(struct nwsockent nwsktent, char name,
  329. int namelen);
  330. nwsktent: (Input) Points to a context block.
  331. name: (Output) Official name of the host.
  332. namelen: (Input) Specifies the size of the array pointed to by name.
  333. Returns:
  334. 0: The call succeeded.
  335. -1: The call failed.
  336. }
  337. function NetDBgethostname(nwsktent:Pnwsockent; name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'NetDBgethostname';
  338. function NetDBgethostname(var nwsktent:Tnwsockent; name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'NetDBgethostname';
  339. // Network file examination
  340. function NWgetnetbyname(nwsktctx:Pnwsockent; name:Pchar):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyname';
  341. function NWgetnetbyname(var nwsktctx:Tnwsockent; name:Pchar):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyname';
  342. function NWgetnetbyaddr(nwsktctx:Pnwsockent; net:longint; _type:longint):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyaddr';
  343. function NWgetnetbyaddr(var nwsktctx:Tnwsockent; net:longint; _type:longint):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyaddr';
  344. function NWgetnetent(nwsktctx:Pnwsockent):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetent';
  345. function NWgetnetent(var nwsktctx:Tnwsockent):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetent';
  346. procedure NWsetnetent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetnetent';
  347. procedure NWsetnetent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetnetent';
  348. procedure NWendnetent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendnetent';
  349. procedure NWendnetent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendnetent';
  350. // Service file examination
  351. function NWgetservbyname(nwsktctx:Pnwsockent; name:Pchar; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyname';
  352. function NWgetservbyname(var nwsktctx:Tnwsockent; name:Pchar; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyname';
  353. function NWgetservbyport(nwsktctx:Pnwsockent; port:longint; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyport';
  354. function NWgetservbyport(var nwsktctx:Tnwsockent; port:longint; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyport';
  355. function NWgetservent(nwsktctx:Pnwsockent):Pservent;cdecl;external {'tcpip'} name 'NWgetservent';
  356. function NWgetservent(var nwsktctx:Tnwsockent):Pservent;cdecl;external {'tcpip'} name 'NWgetservent';
  357. procedure NWsetservent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetservent';
  358. procedure NWsetservent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetservent';
  359. procedure NWendservent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendservent';
  360. procedure NWendservent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendservent';
  361. // Protocol file examination
  362. function NWgetprotobyname(nwsktctx:Pnwsockent; name:Pchar):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobyname';
  363. function NWgetprotobyname(var nwsktctx:Tnwsockent; name:Pchar):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobyname';
  364. function NWgetprotobynumber(nwsktctx:Pnwsockent; protocol:longint):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobynumber';
  365. function NWgetprotobynumber(var nwsktctx:Tnwsockent; protocol:longint):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobynumber';
  366. function NWgetprotoent(nwsktctx:Pnwsockent):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotoent';
  367. function NWgetprotoent(var nwsktctx:Tnwsockent):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotoent';
  368. procedure NWsetprotoent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetprotoent';
  369. procedure NWsetprotoent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetprotoent';
  370. procedure NWendprotoent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendprotoent';
  371. procedure NWendprotoent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendprotoent';
  372. function gethostname(name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'gethostname';
  373. function gethostid:longint;cdecl;external {'tcpip'} name 'gethostid';
  374. {-tiuser.h---------------------------------------------------------------------}
  375. const
  376. EAGAIN = -(1);
  377. { Error values }
  378. TACCES = 1;
  379. TBADADDR = 2;
  380. TBADDATA = 3;
  381. TBADF = 4;
  382. TBADFLAG = 5;
  383. TBADOPT = 6;
  384. TBADSEQ = 7;
  385. TBUFOVFLW = 8;
  386. TFLOW = 9;
  387. TLOOK = 10;
  388. TNOADDR = 11;
  389. TNODATA = 12;
  390. TNOREL = 13;
  391. TNOTSUPPORT = 14;
  392. TOUTSTATE = 15;
  393. TSTATECHNG = 16;
  394. TSYSERR = 17;
  395. TNOUDERR = 18;
  396. TNODIS = 19;
  397. TNOSTRUCTYPE = 20;
  398. TBADNAME = 21;
  399. TBADQLEN = 22;
  400. TADDRBUSY = 23;
  401. { t_look events }
  402. _T_LISTEN = 1;
  403. _T_CONNECT = 2;
  404. _T_DATA = 3;
  405. _T_EXDATA = 4;
  406. _T_DISCONNECT = 5;
  407. _T_ORDREL = 6;
  408. _T_ERROR = 7;
  409. _T_UDERR = 8;
  410. _T_GODATA = 9;
  411. _T_GOEXDATA = 10;
  412. _T_EVENTS = 11;
  413. { Flag definitions }
  414. _T_EXPEDITED = $01;
  415. _T_MORE = $02;
  416. _T_NEGOTIATE = $04;
  417. _T_CHECK = $08;
  418. _T_DEFAULT = $10;
  419. _T_SUCCESS = $20;
  420. _T_FAILURE = $40;
  421. var t_errno : longint;cvar;external;
  422. type
  423. Pt_info = ^Tt_info;
  424. Tt_info = record
  425. addr : longint;
  426. options : longint;
  427. tsdu : longint;
  428. etsdu : longint;
  429. connect : longint;
  430. discon : longint;
  431. servtype : longint;
  432. end;
  433. { Service types }
  434. { Connection-mode service }
  435. const
  436. T_COTS = 1;
  437. { Connection service with orderly release }
  438. T_COTS_ORD = 2;
  439. { Connectionless-mode service }
  440. T_CLTS = 3;
  441. type
  442. Pnetbuf = ^Tnetbuf;
  443. Tnetbuf = record
  444. maxlen : dword;
  445. len : dword;
  446. buf : Pchar;
  447. end;
  448. Pt_bind = ^Tt_bind;
  449. Tt_bind = record
  450. addr : Tnetbuf;
  451. qlen : dword;
  452. end;
  453. Pt_optmgmt = ^Tt_optmgmt;
  454. Tt_optmgmt = record
  455. opt : Tnetbuf;
  456. flags : longint;
  457. end;
  458. Pt_discon = ^Tt_discon;
  459. Tt_discon = record
  460. udata : Tnetbuf;
  461. reason : longint;
  462. sequence : longint;
  463. end;
  464. Pt_call = ^Tt_call;
  465. Tt_call = record
  466. addr : Tnetbuf;
  467. opt : Tnetbuf;
  468. udata : Tnetbuf;
  469. sequence : longint;
  470. end;
  471. Pt_unitdata = ^Tt_unitdata;
  472. Tt_unitdata = record
  473. addr : Tnetbuf;
  474. opt : Tnetbuf;
  475. udata : Tnetbuf;
  476. end;
  477. Pt_uderr = ^Tt_uderr;
  478. Tt_uderr = record
  479. addr : Tnetbuf;
  480. opt : Tnetbuf;
  481. error : longint;
  482. end;
  483. // t_alloc structure types, had to prefix with _ because some
  484. // names conflict with functions
  485. const
  486. _T_BIND = $1;
  487. _T_CALL = $2;
  488. _T_OPTMGMT = $4;
  489. _T_DIS = $8;
  490. _T_UNITDATA = $10;
  491. _T_UDERROR = $20;
  492. _T_INFO = $40;
  493. { XTI names for t_alloc structure types }
  494. _T_BIND_STR = _T_BIND;
  495. _T_OPTMGMT_STR = _T_OPTMGMT;
  496. _T_CALL_STR = _T_CALL;
  497. _T_DIS_STR = _T_DIS;
  498. _T_UNITDATA_STR = _T_UNITDATA;
  499. _T_UDERROR_STR = _T_UDERROR;
  500. _T_INFO_STR = _T_INFO;
  501. { t_alloc field identifiers }
  502. _T_ADDR = $1000;
  503. _T_OPT = $2000;
  504. _T_UDATA = $4000;
  505. _T_ALL = $8000;
  506. { State values }
  507. { added to match xti state tables }
  508. _T_UNINIT = 0;
  509. { unbound }
  510. _T_UNBND = 1;
  511. { idle }
  512. _T_IDLE = 2;
  513. { outgoing connection pending }
  514. _T_OUTCON = 3;
  515. { incoming connection pending }
  516. _T_INCON = 4;
  517. { data transfer }
  518. _T_DATAXFER = 5;
  519. { outgoing orderly release }
  520. _T_OUTREL = 6;
  521. { incoming orderly release }
  522. _T_INREL = 7;
  523. { general purpose defines }
  524. _T_YES = 1;
  525. _T_NO = 0;
  526. _T_UNUSED = -(1);
  527. _T_NULL = 0;
  528. _T_ABSREQ = $8000;
  529. var
  530. t_errlist : array of Pchar;cvar;external;
  531. t_nerr : longint;cvar;external;
  532. {---------------------TCP specific Options-------------------------- }
  533. { TCP Precedence Levels }
  534. const
  535. _T_ROUTINE = 0;
  536. _T_PRIORITY = 1;
  537. _T_IMMEDIATE = 2;
  538. _T_FLASH = 3;
  539. _T_OVERRIDEFLASH = 4;
  540. _T_CRITIC_ECP = 5;
  541. _T_INETCONTROL = 6;
  542. _T_NETCONTROL = 7;
  543. type
  544. Psecoptions = ^Tsecoptions;
  545. Tsecoptions = record
  546. security : smallint;
  547. compartment : smallint;
  548. handling : smallint;
  549. tcc : longint;
  550. end;
  551. Ptcp_options = ^Ttcp_options;
  552. Ttcp_options = record
  553. precedence : smallint; // TCP options
  554. timeout : longint; // abort timeout
  555. max_seg_size : longint;
  556. secopt : Tsecoptions; // security options
  557. end;
  558. function t_accept(fd:longint; resfd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_accept';
  559. function t_alloc(fd:longint; struct_type:longint; fields:longint):Pchar;cdecl;external 'tli' name 't_alloc';
  560. function t_bind(fd:longint; req:Pt_bind; ret:Pt_bind):longint;cdecl;external 'tli' name 't_bind';
  561. function t_blocking(fd:longint):longint;cdecl;external 'tli' name 't_blocking';
  562. function t_close(fd:longint):longint;cdecl;external 'tli' name 't_close';
  563. function t_connect(fd:longint; sndcall:Pt_call; rcvcall:Pt_call):longint;cdecl;external 'tli' name 't_connect';
  564. procedure t_error(errmsg:Pchar);cdecl;external 'tli' name 't_error';
  565. function t_free(ptr:Pchar; struct_type:longint):longint;cdecl;external 'tli' name 't_free';
  566. function t_getinfo(fd:longint; info:Pt_info):longint;cdecl;external 'tli' name 't_getinfo';
  567. function t_getstate(fd:longint):longint;cdecl;external 'tli' name 't_getstate';
  568. function t_listen(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_listen';
  569. function t_look(fd:longint):longint;cdecl;external 'tli' name 't_look';
  570. function t_nonblocking(fd:longint):longint;cdecl;external 'tli' name 't_nonblocking';
  571. function t_open(path:Pchar; oflag:longint; info:Pt_info):longint;cdecl;external 'tli' name 't_open';
  572. function t_optmgmt(fd:longint; req:Pt_optmgmt; ret:Pt_optmgmt):longint;cdecl;external 'tli' name 't_optmgmt';
  573. function t_rcv(fd:longint; buf:Pchar; nbytes:dword; flags:Plongint):longint;cdecl;external 'tli' name 't_rcv';
  574. function t_rcvconnect(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_rcvconnect';
  575. function t_rcvdis(fd:longint; discon:Pt_discon):longint;cdecl;external 'tli' name 't_rcvdis';
  576. function t_rcvrel(fd:longint):longint;cdecl;external 'tli' name 't_rcvrel';
  577. function t_rcvudata(fd:longint; unitdata:Pt_unitdata; flags:Plongint):longint;cdecl;external 'tli' name 't_rcvudata';
  578. function t_rcvuderr(fd:longint; uderr:Pt_uderr):longint;cdecl;external 'tli' name 't_rcvuderr';
  579. function t_snd(fd:longint; buf:Pchar; nbytes:dword; flags:longint):longint;cdecl;external 'tli' name 't_snd';
  580. function t_snddis(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_snddis';
  581. function t_sndrel(fd:longint):longint;cdecl;external 'tli' name 't_sndrel';
  582. function t_sndudata(fd:longint; unitdata:Pt_unitdata):longint;cdecl;external 'tli' name 't_sndudata';
  583. function t_sync(fd:longint):longint;cdecl;external 'tli' name 't_sync';
  584. function t_unbind(fd:longint):longint;cdecl;external 'tli' name 't_unbind';
  585. // havent found the declaration for __get_t_errno_ptr, hope that is correct:
  586. function __get_t_errno_ptr:plongint; cdecl;external 'clib' name '__get_t_errno_ptr';
  587. function t_error : longint;
  588. {-ositli.h---------------------------------------------------------------------}
  589. const
  590. TPDR_NORMAL = 128 + 0;
  591. TPDR_CRCONG = 128 + 1;
  592. TPDR_CONNEG = 128 + 2;
  593. TPDR_DUPSR = 128 + 3;
  594. TPDR_MMREF = 128 + 4;
  595. TPDR_PE = 128 + 5;
  596. TPDR_REOVFL = 128 + 7;
  597. TPDR_NWREF = 128 + 8;
  598. TPDR_INVHD = 128 + 10;
  599. TPDR_RNS = 0;
  600. TPDR_CONG = 1;
  601. TPDR_NOSESS = 2;
  602. TPDR_UNKADDR = 3; // Address unknown
  603. // Options management pre-defined values.
  604. T_YES = 1;
  605. T_NO = 0;
  606. T_UNUSED = -(1);
  607. T_NULL = 0;
  608. T_ABSREQ = $8000;
  609. T_PRIDFLT = 4;
  610. T_PRILOW = 3;
  611. T_PRIMID = 2;
  612. T_PRIHIGH = 1;
  613. T_PRITOP = 0;
  614. T_NOPROTECT = 1;
  615. T_PASSIVEPROTECT = 2;
  616. T_ACTIVEPROTECT = 4;
  617. T_LTPDUDFLT = 2048;
  618. T_CLASS0 = 0;
  619. T_CLASS1 = 1;
  620. T_CLASS2 = 2;
  621. T_CLASS3 = 3;
  622. T_CLASS4 = 4;
  623. // Options Management structures.
  624. type
  625. Prate = ^Trate;
  626. Trate = record
  627. targetvalue : longint; // target value
  628. minacceptvalue : longint; // minimum acceptable value
  629. end;
  630. Preqvalue = ^Treqvalue;
  631. Treqvalue = record
  632. called : Trate; // called rate
  633. calling : Trate; // calling rate
  634. end;
  635. Pthrpt = ^Tthrpt;
  636. Tthrpt = record
  637. maxthrpt : Treqvalue; // maximum throughput
  638. avgthrpt : Treqvalue; // average throughput
  639. end;
  640. Pmanagement = ^Tmanagement;
  641. Tmanagement = record
  642. dflt : smallint;
  643. ltpdu : longint;
  644. reastime : smallint;
  645. _class : char;
  646. altclass : char;
  647. extform : char;
  648. flowctrl : char;
  649. checksum : char;
  650. netexp : char;
  651. netrecptcf: char;
  652. end;
  653. // Connection oriented options.
  654. Pisoco_options = ^Tisoco_options;
  655. Tisoco_options = record
  656. throughput : Tthrpt;
  657. transdel : Treqvalue;
  658. reserrorrate : Trate;
  659. transffailprob : Trate;
  660. estfailprob : Trate;
  661. relfailprob : Trate;
  662. estdelay : Trate;
  663. reldelay : Trate;
  664. connresil : Tnetbuf;
  665. protection : word;
  666. priority : smallint;
  667. mngmt : Tmanagement; // management parameters
  668. expd : char; // expedited data: T_YES or T_NO
  669. end;
  670. // Connectionless options.
  671. Pisocl_options = ^Tisocl_options;
  672. Tisocl_options = record
  673. transdel : Trate; // transit delay
  674. reserrorrate : Trate; // residual error rate
  675. protection : word;
  676. priority : smallint;
  677. end;
  678. // Novell connectionless options.
  679. Pnovell_isocl_options = ^Tnovell_isocl_options;
  680. Tnovell_isocl_options = record
  681. transdel : Trate; // transit delay
  682. reserrorrate : Trate; // residual error rate
  683. protection : word;
  684. priority : smallint;
  685. checksum : longint;
  686. end;
  687. {-param.h----------------------------------------------------------------------}
  688. const
  689. HZ = 18;
  690. NULL = 0;
  691. PZERO = 20;
  692. PCATCH = $8000;
  693. {-poll.h-----------------------------------------------------------------------}
  694. const
  695. NPOLLFILE = 65535;
  696. POLLIN = 1;
  697. POLLPRI = 2;
  698. POLLOUT = 4;
  699. POLLERR = 10;
  700. POLLHUP = 20;
  701. POLLNVAL = 40;
  702. { array of streams to poll }
  703. { Internal "fd" for the benefit of the kernel }
  704. type
  705. Ppollfd = ^Tpollfd;
  706. Tpollfd = record
  707. fd : longint;
  708. events : smallint;
  709. revents : smallint;
  710. _ifd : longint;
  711. end;
  712. { I_POLL structure for ioctl on non-5.3 systems }
  713. Pstrpoll = ^Tstrpoll;
  714. Tstrpoll = record
  715. nfds : dword;
  716. pollfdp : Ppollfd;
  717. timeout : longint;
  718. end;
  719. function poll(const fds:array of Tpollfd; nfds:dword; timeout:longint):longint;cdecl;external 'clib' name 'poll';
  720. {-proc.h-----------------------------------------------------------------------}
  721. type
  722. Pproc = ^Tproc;
  723. Tproc = record
  724. p_pid : smallint;
  725. p_pgrp : smallint;
  726. end;
  727. {-strlog.h---------------------------------------------------------------------}
  728. const
  729. SL_FATAL = $1;
  730. SL_NOTIFY = $2;
  731. SL_ERROR = $4;
  732. SL_TRACE = $8;
  733. I_TRCLOG = 1;
  734. I_ERRLOG = 2;
  735. LOGMSGSZ = 128;
  736. type
  737. Plog_ctl = ^Tlog_ctl;
  738. Tlog_ctl = record
  739. mid : smallint;
  740. sid : smallint;
  741. level : char;
  742. flags : smallint;
  743. ltime : longint;
  744. ttime : longint;
  745. seq_no: longint;
  746. end;
  747. Ptrace_ids = ^Ttrace_ids;
  748. Ttrace_ids = record
  749. ti_mid : smallint;
  750. ti_sid : smallint;
  751. ti_level : char;
  752. ti_flags : smallint;
  753. end;
  754. {-strstat.h--------------------------------------------------------------------}
  755. type
  756. Pmodule_stat = ^Tmodule_stat;
  757. Tmodule_stat = record
  758. ms_pcnt : longint;
  759. ms_scnt : longint;
  760. ms_ocnt : longint;
  761. ms_ccnt : longint;
  762. ms_acnt : longint;
  763. ms_xptr : Pchar;
  764. ms_xsize: smallint;
  765. end;
  766. {-user.h-----------------------------------------------------------------------}
  767. type
  768. Puser = ^Tuser;
  769. Tuser = record
  770. u_error : longint;
  771. u_uid : longint;
  772. u_gid : longint;
  773. u_ruid : longint;
  774. u_rgid : longint;
  775. u_ttyp : Psmallint;
  776. u_procp : Pproc;
  777. end;
  778. {-stream.h---------------------------------------------------------------------}
  779. type
  780. Pmodule_info = ^Tmodule_info;
  781. Tmodule_info = record
  782. mi_idnum : word;
  783. mi_idname : Pchar;
  784. mi_minpsz : smallint;
  785. mi_maxpsz : smallint;
  786. mi_hiwat : smallint;
  787. mi_lowat : smallint;
  788. end;
  789. Pqinit = ^Tqinit;
  790. Tqinit = record
  791. qi_putp : function :longint;cdecl;
  792. qi_srvp : function :longint;
  793. qi_qopen : function :longint;
  794. qi_qclose : function :longint;
  795. qi_qadmin : function :longint;
  796. qi_minfo : Pmodule_info;
  797. qi_mstat : Pmodule_stat;
  798. end;
  799. Pdatab = ^Tdatab;
  800. Tdatab = record
  801. db_freep : Pdatab;
  802. db_base : Pbyte;
  803. db_lim : Pbyte;
  804. db_ref : byte;
  805. db_type : byte;
  806. db_class : byte;
  807. db_pad : array[0..0] of byte;
  808. end;
  809. Tdblk_t = Tdatab;
  810. type
  811. Pmsgb = ^Tmsgb;
  812. Tmsgb = record
  813. b_next : Pmsgb; // next message on queue
  814. b_prev : Pmsgb; // previous message on queue
  815. b_cont : Pmsgb; // next message block of message
  816. b_rptr : PChar; // first unread data byte in buffer
  817. b_wptr : PChar; // first unwritten data byte
  818. b_datap : Pdatab; // data block
  819. end;
  820. Tmblk_t = Tmsgb;
  821. Pmblk_t = Pmsgb;
  822. Pq_xtra = pointer; // dont know where this is defined
  823. Pqueue = ^Tqueue;
  824. Tqueue = record
  825. q_qinfo : Pqinit;
  826. q_first : Pmsgb;
  827. q_last : Pmsgb;
  828. q_next : Pqueue;
  829. q_link : Pqueue;
  830. q_ptr : Pchar;
  831. q_count : byte; //ushort;
  832. q_flag : byte; // ushort;
  833. q_minpsz: smallint;
  834. q_maxpsz: smallint;
  835. q_hiwat : byte; // ushort;
  836. q_lowat : byte; // ushort;
  837. q_osx : Pq_xtra;
  838. q_ffcp : Pqueue;
  839. q_bfcp : Pqueue;
  840. end;
  841. Tqueue_t = Tqueue;
  842. Pqueue_t = Pqueue;
  843. { Q state defines }
  844. const
  845. F_Q_IS_WRITE_Q = $1;
  846. F_Q_DISABLED = $2;
  847. F_Q_FULL = $4;
  848. F_Q_TO_SCHEDULE = $8;
  849. F_Q_PUT_STOPPED = $10;
  850. F_Q_WELDED = $20;
  851. F_Q_SEQUENT_SYNCH = $40;
  852. { Q state defines for 5.4 compatibility }
  853. QREADR = $80;
  854. QFULL = F_Q_FULL;
  855. QENAB = F_Q_TO_SCHEDULE;
  856. { Used in M_IOCTL mblks to muxes (ioc_cmd I_LINK) }
  857. { lowest level write queue of upper stream }
  858. { highest level write queue of lower stream }
  859. { system-unique index for lower stream }
  860. type
  861. Plinkblk = ^Tlinkblk;
  862. Tlinkblk = record
  863. l_qtop : Pqueue_t;
  864. l_qbot : Pqueue_t;
  865. l_index : longint;
  866. end;
  867. { Message types }
  868. const
  869. QNORM = 0;
  870. { Ordinary data }
  871. M_DATA = 0;
  872. { Internal control info and data }
  873. M_PROTO = 1;
  874. { Request a driver to send a break }
  875. M_BREAK = 010;
  876. { Used to pass a file pointer }
  877. M_PASSFP = 011;
  878. { Requests a signal to be sent }
  879. M_SIG = 013;
  880. { Request a real-time delay }
  881. M_DELAY = 014;
  882. { For inter-module communication }
  883. M_CTL = 015;
  884. { Used internally for I_STR requests }
  885. M_IOCTL = 016;
  886. { Alters characteristics of stream head }
  887. M_SETOPTS = 020;
  888. { Priority messages types }
  889. QPCTL = 0200;
  890. { Positive ack of previous M_IOCTL }
  891. M_IOCACK = 0201;
  892. { Previous M_IOCTL failed }
  893. M_IOCNAK = 0202;
  894. { Same as M_PROTO except for priority }
  895. M_PCPROTO = 0203;
  896. { Priority signal }
  897. M_PCSIG = 0204;
  898. { Requests modules to flush queues }
  899. M_FLUSH = 0206;
  900. { Request drivers to stop output }
  901. M_STOP = 0207;
  902. { Request drivers to start output }
  903. M_START = 0210;
  904. { Driver can no longer produce data }
  905. M_HANGUP = 0211;
  906. { Reports downstream error condition }
  907. M_ERROR = 0212;
  908. { Reports client read at stream head }
  909. M_READ = 0213;
  910. { PSE-private type; high priority data }
  911. M_HPDATA = 0214;
  912. FLUSHALL = 1;
  913. FLUSHDATA = 0;
  914. type
  915. Piocblk = ^Tiocblk;
  916. Tiocblk = record
  917. ioc_cmd : longint;
  918. ioc_uid : word;
  919. ioc_gid : word;
  920. ioc_id : dword;
  921. ioc_count : dword;
  922. ioc_error : longint;
  923. ioc_rval : longint;
  924. end;
  925. Pstrpfp = ^Tstrpfp;
  926. Tstrpfp = record
  927. pass_file_cookie : dword;
  928. pass_uid : word;
  929. pass_gid : word;
  930. pass_sth : pointer;
  931. end;
  932. Pstroptions = ^Tstroptions;
  933. Tstroptions = record
  934. so_flags : smallint;
  935. so_readopt : smallint;
  936. so_wroff : word;
  937. so_minpsz : smallint;
  938. so_maxpsz : smallint;
  939. so_hiwat : word;
  940. so_lowat : word;
  941. end;
  942. const
  943. SO_ALL = 0377;
  944. SO_READOPT = 01;
  945. SO_WROFF = 02;
  946. SO_MINPSZ = 04;
  947. SO_MAXPSZ = 010;
  948. SO_HIWAT = 020;
  949. SO_LOWAT = 040;
  950. SO_MREADON = 0100;
  951. SO_MREADOFF = 0200;
  952. BPRI_LO = 1;
  953. BPRI_MED = 2;
  954. BPRI_HI = 3;
  955. INFPSZ = -(1);
  956. const
  957. MAXMSGSIZE = 4096;
  958. OPENFAIL = -(1);
  959. CLONEOPEN = $2;
  960. MODOPEN = $1;
  961. NSTREVENT = 40;
  962. STRMSGSZ = MAXMSGSIZE;
  963. STRCTLSZ = 1024;
  964. STRLOFRAC = 80;
  965. STRMEDFRAC = 90;
  966. MAXBSIZE = MAXMSGSIZE;
  967. type TFuncLongCdecl = function : longint; cdecl;
  968. function allocb(size:longint; pri:longint):Pmblk_t;cdecl;external 'streams' name 'allocb';
  969. function allocq:Pqueue_t;cdecl;external 'streams' name 'allocq';
  970. function adjmsg(mp:Pmblk_t; len_param:longint):longint;cdecl;external 'streams' name 'adjmsg';
  971. function backq(q:Pqueue_t):Pqueue_t;cdecl;external 'streams' name 'backq';
  972. function bufcall(size:longint; pri:longint; func:TFuncLongCdecl; arg:longint):longint;cdecl;external 'streams' name 'bufcall';
  973. procedure bcopy(src:Pchar; dst:Pchar; len:longint);cdecl;external 'streams' name 'bcopy';
  974. procedure bzero(buffer:Pchar; nbytes:longint);cdecl;external 'streams' name 'bzero';
  975. function canput(q:Pqueue_t):longint;cdecl;external 'streams' name 'canput';
  976. function copyb(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'copyb';
  977. function copymsg(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'copymsg';
  978. function dupb(bp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'dupb';
  979. function dupmsg(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'dupmsg';
  980. function flushq(q:Pqueue_t; flag:longint):longint;cdecl;external 'streams' name 'flushq';
  981. function freeb(bp:Pmblk_t):longint;cdecl;external 'streams' name 'freeb';
  982. function freemsg(mp:Pmblk_t):longint;cdecl;external 'streams' name 'freemsg';
  983. function freeq(q:Pqueue_t):longint;cdecl;external 'streams' name 'freeq';
  984. function getq(q:Pqueue_t):Pmblk_t;cdecl;external 'streams' name 'getq';
  985. function insq(q:Pqueue_t; emp:Pmblk_t; nmp:Pmblk_t):longint;cdecl;external 'streams' name 'insq';
  986. function linkb(mp1:Pmblk_t; mp2:Pmblk_t):longint;cdecl;external 'streams' name 'linkb';
  987. function msgdsize(mp:Pmblk_t):longint;cdecl;external 'streams' name 'msgdsize';
  988. function pullupmsg(mp:Pmblk_t; len:longint):longint;cdecl;external 'streams' name 'pullupmsg';
  989. function putbq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'putbq';
  990. function putctl(q:Pqueue_t; _type:longint):longint;cdecl;external 'streams' name 'putctl';
  991. function putctl1(q:Pqueue_t; _type:longint; c:longint):longint;cdecl;external 'streams' name 'putctl1';
  992. function putq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'putq';
  993. function qenable(q:Pqueue_t):longint;cdecl;external 'streams' name 'qenable';
  994. function qreply(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'qreply';
  995. function qsize(q:Pqueue_t):longint;cdecl;external 'streams' name 'qsize';
  996. function rmvb(mp:Pmblk_t; bp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'rmvb';
  997. function rmvq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'rmvq';
  998. function strlog(sid:smallint; mid:smallint; level:char; aflags:smallint; args:array of const):longint;cdecl;external 'streams' name 'strlog';
  999. function strlog(sid:smallint; mid:smallint; level:char; aflags:smallint):longint;cdecl;external 'streams' name 'strlog';
  1000. function testb(size:longint; pri:longint):longint;cdecl;external 'streams' name 'testb';
  1001. function timeout(func:TFuncLongCdecl; arg:pointer; ticks:longint):longint;cdecl;external 'streams' name 'timeout';
  1002. function unlinkb(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'unlinkb';
  1003. function unbufcall(id:longint):longint;cdecl;external 'streams' name 'unbufcall';
  1004. {-tispxipx.h-------------------------------------------------------------------}
  1005. type
  1006. Pipxaddr_s = ^Tipxaddr_s;
  1007. Tipxaddr_s = record
  1008. ipxa_net : array[0..3] of byte;
  1009. ipxa_node : array[0..5] of byte;
  1010. ipxa_socket : array[0..1] of byte;
  1011. end;
  1012. TIPX_ADDR = Tipxaddr_s;
  1013. PIPX_ADDR = ^TIPX_ADDR;
  1014. Pipxopt_s = ^Tipxopt_s;
  1015. Tipxopt_s = record
  1016. ipx_type : byte;
  1017. ipx_pad1 : array[0..2] of byte;
  1018. ipx_hops : byte;
  1019. ipx_pad2 : array[0..2] of byte;
  1020. end;
  1021. TIPX_OPTS = Tipxopt_s;
  1022. PIPX_OPTS = ^TIPX_OPTS;
  1023. Pspxopt_s = ^Tspxopt_s;
  1024. Tspxopt_s = record
  1025. spx_connectionID : array[0..1] of byte;
  1026. spx_allocationNumber : array[0..1] of byte;
  1027. spx_pad1 : array[0..3] of byte;
  1028. end;
  1029. TSPX_OPTS = Tspxopt_s;
  1030. PSPX_OPTS = ^TSPX_OPTS;
  1031. Pspx_optmgmt = ^Tspx_optmgmt;
  1032. Tspx_optmgmt = record
  1033. spxo_retry_count : byte;
  1034. spxo_watchdog_flag : byte;
  1035. spxo_min_retry_delay : dword;
  1036. spxo_pad2 : array[0..1] of byte;
  1037. end;
  1038. const
  1039. OPTIONS_VERSION = 1;
  1040. function OPTIONS_SIZE : longint;
  1041. type
  1042. Pspx2_options = ^Tspx2_options;
  1043. Tspx2_options = record
  1044. versionNumber : dword;
  1045. spxIIOptionNegotiate : dword;
  1046. spxIIRetryCount : dword;
  1047. spxIIMinimumRetryDelay : dword;
  1048. spxIIMaximumRetryDelta : dword;
  1049. spxIIWatchdogTimeout : dword;
  1050. spxIIConnectTimeout : dword;
  1051. spxIILocalWindowSize : dword;
  1052. spxIIRemoteWindowSize : dword;
  1053. spxIIConnectionID : dword;
  1054. spxIIInboundPacketSize : dword;
  1055. spxIIOutboundPacketSize: dword;
  1056. spxIISessionFlags : dword;
  1057. end;
  1058. const
  1059. SPX_WATCHDOG_OFF = 0;
  1060. SPX_WATCHDOG_ON = not (SPX_WATCHDOG_OFF);
  1061. SPX_WATCHDOG_DEFAULT = SPX_WATCHDOG_ON;
  1062. SPX_RETRY_MIN = 3;
  1063. SPX_RETRY_MAX = 50;
  1064. SPX_RETRY_DEFAULT = 10;
  1065. SPX_WATCHDOG_TIMEOUT_MIN = 3000;
  1066. SPX_WATCHDOG_TIMEOUT_MAX = 300000;
  1067. SPX_WATCHDOG_TIMEOUT_DEFAULT = 60000;
  1068. SPX_MIN_RETRY_DELAY_MIN = 1;
  1069. SPX_MIN_RETRY_DELAY_MAX = 60000;
  1070. SPX_MIN_RETRY_DELAY_DEFAULT = 0;
  1071. SPX_MAX_RETRY_DELTA_MIN = 1000;
  1072. SPX_MAX_RETRY_DELTA_MAX = 60000;
  1073. SPX_MAX_RETRY_DELTA_DEFAULT = 5000;
  1074. SPX_OPTION_NEGOTIATE_OFF = 0;
  1075. SPX_OPTION_NEGOTIATE_ON = not (SPX_OPTION_NEGOTIATE_OFF);
  1076. SPX_OPTION_NEGOTIATE_DEFAULT = SPX_OPTION_NEGOTIATE_ON;
  1077. SPX_CONNECT_TIMEOUT_MIN = 1000;
  1078. SPX_CONNECT_TIMEOUT_MAX = 120000;
  1079. SPX_CONNECT_TIMEOUT_DEFAULT = 0;
  1080. SPX_LOCAL_WINDOW_SIZE_MIN = 1;
  1081. SPX_LOCAL_WINDOW_SIZE_MAX = 8;
  1082. SPX_LOCAL_WINDOW_SIZE_DEFAULT = 0;
  1083. SPX2_SF_NONE = $00;
  1084. SPX2_SF_IPX_CHECKSUM = $01;
  1085. SPX2_SF_SPX2_SESSION = $02;
  1086. TLI_SPX_CONNECTION_FAILED = $ed;
  1087. TLI_SPX_CONNECTION_TERMINATED = $ec;
  1088. TLI_SPX_MALFORMED_PACKET = $fe;
  1089. TLI_SPX_PACKET_OVERFLOW = $fd;
  1090. TLI_SPX_UNREACHABLE_DEST = $70;
  1091. TLI_IPX_MALFORMED_ADDRESS = $fe;
  1092. TLI_IPX_PACKET_OVERFLOW = $fd;
  1093. {-in.pp------------------------------------------------------------------------}
  1094. const
  1095. IPPROTO_IP = 0;
  1096. IPPROTO_ICMP = 1;
  1097. IPPROTO_IGMP = 2;
  1098. IPPROTO_GGP = 3;
  1099. IPPROTO_TCP = 6;
  1100. IPPROTO_EGP = 8;
  1101. IPPROTO_PUP = 12;
  1102. IPPROTO_UDP = 17;
  1103. IPPROTO_IDP = 22;
  1104. IPPROTO_ND = 77;
  1105. IPPROTO_RAW = 255;
  1106. IPPROTO_MAX = 256;
  1107. // Port/socket numbers: network standard functions
  1108. IPPORT_ECHO = 7;
  1109. IPPORT_DISCARD = 9;
  1110. IPPORT_SYSTAT = 11;
  1111. IPPORT_DAYTIME = 13;
  1112. IPPORT_NETSTAT = 15;
  1113. IPPORT_FTP = 21;
  1114. IPPORT_TELNET = 23;
  1115. IPPORT_SMTP = 25;
  1116. IPPORT_TIMESERVER = 37;
  1117. IPPORT_NAMESERVER = 42;
  1118. IPPORT_WHOIS = 43;
  1119. IPPORT_MTP = 57;
  1120. // Port/socket numbers: host specific functions
  1121. IPPORT_TFTP = 69;
  1122. IPPORT_RJE = 77;
  1123. IPPORT_FINGER = 79;
  1124. IPPORT_TTYLINK = 87;
  1125. IPPORT_SUPDUP = 95;
  1126. // UNIX TCP sockets
  1127. IPPORT_EXECSERVER = 512;
  1128. IPPORT_LOGINSERVER = 513;
  1129. IPPORT_CMDSERVER = 514;
  1130. IPPORT_EFSSERVER = 520;
  1131. // UNIX UDP sockets
  1132. IPPORT_BIFFUDP = 512;
  1133. IPPORT_WHOSERVER = 513;
  1134. { 520+1 also used }
  1135. IPPORT_ROUTESERVER = 520;
  1136. IPPORT_RESERVED = 1024;
  1137. IPPORT_USERRESERVED = 5000;
  1138. type
  1139. Pin_addr = ^Tin_addr;
  1140. Tin_addr = record
  1141. s_addr : dword;
  1142. end;
  1143. const
  1144. IN_CLASSA_NET = $ff000000;
  1145. IN_CLASSA_NSHIFT = 24;
  1146. IN_CLASSA_HOST = $00ffffff;
  1147. IN_CLASSA_MAX = 128;
  1148. IN_CLASSB_NET = $ffff0000;
  1149. IN_CLASSB_NSHIFT = 16;
  1150. IN_CLASSB_HOST = $0000ffff;
  1151. IN_CLASSB_MAX = 65536;
  1152. IN_CLASSC_NET = $ffffff00;
  1153. IN_CLASSC_NSHIFT = 8;
  1154. IN_CLASSC_HOST = $000000ff;
  1155. IN_LOOPBACKNET = 127;
  1156. // var sin_port : word;cvar;public;
  1157. // sin_zero : array[0..7] of char;cvar;public;
  1158. const
  1159. IP_OPTIONS = 1;
  1160. function ntohs(value:word):word;cdecl;external {'tcpip'} name 'ntohs';
  1161. function htons(value:word):word;cdecl;external {'tcpip'} name 'htons';
  1162. function ntohl(value:dword):dword;cdecl;external {'tcpip'} name 'ntohl';
  1163. function htonl(value:dword):dword;cdecl;external {'tcpip'} name 'htonl';
  1164. {------------------------------------------------------------------------------}
  1165. implementation
  1166. function t_error : longint;
  1167. begin
  1168. t_error := __get_t_errno_ptr^;
  1169. end;
  1170. function OPTIONS_SIZE : longint;
  1171. begin
  1172. OPTIONS_SIZE:=13 * (sizeof(longint));
  1173. end;
  1174. end.