summaryrefslogtreecommitdiff
path: root/fpcsrc/rtl/netware/nwprot.pp
blob: 6d27d6ad3cb04e49a6708e96afe1cf8ac34592fb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
{
  Netware Server Imports for FreePascal, contains definitions for the
  netware server protocol library

  Initial Version 2003/02/23 Armin (diehl@nordrhein.de or armin@freepascal.org)

  The C-NDK and Documentation can be found here:
    http://developer.novell.com

  This program is distributed in the hope that it will be useful,but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.

  Do not blame Novell if there are errors in this file, instead
  contact me and i will se what i can do.

  This module is untested, for the socket functions please use winsock
}

unit nwprot;

interface

{$mode objfpc}
{$packrecords C}

const
   O_RDONLY   = $0000;
   O_WRONLY   = $0001;
   O_RDWR     = $0002;
   O_ACCMODE  = $0003;
   O_APPEND   = $0010;
   O_CREAT    = $0020;
   O_TRUNC    = $0040;
   O_EXCL     = $0080;
   O_TEXT     = $0100;
   O_BINARY   = $0200;
   O_NDELAY   = $0400;
   O_NOCTTY   = $0800;
   O_NONBLOCK = O_NDELAY;


{-ip_route.h-------------------------------------------------------------------}
// dont know where the symbols came from, may be TCPIP.NLM, for now we
// define 'clib'

{ total size of an IP address in bytes  }

const
   IP_ADDR_SZ = 4;


type
   Pip_addr = ^Tip_addr;
   Tip_addr = record
     case longint of
       0 : ( ip_array : array[0..(IP_ADDR_SZ)-1] of byte );
       1 : ( ip_short : array[0..(IP_ADDR_SZ DIV 2)-1] of word );
       2 : ( ip_long  : dword );
     end;

const
   SNPA_MX = 10;   // maximum address mapping size is that largest we currently use

// Simple IP interface information block --
type
   Pip_if_info = ^Tip_if_info;
   Tip_if_info = record
     ifi_local_addr : Tip_addr;    // interface's IP address
     ifi_net_mask   : Tip_addr;    // Netmask
     ifi_broadcast  : Tip_addr;    // Broadcast
   end;

// Extended IP interface information block
   Pip_extended_if_info = ^Tip_extended_if_info;
   Tip_extended_if_info = record
     iex_signature    : dword;    // API signature
     iex_version      : dword;    // API version
     iex_length       : dword;    // bufsize
     iex_flags        : dword;
     iex_if_id        : dword;    // Interface-ID
     iex_timestamp    : dword;    // creation time
     iex_local_addr   : Tip_addr; // IP Address
     iex_net_mask     : Tip_addr; // Netmask
     iex_broadcast    : Tip_addr; // Broadcast Address
     iex_packet_mx    : dword;    // max out packet size
     iex_packet_opt   : dword;    // optimum packet size
     iex_reasm_mx     : dword;    // maximum reassembled packet
     iex_net_type     : longint;  // Network type
     iex_board_num    : dword;    // ODLI voardnumber
     iex_our_snpa     : array[0..(SNPA_MX)-1] of byte;  // SNPA for interface
   end;

function IPExtendedIFInfo(info_pt:Pip_extended_if_info):longint;cdecl;external 'clib' name 'IPExtendedIFInfo';
function IPExtendedIFInfo(var info_t:Tip_extended_if_info):longint;cdecl;external 'clib' name 'IPExtendedIFInfo';
function IPGetIFInfo(if_info_pt:Pip_if_info):longint;cdecl;external 'clib' name 'IPGetIFInfo';
function IPGetIFInfo(var if_info_t:Tip_if_info):longint;cdecl;external 'clib' name 'IPGetIFInfo';
function IPGetLocalAddr(last_addr:dword):dword;cdecl;external 'clib' name 'IPGetLocalAddr';function IPGetLocalAddrIncludingAux(last_addr:dword):dword;cdecl;external 'clib' name 'IPGetLocalAddrIncludingAux';

{-netdb.h----------------------------------------------------------------------}

// Macros mapping the standard 4.3BSD names are not implemented in pascal

{
   $Abstract:
   Standard definitions for accessing the socket interface's network
   database in Novell's NetWare 386 TCP/IP.  Since process context is
   limited in NetWare 386, we need to play some games to provide context
   to the database.
   $

   $Implementation Notes:
   The actual NetWare 386 TCP/IP routines take an additional parameter
   to provide them a block for maintaining context.  The normal routines
   are actually macros which call the context aware routines.

   One modification is required for porting an NLM the NetWare 386
   versions of the database routines: a context block must be defined.
   This is done by using the macro NETDB_DEFINE_CONTEXT in any one
   module linked into the NLM.

   If the preprocessor symbol NOT_NETWARE_386 is defined, this becomes
   the standard netdb.h from 4.3BSD for use in more typical environments.
   $

   The HOSTS database macros (i.e. gethostxxx) have the capability to
   evaluate either to the routines that access just the local /etc/hosts
   file (i.e. NWgethostxxx), or else the routines that automatically access
   a combination of local file, DNS, and NIS (i.e. NetDBgethostxxx).  The
   former case is the way previous SDK usage of the macro was implemented.
   The latter case is a newer option that utilizes network name services
   transparent to the NLM, but it requires NETDB.NLM (which is also provided
   in this SDK).  NETDB.NLM is an extension to TCP/IP and may be freely
   distributed with your product.

   The developer may choose which routines to use by directly calling the
   routines desired (either NWgethostxxx or NetDBgethostxxx).  If the macros
   are used, then the macros will call the local-file-only versions of the
   calls (i.e. NWgethostxxx) unless the symbol NETDB_USE_INTERNET is
   defined below.  If you wish to use the internet name services such as
   NIS or DNS in addition to the local hosts file for host access, then this
   symbol must be defined (either here or in your source file).
  }
{$define NETDB_USE_INTERNET}

const
   HOST_NOT_FOUND = 1;
   TRY_AGAIN      = 2;
   NO_RECOVERY    = 3;
   NO_ADDRESS     = 4;

{  Structures returned by network
   data base library.  All addresses
   are supplied in host order, and
   returned in network order (suitable
   for use in system calls). }

{  define  h_addr   h_addr_list[0] /* address, for backward compatiblity */ }
type
   Phostent = ^Thostent;
   Thostent = record
     h_name      : Pchar;    // official name of host
     h_aliases   : ^Pchar;   // alias list
     h_addrtype  : longint;
     h_length    : longint;  // length of address
     h_addr_list : ^Pchar;   // list of addresses from name server
   end;

// Assumption here is that a network number fits in 32 bits -- probably a poor one.
   Pnetent = ^Tnetent;
   Tnetent = record
     n_name     : Pchar;    // official name of net
     n_aliases  : ^Pchar;   // alias list
     n_addrtype : longint;
     n_net      : dword;
     n_mask     : dword;    // Netmask, Novell extension
   end;

   Pservent = ^Tservent;
   Tservent = record
     s_name    : Pchar;        // official service name
     s_aliases : ^Pchar;       // alias list
     s_port    : longint;      // portnumber
     s_proto   : Pchar;        // protocol to use
   end;

   Pprotoent = ^Tprotoent;
   Tprotoent = record
     p_name    : Pchar;     // official protocol name
     p_aliases : ^Pchar;
     p_proto   : longint;
   end;

// var h_errno : longint;cvar;external;

    const
       SCRATCHBUFSIZE = 1024;
       MAXALIASES = 10;
       MAXALIASSIZE = 64;
       MAXNAMESIZE = 64;
       MAXADDRSIZE = 19;
       MAXHOSTADDR = 1;

    { Special Novell structure for providing context in the otherwise
      context-free NetWare 386 environment. The applications SHOULD NOT
      access this structure ! }
    type
       Pnwsockent = ^Tnwsockent;
       Tnwsockent = record
            nse_hostctx  : pointer;  // PFILE;
            nse_netctx   : pointer;  // PFILE;
            nse_protoctx : pointer;  // PFILE;
            nse_servctx  : pointer;  // PFILE;
            nse_h_errno  : longint;
            nse_sockent_un : record
                case longint of
                   0 : ( nsu_hst   : Thostent );
                   1 : ( nsu_net   : Tnetent );
                   2 : ( nsu_proto : Tprotoent );
                   3 : ( nsu_serv  : Tservent );
                end;
            nse_scratch : array[0..(SCRATCHBUFSIZE)-1] of char;
         end;
    { Declare the context block.  The client must supply the actual
      block by placing NETDB_DEFINE_CONTEXT in one of the C modules
      in the link. }
//      var nwSocketCtx : longint;cvar;external;

    { ------------------------------------------------------------------------
                            Host file examination
       ------------------------------------------------------------------------  }
{ Local-file-only routines  }

function NWgethostbyname(nwsktctx:Pnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyname';
function NWgethostbyname(var nwsktctx:Tnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyname';

function NWgethostbyaddr(nwsktctx:Pnwsockent; addr:Pchar; length:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyaddr';
function NWgethostbyaddr(var nwsktctx:Tnwsockent; addr:Pchar; length:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NWgethostbyaddr';

function NWgethostent(nwsktctx:Pnwsockent):Phostent;cdecl;external {'tcpip'} name 'NWgethostent';
function NWgethostent(var nwsktctx:Tnwsockent):Phostent;cdecl;external {'tcpip'} name 'NWgethostent';

procedure NWsethostent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsethostent';
procedure NWsethostent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsethostent';

procedure NWendhostent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendhostent';
procedure NWendhostent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendhostent';
    { Internet Name Service routines  }
    {
       NetDBgethostbyname() -- returns the host entry (struct hostent  ) given
        the name of a host.

        The local file sys:/etc/hosts is consulted first to see if the entry
        exists there.  If so, then that is returned.  If not, then if DNS is
        installed on the machine, it will be consulted to perform the lookup.
        If the host still is not found, then NIS will be consulted if at all
        possible.

        This function returns NULL when an error occurs.  The integer
        nwsktent->nse_h_errno can be checked to determine the nature of the
        error.

        The integer nwsktent->nse_h_errno can have the following values:

          HOST_NOT_FOUND       No such host exists.

        If the NetDBgethostbyname function succeeds, it will return a pointer
        to a structure of type struct hostent.

        Syntax:
          struct hostent   NetDBgethostbyname(struct nwsockent  nwsktent,
                                              char  name);

             nwskent: Points to a context block.

             name:    Official name of the host.

        Returns:
          A pointer to the appropriate struct hostent if any that matches.
          NULL if no match found.
                                                                              }
function NetDBgethostbyname(nwskent:Pnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyname';
function NetDBgethostbyname(var nwskent:Tnwsockent; name:Pchar):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyname';
    {
       NetDBgethostbyaddr() -- returns the host entry (struct hostent  ) given
        the address of a host.

        The local file sys:/etc/hosts is consulted first to see if the entry
        exists there.  If so, then that is returned.  If not, then if DNS is
        installed on the machine, it will be consulted to perform the lookup.
        If the host still is not found, then NIS will be consulted if at all
        possible.

        This function returns NULL when an error occurs.  The integer
        nwsktent->nse_h_errno can be checked to determine the nature of the
        error.

        The integer nwsktent->nse_h_errno can have the following values:

          HOST_NOT_FOUND       No such host exists.

        If the NetDBgethostbyaddr function succeeds, it will return a pointer
        to a structure of type struct hostent.

        Syntax:
          struct hostent   NetDBgethostbyaddr(struct nwsockent  nwskent,
                                              char  addr, int len, int type);

             nwsktent: (Input) Points to a context block.

             addr:     (Input) Internet address of the host.

             len:      (Input) Length of the Internet address, in bytes.

             type:     (Input) Value corresponding to the type of Internet
                       address.  Currently, the type is always AF_INET.

        Returns:
          A pointer to the appropriate struct hostent if any that matches.
          NULL if no match found.
                                                                              }
function NetDBgethostbyaddr(nwsktent:Pnwsockent; addr:Pchar; len:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyaddr';
function NetDBgethostbyaddr(var nwsktent:Tnwsockent; addr:Pchar; len:longint; _type:longint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostbyaddr';
    {
       NetDBgethostent() -- returns the next sequential entry from the
        SYS:ETC/HOSTS file, opening the file it it is not already open.  Once
        the local file is depleted, all of the NIS host entries will be
        retrieved until those are depleted.

        Note that there may be duplicate entries in the local and NIS databases.
        The caller should handle these appropriately.

        This function returns NULL when an error occurs.  The integer
        nwsktent->nse_h_errno can be checked to determine the nature of the
        error.

        The integer nwsktent->nse_h_errno can have the following values:

          HOST_NOT_FOUND       No more hosts exist in either SYS:ETC/HOSTS or
                               NIS.

        Syntax:
          struct hostent   NetDBgethostent(struct nwsockent  nwsktent,
                                           short   ploc);

          nwsktent:  (Input) Points to a context block.

          ploc:      (Output) If non-NULL, this short will indicate if this
                     entry is from the local sys:etc/hosts file (NETDB_LOC_LOCAL)
                     or from the NIS database (NETDB_LOC_NIS).

                     Pass in NULL if you're not interested in this information.

        Returns:
          A pointer to the next host entry if the function is successful.
          NULL if no more entries or an error occurred.
                                                                              }
function NetDBgethostent(nwsktent:Pnwsockent; ploc:Psmallint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostent';
function NetDBgethostent(var nwsktent:Tnwsockent; ploc:Psmallint):Phostent;cdecl;external {'tcpip'} name 'NetDBgethostent';
    {
       NetDBsethostent() -- rewinds the SYS:ETC/HOSTS file if the file is
        already open.  This call guarantees that the next call to
        NetDBgethostent() will return the FIRST record in the local hosts file,
        regardless of whether the LAST call returned an entry from the local
        file or from NIS.

        If the stayopen flag is set (nonzero), the SYS:ETC/HOSTS file is NOT
        closed after each call made to NetDBgethostbyname() or
        NetDBgethostbyaddr().

        Syntax:
          void NetDBsethostent(struct nwsockent  nwsktent, int stayopen);

          nwsktent:  (Input) Points to a context block.

          stayopen:  (Input) If nonzero, causes SYS:ETC/HOSTS to remain open
                     after a call to NetDBgethostbyname() or
                     NetDBgethostbyaddr().

        Returns:
          Nothing.
                                                                              }
procedure NetDBsethostent(nwsktent:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NetDBsethostent';
procedure NetDBsethostent(var nwsktent:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NetDBsethostent';
    {
       NetDBendhostent() -- closes the SYS:ETC/HOSTS file.  Also ends access
        to the NIS database.  After this call, the next call to
        NetDBgethostent() will be from the beginning of the local file again.

        Syntax:
          void NetDBendhostent(struct nwsockent  nwsktent);

          nwsktent:  (Input) Points to a context block.

        Returns:
          Nothing.
                                                                              }
procedure NetDBendhostent(nwsktent:Pnwsockent);cdecl;external {'tcpip'} name 'NetDBendhostent';
procedure NetDBendhostent(var nwsktent:Tnwsockent);cdecl;external {'tcpip'} name 'NetDBendhostent';
    {
       NetDBgethostname() -- this gets the current machine's host name into the
        passed in buffer (if it is large enough).

        This will use the local hosts file if it exists, otherwise it will then
        try both DNS and NIS if available in order to get the official name of
        our own machine.

        Syntax:
          int NetDBgethostname(struct nwsockent  nwsktent, char  name,
                                                                int namelen);

          nwsktent: (Input)  Points to a context block.

          name:     (Output) Official name of the host.

          namelen:  (Input)  Specifies the size of the array pointed to by name.

        Returns:
           0: The call succeeded.
          -1: The call failed.
                                                                              }
function NetDBgethostname(nwsktent:Pnwsockent; name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'NetDBgethostname';
function NetDBgethostname(var nwsktent:Tnwsockent; name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'NetDBgethostname';

// Network file examination
function NWgetnetbyname(nwsktctx:Pnwsockent; name:Pchar):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyname';
function NWgetnetbyname(var nwsktctx:Tnwsockent; name:Pchar):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyname';

function NWgetnetbyaddr(nwsktctx:Pnwsockent; net:longint; _type:longint):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyaddr';
function NWgetnetbyaddr(var nwsktctx:Tnwsockent; net:longint; _type:longint):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetbyaddr';

function NWgetnetent(nwsktctx:Pnwsockent):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetent';
function NWgetnetent(var nwsktctx:Tnwsockent):Pnetent;cdecl;external {'tcpip'} name 'NWgetnetent';

procedure NWsetnetent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetnetent';
procedure NWsetnetent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetnetent';

procedure NWendnetent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendnetent';
procedure NWendnetent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendnetent';

// Service file examination
function NWgetservbyname(nwsktctx:Pnwsockent; name:Pchar; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyname';
function NWgetservbyname(var nwsktctx:Tnwsockent; name:Pchar; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyname';

function NWgetservbyport(nwsktctx:Pnwsockent; port:longint; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyport';
function NWgetservbyport(var nwsktctx:Tnwsockent; port:longint; protocol:Pchar):Pservent;cdecl;external {'tcpip'} name 'NWgetservbyport';

function NWgetservent(nwsktctx:Pnwsockent):Pservent;cdecl;external {'tcpip'} name 'NWgetservent';
function NWgetservent(var nwsktctx:Tnwsockent):Pservent;cdecl;external {'tcpip'} name 'NWgetservent';

procedure NWsetservent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetservent';
procedure NWsetservent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetservent';

procedure NWendservent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendservent';
procedure NWendservent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendservent';

// Protocol file examination
function NWgetprotobyname(nwsktctx:Pnwsockent; name:Pchar):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobyname';
function NWgetprotobyname(var nwsktctx:Tnwsockent; name:Pchar):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobyname';

function NWgetprotobynumber(nwsktctx:Pnwsockent; protocol:longint):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobynumber';
function NWgetprotobynumber(var nwsktctx:Tnwsockent; protocol:longint):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotobynumber';

function NWgetprotoent(nwsktctx:Pnwsockent):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotoent';
function NWgetprotoent(var nwsktctx:Tnwsockent):Pprotoent;cdecl;external {'tcpip'} name 'NWgetprotoent';

procedure NWsetprotoent(nwsktctx:Pnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetprotoent';
procedure NWsetprotoent(var nwsktctx:Tnwsockent; stayopen:longint);cdecl;external {'tcpip'} name 'NWsetprotoent';

procedure NWendprotoent(nwsktctx:Pnwsockent);cdecl;external {'tcpip'} name 'NWendprotoent';
procedure NWendprotoent(var nwsktctx:Tnwsockent);cdecl;external {'tcpip'} name 'NWendprotoent';

function gethostname(name:Pchar; namelen:longint):longint;cdecl;external {'tcpip'} name 'gethostname';
function gethostid:longint;cdecl;external {'tcpip'} name 'gethostid';
{-tiuser.h---------------------------------------------------------------------}
const
   EAGAIN = -(1);
{ Error values  }
   TACCES = 1;
   TBADADDR = 2;
   TBADDATA = 3;
   TBADF = 4;
   TBADFLAG = 5;
   TBADOPT = 6;
   TBADSEQ = 7;
   TBUFOVFLW = 8;
   TFLOW = 9;
   TLOOK = 10;
   TNOADDR = 11;
   TNODATA = 12;
   TNOREL = 13;
   TNOTSUPPORT = 14;
   TOUTSTATE = 15;
   TSTATECHNG = 16;
   TSYSERR = 17;
   TNOUDERR = 18;
   TNODIS = 19;
   TNOSTRUCTYPE = 20;
   TBADNAME = 21;
   TBADQLEN = 22;
   TADDRBUSY = 23;
{ t_look events  }
   _T_LISTEN = 1;
   _T_CONNECT = 2;
   _T_DATA = 3;
   _T_EXDATA = 4;
   _T_DISCONNECT = 5;
   _T_ORDREL = 6;
   _T_ERROR = 7;
   _T_UDERR = 8;
   _T_GODATA = 9;
   _T_GOEXDATA = 10;
   _T_EVENTS = 11;
{ Flag definitions  }
   _T_EXPEDITED = $01;
   _T_MORE = $02;
   _T_NEGOTIATE = $04;
   _T_CHECK = $08;
   _T_DEFAULT = $10;
   _T_SUCCESS = $20;
   _T_FAILURE = $40;

var t_errno : longint;cvar;external;

    type
       Pt_info = ^Tt_info;
       Tt_info = record
         addr     : longint;
         options  : longint;
         tsdu     : longint;
         etsdu    : longint;
         connect  : longint;
         discon   : longint;
         servtype : longint;
       end;

    { Service types  }
    { Connection-mode service  }

    const
       T_COTS = 1;
    { Connection service with orderly release  }
       T_COTS_ORD = 2;
    { Connectionless-mode service  }
       T_CLTS = 3;
    type
       Pnetbuf = ^Tnetbuf;
       Tnetbuf = record
         maxlen : dword;
         len    : dword;
         buf    : Pchar;
       end;

       Pt_bind = ^Tt_bind;
       Tt_bind = record
         addr : Tnetbuf;
         qlen : dword;
       end;

       Pt_optmgmt = ^Tt_optmgmt;
       Tt_optmgmt = record
         opt   : Tnetbuf;
         flags : longint;
       end;

       Pt_discon = ^Tt_discon;
       Tt_discon = record
         udata    : Tnetbuf;
         reason   : longint;
         sequence : longint;
       end;

       Pt_call = ^Tt_call;
       Tt_call = record
         addr     : Tnetbuf;
         opt      : Tnetbuf;
         udata    : Tnetbuf;
         sequence : longint;
       end;

       Pt_unitdata = ^Tt_unitdata;
       Tt_unitdata = record
         addr  : Tnetbuf;
         opt   : Tnetbuf;
         udata : Tnetbuf;
       end;

       Pt_uderr = ^Tt_uderr;
       Tt_uderr = record
         addr  : Tnetbuf;
         opt   : Tnetbuf;
         error : longint;
       end;

    // t_alloc structure types, had to prefix with _ because some
    // names conflict with functions

    const
       _T_BIND = $1;
       _T_CALL = $2;
       _T_OPTMGMT = $4;
       _T_DIS = $8;
       _T_UNITDATA = $10;
       _T_UDERROR = $20;
       _T_INFO = $40;
    { XTI names for t_alloc structure types  }
       _T_BIND_STR = _T_BIND;
       _T_OPTMGMT_STR = _T_OPTMGMT;
       _T_CALL_STR = _T_CALL;
       _T_DIS_STR = _T_DIS;
       _T_UNITDATA_STR = _T_UNITDATA;
       _T_UDERROR_STR = _T_UDERROR;
       _T_INFO_STR = _T_INFO;
    { t_alloc field identifiers  }
       _T_ADDR = $1000;
       _T_OPT = $2000;
       _T_UDATA = $4000;
       _T_ALL = $8000;
    { State values  }
    { added to match xti state tables  }
       _T_UNINIT = 0;
    { unbound  }
       _T_UNBND = 1;
    { idle  }
       _T_IDLE = 2;
    { outgoing connection pending  }
       _T_OUTCON = 3;
    { incoming connection pending  }
       _T_INCON = 4;
    { data transfer  }
       _T_DATAXFER = 5;
    { outgoing orderly release  }
       _T_OUTREL = 6;
    { incoming orderly release  }
       _T_INREL = 7;
    { general purpose defines  }
       _T_YES = 1;
       _T_NO = 0;
       _T_UNUSED = -(1);
       _T_NULL = 0;
       _T_ABSREQ = $8000;
      var
         t_errlist : array of Pchar;cvar;external;
         t_nerr : longint;cvar;external;
    {---------------------TCP specific Options-------------------------- }
    { TCP Precedence Levels  }

    const
       _T_ROUTINE = 0;
       _T_PRIORITY = 1;
       _T_IMMEDIATE = 2;
       _T_FLASH = 3;
       _T_OVERRIDEFLASH = 4;
       _T_CRITIC_ECP = 5;
       _T_INETCONTROL = 6;
       _T_NETCONTROL = 7;

    type
       Psecoptions = ^Tsecoptions;
       Tsecoptions = record
         security    : smallint;
         compartment : smallint;
         handling    : smallint;
         tcc         : longint;
       end;

       Ptcp_options = ^Ttcp_options;
       Ttcp_options = record
         precedence   : smallint;      // TCP options
         timeout      : longint;       // abort timeout
         max_seg_size : longint;
         secopt       : Tsecoptions;   // security options
       end;


function t_accept(fd:longint; resfd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_accept';
function t_alloc(fd:longint; struct_type:longint; fields:longint):Pchar;cdecl;external 'tli' name 't_alloc';
function t_bind(fd:longint; req:Pt_bind; ret:Pt_bind):longint;cdecl;external 'tli' name 't_bind';
function t_blocking(fd:longint):longint;cdecl;external 'tli' name 't_blocking';
function t_close(fd:longint):longint;cdecl;external 'tli' name 't_close';
function t_connect(fd:longint; sndcall:Pt_call; rcvcall:Pt_call):longint;cdecl;external 'tli' name 't_connect';
procedure t_error(errmsg:Pchar);cdecl;external 'tli' name 't_error';
function t_free(ptr:Pchar; struct_type:longint):longint;cdecl;external 'tli' name 't_free';
function t_getinfo(fd:longint; info:Pt_info):longint;cdecl;external 'tli' name 't_getinfo';
function t_getstate(fd:longint):longint;cdecl;external 'tli' name 't_getstate';
function t_listen(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_listen';
function t_look(fd:longint):longint;cdecl;external 'tli' name 't_look';
function t_nonblocking(fd:longint):longint;cdecl;external 'tli' name 't_nonblocking';
function t_open(path:Pchar; oflag:longint; info:Pt_info):longint;cdecl;external 'tli' name 't_open';
function t_optmgmt(fd:longint; req:Pt_optmgmt; ret:Pt_optmgmt):longint;cdecl;external 'tli' name 't_optmgmt';
function t_rcv(fd:longint; buf:Pchar; nbytes:dword; flags:Plongint):longint;cdecl;external 'tli' name 't_rcv';
function t_rcvconnect(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_rcvconnect';
function t_rcvdis(fd:longint; discon:Pt_discon):longint;cdecl;external 'tli' name 't_rcvdis';
function t_rcvrel(fd:longint):longint;cdecl;external 'tli' name 't_rcvrel';
function t_rcvudata(fd:longint; unitdata:Pt_unitdata; flags:Plongint):longint;cdecl;external 'tli' name 't_rcvudata';
function t_rcvuderr(fd:longint; uderr:Pt_uderr):longint;cdecl;external 'tli' name 't_rcvuderr';
function t_snd(fd:longint; buf:Pchar; nbytes:dword; flags:longint):longint;cdecl;external 'tli' name 't_snd';
function t_snddis(fd:longint; call:Pt_call):longint;cdecl;external 'tli' name 't_snddis';
function t_sndrel(fd:longint):longint;cdecl;external 'tli' name 't_sndrel';
function t_sndudata(fd:longint; unitdata:Pt_unitdata):longint;cdecl;external 'tli' name 't_sndudata';
function t_sync(fd:longint):longint;cdecl;external 'tli' name 't_sync';
function t_unbind(fd:longint):longint;cdecl;external 'tli' name 't_unbind';

// havent found the declaration for __get_t_errno_ptr, hope that is correct:
function __get_t_errno_ptr:plongint; cdecl;external 'clib' name '__get_t_errno_ptr';

function t_error : longint;

{-ositli.h---------------------------------------------------------------------}
const
   TPDR_NORMAL = 128 + 0;
   TPDR_CRCONG = 128 + 1;
   TPDR_CONNEG = 128 + 2;
   TPDR_DUPSR = 128 + 3;
   TPDR_MMREF = 128 + 4;
   TPDR_PE = 128 + 5;
   TPDR_REOVFL = 128 + 7;
   TPDR_NWREF = 128 + 8;
   TPDR_INVHD = 128 + 10;
   TPDR_RNS = 0;
   TPDR_CONG = 1;
   TPDR_NOSESS = 2;
   TPDR_UNKADDR = 3;   // Address unknown

// Options management pre-defined values.
   T_YES = 1;
   T_NO = 0;
   T_UNUSED = -(1);
   T_NULL = 0;
   T_ABSREQ = $8000;
   T_PRIDFLT = 4;
   T_PRILOW = 3;
   T_PRIMID = 2;
   T_PRIHIGH = 1;
   T_PRITOP = 0;
   T_NOPROTECT = 1;
   T_PASSIVEPROTECT = 2;
   T_ACTIVEPROTECT = 4;
   T_LTPDUDFLT = 2048;
   T_CLASS0 = 0;
   T_CLASS1 = 1;
   T_CLASS2 = 2;
   T_CLASS3 = 3;
   T_CLASS4 = 4;

 // Options Management structures.
type
   Prate = ^Trate;
   Trate = record
     targetvalue    : longint;   // target value
     minacceptvalue : longint;   // minimum acceptable value
   end;

   Preqvalue = ^Treqvalue;
   Treqvalue = record
     called  : Trate;    // called rate
     calling : Trate;    // calling rate
   end;

   Pthrpt = ^Tthrpt;
   Tthrpt = record
     maxthrpt : Treqvalue;   // maximum throughput
     avgthrpt : Treqvalue;   // average throughput
   end;

   Pmanagement = ^Tmanagement;
   Tmanagement = record
     dflt      : smallint;
     ltpdu     : longint;
     reastime  : smallint;
     _class    : char;
     altclass  : char;
     extform   : char;
     flowctrl  : char;
     checksum  : char;
     netexp    : char;
     netrecptcf: char;
   end;

// Connection oriented options.
   Pisoco_options = ^Tisoco_options;
   Tisoco_options = record
     throughput     : Tthrpt;
     transdel       : Treqvalue;
     reserrorrate   : Trate;
     transffailprob : Trate;
     estfailprob    : Trate;
     relfailprob    : Trate;
     estdelay       : Trate;
     reldelay       : Trate;
     connresil      : Tnetbuf;
     protection     : word;
     priority       : smallint;
     mngmt          : Tmanagement;   // management parameters
     expd           : char;          // expedited data: T_YES or T_NO
   end;

// Connectionless options.
   Pisocl_options = ^Tisocl_options;
   Tisocl_options = record
     transdel     : Trate;     // transit delay
     reserrorrate : Trate;     // residual error rate
     protection   : word;
     priority     : smallint;
   end;

// Novell connectionless options.
   Pnovell_isocl_options = ^Tnovell_isocl_options;
   Tnovell_isocl_options = record
     transdel     : Trate;     // transit delay
     reserrorrate : Trate;     // residual error rate
     protection   : word;
     priority     : smallint;
     checksum     : longint;
   end;
{-param.h----------------------------------------------------------------------}
const
   HZ     = 18;
   NULL   = 0;
   PZERO  = 20;
   PCATCH = $8000;
{-poll.h-----------------------------------------------------------------------}
const
   NPOLLFILE = 65535;
   POLLIN    =  1;
   POLLPRI   =  2;
   POLLOUT   =  4;
   POLLERR   = 10;
   POLLHUP   = 20;
   POLLNVAL  = 40;
{ array of streams to poll  }
{ Internal "fd" for the benefit of the kernel  }
type
   Ppollfd = ^Tpollfd;
   Tpollfd = record
     fd      : longint;
     events  : smallint;
     revents : smallint;
     _ifd    : longint;
   end;

{ I_POLL structure for ioctl on non-5.3 systems  }
   Pstrpoll = ^Tstrpoll;
   Tstrpoll = record
     nfds    : dword;
     pollfdp : Ppollfd;
     timeout : longint;
   end;

function poll(const fds:array of Tpollfd; nfds:dword; timeout:longint):longint;cdecl;external 'clib' name 'poll';
{-proc.h-----------------------------------------------------------------------}
type
   Pproc = ^Tproc;
   Tproc = record
     p_pid  : smallint;
     p_pgrp : smallint;
   end;
{-strlog.h---------------------------------------------------------------------}
const
   SL_FATAL  = $1;
   SL_NOTIFY = $2;
   SL_ERROR  = $4;
   SL_TRACE  = $8;
   I_TRCLOG  = 1;
   I_ERRLOG  = 2;
   LOGMSGSZ  = 128;

type
   Plog_ctl = ^Tlog_ctl;
   Tlog_ctl = record
     mid   : smallint;
     sid   : smallint;
     level : char;
     flags : smallint;
     ltime : longint;
     ttime : longint;
     seq_no: longint;
   end;

   Ptrace_ids = ^Ttrace_ids;
   Ttrace_ids = record
     ti_mid   : smallint;
     ti_sid   : smallint;
     ti_level : char;
     ti_flags : smallint;
   end;
{-strstat.h--------------------------------------------------------------------}
type
   Pmodule_stat = ^Tmodule_stat;
   Tmodule_stat = record
     ms_pcnt : longint;
     ms_scnt : longint;
     ms_ocnt : longint;
     ms_ccnt : longint;
     ms_acnt : longint;
     ms_xptr : Pchar;
     ms_xsize: smallint;
   end;
{-user.h-----------------------------------------------------------------------}
type
   Puser = ^Tuser;
   Tuser = record
     u_error : longint;
     u_uid   : longint;
     u_gid   : longint;
     u_ruid  : longint;
     u_rgid  : longint;
     u_ttyp  : Psmallint;
     u_procp : Pproc;
   end;
{-stream.h---------------------------------------------------------------------}
type
   Pmodule_info = ^Tmodule_info;
   Tmodule_info = record
     mi_idnum  : word;
     mi_idname : Pchar;
     mi_minpsz : smallint;
     mi_maxpsz : smallint;
     mi_hiwat  : smallint;
     mi_lowat  : smallint;
   end;

   Pqinit = ^Tqinit;
   Tqinit = record
     qi_putp   : function :longint;cdecl;
     qi_srvp   : function :longint;
     qi_qopen  : function :longint;
     qi_qclose : function :longint;
     qi_qadmin : function :longint;
     qi_minfo  : Pmodule_info;
     qi_mstat  : Pmodule_stat;
   end;

   Pdatab = ^Tdatab;
   Tdatab = record
     db_freep  : Pdatab;
     db_base   : Pbyte;
     db_lim    : Pbyte;
     db_ref    : byte;
     db_type   : byte;
     db_class  : byte;
     db_pad    : array[0..0] of byte;
   end;

   Tdblk_t = Tdatab;

type
   Pmsgb = ^Tmsgb;
   Tmsgb = record
     b_next  : Pmsgb;   // next message on queue
     b_prev  : Pmsgb;   // previous message on queue
     b_cont  : Pmsgb;   // next message block of message
     b_rptr  : PChar;   // first unread data byte in buffer
     b_wptr  : PChar;   // first unwritten data byte
     b_datap : Pdatab;  // data block
   end;

   Tmblk_t = Tmsgb;
   Pmblk_t = Pmsgb;

   Pq_xtra = pointer;  // dont know where this is defined

   Pqueue = ^Tqueue;
   Tqueue = record
     q_qinfo : Pqinit;
     q_first : Pmsgb;
     q_last  : Pmsgb;
     q_next  : Pqueue;
     q_link  : Pqueue;
     q_ptr   : Pchar;
     q_count : byte;  //ushort;
     q_flag  : byte;  // ushort;
     q_minpsz: smallint;
     q_maxpsz: smallint;
     q_hiwat : byte;  // ushort;
     q_lowat : byte;  // ushort;
     q_osx   : Pq_xtra;
     q_ffcp  : Pqueue;
     q_bfcp  : Pqueue;
   end;

   Tqueue_t = Tqueue;
   Pqueue_t = Pqueue;
{ Q state defines  }

const
   F_Q_IS_WRITE_Q = $1;
   F_Q_DISABLED = $2;
   F_Q_FULL = $4;
   F_Q_TO_SCHEDULE = $8;
   F_Q_PUT_STOPPED = $10;
   F_Q_WELDED = $20;
   F_Q_SEQUENT_SYNCH = $40;
{ Q state defines for 5.4 compatibility  }
   QREADR = $80;
   QFULL = F_Q_FULL;
   QENAB = F_Q_TO_SCHEDULE;
{ Used in M_IOCTL mblks to muxes (ioc_cmd I_LINK)  }
{ lowest level write queue of upper stream  }
{ highest level write queue of lower stream  }
{ system-unique index for lower stream  }
type
   Plinkblk = ^Tlinkblk;
   Tlinkblk = record
     l_qtop  : Pqueue_t;
     l_qbot  : Pqueue_t;
     l_index : longint;
   end;

{ Message types  }

const
   QNORM = 0;
{ Ordinary data  }
   M_DATA = 0;
{ Internal control info and data  }
   M_PROTO = 1;
{ Request a driver to send a break  }
   M_BREAK = 010;
{ Used to pass a file pointer  }
   M_PASSFP = 011;
{ Requests a signal to be sent  }
   M_SIG = 013;
{ Request a real-time delay  }
   M_DELAY = 014;
{ For inter-module communication  }
   M_CTL = 015;
{ Used internally for I_STR requests  }
   M_IOCTL = 016;
{ Alters characteristics of stream head  }
   M_SETOPTS = 020;
{ Priority messages types  }
   QPCTL = 0200;
{ Positive ack of previous M_IOCTL  }
   M_IOCACK = 0201;
{ Previous M_IOCTL failed  }
   M_IOCNAK = 0202;
{ Same as M_PROTO except for priority }
   M_PCPROTO = 0203;
{ Priority signal  }
   M_PCSIG = 0204;
{ Requests modules to flush queues  }
   M_FLUSH = 0206;
{ Request drivers to stop output  }
   M_STOP = 0207;
{ Request drivers to start output  }
   M_START = 0210;
{ Driver can no longer produce data  }
   M_HANGUP = 0211;
{ Reports downstream error condition  }
   M_ERROR = 0212;
{ Reports client read at stream head  }
   M_READ = 0213;
{ PSE-private type; high priority data  }
   M_HPDATA = 0214;
   FLUSHALL = 1;
   FLUSHDATA = 0;

type
   Piocblk = ^Tiocblk;
   Tiocblk = record
     ioc_cmd   : longint;
     ioc_uid   : word;
     ioc_gid   : word;
     ioc_id    : dword;
     ioc_count : dword;
     ioc_error : longint;
     ioc_rval  : longint;
   end;

   Pstrpfp = ^Tstrpfp;
   Tstrpfp = record
     pass_file_cookie : dword;
     pass_uid : word;
     pass_gid : word;
     pass_sth : pointer;
   end;

   Pstroptions = ^Tstroptions;
   Tstroptions = record
     so_flags   : smallint;
     so_readopt : smallint;
     so_wroff   : word;
     so_minpsz  : smallint;
     so_maxpsz  : smallint;
     so_hiwat   : word;
     so_lowat   : word;
   end;

const
   SO_ALL = 0377;
   SO_READOPT = 01;
   SO_WROFF = 02;
   SO_MINPSZ = 04;
   SO_MAXPSZ = 010;
   SO_HIWAT = 020;
   SO_LOWAT = 040;
   SO_MREADON = 0100;
   SO_MREADOFF = 0200;
   BPRI_LO = 1;
   BPRI_MED = 2;
   BPRI_HI = 3;
   INFPSZ = -(1);

const
   MAXMSGSIZE = 4096;
   OPENFAIL = -(1);
   CLONEOPEN = $2;
   MODOPEN = $1;
   NSTREVENT = 40;
   STRMSGSZ = MAXMSGSIZE;
   STRCTLSZ = 1024;
   STRLOFRAC = 80;
   STRMEDFRAC = 90;
   MAXBSIZE = MAXMSGSIZE;

type TFuncLongCdecl = function : longint; cdecl;

function allocb(size:longint; pri:longint):Pmblk_t;cdecl;external 'streams' name 'allocb';
function allocq:Pqueue_t;cdecl;external 'streams' name 'allocq';
function adjmsg(mp:Pmblk_t; len_param:longint):longint;cdecl;external 'streams' name 'adjmsg';
function backq(q:Pqueue_t):Pqueue_t;cdecl;external 'streams' name 'backq';
function bufcall(size:longint; pri:longint; func:TFuncLongCdecl; arg:longint):longint;cdecl;external 'streams' name 'bufcall';
procedure bcopy(src:Pchar; dst:Pchar; len:longint);cdecl;external 'streams' name 'bcopy';
procedure bzero(buffer:Pchar; nbytes:longint);cdecl;external 'streams' name 'bzero';
function canput(q:Pqueue_t):longint;cdecl;external 'streams' name 'canput';
function copyb(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'copyb';
function copymsg(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'copymsg';
function dupb(bp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'dupb';
function dupmsg(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'dupmsg';
function flushq(q:Pqueue_t; flag:longint):longint;cdecl;external 'streams' name 'flushq';
function freeb(bp:Pmblk_t):longint;cdecl;external 'streams' name 'freeb';
function freemsg(mp:Pmblk_t):longint;cdecl;external 'streams' name 'freemsg';
function freeq(q:Pqueue_t):longint;cdecl;external 'streams' name 'freeq';
function getq(q:Pqueue_t):Pmblk_t;cdecl;external 'streams' name 'getq';
function insq(q:Pqueue_t; emp:Pmblk_t; nmp:Pmblk_t):longint;cdecl;external 'streams' name 'insq';
function linkb(mp1:Pmblk_t; mp2:Pmblk_t):longint;cdecl;external 'streams' name 'linkb';
function msgdsize(mp:Pmblk_t):longint;cdecl;external 'streams' name 'msgdsize';
function pullupmsg(mp:Pmblk_t; len:longint):longint;cdecl;external 'streams' name 'pullupmsg';
function putbq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'putbq';
function putctl(q:Pqueue_t; _type:longint):longint;cdecl;external 'streams' name 'putctl';
function putctl1(q:Pqueue_t; _type:longint; c:longint):longint;cdecl;external 'streams' name 'putctl1';
function putq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'putq';
function qenable(q:Pqueue_t):longint;cdecl;external 'streams' name 'qenable';
function qreply(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'qreply';
function qsize(q:Pqueue_t):longint;cdecl;external 'streams' name 'qsize';
function rmvb(mp:Pmblk_t; bp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'rmvb';
function rmvq(q:Pqueue_t; mp:Pmblk_t):longint;cdecl;external 'streams' name 'rmvq';
function strlog(sid:smallint; mid:smallint; level:char; aflags:smallint; args:array of const):longint;cdecl;external 'streams' name 'strlog';
function strlog(sid:smallint; mid:smallint; level:char; aflags:smallint):longint;cdecl;external 'streams' name 'strlog';
function testb(size:longint; pri:longint):longint;cdecl;external 'streams' name 'testb';
function timeout(func:TFuncLongCdecl; arg:pointer; ticks:longint):longint;cdecl;external 'streams' name 'timeout';
function unlinkb(mp:Pmblk_t):Pmblk_t;cdecl;external 'streams' name 'unlinkb';
function unbufcall(id:longint):longint;cdecl;external 'streams' name 'unbufcall';
{-tispxipx.h-------------------------------------------------------------------}
type
   Pipxaddr_s = ^Tipxaddr_s;
   Tipxaddr_s = record
     ipxa_net    : array[0..3] of byte;
     ipxa_node   : array[0..5] of byte;
     ipxa_socket : array[0..1] of byte;
   end;
   TIPX_ADDR = Tipxaddr_s;
   PIPX_ADDR = ^TIPX_ADDR;

   Pipxopt_s = ^Tipxopt_s;
   Tipxopt_s = record
     ipx_type : byte;
     ipx_pad1 : array[0..2] of byte;
     ipx_hops : byte;
     ipx_pad2 : array[0..2] of byte;
   end;
   TIPX_OPTS = Tipxopt_s;
   PIPX_OPTS = ^TIPX_OPTS;

   Pspxopt_s = ^Tspxopt_s;
   Tspxopt_s = record
     spx_connectionID     : array[0..1] of byte;
     spx_allocationNumber : array[0..1] of byte;
     spx_pad1             : array[0..3] of byte;
   end;
   TSPX_OPTS = Tspxopt_s;
   PSPX_OPTS = ^TSPX_OPTS;

   Pspx_optmgmt = ^Tspx_optmgmt;
   Tspx_optmgmt = record
     spxo_retry_count     : byte;
     spxo_watchdog_flag   : byte;
     spxo_min_retry_delay : dword;
     spxo_pad2            : array[0..1] of byte;
   end;

const
   OPTIONS_VERSION = 1;

function OPTIONS_SIZE : longint;

type
   Pspx2_options = ^Tspx2_options;
   Tspx2_options = record
     versionNumber          : dword;
     spxIIOptionNegotiate   : dword;
     spxIIRetryCount        : dword;
     spxIIMinimumRetryDelay : dword;
     spxIIMaximumRetryDelta : dword;
     spxIIWatchdogTimeout   : dword;
     spxIIConnectTimeout    : dword;
     spxIILocalWindowSize   : dword;
     spxIIRemoteWindowSize  : dword;
     spxIIConnectionID      : dword;
     spxIIInboundPacketSize : dword;
     spxIIOutboundPacketSize: dword;
     spxIISessionFlags      : dword;
   end;

const
   SPX_WATCHDOG_OFF = 0;
   SPX_WATCHDOG_ON =  not (SPX_WATCHDOG_OFF);
   SPX_WATCHDOG_DEFAULT = SPX_WATCHDOG_ON;
   SPX_RETRY_MIN = 3;
   SPX_RETRY_MAX = 50;
   SPX_RETRY_DEFAULT = 10;
   SPX_WATCHDOG_TIMEOUT_MIN = 3000;
   SPX_WATCHDOG_TIMEOUT_MAX = 300000;
   SPX_WATCHDOG_TIMEOUT_DEFAULT = 60000;
   SPX_MIN_RETRY_DELAY_MIN = 1;
   SPX_MIN_RETRY_DELAY_MAX = 60000;
   SPX_MIN_RETRY_DELAY_DEFAULT = 0;
   SPX_MAX_RETRY_DELTA_MIN = 1000;
   SPX_MAX_RETRY_DELTA_MAX = 60000;
   SPX_MAX_RETRY_DELTA_DEFAULT = 5000;
   SPX_OPTION_NEGOTIATE_OFF = 0;
   SPX_OPTION_NEGOTIATE_ON =  not (SPX_OPTION_NEGOTIATE_OFF);
   SPX_OPTION_NEGOTIATE_DEFAULT = SPX_OPTION_NEGOTIATE_ON;
   SPX_CONNECT_TIMEOUT_MIN = 1000;
   SPX_CONNECT_TIMEOUT_MAX = 120000;
   SPX_CONNECT_TIMEOUT_DEFAULT = 0;
   SPX_LOCAL_WINDOW_SIZE_MIN = 1;
   SPX_LOCAL_WINDOW_SIZE_MAX = 8;
   SPX_LOCAL_WINDOW_SIZE_DEFAULT = 0;
   SPX2_SF_NONE = $00;
   SPX2_SF_IPX_CHECKSUM = $01;
   SPX2_SF_SPX2_SESSION = $02;
   TLI_SPX_CONNECTION_FAILED = $ed;
   TLI_SPX_CONNECTION_TERMINATED = $ec;
   TLI_SPX_MALFORMED_PACKET = $fe;
   TLI_SPX_PACKET_OVERFLOW = $fd;
   TLI_SPX_UNREACHABLE_DEST = $70;
   TLI_IPX_MALFORMED_ADDRESS = $fe;
   TLI_IPX_PACKET_OVERFLOW = $fd;

{-in.pp------------------------------------------------------------------------}
const
   IPPROTO_IP = 0;
   IPPROTO_ICMP = 1;
   IPPROTO_IGMP = 2;
   IPPROTO_GGP = 3;
   IPPROTO_TCP = 6;
   IPPROTO_EGP = 8;
   IPPROTO_PUP = 12;
   IPPROTO_UDP = 17;
   IPPROTO_IDP = 22;
   IPPROTO_ND = 77;
   IPPROTO_RAW = 255;
   IPPROTO_MAX = 256;

// Port/socket numbers: network standard functions
   IPPORT_ECHO = 7;
   IPPORT_DISCARD = 9;
   IPPORT_SYSTAT = 11;
   IPPORT_DAYTIME = 13;
   IPPORT_NETSTAT = 15;
   IPPORT_FTP = 21;
   IPPORT_TELNET = 23;
   IPPORT_SMTP = 25;
   IPPORT_TIMESERVER = 37;
   IPPORT_NAMESERVER = 42;
   IPPORT_WHOIS = 43;
   IPPORT_MTP = 57;

// Port/socket numbers: host specific functions
   IPPORT_TFTP = 69;
   IPPORT_RJE = 77;
   IPPORT_FINGER = 79;
   IPPORT_TTYLINK = 87;
   IPPORT_SUPDUP = 95;

// UNIX TCP sockets
   IPPORT_EXECSERVER = 512;
   IPPORT_LOGINSERVER = 513;
   IPPORT_CMDSERVER = 514;
   IPPORT_EFSSERVER = 520;

// UNIX UDP sockets
   IPPORT_BIFFUDP = 512;
   IPPORT_WHOSERVER = 513;
{ 520+1 also used  }
   IPPORT_ROUTESERVER = 520;

   IPPORT_RESERVED = 1024;
   IPPORT_USERRESERVED = 5000;

type
   Pin_addr = ^Tin_addr;
   Tin_addr = record
     s_addr : dword;
   end;

const
   IN_CLASSA_NET = $ff000000;
   IN_CLASSA_NSHIFT = 24;
   IN_CLASSA_HOST = $00ffffff;
   IN_CLASSA_MAX = 128;
   IN_CLASSB_NET = $ffff0000;
   IN_CLASSB_NSHIFT = 16;
   IN_CLASSB_HOST = $0000ffff;
   IN_CLASSB_MAX = 65536;
   IN_CLASSC_NET = $ffffff00;
   IN_CLASSC_NSHIFT = 8;
   IN_CLASSC_HOST = $000000ff;
   IN_LOOPBACKNET = 127;

// var sin_port : word;cvar;public;
//   sin_zero : array[0..7] of char;cvar;public;

    const
       IP_OPTIONS = 1;

function ntohs(value:word):word;cdecl;external {'tcpip'} name 'ntohs';
function htons(value:word):word;cdecl;external {'tcpip'} name 'htons';
function ntohl(value:dword):dword;cdecl;external {'tcpip'} name 'ntohl';
function htonl(value:dword):dword;cdecl;external {'tcpip'} name 'htonl';
{------------------------------------------------------------------------------}

implementation

function t_error : longint;
begin
  t_error := __get_t_errno_ptr^;
end;

function OPTIONS_SIZE : longint;
begin
  OPTIONS_SIZE:=13 * (sizeof(longint));
end;


end.