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
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
|
{$MACRO ON}
{$define Rsc := }
(******************************************************************************
*
* Copyright (c) 1996-2000 Palm, Inc. or its subsidiaries.
* All rights reserved.
*
* File: NetMgr.h
*
* Release: Palm OS SDK 4.0 (63220)
*
* Description:
* This module contains the interface definition for the TCP/IP
* library on Pilot.
*
* History:
* 2/14/96 Created by Ron Marianetti
* Name Date Description
* ---- ---- -----------
* jrb 3/13/98 Removed NetIFSettings that are Mobitex specific.
* Added RadioStateEnum for the setting.
* Added NetIFSettingSpecificMobitex
* Added what are considered "generic" wirless settings.
* jaq 10/1/98 added netMaxIPAddrStrLen constant
* scl 3/ 5/99 integrated Eleven's changes into Main
* jhl 7/14/00 added net notice
*
*****************************************************************************)
unit netmgr;
interface
uses palmos, libtraps, errorbase, sysevent, event_;
(********************************************************************
* Type and creator of Net Library database
********************************************************************)
// Creator. Used for both the database that contains the Net Library and
// it's preferences database.
const
netCreator = Rsc('netl'); // Our Net Library creator
// Feature Creators and numbers, for use with the FtrGet() call. This
// feature can be obtained to get the current version of the Net Library
netFtrCreator = netCreator;
netFtrNumVersion = 0; // get version of Net Library
// 0xMMmfsbbb, where MM is major version, m is minor version
// f is bug fix, s is stage: 3-release,2-beta,1-alpha,0-development,
// bbb is build number for non-releases
// V1.12b3 would be: 0x01122003
// V2.00a2 would be: 0x02001002
// V1.01 would be: 0x01013000
// Begin Change (BGT)
// Feature for defining the number of command blocks to allocate
netFtrCommandBlocks = 1; // get the number of command blocks
// Types. Used to identify the Net Library from it's prefs.
netLibType = Rsc('libr'); // Our Net Code Resources Database type
netPrefsType = Rsc('rsrc'); // Our Net Preferences Database type
// All Network interface's have the following type:
netIFFileType = Rsc('neti'); // The filetype of all Network Interfaces
// Each Network interface has a unique creator:
netIFCreatorLoop = Rsc('loop'); // Loopback network interface creator.
netIFCreatorSLIP = Rsc('slip'); // SLIP network interface creator.
netIFCreatorPPP = Rsc('ppp_'); // PPP network interface creator.
//<chg 1-28-98 RM>
netIFCreatorRAM = Rsc('ram_'); // Mobitex network interface creator
// Special value for configIndex parameter to NetLibOpenConfig that tells it
// to use the current settings - even if they are not the defined default settings
// This is provided for testing purposes
netConfigIndexCurSettings = $FFFF;
// <SCL 3/5/99> Commented out netMaxNetIFs since Tim says it should NOT be here!!
// Still need to fix (Eleven) code that currently depends on it...
// Max # of interfaces that can be installed
// netMaxNetIFs = 4;
//-----------------------------------------------------------------------------
// Misc. constants
//-----------------------------------------------------------------------------
const
netDrvrTypeNameLen = 8; // Maximum driver type length
netDrvrHWNameLen = 16; // Maximum driver hardware name length
netIFNameLen = 10; // Maximum interface name (driver type + instance num)
netIFMaxHWAddrLen = 14; // Maximum size of a hardware address
netMaxIPAddrStrLen = 16; // Max length of an IP address string with null terminator (255.255.255.255)
//-----------------------------------------------------------------------------
// Names of built-in configuration aliases available through the
// NetLibConfigXXX calls
//-----------------------------------------------------------------------------
netCfgNameDefault = '.Default'; // The default configuration
netCfgNameDefWireline = '.DefWireline'; // The default wireline configuration
netCfgNameDefWireless = '.DefWireless'; // The default wireless configuration
netCfgNameCTPWireline = '.CTPWireline'; // Wireline through the Jerry Proxy
netCfgNameCTPWireless = '.CTPWireless'; // Wireless through the Jerry Proxy
//-----------------------------------------------------------------------------
//Flags for the NetUWirelessAppHandleEvent() utility routine
//-----------------------------------------------------------------------------
const
netWLAppEventFlagCTPOnly = $00000001; // using wireless radio for CTP protocol only
netWLAppEventFlagDisplayErrs = $00000002; // Show error alerts for any errors
//-----------------------------------------------------------------------------
// Option constants that can be passed to NetSocketOptionSet and NetSocketOptionGet
// When an option is set or retrieved, both the level of the option and the
// option number must be specified. The level refers to which layer the option
// refers to, like the uppermost socket layer, for example.
//-----------------------------------------------------------------------------
// Socket level options
type
NetSocketOptEnum = WordEnum;
const
// IP Level options
netSocketOptIPOptions = 1; // options in IP header (IP_OPTIONS)
// TCP Level options
netSocketOptTCPNoDelay = 1; // don't delay send to coalesce packets
netSocketOptTCPMaxSeg = 2; // TCP maximum segment size (TCP_MAXSEG)
// Socket level options
netSocketOptSockDebug = $0001; // turn on debugging info recording
netSocketOptSockAcceptConn = $0002; // socket has had listen
netSocketOptSockReuseAddr = $0004; // allow local address reuse
netSocketOptSockKeepAlive = $0008; // keep connections alive
netSocketOptSockDontRoute = $0010; // just use interface addresses
netSocketOptSockBroadcast = $0020; // permit sending of broadcast msgs
netSocketOptSockUseLoopback = $0040; // bypass hardware when possible
netSocketOptSockLinger = $0080; // linger on close if data present
netSocketOptSockOOBInLine = $0100; // leave received OutOfBand data in line
netSocketOptSockSndBufSize = $1001; // send buffer size
netSocketOptSockRcvBufSize = $1002; // receive buffer size
netSocketOptSockSndLowWater = $1003; // send low-water mark
netSocketOptSockRcvLowWater = $1004; // receive low-water mark
netSocketOptSockSndTimeout = $1005; // send timeout
netSocketOptSockRcvTimeout = $1006; // receive timeout
netSocketOptSockErrorStatus = $1007; // get error status and clear
netSocketOptSockSocketType = $1008; // get socket type
// The following are Pilot specific options
netSocketOptSockNonBlocking = $2000; // set non-blocking mode on or off
netSocketOptSockRequireErrClear = $2001; // return error from all further calls to socket
// unless netSocketOptSockErrorStatus is cleared.
netSocketOptSockMultiPktAddr = $2002; // for SOCK_RDM (RMP) sockets. This is the
// fixed IP addr (i.e. Mobitex MAN #) to use
// for multiple packet requests.
// for socket notification
// 05/20/00 jhl
netSocketOptSockNotice = $2003; // prime socket for notification
// Option levels for SocketOptionSet and SocketOptionGet
type
NetSocketOptLevelEnum = WordEnum;
const
netSocketOptLevelIP = 0; // IP level options (IPPROTO_IP)
netSocketOptLevelTCP = 6; // TCP level options (IPPROTO_TCP)
netSocketOptLevelSocket = $FFFF; // Socket level options (SOL_SOCKET)
// Structure used for manipulating the linger option
type
NetSocketLingerType = record
onOff: Int16; // option on/off
time: Int16; // linger time in seconds
end;
//-----------------------------------------------------------------------------
// Enumeration of Socket domains and types passed to NetSocketOpen
//-----------------------------------------------------------------------------
type
NetSocketAddrEnum = Enum;
const
netSocketAddrRaw = 0; // (AF_UNSPEC, AF_RAW)
netSocketAddrINET = 2; // (AF_INET)
type
NetSocketTypeEnum = Enum;
const
netSocketTypeStream = 1; // (SOCK_STREAM)
netSocketTypeDatagram = 2; // (SOCK_DGRAM)
netSocketTypeRaw = 3; // (SOCK_RAW)
netSocketTypeReliableMsg = 4; // (SOCK_RDM)
netSocketTypeLicensee = 8; // Socket entry reserved for licensees.
// Protocols, passed in the protocol parameter to NetLibSocketOpen
const
netSocketProtoIPICMP = 1; // IPPROTO_ICMP
netSocketProtoIPTCP = 6; // IPPROTO_TCP
netSocketProtoIPUDP = 17; // IPPROTO_UDP
netSocketProtoIPRAW = 255; // IPPROTO_RAW
//-----------------------------------------------------------------------------
// Enumeration of Socket direction, passed to NetSocketShutdown
//-----------------------------------------------------------------------------
type
NetSocketDirEnum = Enum;
const
netSocketDirInput = 0;
netSocketDirOutput = 1;
netSocketDirBoth = 2;
//-----------------------------------------------------------------------------
// Basic Types
//-----------------------------------------------------------------------------
// Socket refnum
type
NetSocketRef = Int16;
// Type used to hold internet addresses
NetIPAddr = UInt32; // a 32-bit IP address.
// IFMediaEvent notifications types
type
NetLibIFMediaEventNotificationTypeEnum = Enum;
const
netIFMediaUp = 1; // Usually sent by Network interfaces
// after they have displayed the UI for displaying
// connection establishment progress.
netIFMediaDown = Succ(netIFMediaUp);
// Sent by Network interface's when their inactivity timer
// is ellapsed.
// Notification structure sent in SysNotifyNetLibIFMedia.
type
SysNotifyNetLibIFMediaTag = record
eType: NetLibIFMediaEventNotificationTypeEnum;
ifCreator: UInt32; // interface creator
ifInstance: UInt16; // interface instance
end;
SysNotifyNetLibIFMediaType = SysNotifyNetLibIFMediaTag;
//-----------------------------------------------------------------------------
// For socket notification
// 05/20/00 jhl
//-----------------------------------------------------------------------------
// Notice types
type
NoticeTypeEnum = Enum;
const
netSocketNoticeNotify = 1;
// ummmm...
// shouldn't do this - must fix EventMgr before background/ISR events can be posted
netSocketNoticeEvent = Succ(netSocketNoticeNotify);
netSocketNoticeMailbox = Succ(netSocketNoticeEvent);
netSocketNoticeCallback = Succ(netSocketNoticeMailbox);
netSocketNoticeWake = Succ(netSocketNoticeCallback);
// Notification structure sent for netSocketNoticeNotify.
type
SysNotifyNetSocketType = record
socketRef: NetSocketRef; // Socket sending the notification
condition: UInt32; // Bit field reporting trigger conditions
end;
// Event structure sent for netSocketNoticeEvent.
// This should be defined via Event.h, so it stays in sync.
type
netSocketNotice = record
socketRef: NetSocketRef; // Socket sending the notification
condition: UInt32; // Bit field reporting trigger conditions
end;
type
NetSocketNoticeEventType = record
eType: eventsEnum; // User specified event type
penDown: Boolean;
tapCount: UInt8;
screenX: Int16;
screenY: Int16;
case Integer of
1: (generic: _GenericEventType); // Establish size of union
2: (netSocketNotice: netSocketNotice);
end;
// Mailbox structure sent for netSocketNoticeMailbox.
type
NetSocketNoticeMailboxType = record
message_: UInt32; // User specified message
reserved: UInt16;
socketRef: NetSocketRef; // Socket sending the notification
condition: UInt32; // Bit field reporting trigger conditions
end;
// Callback definition for netSocketNoticeCallback.
type
NetSocketNoticeCallbackPtr = function(userDataP: Pointer; socketRef: UInt16; condition: UInt32): Err;
type
notify = record
notifyType: UInt32; // Notification type
// sends SysNotifyNetSocketType in notification
end;
type
event = record
eType: eventsEnum; // Event type
// adds NetSocketNoticeEventType event to UI event queue
end;
type
mailbox = record
mailboxID: UInt32; // ID of mailbox for send
message_: UInt32; // first element of mailbox message
wAck: UInt32; // third argument to SysMailboxSend()
// sends NetSocketNoticeMailboxType message to specified mailboxID
end;
type
callback = record
callbackP: NetSocketNoticeCallbackPtr; // Callback proc pointer
userDataP: Pointer; // User specified ptr passed as callback parameter
// (*callbackP)(userDataP,socketRef,condition)
end;
type
wake = record
taskID: UInt32; // ID of task to wake
socketRefP: ^NetSocketRef; // address to receive socketRef
conditionP: ^UInt32; // address to receive trigger condition
end;
// Structure used to register for a notice
type
NetSocketNoticeType = record
condition: UInt32; // Bit field specifying trigger conditions
type_: NoticeTypeEnum; // Notice type
case Integer of
1: (notify: notify);
// ummmm...
// shouldn't do this - must fix EventMgr before background/ISR events can be posted
2: (event: event);
3: (mailbox: mailbox);
4: (callback: callback);
5: (wake: wake); // SysTaskWake(taskID)
end;
// Bit values for specifying and reporting trigger conditions
const
netSocketNoticeErr = $00000001;
netSocketNoticeUDPReceive = $00000002;
netSocketNoticeTCPReceive = $00000004;
netSocketNoticeTCPTransmit = $00000008;
netSocketNoticeTCPRemoteClosed = $00000010;
netSocketNoticeTCPClosed = $00000020;
netSocketNoticeConnectInbound = $00000040;
netSocketNoticeConnectOutbound = $00000080;
//-----------------------------------------------------------------------------
// Structure used to hold an internet socket address. This includes the internet
// address and the port number. This structure directly maps to the BSD unix
// struct sockaddr_in.
//-----------------------------------------------------------------------------
type
NetSocketAddrINType = record
family: Int16; // Address family in HBO (Host UInt8 Order)
port: UInt16; // the UDP port in NBO (Network UInt8 Order)
addr: NetIPAddr; // IP address in NBO (Network UInt8 Order)
end;
// Constant that means "use the local machine's IP address"
const
netIPAddrLocal = 0; // Can be used in NetSockAddrINType.addr
// Structure used to hold a generic socket address. This is a generic struct
// designed to hold any type of address including internet addresses. This
// structure directly maps to the BSD unix struct sockaddr.
type
NetSocketAddrType = record
family: Int16; // Address family
data: array [0..14-1] of UInt8; // 14 bytes of address
end;
NetSocketAddrPtr = ^NetSocketAddrType;
// Structure used to hold a raw socket address. When using the netSocketAddrRaw
// protocol family, the caller must bind() the socket to an interface and
// specifies the interface using this structure. IMPORTANT: NUMEROUS
// ROUTINES IN NETLIB RELY ON THE FACT THAT THIS STRUCTURE IS THE SAME
// SIZE AS A NetSocketAddrINType STRUCTURE.
type
NetSocketAddrRawType = record
family: Int16; // Address family in HBO (Host UInt8 Order)
ifInstance: UInt16; // the interface instance number
ifCreator: UInt32; // the interface creator
end;
//-----------------------------------------------------------------------------
// Structure used to hold information about data to be sent. This structure
// is passed to NetLibSendMsg and contains the optional address to send to,
// a scatter-write array of data to be sent, and optional access rights
//-----------------------------------------------------------------------------
// Scatter/Gather array type. A pointer to an array of these structs is
// passed to the NetLibSendPB and NetLibRecvPB calls. It specifies where
// data should go to or come from as a list of buffer addresses and sizes.
type
NetIOVecType = record
bufP: ^UInt8; // buffer address
bufLen: UInt16; // buffer length
end;
NetIOVecPtr = ^NetIOVecType;
const
netIOVecMaxLen = 16; // max# of NetIOVecTypes in an array
// Read/Write ParamBlock type. Passed directly to the SendPB and RecvPB calls.
type
NetIOParamType = record
addrP: ^UInt8; // address - or 0 for default
addrLen: UInt16; // length of address
iov: NetIOVecPtr; // scatter/gather array
iovLen: UInt16; // length of above array
accessRights: ^UInt8; // access rights
accessRightsLen: UInt16; // length of accessrights
end;
NetIOParamPtr = ^NetIOParamType;
// Flags values for the NetLibSend, NetLibReceive calls
const
netIOFlagOutOfBand = $01; // process out-of-band data
netIOFlagPeek = $02; // peek at incoming message
netIOFlagDontRoute = $04; // send without using routing
//-----------------------------------------------------------------------------
// Structures used for looking up a host by name or address (NetLibGetHostByName)
//-----------------------------------------------------------------------------
// Equates for DNS names, from RFC-1035
netDNSMaxDomainName = 255;
netDNSMaxDomainLabel = 63;
netDNSMaxAliases = 1; // max # of aliases for a host
netDNSMaxAddresses = 4; // max # of addresses for a host
// The actual results of NetLibGetHostByName() are returned in this structure.
// This structure is designed to match the "struct hostent" structure in Unix.
type
NetHostInfoType = record
nameP: PChar; // official name of host
nameAliasesP: ^PChar; // array of alias's for the name
addrType: UInt16; // address type of return addresses
addrLen: UInt16; // the length, in bytes, of the addresses
// Note this denotes length of a address, not # of addresses.
addrListP: ^UInt8Ptr; // array of ptrs to addresses in HBO
end;
NetHostInfoPtr = ^NetHostInfoType;
// "Buffer" passed to call as a place to store the results
NetHostInfoBufType = record
hostInfo: NetHostInfoType; // high level results of call are here
// The following fields contain the variable length data that
// hostInfo points to
name: array [0..netDNSMaxDomainName] of Char; // hostInfo->name
aliasList: array [0..netDNSMaxAliases] of PChar; // +1 for 0 termination.
aliases: array [0..netDNSMaxAliases-1, 0..netDNSMaxDomainName] of Char;
addressList: array [0..netDNSMaxAddresses-1] of ^NetIPAddr;
address: array [0..netDNSMaxAddresses-1] of NetIPAddr;
end;
NetHostInfoBufPtr = ^NetHostInfoBufType;
//-----------------------------------------------------------------------------
// Structures used for looking up a service (NetLibGetServByName)
//-----------------------------------------------------------------------------
// Equates for service names
const
netServMaxName = 15; // max # characters in service name
netProtoMaxName = 15; // max # characters in protocol name
netServMaxAliases = 1; // max # of aliases for a service
// The actual results of NetLibGetServByName() are returned in this structure.
// This structure is designed to match the "struct servent" structure in Unix.
type
NetServInfoType = record
nameP: PChar; // official name of service
nameAliasesP: ^PChar; // array of alias's for the name
port: UInt16; // port number for this service
protoP: PChar; // name of protocol to use
end;
NetServInfoPtr = ^NetServInfoType;
// "Buffer" passed to call as a place to store the results
NetServInfoBufType = record
servInfo: NetServInfoType; // high level results of call are here
// The following fields contain the variable length data that
// servInfo points to
name: array [0..netServMaxName] of Char; // hostInfo->name
aliasList: array [0..netServMaxAliases] of PChar; // +1 for 0 termination.
aliases: array [0..netServMaxAliases-1, 0..netServMaxName-1] of Char;
protoName: array [0..netProtoMaxName] of Char;
reserved: UInt8;
end;
NetServInfoBufPtr = ^NetServInfoBufType;
//--------------------------------------------------------------------
// Structure of a configuration name. Used by NetLibConfigXXX calls
// <chg 1-28-98 RM> added for the new Config calls.
//---------------------------------------------------------------------
const
netConfigNameSize = 32;
type
NetConfigNameType = record
name: array [0..netConfigNameSize-1] of Char; // name of configuration
end;
NetConfigNamePtr = ^NetConfigNameType;
(********************************************************************
* Tracing Flags. These flags are ORed together and passed as a UInt32
* in the netSettingTraceFlags setting and netIFSettingTraceFlags to
* enable/disable various trace options.
********************************************************************)
const
netTracingErrors = $00000001; // record errors
netTracingMsgs = $00000002; // record messages
netTracingPktIP = $00000004; // record packets sent/received
// to/from interfaces at the IP layer
// NOTE: netTracingPktData40 & netTracingPktData
// will control how much data of each packet is
// recorded.
netTracingFuncs = $00000008; // record function flow
netTracingAppMsgs = $00000010; // record application messages
// (NetLibTracePrintF, NetLibTracePutS)
netTracingPktData40 = $00000020; // record first 40 bytes of packets
// when netTracingPktsXX is also on.
// NOTE: Mutually exclusive with
// netTracingPktData and only applicable if
// one of the netTracingPktsXX bits is also set
netTracingPktData = $00000040; // record all bytes of IP packets
// sent/received to/from interfaces
// NOTE: Mutually exclusive with
// netTracingPkts & netTracingPktData64
netTracingPktIFHi = $00000080; // record packets sent/received at highest layer
// of interface (just below IP layer).
// NOTE: netTracingPktData40 & netTracingPktData
// will control how much data of each packet is
// recorded.
netTracingPktIFMid = $00000100; // record packets sent/received at mid layer
// of interface (just below IFHi layer).
// NOTE: netTracingPktData40 & netTracingPktData
// will control how much data of each packet is
// recorded.
netTracingPktIFLow = $00000200; // record packets sent/received at low layer
// of interface (just below IFMid layer).
// NOTE: netTracingPktData40 & netTracingPktData
// will control how much data of each packet is
// recorded.
// OBSOLETE tracing bit, still used by Network Panel
netTracingPkts = netTracingPktIP;
(********************************************************************
* Command numbers and parameter blocks for the NetLibMaster() call.
* This call is used to put the Net library into certain debugging modes
* or for obtaining statistics from the Net Library.
*
********************************************************************)
type
NetMasterEnum = Enum;
const
// These calls return info
netMasterInterfaceInfo = 0;
netMasterInterfaceStats = Succ(netMasterInterfaceInfo);
netMasterIPStats = Succ(netMasterInterfaceStats);
netMasterICMPStats = Succ(netMasterIPStats);
netMasterUDPStats = Succ(netMasterICMPStats);
netMasterTCPStats = Succ(netMasterUDPStats);
// This call used to read the trace buffer.
netMasterTraceEventGet = Succ(netMasterTCPStats); // get trace event by index
type
//.............................................................
// InterfaceInfo command
//.............................................................
interfaceInfo = record
index: UInt16; // -> index of interface
creator: UInt32; // <- creator
instance: UInt16; // <- instance
netIFP: Pointer; // <- net_if pointer
// driver level info
drvrName: array [0..netDrvrTypeNameLen-1] of Char; // <- type of driver (SLIP,PPP, etc)
hwName: array [0..netDrvrHWNameLen-1] of Char; // <- hardware name (Serial Library, etc)
localNetHdrLen: UInt8; // <- local net header length
localNetTrailerLen: UInt8; // <- local net trailer length
localNetMaxFrame: UInt16; // <- local net maximum frame size
// media layer info
ifName: array [0..netIFNameLen-1] of Char; // <- interface name w/instance
driverUp: Boolean; // <- true if interface driver up
ifUp: Boolean; // <- true if interface is up
hwAddrLen: UInt16; // <- length of hardware address
hwAddr: array [0..netIFMaxHWAddrLen-1] of UInt8; // <- hardware address
mtu: UInt16; // <- maximum transfer unit of interface
speed: UInt32; // <- speed in bits/sec.
lastStateChange: UInt32; // <- time in milliseconds of last state change
// Address info
ipAddr: NetIPAddr; // Address of this interface
subnetMask: NetIPAddr; // subnet mask of local network
broadcast: NetIPAddr; // broadcast address of local network
end;
//.............................................................
// InterfaceStats command
//.............................................................
interfaceStats = record
index: UInt16; // -> index of interface
inOctets: UInt32; // <- ....
inUcastPkts: UInt32;
inNUcastPkts: UInt32;
inDiscards: UInt32;
inErrors: UInt32;
inUnknownProtos: UInt32;
outOctets: UInt32;
outUcastPkts: UInt32;
outNUcastPkts: UInt32;
outDiscards: UInt32;
outErrors: UInt32;
end;
//.............................................................
// IPStats command
//.............................................................
ipStats = record
ipInReceives: UInt32;
ipInHdrErrors: UInt32;
ipInAddrErrors: UInt32;
ipForwDatagrams: UInt32;
ipInUnknownProtos: UInt32;
ipInDiscards: UInt32;
ipInDelivers: UInt32;
ipOutRequests: UInt32;
ipOutDiscards: UInt32;
ipOutNoRoutes: UInt32;
ipReasmReqds: UInt32;
ipReasmOKs: UInt32;
ipReasmFails: UInt32;
ipFragOKs: UInt32;
ipFragFails: UInt32;
ipFragCreates: UInt32;
ipRoutingDiscards: UInt32;
ipDefaultTTL: UInt32;
ipReasmTimeout: UInt32;
end;
//.............................................................
// ICMPStats command
//.............................................................
icmpStats = record
icmpInMsgs: UInt32;
icmpInErrors: UInt32;
icmpInDestUnreachs: UInt32;
icmpInTimeExcds: UInt32;
icmpInParmProbs: UInt32;
icmpInSrcQuenchs: UInt32;
icmpInRedirects: UInt32;
icmpInEchos: UInt32;
icmpInEchoReps: UInt32;
icmpInTimestamps: UInt32;
icmpInTimestampReps: UInt32;
icmpInAddrMasks: UInt32;
icmpInAddrMaskReps: UInt32;
icmpOutMsgs: UInt32;
icmpOutErrors: UInt32;
icmpOutDestUnreachs: UInt32;
icmpOutTimeExcds: UInt32;
icmpOutParmProbs: UInt32;
icmpOutSrcQuenchs: UInt32;
icmpOutRedirects: UInt32;
icmpOutEchos: UInt32;
icmpOutEchoReps: UInt32;
icmpOutTimestamps: UInt32;
icmpOutTimestampReps: UInt32;
icmpOutAddrMasks: UInt32;
icmpOutAddrMaskReps: UInt32;
end;
//.............................................................
// UDPStats command
//.............................................................
udpStats = record
udpInDatagrams: UInt32;
udpNoPorts: UInt32;
udpInErrors: UInt32;
udpOutDatagrams: UInt32;
end;
//.............................................................
// TCPStats command
//.............................................................
tcpStats = record
tcpRtoAlgorithm: UInt32;
tcpRtoMin: UInt32;
tcpRtoMax: UInt32;
tcpMaxConn: UInt32;
tcpActiveOpens: UInt32;
tcpPassiveOpens: UInt32;
tcpAttemptFails: UInt32;
tcpEstabResets: UInt32;
tcpCurrEstab: UInt32;
tcpInSegs: UInt32;
tcpOutSegs: UInt32;
tcpRetransSegs: UInt32;
tcpInErrs: UInt32;
tcpOutRsts: UInt32;
end;
//.............................................................
// TraceEventGet command
//.............................................................
traceEventGet = record
index: UInt16; // which event
textP: PChar; // ptr to text string to return it in
end;
type
NetMasterPBType = record
// These fields are specific to each command
case Integer of
0: (interfaceInfo: interfaceInfo);
1: (interfaceStats: interfaceStats);
2: (ipStats: ipStats);
3: (icmpStats: icmpStats);
4: (udpStats: udpStats);
5: (tcpStats: tcpStats);
6: (traceEventGet: traceEventGet);
end;
NetMasterPBPtr = ^NetMasterPBType;
//-----------------------------------------------------------------------------
// Enumeration of Net settings as passed to NetLibSettingGet/Set.
//-----------------------------------------------------------------------------
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Global environment settings common to all attached network interfaces,
// passed to NetLibSettingGet/Set
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
type
NetSettingEnum = WordEnum;
const
netSettingResetAll = 0; // void, NetLibSettingSet only, resets all settings
// to their defaults.
netSettingPrimaryDNS = Succ(netSettingResetAll); // UInt32, IP address of Primary DN Server
netSettingSecondaryDNS = Succ(netSettingPrimaryDNS); // UInt32, IP address of Secondary DN Server
netSettingDefaultRouter = Succ(netSettingSecondaryDNS); // UInt32, IP address of Default router
netSettingDefaultIFCreator = Succ(netSettingDefaultRouter); // UInt32, Creator type of default interface
netSettingDefaultIFInstance = Succ(netSettingDefaultIFCreator); // UInt16, Instance# of default interface
netSettingHostName = Succ(netSettingDefaultIFInstance); // Char[64], name of host (not including domain)
netSettingDomainName = Succ(netSettingHostName); // Char[256], domain name of hosts's domain
netSettingHostTbl = Succ(netSettingDomainName); // Char[], host table
netSettingCloseWaitTime = Succ(netSettingHostTbl); // UInt32, time in milliseconds to stay in close-wait state
netSettingInitialTCPResendTime = Succ(netSettingCloseWaitTime); // UInt32, time in milliseconds before TCP resends a packet.
// This is just the initial value, the timeout is adjusted
// from this initial value depending on history of ACK times.
// This is sometimes referred to as the RTO (Roundtrip Time Out)
// See RFC-1122 for additional information.
// The following settings are not used for configuration, but rather put the
// stack into various modes for debugging, etc.
netSettingTraceBits = $1000; // UInt32, enable/disable various trace flags (netTraceBitXXXX)
netSettingTraceSize = Succ(netSettingTraceBits); // UInt32, max trace buffer size in bytes. Default 0x800.
// Setting this will also clear the trace buffer.
netSettingTraceStart = Succ(netSettingTraceSize); // UInt32, for internal use ONLY!!
netSettingTraceRoll = Succ(netSettingTraceStart); // UInt8, if true, trace buffer will rollover after it fills.
// Default is true.
netSettingRTPrimaryDNS = Succ(netSettingTraceRoll); // used internally by Network interfaces
// that dynamically obtain the DNS address
netSettingRTSecondaryDNS = Succ(netSettingRTPrimaryDNS); // used internally by Network interfaces
// that dynamically obtain the DNS address
netSettingConfigTable = Succ(netSettingRTSecondaryDNS); // used internally by NetLib - NOT FOR USE BY
// APPLICATIONS!!
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Settings for each Network Interface, passed to NetLibIFSettingGet/Set
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
type
NetIFSettingEnum = WordEnum;
const
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Reset all settings to defaults
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingResetAll = 0; // void, NetLibIFSettingSet only, resets all settings
// to their defaults.
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Status - read only
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingUp = Succ(netIFSettingResetAll); // UInt8, true if interface is UP.
netIFSettingName = Succ(netIFSettingUp); // Char[32], name of interface
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Addressing
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingReqIPAddr = Succ(netIFSettingName); // UInt32, requested IP address of this interface
netIFSettingSubnetMask = Succ(netIFSettingReqIPAddr); // UInt32, subnet mask of this interface
netIFSettingBroadcast = Succ(netIFSettingSubnetMask); // UInt32, broadcast address for this interface
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// User Info
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingUsername = Succ(netIFSettingBroadcast); // Char[], login script user name
// If 0 length, then user will be prompted for it
netIFSettingPassword = Succ(netIFSettingUsername); // Char[], login script user password
// If 0 length, then user will be prompted for it
netIFSettingDialbackUsername = Succ(netIFSettingPassword); // Char[], login script dialback user name.
// If 0 length, then netIFSettingUsername is used
netIFSettingDialbackPassword = Succ(netIFSettingDialbackUsername); // Char[], login script dialback user password.
// If 0 length, then user will be prompted for it
netIFSettingAuthUsername = Succ(netIFSettingDialbackPassword); // Char[], PAP/CHAP name.
// If 0 length, then netIFSettingUsername is used
netIFSettingAuthPassword = Succ(netIFSettingAuthUsername); // Char[], PAP/CHAP password.
// If "$", then user will be prompted for it
// else If 0 length, then netIFSettingPassword or result
// of it's prompt (if it was empty) will be used
// else it is used as-is.
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// Connect Settings
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingServiceName = Succ(netIFSettingAuthPassword); // Char[], name of service
netIFSettingLoginScript = Succ(netIFSettingServiceName); // Char[], login script
netIFSettingConnectLog = Succ(netIFSettingLoginScript); // Char[], connect log
netIFSettingInactivityTimeout = Succ(netIFSettingConnectLog); // UInt16, # of seconds of inactivity allowed before
// interface is brought down. If 0 then
// no inactivity timeout enforced.
netIFSettingEstablishmentTimeout = Succ(netIFSettingInactivityTimeout); // UInt16, max delay in seconds between connection
// establishment stages
// Serial based protocol options
netIFSettingDynamicIP = Succ(netIFSettingEstablishmentTimeout); // UInt8, if true, get IP address from server
// N/A for SLIP
netIFSettingVJCompEnable = Succ(netIFSettingDynamicIP); // UInt8, if true enable VJ Header compression
// Default is on for PPP, off for SLIP
netIFSettingVJCompSlots = Succ(netIFSettingVJCompEnable); // UInt8, # of slots to use for VJ compression.
// Default is 4 for PPP, 16 for SLIP
// (each slot uses 256 bytes of RAM).
netIFSettingMTU = Succ(netIFSettingVJCompSlots); // UInt16, maximum transmission unit in bytes
// ignored in current PPP and SLIP interfaces
netIFSettingAsyncCtlMap = Succ(netIFSettingMTU); // UInt32, bitmask of characters to escape
// ignored in current PPP interfaces
// Serial settings, used by serial based network interfaces
netIFSettingPortNum = Succ(netIFSettingAsyncCtlMap); // UInt16, port number to use
netIFSettingBaudRate = Succ(netIFSettingPortNum); // UInt32, baud rate in bits/sec.
netIFSettingFlowControl = Succ(netIFSettingBaudRate); // UInt8, flow control setting bits. Set to 0x01 for
// hardware flow control, else set to 0x00.
netIFSettingStopBits = Succ(netIFSettingFlowControl); // UInt8, # of stop bits
netIFSettingParityOn = Succ(netIFSettingStopBits); // UInt8, true if parity on
netIFSettingParityEven = Succ(netIFSettingParityOn); // UInt8, true if parity even
// Modem settings, optionally used by serial based network interfaces
netIFSettingUseModem = Succ(netIFSettingParityEven); // UInt8, if true dial-up through modem
netIFSettingPulseDial = Succ(netIFSettingUseModem); // UInt8, if true use pulse dial, else tone
netIFSettingModemInit = Succ(netIFSettingPulseDial); // Char[], modem initialization string
netIFSettingModemPhone = Succ(netIFSettingModemInit); // Char[], modem phone number string
netIFSettingRedialCount = Succ(netIFSettingModemPhone); // UInt16, # of times to redial
//---------------------------------------------------------------------------------
// New Settings as of PalmOS 3.0
// Power control, usually only implemented by wireless interfaces
//---------------------------------------------------------------------------------
netIFSettingPowerUp = Succ(netIFSettingRedialCount); // UInt8, true if this interface is powered up
// false if this interface is in power-down mode
// interfaces that don't support power modes should
// quietly ignore this setting.
// Wireless or Wireline, read-only, returns true for wireless interfaces. this
// setting is used by application level functions to determine which interface(s)
// to attach/detach given user preference and/or state of the antenna.
netIFSettingWireless = Succ(netIFSettingPowerUp); // UInt8, true if this interface is wireless
// Option to query server for address of DNS servers
netIFSettingDNSQuery = Succ(netIFSettingWireless); // UInt8, if true PPP queries for DNS address. Default true
//---------------------------------------------------------------------------------
// New Settings as of PalmOS 3.2
// Power control, usually only implemented by wireless interfaces
//---------------------------------------------------------------------------------
netIFSettingQuitOnTxFail = Succ(netIFSettingDNSQuery); // BYTE W-only. Power down RF on tx fail
netIFSettingQueueSize = Succ(netIFSettingQuitOnTxFail); // UInt8 R-only. The size of the Tx queue in the RF interface
netIFSettingTxInQueue = Succ(netIFSettingQueueSize); // BYTE R-only. Packets remaining to be sent
netIFSettingTxSent = Succ(netIFSettingTxInQueue); // BYTE R-only. Packets sent since SocketOpen
netIFSettingTxDiscard = Succ(netIFSettingTxSent); // BYTE R-only. Packets discarded on SocketClose
netIFSettingRssi = Succ(netIFSettingTxDiscard); // char R-only. signed value in dBm.
netIFSettingRssiAsPercent = Succ(netIFSettingRssi); // char R-only. signed value in percent, with 0 being no coverage and 100 being excellent.
netIFSettingRadioState = Succ(netIFSettingRssiAsPercent); // enum R-only. current state of the radio
netIFSettingBase = Succ(netIFSettingRadioState); // UInt32 R-only. Interface specific
netIFSettingRadioID = Succ(netIFSettingBase); // UInt32[2] R-only, two 32-bit. interface specific
netIFSettingBattery = Succ(netIFSettingRadioID); // UInt8, R-only. percentage of battery left
netIFSettingNetworkLoad = Succ(netIFSettingBattery); // UInt8, R-only. percent estimate of network loading
//---------------------------------------------------------------------------------
// New Settings as of PalmOS 3.3
//---------------------------------------------------------------------------------
netIFSettingConnectionName = Succ(netIFSettingNetworkLoad); // Char [] Connection Profile Name
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// The following settings are not used for configuration, but rather put the
// stack into various modes for debugging, etc.
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingTraceBits = $1000; // UInt32, enable/disable various trace flags (netTraceBitXXXX)
netIFSettingGlobalsPtr = Succ(netIFSettingTraceBits); // UInt32, (Read-Only) sinterface's globals ptr
netIFSettingActualIPAddr = Succ(netIFSettingGlobalsPtr); // UInt32, (Read-Only) the actual IP address that the interface
// ends up using. The login script executor stores
// the result of the "g" script command here as does
// the PPP negotiations.
netIFSettingServerIPAddr = Succ(netIFSettingActualIPAddr); // UInt32, (Read-Only) the IP address of the PPP server
// we're connected to
// The following setting should be true if this network interface should be
// brought down when the Pilot is turned off.
netIFSettingBringDownOnPowerDown = Succ(netIFSettingServerIPAddr); // UInt8, if true interface will be brought down when
// Pilot is turned off.
// The following setting is used by the TCP/IP stack ONLY!! It tells the interface
// to pass all received packets as-is to the NetIFCallbacksPtr->raw_rcv() routine.
// This setting gets setup when an application creates a raw socket in the raw domain
netIFSettingRawMode = Succ(netIFSettingBringDownOnPowerDown); // UInt32, parameter to pass to raw_rcv() along with
// packet pointer.
//---------------------------------------------------------------------------------
// New Settings as of PalmOS 4.0
//---------------------------------------------------------------------------------
// The following setting is a new interface in PalmOS 4.0 that allow INetlib
// or other NetLib clients to get raw location information as described in
// PalmLocRawData.h.
// NetLib will return a pointer to a newly allocated memory buffer containing
// the raw location information to send to Elaine (Web Clipping proxy server).
// Elaine will then use a Windows DLL to analyse the raw location information
// in order to transform it into something useful like zipcode, cityname, etc.
// See PalmLocRawData.h for more details...
netIFSettingLocRawInfo = Succ(netIFSettingRawMode); // void* R-only: Allocated memory buffer - must be free by caller
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
// 3rd party settings start here...
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
netIFSettingCustom = $8000;
//=========================================================================================
// Enums for the netIFSettingRadioState setting
//
// JB added for the radio state setting.
// <chg 3-17-98 RM> fixed naming conventions.
//=========================================================================================
type
NetRadioStateEnum = Enum;
const
netRadioStateOffNotConnected = 0;
netRadioStateOnNotConnected = Succ(netRadioStateOffNotConnected); // scanning
netRadioStateOnConnected = Succ(netRadioStateOnNotConnected); // have channel
netRadioStateOffConnected = Succ(netRadioStateOnConnected);
(************************************************************
* Net Library Macros
*************************************************************)
// Return current time in milliseconds.
function NetNow: UInt32;
// File Descriptor macros used for the NetLibSelect() call
type
NetFDSetType = UInt32;
NetFDSetPtr = ^NetFDSetType;
const
netFDSetSize = 32;
procedure netFDSet(n: UInt8; var p: NetFDSetType);
procedure nnetFDClr(n: UInt8; var p: NetFDSetType);
function nnetFDIsSet(n: UInt8; var p: NetFDSetType): Boolean;
procedure nnetFDZero(var p: NetFDSetType);
//-----------------------------------------------------------------------------
// Net error codes
//-----------------------------------------------------------------------------
const
netErrAlreadyOpen = netErrorClass or 1;
netErrNotOpen = netErrorClass or 2;
netErrStillOpen = netErrorClass or 3;
netErrParamErr = netErrorClass or 4;
netErrNoMoreSockets = netErrorClass or 5;
netErrOutOfResources = netErrorClass or 6;
netErrOutOfMemory = netErrorClass or 7; // Might be because free heap space is <32K probably because handheld's RAM <2MB
netErrSocketNotOpen = netErrorClass or 8;
netErrSocketBusy = netErrorClass or 9; //EINPROGRESS
netErrMessageTooBig = netErrorClass or 10;
netErrSocketNotConnected = netErrorClass or 11;
netErrNoInterfaces = netErrorClass or 12; //ENETUNREACH
netErrBufTooSmall = netErrorClass or 13;
netErrUnimplemented = netErrorClass or 14;
netErrPortInUse = netErrorClass or 15; //EADDRINUSE
netErrQuietTimeNotElapsed = netErrorClass or 16; //EADDRINUSE
netErrInternal = netErrorClass or 17;
netErrTimeout = netErrorClass or 18; //ETIMEDOUT
netErrSocketAlreadyConnected = netErrorClass or 19; //EISCONN
netErrSocketClosedByRemote = netErrorClass or 20;
netErrOutOfCmdBlocks = netErrorClass or 21;
netErrWrongSocketType = netErrorClass or 22;
netErrSocketNotListening = netErrorClass or 23;
netErrUnknownSetting = netErrorClass or 24;
netErrInvalidSettingSize = netErrorClass or 25;
netErrPrefNotFound = netErrorClass or 26;
netErrInvalidInterface = netErrorClass or 27;
netErrInterfaceNotFound = netErrorClass or 28;
netErrTooManyInterfaces = netErrorClass or 29;
netErrBufWrongSize = netErrorClass or 30;
netErrUserCancel = netErrorClass or 31;
netErrBadScript = netErrorClass or 32;
netErrNoSocket = netErrorClass or 33;
netErrSocketRcvBufFull = netErrorClass or 34;
netErrNoPendingConnect = netErrorClass or 35;
netErrUnexpectedCmd = netErrorClass or 36;
netErrNoTCB = netErrorClass or 37;
netErrNilRemoteWindowSize = netErrorClass or 38;
netErrNoTimerProc = netErrorClass or 39;
netErrSocketInputShutdown = netErrorClass or 40; // EOF to sockets API
netErrCmdBlockNotCheckedOut = netErrorClass or 41;
netErrCmdNotDone = netErrorClass or 42;
netErrUnknownProtocol = netErrorClass or 43;
netErrUnknownService = netErrorClass or 44;
netErrUnreachableDest = netErrorClass or 45;
netErrReadOnlySetting = netErrorClass or 46;
netErrWouldBlock = netErrorClass or 47; //EWOULDBLOCK
netErrAlreadyInProgress = netErrorClass or 48; //EALREADY
netErrPPPTimeout = netErrorClass or 49;
netErrPPPBroughtDown = netErrorClass or 50;
netErrAuthFailure = netErrorClass or 51;
netErrPPPAddressRefused = netErrorClass or 52;
// The following map into the Epilogue DNS errors declared in DNS.ep.h:
// and MUST be kept in this order!!
netErrDNSNameTooLong = netErrorClass or 53;
netErrDNSBadName = netErrorClass or 54;
netErrDNSBadArgs = netErrorClass or 55;
netErrDNSLabelTooLong = netErrorClass or 56;
netErrDNSAllocationFailure = netErrorClass or 57;
netErrDNSTimeout = netErrorClass or 58;
netErrDNSUnreachable = netErrorClass or 59;
netErrDNSFormat = netErrorClass or 60;
netErrDNSServerFailure = netErrorClass or 61;
netErrDNSNonexistantName = netErrorClass or 62;
netErrDNSNIY = netErrorClass or 63;
netErrDNSRefused = netErrorClass or 64;
netErrDNSImpossible = netErrorClass or 65;
netErrDNSNoRRS = netErrorClass or 66;
netErrDNSAborted = netErrorClass or 67;
netErrDNSBadProtocol = netErrorClass or 68;
netErrDNSTruncated = netErrorClass or 69;
netErrDNSNoRecursion = netErrorClass or 70;
netErrDNSIrrelevant = netErrorClass or 71;
netErrDNSNotInLocalCache = netErrorClass or 72;
netErrDNSNoPort = netErrorClass or 73;
// The following map into the Epilogue IP errors declared in IP.ep.h:
// and MUST be kept in this order!!
netErrIPCantFragment = netErrorClass or 74;
netErrIPNoRoute = netErrorClass or 75;
netErrIPNoSrc = netErrorClass or 76;
netErrIPNoDst = netErrorClass or 77;
netErrIPktOverflow = netErrorClass or 78;
// End of Epilogue IP errors
netErrTooManyTCPConnections = netErrorClass or 79;
netErrNoDNSServers = netErrorClass or 80;
netErrInterfaceDown = netErrorClass or 81;
// Mobitex network radio interface error code returns
netErrNoChannel = netErrorClass or 82; // The datalink layer cannot acquire a channel
netErrDieState = netErrorClass or 83; // Mobitex network has issued a DIE command.
netErrReturnedInMail = netErrorClass or 84; // The addressed of the transmitted packet was not available, and the message was placed in the network's mailbox.
netErrReturnedNoTransfer = netErrorClass or 85; // This message cannot be transferred or put in the network mailbox.
netErrReturnedIllegal = netErrorClass or 86; // The message could not be switched to the network
netErrReturnedCongest = netErrorClass or 87; // Line, radio channels, or network nodes are congested.
netErrReturnedError = netErrorClass or 88; // Technical error in the network.
netErrReturnedBusy = netErrorClass or 89; // The B-party is busy.
netErrGMANState = netErrorClass or 90; // The modem has not registered with the network.
netErrQuitOnTxFail = netErrorClass or 91; // Couldn't get packet through, shutdown.
netErrFlexListFull = netErrorClass or 92; // raw IF error message: see Mobitex spec.
netErrSenderMAN = netErrorClass or 93; // ditto
netErrIllegalType = netErrorClass or 94; // ditto
netErrIllegalState = netErrorClass or 95; // ditto
netErrIllegalFlags = netErrorClass or 96; // ditto
netErrIllegalSendlist = netErrorClass or 97; // ditto
netErrIllegalMPAKLength = netErrorClass or 98; // ditto
netErrIllegalAddressee = netErrorClass or 99; // ditto
netErrIllegalPacketClass = netErrorClass or 100; // ditto
netErrBufferLength = netErrorClass or 101; // any
netErrNiCdLowBattery = netErrorClass or 102; // any
netErrRFinterfaceFatal = netErrorClass or 103; // any
netErrIllegalLogout = netErrorClass or 104; // raw IF error message
netErrAAARadioLoad = netErrorClass or 105; // 7/20/98 JB. If there is insufficient AAA
netErrAntennaDown = netErrorClass or 106;
netErrNiCdCharging = netErrorClass or 107; // just for charging
netErrAntennaWentDown = netErrorClass or 108;
netErrNotActivated = netErrorClass or 109; // The unit has not been FULLY activated. George and Morty completed.
netErrRadioTemp = netErrorClass or 110; // Radio's temp is too high for FCC compliant TX
netErrNiCdChargeError = netErrorClass or 111; // Charging stopped due to NiCd charging characteristic
netErrNiCdSag = netErrorClass or 112; // the computed sag or actual sag indicates a NiCd with diminished capacity.
netErrNiCdChargeSuspend = netErrorClass or 113; // Charging has been suspended due to low AAA batteries.
// Left room for more Mobitex errors
// Configuration errors
netErrConfigNotFound = netErrorClass or 115;
netErrConfigCantDelete = netErrorClass or 116;
netErrConfigTooMany = netErrorClass or 117;
netErrConfigBadName = netErrorClass or 118;
netErrConfigNotAlias = netErrorClass or 119;
netErrConfigCantPointToAlias = netErrorClass or 120;
netErrConfigEmpty = netErrorClass or 121;
netErrAlreadyOpenWithOtherConfig = netErrorClass or 122;
netErrConfigAliasErr = netErrorClass or 123;
netErrNoMultiPktAddr = netErrorClass or 124;
netErrOutOfPackets = netErrorClass or 125;
netErrMultiPktAddrReset = netErrorClass or 126;
netErrStaleMultiPktAddr = netErrorClass or 127;
// Login scripting plugin errors
netErrScptPluginMissing = netErrorClass or 128;
netErrScptPluginLaunchFail = netErrorClass or 129;
netErrScptPluginCmdFail = netErrorClass or 130;
netErrScptPluginInvalidCmd = netErrorClass or 131;
// Telephony errors
netErrTelMissingComponent = netErrorClass or 132;
netErrTelErrorNotHandled = netErrorClass or 133;
netErrMobitexStart = netErrNoChannel;
netErrMobitexEnd = netErrNiCdChargeSuspend;
//-----------------------------------------------------------------------------
// Net library call ID's. Each library call gets the trap number:
// netTrapXXXX which serves as an index into the library's dispatch table.
// The constant sysLibTrapCustom is the first available trap number after
// the system predefined library traps Open,Close,Sleep & Wake.
//
// WARNING!!! This order of these traps MUST match the order of the dispatch
// table in NetDispatch.c!!!
//-----------------------------------------------------------------------------
type
NetLibTrapNumberEnum = Enum;
const
netLibTrapAddrINToA = sysLibTrapCustom;
netLibTrapAddrAToIN = Succ(netLibTrapAddrINToA);
netLibTrapSocketOpen = Succ(netLibTrapAddrAToIN);
netLibTrapSocketClose = Succ(netLibTrapSocketOpen);
netLibTrapSocketOptionSet = Succ(netLibTrapSocketClose);
netLibTrapSocketOptionGet = Succ(netLibTrapSocketOptionSet);
netLibTrapSocketBind = Succ(netLibTrapSocketOptionGet);
netLibTrapSocketConnect = Succ(netLibTrapSocketBind);
netLibTrapSocketListen = Succ(netLibTrapSocketConnect);
netLibTrapSocketAccept = Succ(netLibTrapSocketListen);
netLibTrapSocketShutdown = Succ(netLibTrapSocketAccept);
netLibTrapSendPB = Succ(netLibTrapSocketShutdown);
netLibTrapSend = Succ(netLibTrapSendPB);
netLibTrapReceivePB = Succ(netLibTrapSend);
netLibTrapReceive = Succ(netLibTrapReceivePB);
netLibTrapDmReceive = Succ(netLibTrapReceive);
netLibTrapSelect = Succ(netLibTrapDmReceive);
netLibTrapPrefsGet = Succ(netLibTrapSelect);
netLibTrapPrefsSet = Succ(netLibTrapPrefsGet);
// The following traps are for internal and Network interface
// use only.
netLibTrapDrvrWake = Succ(netLibTrapPrefsSet);
netLibTrapInterfacePtr = Succ(netLibTrapDrvrWake);
netLibTrapMaster = Succ(netLibTrapInterfacePtr);
// New Traps
netLibTrapGetHostByName = Succ(netLibTrapMaster);
netLibTrapSettingGet = Succ(netLibTrapGetHostByName);
netLibTrapSettingSet = Succ(netLibTrapSettingGet);
netLibTrapIFAttach = Succ(netLibTrapSettingSet);
netLibTrapIFDetach = Succ(netLibTrapIFAttach);
netLibTrapIFGet = Succ(netLibTrapIFDetach);
netLibTrapIFSettingGet = Succ(netLibTrapIFGet);
netLibTrapIFSettingSet = Succ(netLibTrapIFSettingGet);
netLibTrapIFUp = Succ(netLibTrapIFSettingSet);
netLibTrapIFDown = Succ(netLibTrapIFUp);
netLibTrapIFMediaUp = Succ(netLibTrapIFDown);
netLibTrapScriptExecuteV32 = Succ(netLibTrapIFMediaUp);
netLibTrapGetHostByAddr = Succ(netLibTrapScriptExecuteV32);
netLibTrapGetServByName = Succ(netLibTrapGetHostByAddr);
netLibTrapSocketAddr = Succ(netLibTrapGetServByName);
netLibTrapFinishCloseWait = Succ(netLibTrapSocketAddr);
netLibTrapGetMailExchangeByName = Succ(netLibTrapFinishCloseWait);
netLibTrapPrefsAppend = Succ(netLibTrapGetMailExchangeByName);
netLibTrapIFMediaDown = Succ(netLibTrapPrefsAppend);
netLibTrapOpenCount = Succ(netLibTrapIFMediaDown);
netLibTrapTracePrintF = Succ(netLibTrapOpenCount);
netLibTrapTracePutS = Succ(netLibTrapTracePrintF);
netLibTrapOpenIfCloseWait = Succ(netLibTrapTracePutS);
netLibTrapHandlePowerOff = Succ(netLibTrapOpenIfCloseWait);
netLibTrapConnectionRefresh = Succ(netLibTrapHandlePowerOff);
// Traps added after 1.0 release of NetLib
netLibTrapBitMove = Succ(netLibTrapConnectionRefresh);
netLibTrapBitPutFixed = Succ(netLibTrapBitMove);
netLibTrapBitGetFixed = Succ(netLibTrapBitPutFixed);
netLibTrapBitPutUIntV = Succ(netLibTrapBitGetFixed);
netLibTrapBitGetUIntV = Succ(netLibTrapBitPutUIntV);
netLibTrapBitPutIntV = Succ(netLibTrapBitGetUIntV);
netLibTrapBitGetIntV = Succ(netLibTrapBitPutIntV);
// Traps added after 2.0 release of NetLib
netLibOpenConfig_ = Succ(netLibTrapBitGetIntV);
netLibConfigMakeActive_ = Succ(netLibOpenConfig_);
netLibConfigList_ = Succ(netLibConfigMakeActive_);
netLibConfigIndexFromName_ = Succ(netLibConfigList_);
netLibConfigDelete_ = Succ(netLibConfigIndexFromName_);
netLibConfigSaveAs_ = Succ(netLibConfigDelete_);
netLibConfigRename_ = Succ(netLibConfigSaveAs_);
netLibConfigAliasSet_ = Succ(netLibConfigRename_);
netLibConfigAliasGet_ = Succ(netLibConfigAliasSet_);
// Traps added after 3.2 release of NetLib
netLibTrapScriptExecute = Succ(netLibConfigAliasGet_);
netLibTrapLast = Succ(netLibTrapScriptExecute);
(************************************************************
* Net Library procedures.
*************************************************************)
//--------------------------------------------------
// Library initialization, shutdown, sleep and wake
//--------------------------------------------------
function NetLibOpen(libRefnum: UInt16; var netIFErrsP: UInt16): Err; syscall sysLibTrapOpen;
function NetLibClose(libRefnum: UInt16; immediate: UInt16): Err; syscall sysLibTrapClose;
function NetLibSleep(libRefnum: UInt16): Err; syscall sysLibTrapSleep;
function NetLibWake(libRefnum: UInt16): Err; syscall sysLibTrapWake;
// This call forces the library to complete a close if it's
// currently in the close-wait state. Returns 0 if library is closed,
// Returns netErrFullyOpen if library is still open by some other task.
function NetLibFinishCloseWait(libRefnum: UInt16): Err; syscall netLibTrapFinishCloseWait;
// This call is for use by the Network preference panel only. It
// causes the NetLib to fully open if it's currently in the close-wait
// state. If it's not in the close wait state, it returns an error code
function NetLibOpenIfCloseWait(libRefnum: UInt16): Err; syscall netLibTrapOpenIfCloseWait;
// Get the open Count of the NetLib
function NetLibOpenCount(refNum: UInt16; var countP: UInt16): Err; syscall netLibTrapOpenCount;
// Give NetLib a chance to close the connection down in response
// to a power off event. Returns non-zero if power should not be
// turned off. EventP points to the event that initiated the power off
// which is either a keyDownEvent of the hardPowerChr or the autoOffChr.
// Don't include unless building for Viewer
function NetLibHandlePowerOff(refNum: UInt16; var eventP: SysEventType): Err; syscall netLibTrapHandlePowerOff;
// Check status or try and reconnect any interfaces which have come down.
// This call can be made by applications when they suspect that an interface
// has come down (like PPP or SLIP). NOTE: This call can display UI
// (if 'refresh' is true) so it MUST be called from the UI task.
function NetLibConnectionRefresh(refNum: UInt16; refresh: Boolean;
var allInterfacesUpP: UInt8; var netIFErrP: UInt16): Err; syscall netLibTrapConnectionRefresh;
//--------------------------------------------------
// Net address translation and conversion routines.
//--------------------------------------------------
// (The NetHToNS, NetHToNL, NetNToHS, and NetNToHL macros which used to be
// defined here are now defined in NetBitUtils.h. They can still be used
// by #including <NetMgr.h> (this file), because <NetBitUtils.h> is
// unconditionally included below.)
// convert host Int16 to network Int16
function NetHToNS(x: Int16): Int16;
// convert host long to network long
function NetHToNL(x: Int32): Int32;
// convert network Int16 to host Int16
function NetNToHS(x: Int16): Int16;
// convert network long to host long
function NetNToHL(x: Int32): Int32;
// Convert 32-bit IP address to ascii dotted decimal form. The Sockets glue
// macro inet_ntoa will pass the address of an application global string in
// spaceP.
function NetLibAddrINToA(libRefnum: UInt16; inet: NetIPAddr; spaceP: PChar): PChar; syscall netLibTrapAddrINToA;
// Convert a dotted decimal ascii string format of an IP address into
// a 32-bit value.
function NetLibAddrAToIN(libRefnum: UInt16; const a: PChar): NetIPAddr; syscall netLibTrapAddrAToIN;
//--------------------------------------------------
// Socket creation and option setting
//--------------------------------------------------
// Create a socket and return a refnum to it. Protocol is normally 0.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketOpen(libRefnum: UInt16; domain: NetSocketAddrEnum;
type_: NetSocketTypeEnum; protocol: Int16; timeout: Int32;
var errP: Err): NetSocketRef; syscall netLibTrapSocketOpen;
// Close a socket.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketClose(libRefnum: UInt16; socket: NetSocketRef; timeout: Int32;
var errP: Err): Int16; syscall netLibTrapSocketClose;
// Set a socket option. Level is usually netSocketOptLevelSocket. Option is one of
// netSocketOptXXXXX. OptValueP is a pointer to the new value and optValueLen is
// the length of the option value.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketOptionSet(libRefnum: UInt16; socket: NetSocketRef;
level: UInt16 {NetSocketOptLevelEnum}; option: UInt16 {NetSocketOptEnum};
optValueP: Pointer; optValueLen: UInt16;
timeout: Int32; var errP: Err): Int16; syscall netLibTrapSocketOptionSet;
// Get a socket option.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketOptionGet(libRefnum: UInt16; socket: NetSocketRef;
level: UInt16 {NetSocketOptLevelEnum}; option: UInt16 {NetSocketOptEnum};
optValueP: Pointer; var optValueLenP: UInt16;
timeout: Int32; var errP: Err): Int16; syscall netLibTrapSocketOptionGet;
//--------------------------------------------------
// Socket Control
//--------------------------------------------------
// Bind a source address and port number to a socket. This makes the
// socket accept incoming packets destined for the given socket address.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketBind(libRefnum: UInt16; socket: NetSocketRef;
sockAddrP: NetSocketAddrPtr; addrLen: Int16; timeout: Int32;
var errP: Err): Int16; syscall netLibTrapSocketBind;
// Connect to a remote socket. For a stream based socket (i.e. TCP), this initiates
// a 3-way handshake with the remote machine to establish a connection. For
// non-stream based socket, this merely specifies a destination address and port
// number for future outgoing packets from this socket.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketConnect(libRefnum: UInt16; socket: NetSocketRef;
sockAddrP: NetSocketAddrPtr; addrLen: Int16; timeout: Int32;
var errP: Err): Int16; syscall netLibTrapSocketConnect;
// Makes a socket ready to accept incoming connection requests. The queueLen
// specifies the max number of pending connection requests that will be enqueued
// while the server is busy handling other requests.
// Only applies to stream based (i.e. TCP) sockets.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketListen(libRefnum: UInt16; socket: NetSocketRef;
queueLen: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapSocketListen;
// Blocks the current process waiting for an incoming connection request. The socket
// must have previously be put into listen mode through the NetLibSocketListen call.
// On return, *sockAddrP will have the remote machines address and port number.
// Only applies to stream based (i.e. TCP) sockets.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketAccept(libRefnum: UInt16; socket: NetSocketRef;
sockAddrP: NetSocketAddrPtr; var addrLenP: Int16; timeout: Int32;
var errP: Err): Int16; syscall netLibTrapSocketAccept;
// Shutdown a connection in one or both directions.
// Only applies to stream based (i.e. TCP) sockets.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketShutdown(libRefnum: UInt16; socket: NetSocketRef;
direction: Int16 {NetSocketDirEnum}; timeout: Int32; var errP: Err): Int16; syscall netLibTrapSocketShutdown;
// Gets the local and remote addresses of a socket. Useful for TCP sockets that
// get dynamically bound at connect time.
// Returns 0 on success, -1 on error. If error, *errP gets filled in with error code.
function NetLibSocketAddr(libRefnum: UInt16; socketRef: NetSocketRef;
locAddrP: NetSocketAddrPtr; var locAddrLenP: Int16;
remAddrP: NetSocketAddrPtr; var remAddrLenP: Int16;
timeout: Int32; var errP: Err): Int16; syscall netLibTrapSocketAddr;
//--------------------------------------------------
// Sending and Receiving
//--------------------------------------------------
// Send data through a socket. The data is specified through the NetIOParamType
// structure.
// Flags is one or more of netMsgFlagXXX.
// Returns # of bytes sent on success, or -1 on error. If error, *errP gets filled
// in with error code.
function NetLibSendPB(libRefNum: UInt16; socket: NetSocketRef;
pbP: NetIOParamPtr; flags: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapSendPB;
// Send data through a socket. The data to send is passed in a single buffer,
// unlike NetLibSendPB. If toAddrP is not nil, the data will be sent to
// address *toAddrP.
// Flags is one or more of netMsgFlagXXX.
// Returns # of bytes sent on success, or -1 on error. If error, *errP gets filled
// in with error code.
function NetLibSend(libRefNum: UInt16; socket: NetSocketRef;
bufP: Pointer; bufLen, flags: UInt16;
toAddrP: Pointer; toLen: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapSend;
// Receive data from a socket. The data is gatthered into buffers specified in the
// NetIOParamType structure.
// Flags is one or more of netMsgFlagXXX.
// Timeout is max # of ticks to wait, or -1 for infinite, or 0 for none.
// Returns # of bytes received, or -1 on error. If error, *errP gets filled in
// with error code.
function NetLibReceivePB(libRefNum: UInt16; socket: NetSocketRef;
pbP: NetIOParamPtr; flags: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapReceivePB;
// Receive data from a socket. The data is read into a single buffer, unlike
// NetLibReceivePB. If fromAddrP is not nil, *fromLenP must be initialized to
// the size of the buffer that fromAddrP points to and on exit *fromAddrP will
// have the address of the sender in it.
// Flags is one or more of netMsgFlagXXX.
// Timeout is max # of ticks to wait, or -1 for infinite, or 0 for none.
// Returns # of bytes received, or -1 on error. If error, *errP gets filled in
// with error code.
function NetLibReceive(libRefNum: UInt16; socket: NetSocketRef;
bufP: Pointer; bufLen, flags: UInt16;
fromAddrP: Pointer; var fromLenP: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapReceive;
// Receive data from a socket directly into a (write-protected) Data Manager
// record.
// If fromAddrP is not nil, *fromLenP must be initialized to
// the size of the buffer that fromAddrP points to and on exit *fromAddrP will
// have the address of the sender in it.
// Flags is one or more of netMsgFlagXXX.
// Timeout is max # of ticks to wait, or -1 for infinite, or 0 for none.
// Returns # of bytes received, or -1 on error. If error, *errP gets filled in
// with error code.
function NetLibDmReceive(libRefNum: UInt16; socket: NetSocketRef;
recordP: Pointer; recordOffset: UInt32; rcvLen, flags: UInt16;
fromAddrP: Pointer; var fromLenP: UInt16; timeout: Int32; var errP: Err): Int16; syscall netLibTrapDmReceive;
//--------------------------------------------------
// Name Lookups
//--------------------------------------------------
function NetLibGetHostByName(libRefNum: UInt16; const nameP: PChar; bufP: NetHostInfoBufPtr; timeout: Int32; var errP: Err): NetHostInfoPtr; syscall netLibTrapGetHostByName;
function NetLibGetHostByAddr(libRefNum: UInt16; var addrP: UInt8; len, type_: UInt16;
bufP: NetHostInfoBufPtr; timeout: Int32; var errP: Err): NetHostInfoPtr; syscall netLibTrapGetHostByAddr;
function NetLibGetServByName(libRefNum: UInt16; const servNameP: PChar;
const protoNameP: PChar; bufP: NetServInfoBufPtr;
timeout: Int32; var errP: Err): NetServInfoPtr; syscall netLibTrapGetServByName;
// Looks up a mail exchange name and returns a list of hostnames for it. Caller
// must pass space for list of return names (hostNames), space for
// list of priorities for those hosts (priorities) and max # of names to
// return (maxEntries).
// Returns # of entries found, or -1 on error. If error, *errP gets filled in
// with error code.
function NetLibGetMailExchangeByName(libRefNum: UInt16; mailNameP: PChar;
maxEntries: UInt16; hostNames: Pointer{Char hostNames[][netDNSMaxDomainName+1]};
priorities: Pointer{UInt16 priorities[]};
timeout: Int32; var errP: Err): Int16; syscall netLibTrapGetMailExchangeByName;
//--------------------------------------------------
// Interface setup
//--------------------------------------------------
function NetLibIFGet(libRefNum: UInt16; index: UInt16; var ifCreatorP: UInt32; var ifInstanceP: UInt16): Err; syscall netLibTrapIFGet;
function NetLibIFAttach(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16; timeout: Int32): Err; syscall netLibTrapIFAttach;
function NetLibIFDetach(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16; timeout: Int32): Err; syscall netLibTrapIFDetach;
function NetLibIFUp(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16): Err; syscall netLibTrapIFUp;
function NetLibIFDown(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16; timeout: Int32): Err; syscall netLibTrapIFDown;
//--------------------------------------------------
// Settings
//--------------------------------------------------
// General settings
function NetLibSettingGet(libRefNum: UInt16; setting: UInt16 {NetSettingEnum}; valueP: Pointer; var valueLenP: UInt16): Err; syscall netLibTrapSettingGet;
function NetLibSettingSet(libRefNum: UInt16; setting: UInt16 {NetSettingEnum}; valueP: Pointer; valueLen: UInt16): Err; syscall netLibTrapSettingSet;
// Network interface specific settings.
function NetLibIFSettingGet(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16;
setting: UInt16 {NetIFSettingEnum}; valueP: Pointer; var valueLenP: UInt16): Err; syscall netLibTrapIFSettingGet;
function NetLibIFSettingSet(libRefNum: UInt16; ifCreator: UInt32; ifInstance: UInt16;
setting: UInt16 {NetIFSettingEnum}; valueP: Pointer; valueLen: UInt16): Err; syscall netLibTrapIFSettingSet;
//--------------------------------------------------
// System level
//--------------------------------------------------
function NetLibSelect(libRefNum: UInt16; width: UInt16; readFDs, writeFDs, exceptFDs: NetFDSetPtr;
timeout: Int32; var errP: Err): Int16; syscall netLibTrapSelect;
//--------------------------------------------------
// Debugging support
//--------------------------------------------------
function NetLibMaster(libRefNum: UInt16; cmd: UInt16; pbP: NetMasterPBPtr;
timeout: Int32): Err; syscall netLibTrapMaster;
{!!!
function NetLibTracePrintF(libRefNum: UInt16; const formatStr: PChar; ...): Err; syscall netLibTrapTracePrintF;
!!!}
function NetLibTracePutS(libRefNum: UInt16; strP: PChar): Err; syscall netLibTrapTracePutS;
//--------------------------------------------------
// Configuration Calls
//--------------------------------------------------
function NetLibOpenConfig(refNum: UInt16; configIndex: UInt16; openFlags: UInt32;
var netIFErrP: UInt16): Err; syscall netLibOpenConfig_;
function NetLibConfigMakeActive(refNum: UInt16; configIndex: UInt16): Err; syscall netLibConfigMakeActive_;
function NetLibConfigList(refNum: UInt16; nameArray: Pointer {NetConfigNameType nameArray[]};
var arrayEntriesP: UInt16): Err; syscall netLibConfigList_;
function NetLibConfigIndexFromName(refNum: UInt16; nameP: NetConfigNamePtr;
var indexP: UInt16): Err; syscall netLibConfigIndexFromName_;
function NetLibConfigDelete(refNum: UInt16; index: UInt16): Err; syscall netLibConfigDelete_;
function NetLibConfigSaveAs(refNum: UInt16; nameP: NetConfigNamePtr): Err; syscall netLibConfigSaveAs_;
function NetLibConfigRename(refNum: UInt16; index: UInt16; newNameP: NetConfigNamePtr): Err; syscall netLibConfigRename_;
function NetLibConfigAliasSet(refNum: UInt16; configIndex, aliasToIndex: UInt16): Err; syscall netLibConfigAliasSet_;
function NetLibConfigAliasGet(refNum: UInt16; aliasIndex: UInt16; var indexP: UInt16; var isAnotherAliasP: Boolean): Err; syscall netLibConfigAliasGet_;
implementation
uses SystemMgr, TimeMgr;
function NetNow: UInt32;
begin
NetNow := TimGetTicks * 1000 div sysTicksPerSecond;
end;
procedure netFDSet(n: UInt8; var p: NetFDSetType);
begin
p := p or (1 shl n);
end;
procedure nnetFDClr(n: UInt8; var p: NetFDSetType);
begin
p := p and not (1 shl n);
end;
function nnetFDIsSet(n: UInt8; var p: NetFDSetType): Boolean;
begin
nnetFDIsSet := (p and (1 shl n)) <> 0;
end;
procedure nnetFDZero(var p: NetFDSetType);
begin
p := 0;
end;
// convert host Int16 to network Int16
function NetHToNS(x: Int16): Int16;
begin
NetHToNS := x;
end;
// convert host long to network long
function NetHToNL(x: Int32): Int32;
begin
NetHToNL := x;
end;
// convert network Int16 to host Int16
function NetNToHS(x: Int16): Int16;
begin
NetNToHS := x;
end;
// convert network long to host long
function NetNToHL(x: Int32): Int32;
begin
NetNToHL := x;
end;
end.
|