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