AmendHub

Download

jcs

/

subtext

/

MacTCP.h

 

(View History)

jcs   *: Lots of little cleanup Latest amendment: 101 on 2022-05-15

1 /*
2 File: MacTCP.h
3
4 Contains: TCP Manager Interfaces.
5
6 Version: Technology: MacTCP 2.0.6
7 Package: Universal Interfaces 2.1ß1 in “MPW Prerelease” on ETO #17
8
9 Copyright: © 1984-1995 by Apple Computer, Inc.
10 All rights reserved.
11
12 Bugs?: If you find a problem with this file, use the Apple Bug Reporter
13 stack. Include the file and version information (from above)
14 in the problem description and send to:
15 Internet: apple.bugs@applelink.apple.com
16 AppleLink: APPLE.BUGS
17
18 */
19
20 #ifndef __MACTCP__
21 #define __MACTCP__
22
23
24 #ifndef __TYPES__
25 #include <Types.h>
26 #endif
27
28 #if 0
29 #ifndef __APPLETALK__
30 #include <AppleTalk.h>
31 #endif
32 #endif
33
34 enum {
35 kPascalStackBased = 0,
36 kCStackBased = 0,
37 kThinkCStackBased = 0
38 };
39 #define SIZE_CODE(size) (0)
40 #define RESULT_SIZE(sizeCode) (0)
41 #define STACK_ROUTINE_PARAMETER(whichParam, sizeCode) (0)
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47 #if PRAGMA_ALIGN_SUPPORTED
48 #pragma options align=mac68k
49 #endif
50
51 #if PRAGMA_IMPORT_SUPPORTED
52 #pragma import on
53 #endif
54
55 /*
56 Developer Notes:
57 0. This MacTCP header replaces what used to be defined in the following header files
58 MacTCPCommonTypes.h
59 GetMyIPAddr.h
60 MiscIPPB.h
61 TCPPB.h
62 UDPPB.h
63
64 When the various control calls are made to the ip driver, you must set up a
65 NewRoutineDescriptor for every non-nil completion routine and/or notifyProc parameter.
66 Otherwise, the 68K driver code, will not correctly call your routine.
67 1. For ipctlGetAddr Control calls, use NewGetIPIOCompletionProc
68 to set up a GetIPIOCompletionUPP universal procptr to pass as
69 the ioCompletion parameter.
70 2. For the ipctlEchoICMP and ipctlLAPStats Control calls, use
71 NewIPIOCompletion to set up a IPIOCompletionUPP universal procptr
72 to pass in the ioCompletion field of the parameter block.
73 3. For TCPCreatePB Control calls, use NewTCPNotifyProc to set up a
74 TCPNotifyUPP universal procptr to pass in the notifyProc field
75 of the parameter block
76 4. For all of the TCP Control calls using the TCPiopb parameter block,
77 use NewTCPIOCompletionProc to set up a TCPIOCompletionUPP
78 universal procptr to pass in the ioCompletion field of the paramter
79 block.
80 5. For UDBCreatePB Control calls, use NewUDPNotifyProc to set up a
81 UDPNotifyUPP universal procptr to pass in the notifyProc field
82 of the parameter block
83 6. For all of the UDP Control calls using the UDPiopb parameter block,
84 use NewUDPIOCompletionProc to set up a UDPIOCompletionUPP
85 universal procptr to pass in the ioCompletion field of the paramter
86 block.
87 7. For all calls implementing a notifyProc or ioCompletion routine
88 which was set up using a NewTCPRoutineProc call, do not call
89 DisposeRoutineSDescriptor on the universal procptr until
90 after the completion or notify proc has completed.
91 */
92 /* MacTCP return Codes in the range -23000 through -23049 */
93
94 enum {
95 inProgress = 1, /* I/O in progress */
96 ipBadLapErr = -23000, /* bad network configuration */
97 ipBadCnfgErr = -23001, /* bad IP configuration error */
98 ipNoCnfgErr = -23002, /* missing IP or LAP configuration error */
99 ipLoadErr = -23003, /* error in MacTCP load */
100 ipBadAddr = -23004, /* error in getting address */
101 connectionClosing = -23005, /* connection is closing */
102 invalidLength = -23006,
103 connectionExists = -23007, /* request conflicts with existing connection */
104 connectionDoesntExist = -23008, /* connection does not exist */
105 insufficientResources = -23009, /* insufficient resources to perform request */
106 invalidStreamPtr = -23010,
107 streamAlreadyOpen = -23011,
108 connectionTerminated = -23012,
109 invalidBufPtr = -23013,
110 invalidRDS = -23014,
111 invalidWDS = -23014,
112 openFailed = -23015,
113 commandTimeout = -23016,
114 duplicateSocket = -23017
115 };
116
117 /* Error codes from internal IP functions */
118 enum {
119 ipDontFragErr = -23032, /* Packet too large to send w/o fragmenting */
120 ipDestDeadErr = -23033, /* destination not responding */
121 icmpEchoTimeoutErr = -23035, /* ICMP echo timed-out */
122 ipNoFragMemErr = -23036, /* no memory to send fragmented pkt */
123 ipRouteErr = -23037, /* can't route packet off-net */
124 nameSyntaxErr = -23041,
125 cacheFault = -23042,
126 noResultProc = -23043,
127 noNameServer = -23044,
128 authNameErr = -23045,
129 noAnsErr = -23046,
130 dnrErr = -23047,
131 outOfMemory = -23048
132 };
133
134 enum {
135 BYTES_16WORD = 2, /* bytes per = 16, bit ip word */
136 BYTES_32WORD = 4, /* bytes per = 32, bit ip word */
137 BYTES_64WORD = 8 /* bytes per = 64, bit ip word */
138 };
139
140 /* 8-bit quantity */
141 typedef unsigned char UInt8;
142 typedef signed char SInt8;
143 typedef UInt8 b_8;
144
145 /* 16-bit quantity */
146 typedef unsigned short UInt16;
147 typedef signed short SInt16;
148 typedef UInt16 b_16;
149
150 /* 32-bit quantity */
151 typedef unsigned long UInt32;
152 typedef signed long SInt32;
153 typedef UInt32 b_32;
154
155 /* IP address is 32-bits */
156 typedef b_32 ip_addr;
157
158 struct ip_addrbytes {
159 union {
160 b_32 addr;
161 UInt8 byte[4];
162 } a;
163 };
164 typedef struct ip_addrbytes ip_addrbytes;
165
166 struct wdsEntry {
167 unsigned short length; /* length of buffer */
168 Ptr ptr; /* pointer to buffer */
169 };
170 typedef struct wdsEntry wdsEntry;
171
172 struct rdsEntry {
173 unsigned short length; /* length of buffer */
174 Ptr ptr; /* pointer to buffer */
175 };
176 typedef struct rdsEntry rdsEntry;
177
178 typedef unsigned long BufferPtr;
179
180 typedef unsigned long StreamPtr;
181
182
183 enum {
184 netUnreach = 0,
185 hostUnreach = 1,
186 protocolUnreach = 2,
187 portUnreach = 3,
188 fragReqd = 4,
189 sourceRouteFailed = 5,
190 timeExceeded = 6,
191 parmProblem = 7,
192 missingOption = 8,
193 lastICMPMsgType = 32767
194 };
195
196 typedef unsigned short ICMPMsgType;
197
198 typedef b_16 ip_port;
199
200 struct ICMPReport {
201 StreamPtr streamPtr;
202 ip_addr localHost;
203 ip_port localPort;
204 ip_addr remoteHost;
205 ip_port remotePort;
206 short reportType;
207 unsigned short optionalAddlInfo;
208 unsigned long optionalAddlInfoPtr;
209 };
210 typedef struct ICMPReport ICMPReport;
211
212 /* csCode to get our IP address */
213
214 enum {
215 ipctlGetAddr = 15
216 };
217
218 typedef void (*GetIPIOCompletionProcPtr)(struct GetAddrParamBlock *iopb);
219
220 #if GENERATINGCFM
221 typedef UniversalProcPtr GetIPIOCompletionUPP;
222 #else
223 typedef GetIPIOCompletionProcPtr GetIPIOCompletionUPP;
224 #endif
225
226 #define GetIPParamBlockHeader \
227 struct QElem* qLink; \
228 short qType; \
229 short ioTrap; \
230 Ptr ioCmdAddr; \
231 GetIPIOCompletionUPP ioCompletion; \
232 OSErr ioResult; \
233 StringPtr ioNamePtr; \
234 short ioVRefNum; \
235 short ioCRefNum; \
236 short csCode
237 struct GetAddrParamBlock {
238 struct QElem *qLink;
239 short qType;
240 short ioTrap;
241 Ptr ioCmdAddr;
242 GetIPIOCompletionUPP ioCompletion;
243 OSErr ioResult;
244 StringPtr ioNamePtr;
245 short ioVRefNum;
246 short ioCRefNum;
247 short csCode; /* standard I/O header */
248 ip_addr ourAddress; /* our IP address */
249 long ourNetMask; /* our IP net mask */
250 };
251 typedef struct GetAddrParamBlock GetAddrParamBlock;
252
253 /* control codes */
254
255 enum {
256 ipctlEchoICMP = 17, /* send icmp echo */
257 ipctlLAPStats = 19 /* get lap stats */
258 };
259
260 typedef void (*IPIOCompletionProcPtr)(struct ICMPParamBlock *iopb);
261
262 #if GENERATINGCFM
263 typedef UniversalProcPtr IPIOCompletionUPP;
264 #else
265 typedef IPIOCompletionProcPtr IPIOCompletionUPP;
266 #endif
267
268 #define IPParamBlockHeader \
269 struct QElem* qLink; \
270 short qType; \
271 short ioTrap; \
272 Ptr ioCmdAddr; \
273 IPIOCompletionUPP ioCompletion; \
274 OSErr ioResult; \
275 StringPtr ioNamePtr; \
276 short ioVRefNum; \
277 short ioCRefNum; \
278 short csCode
279 struct ICMPParamBlock {
280 struct QElem *qLink;
281 short qType;
282 short ioTrap;
283 Ptr ioCmdAddr;
284 IPIOCompletionUPP ioCompletion;
285 OSErr ioResult;
286 StringPtr ioNamePtr;
287 short ioVRefNum;
288 short ioCRefNum;
289 short csCode; /* standard I/O header */
290 short params[11];
291 struct {
292 unsigned long echoRequestOut; /* time in ticks of when the echo request went out */
293 unsigned long echoReplyIn; /* time in ticks of when the reply was received */
294 struct rdsEntry echoedData; /* data received in responce */
295 Ptr options;
296 unsigned long userDataPtr;
297 } icmpEchoInfo;
298 };
299 typedef pascal void (*ICMPEchoNotifyProcPtr)(struct ICMPParamBlock *iopb);
300
301 #if GENERATINGCFM
302 typedef UniversalProcPtr ICMPEchoNotifyUPP;
303 #else
304 typedef ICMPEchoNotifyProcPtr ICMPEchoNotifyUPP;
305 #endif
306
307 struct IPParamBlock {
308 struct QElem *qLink;
309 short qType;
310 short ioTrap;
311 Ptr ioCmdAddr;
312 IPIOCompletionUPP ioCompletion;
313 OSErr ioResult;
314 StringPtr ioNamePtr;
315 short ioVRefNum;
316 short ioCRefNum;
317 short csCode; /* standard I/O header */
318 union {
319 struct {
320 ip_addr dest; /* echo to IP address */
321 wdsEntry data;
322 short timeout;
323 Ptr options;
324 unsigned short optLength;
325 ICMPEchoNotifyUPP icmpCompletion;
326 unsigned long userDataPtr;
327 } IPEchoPB;
328 struct {
329 struct LAPStats *lapStatsPtr;
330 } LAPStatsPB;
331 } csParam;
332 };
333 union LAPStatsAddrXlation {
334 struct arp_entry *arp_table;
335 struct nbp_entry *nbp_table;
336 };
337 struct LAPStats {
338 short ifType;
339 char *ifString;
340 short ifMaxMTU;
341 long ifSpeed;
342 short ifPhyAddrLength;
343 char *ifPhysicalAddress;
344 union LAPStatsAddrXlation AddrXlation;
345 short slotNumber;
346 };
347 typedef struct LAPStats LAPStats;
348
349 #ifdef __APPLETALK__
350 struct nbp_entry {
351 ip_addr ip_address; /* IP address */
352 AddrBlock at_address; /* matching AppleTalk address */
353 Boolean gateway; /* TRUE if entry for a gateway */
354 Boolean valid; /* TRUE if LAP address is valid */
355 Boolean probing; /* TRUE if NBP lookup pending */
356 SInt8 afiller; /* Filler for proper byte alignment */
357 long age; /* ticks since cache entry verified */
358 long access; /* ticks since last access */
359 SInt8 filler[116]; /* for internal use only !!! */
360 };
361 #endif
362 struct Enet_addr {
363 b_16 en_hi;
364 b_32 en_lo;
365 };
366 typedef struct Enet_addr Enet_addr;
367
368 struct arp_entry {
369 short age; /* cache aging field */
370 b_16 protocol; /* Protocol type */
371 ip_addr ip_address; /* IP address */
372 Enet_addr en_address; /* matching Ethernet address */
373 };
374 typedef struct arp_entry arp_entry;
375
376 /* number of ARP table entries */
377
378 enum {
379 ARP_TABLE_SIZE = 20
380 };
381
382 enum {
383 NBP_TABLE_SIZE = 20, /* number of NBP table entries */
384 NBP_MAX_NAME_SIZE = 16 + 10 + 2
385 };
386
387 /* Command codes */
388 enum {
389 TCPCreate = 30,
390 TCPPassiveOpen = 31,
391 TCPActiveOpen = 32,
392 TCPSend = 34,
393 TCPNoCopyRcv = 35,
394 TCPRcvBfrReturn = 36,
395 TCPRcv = 37,
396 TCPClose = 38,
397 TCPAbort = 39,
398 TCPStatus = 40,
399 TCPExtendedStat = 41,
400 TCPRelease = 42,
401 TCPGlobalInfo = 43,
402 TCPCtlMax = 49
403 };
404
405 enum {
406 TCPClosing = 1,
407 TCPULPTimeout = 2,
408 TCPTerminate = 3,
409 TCPDataArrival = 4,
410 TCPUrgent = 5,
411 TCPICMPReceived = 6,
412 lastEvent = 32767
413 };
414
415 typedef unsigned short TCPEventCode;
416
417
418 enum {
419 TCPRemoteAbort = 2,
420 TCPNetworkFailure = 3,
421 TCPSecPrecMismatch = 4,
422 TCPULPTimeoutTerminate = 5,
423 TCPULPAbort = 6,
424 TCPULPClose = 7,
425 TCPServiceError = 8,
426 lastReason = 32767
427 };
428
429 typedef unsigned short TCPTerminationReason;
430
431 typedef pascal void (*TCPNotifyProcPtr)(StreamPtr tcpStream, unsigned short eventCode, Ptr userDataPtr, unsigned short terminReason, struct ICMPReport *icmpMsg);
432
433 #if GENERATINGCFM
434 typedef UniversalProcPtr TCPNotifyUPP;
435 #else
436 typedef TCPNotifyProcPtr TCPNotifyUPP;
437 #endif
438
439 typedef unsigned short tcp_port;
440
441 /* ValidityFlags */
442
443 enum {
444 timeoutValue = 0x80,
445 timeoutAction = 0x40,
446 typeOfService = 0x20,
447 precedence = 0x10
448 };
449
450 /* TOSFlags */
451 enum {
452 lowDelay = 0x01,
453 throughPut = 0x02,
454 reliability = 0x04
455 };
456
457 struct TCPCreatePB {
458 Ptr rcvBuff;
459 unsigned long rcvBuffLen;
460 TCPNotifyUPP notifyProc;
461 Ptr userDataPtr;
462 };
463 typedef struct TCPCreatePB TCPCreatePB;
464
465 struct TCPOpenPB {
466 SInt8 ulpTimeoutValue;
467 SInt8 ulpTimeoutAction;
468 SInt8 validityFlags;
469 SInt8 commandTimeoutValue;
470 ip_addr remoteHost;
471 tcp_port remotePort;
472 ip_addr localHost;
473 tcp_port localPort;
474 SInt8 tosFlags;
475 SInt8 precedence;
476 Boolean dontFrag;
477 SInt8 timeToLive;
478 SInt8 security;
479 SInt8 optionCnt;
480 SInt8 options[40];
481 Ptr userDataPtr;
482 };
483 typedef struct TCPOpenPB TCPOpenPB;
484
485 struct TCPSendPB {
486 SInt8 ulpTimeoutValue;
487 SInt8 ulpTimeoutAction;
488 SInt8 validityFlags;
489 Boolean pushFlag;
490 Boolean urgentFlag;
491 SInt8 filler; /* Filler for proper byte alignment */
492 Ptr wdsPtr;
493 unsigned long sendFree;
494 unsigned short sendLength;
495 Ptr userDataPtr;
496 };
497 typedef struct TCPSendPB TCPSendPB;
498
499 /* for receive and return rcv buff calls */
500 /* Note: the filler in the following structure is in a different location than */
501 /* that specified in the Programmer's Guide. */
502 struct TCPReceivePB {
503 SInt8 commandTimeoutValue;
504 Boolean markFlag;
505 Boolean urgentFlag;
506 SInt8 filler; /* Filler for proper byte alignment */
507 Ptr rcvBuff;
508 unsigned short rcvBuffLen;
509 Ptr rdsPtr;
510 unsigned short rdsLength;
511 unsigned short secondTimeStamp;
512 Ptr userDataPtr;
513 };
514 typedef struct TCPReceivePB TCPReceivePB;
515
516 struct TCPClosePB {
517 SInt8 ulpTimeoutValue;
518 SInt8 ulpTimeoutAction;
519 SInt8 validityFlags;
520 SInt8 filler; /* Filler for proper byte alignment */
521 Ptr userDataPtr;
522 };
523 typedef struct TCPClosePB TCPClosePB;
524
525 struct HistoBucket {
526 unsigned short value;
527 unsigned long counter;
528 };
529 typedef struct HistoBucket HistoBucket;
530
531
532 enum {
533 NumOfHistoBuckets = 7
534 };
535
536 enum {
537 ConnectionStateClosed = 0,
538 ConnectionStateListening = 2,
539 ConnectionStateSYNReceived = 4,
540 ConnectionStateSYNSent = 6,
541 ConnectionStateEstablished = 8,
542 ConnectionStateFINWait1 = 10,
543 ConnectionStateFINWait2 = 12,
544 ConnectionStateCloseWait = 14,
545 ConnectionStateClosing = 16,
546 ConnectionStateLastAck = 18,
547 ConnectionStateTimeWait = 20
548 };
549
550 struct TCPConnectionStats {
551 unsigned long dataPktsRcvd;
552 unsigned long dataPktsSent;
553 unsigned long dataPktsResent;
554 unsigned long bytesRcvd;
555 unsigned long bytesRcvdDup;
556 unsigned long bytesRcvdPastWindow;
557 unsigned long bytesSent;
558 unsigned long bytesResent;
559 unsigned short numHistoBuckets;
560 struct HistoBucket sentSizeHisto[NumOfHistoBuckets];
561 unsigned short lastRTT;
562 unsigned short tmrSRTT;
563 unsigned short rttVariance;
564 unsigned short tmrRTO;
565 SInt8 sendTries;
566 SInt8 sourchQuenchRcvd;
567 };
568 typedef struct TCPConnectionStats TCPConnectionStats;
569
570 struct TCPStatusPB {
571 SInt8 ulpTimeoutValue;
572 SInt8 ulpTimeoutAction;
573 long unused;
574 ip_addr remoteHost;
575 tcp_port remotePort;
576 ip_addr localHost;
577 tcp_port localPort;
578 SInt8 tosFlags;
579 SInt8 precedence;
580 SInt8 connectionState;
581 SInt8 filler; /* Filler for proper byte alignment */
582 unsigned short sendWindow;
583 unsigned short rcvWindow;
584 unsigned short amtUnackedData;
585 unsigned short amtUnreadData;
586 Ptr securityLevelPtr;
587 unsigned long sendUnacked;
588 unsigned long sendNext;
589 unsigned long congestionWindow;
590 unsigned long rcvNext;
591 unsigned long srtt;
592 unsigned long lastRTT;
593 unsigned long sendMaxSegSize;
594 struct TCPConnectionStats *connStatPtr;
595 Ptr userDataPtr;
596 };
597 typedef struct TCPStatusPB TCPStatusPB;
598
599 struct TCPAbortPB {
600 Ptr userDataPtr;
601 };
602 typedef struct TCPAbortPB TCPAbortPB;
603
604 struct TCPParam {
605 unsigned long tcpRtoA;
606 unsigned long tcpRtoMin;
607 unsigned long tcpRtoMax;
608 unsigned long tcpMaxSegSize;
609 unsigned long tcpMaxConn;
610 unsigned long tcpMaxWindow;
611 };
612 typedef struct TCPParam TCPParam;
613
614 struct TCPStats {
615 unsigned long tcpConnAttempts;
616 unsigned long tcpConnOpened;
617 unsigned long tcpConnAccepted;
618 unsigned long tcpConnClosed;
619 unsigned long tcpConnAborted;
620 unsigned long tcpOctetsIn;
621 unsigned long tcpOctetsOut;
622 unsigned long tcpOctetsInDup;
623 unsigned long tcpOctetsRetrans;
624 unsigned long tcpInputPkts;
625 unsigned long tcpOutputPkts;
626 unsigned long tcpDupPkts;
627 unsigned long tcpRetransPkts;
628 };
629 typedef struct TCPStats TCPStats;
630
631 typedef StreamPtr *StreamPPtr;
632
633 struct TCPGlobalInfoPB {
634 struct TCPParam *tcpParamPtr;
635 struct TCPStats *tcpStatsPtr;
636 StreamPPtr tcpCDBTable[1];
637 Ptr userDataPtr;
638 unsigned short maxTCPConnections;
639 };
640 typedef struct TCPGlobalInfoPB TCPGlobalInfoPB;
641
642 typedef void (*TCPIOCompletionProcPtr)(struct TCPiopb *iopb);
643
644 #if GENERATINGCFM
645 typedef UniversalProcPtr TCPIOCompletionUPP;
646 #else
647 typedef TCPIOCompletionProcPtr TCPIOCompletionUPP;
648 #endif
649
650 struct TCPiopb {
651 SInt8 fill12[12];
652 TCPIOCompletionUPP ioCompletion;
653 short ioResult;
654 Ptr ioNamePtr;
655 short ioVRefNum;
656 short ioCRefNum;
657 short csCode;
658 StreamPtr tcpStream;
659 union {
660 struct TCPCreatePB create;
661 struct TCPOpenPB open;
662 struct TCPSendPB send;
663 struct TCPReceivePB receive;
664 struct TCPClosePB close;
665 struct TCPAbortPB abort;
666 struct TCPStatusPB status;
667 struct TCPGlobalInfoPB globalInfo;
668 } csParam;
669 };
670 typedef struct TCPiopb TCPiopb;
671
672
673 enum {
674 UDPCreate = 20,
675 UDPRead = 21,
676 UDPBfrReturn = 22,
677 UDPWrite = 23,
678 UDPRelease = 24,
679 UDPMaxMTUSize = 25,
680 UDPStatus = 26,
681 UDPMultiCreate = 27,
682 UDPMultiSend = 28,
683 UDPMultiRead = 29,
684 UDPCtlMax = 29
685 };
686
687 enum {
688 UDPDataArrival = 1,
689 UDPICMPReceived = 2,
690 lastUDPEvent = 32767
691 };
692
693 typedef unsigned short UDPEventCode;
694
695 typedef pascal void (*UDPNotifyProcPtr)(StreamPtr udpStream, unsigned short eventCode, Ptr userDataPtr, struct ICMPReport *icmpMsg);
696
697 #if GENERATINGCFM
698 typedef UniversalProcPtr UDPNotifyUPP;
699 #else
700 typedef UDPNotifyProcPtr UDPNotifyUPP;
701 #endif
702
703 typedef unsigned short udp_port;
704
705 /* for create and release calls */
706 struct UDPCreatePB {
707 Ptr rcvBuff;
708 unsigned long rcvBuffLen;
709 UDPNotifyUPP notifyProc;
710 unsigned short localPort;
711 Ptr userDataPtr;
712 udp_port endingPort;
713 };
714 typedef struct UDPCreatePB UDPCreatePB;
715
716 struct UDPSendPB {
717 unsigned short reserved;
718 ip_addr remoteHost;
719 udp_port remotePort;
720 Ptr wdsPtr;
721 Boolean checkSum;
722 SInt8 filler; /* Filler for proper byte alignment */
723 unsigned short sendLength;
724 Ptr userDataPtr;
725 udp_port localPort;
726 };
727 typedef struct UDPSendPB UDPSendPB;
728
729 /* for receive and buffer return calls */
730 struct UDPReceivePB {
731 unsigned short timeOut;
732 ip_addr remoteHost;
733 udp_port remotePort;
734 Ptr rcvBuff;
735 unsigned short rcvBuffLen;
736 unsigned short secondTimeStamp;
737 Ptr userDataPtr;
738 ip_addr destHost; /* only for use with multi rcv */
739 udp_port destPort; /* only for use with multi rcv */
740 };
741 typedef struct UDPReceivePB UDPReceivePB;
742
743 struct UDPMTUPB {
744 unsigned short mtuSize;
745 ip_addr remoteHost;
746 Ptr userDataPtr;
747 };
748 typedef struct UDPMTUPB UDPMTUPB;
749
750 typedef struct UDPiopb UDPiopb;
751 typedef void (*UDPIOCompletionProcPtr)(struct UDPiopb *iopb);
752
753 #if GENERATINGCFM
754 typedef UniversalProcPtr UDPIOCompletionUPP;
755 #else
756 typedef UDPIOCompletionProcPtr UDPIOCompletionUPP;
757 #endif
758
759 struct UDPiopb {
760 SInt8 fill12[12];
761 UDPIOCompletionUPP ioCompletion;
762 short ioResult;
763 Ptr ioNamePtr;
764 short ioVRefNum;
765 short ioCRefNum;
766 short csCode;
767 StreamPtr udpStream;
768 union {
769 struct UDPCreatePB create;
770 struct UDPSendPB send;
771 struct UDPReceivePB receive;
772 struct UDPMTUPB mtu;
773 } csParam;
774 };
775
776 enum {
777 uppGetIPIOCompletionProcInfo = kCStackBased
778 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct GetAddrParamBlock*))),
779 uppIPIOCompletionProcInfo = kCStackBased
780 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct ICMPParamBlock*))),
781 uppICMPEchoNotifyProcInfo = kPascalStackBased
782 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct ICMPParamBlock*))),
783 uppTCPNotifyProcInfo = kPascalStackBased
784 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
785 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
786 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
787 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(unsigned short)))
788 | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(struct ICMPReport*))),
789 uppTCPIOCompletionProcInfo = kCStackBased
790 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct TCPiopb*))),
791 uppUDPNotifyProcInfo = kPascalStackBased
792 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(StreamPtr)))
793 | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(unsigned short)))
794 | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Ptr)))
795 | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(struct ICMPReport*))),
796 uppUDPIOCompletionProcInfo = kCStackBased
797 | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(struct UDPiopb*)))
798 };
799
800 #if GENERATINGCFM
801 #define NewGetIPIOCompletionProc(userRoutine) \
802 (GetIPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, GetCurrentArchitecture())
803 #define NewIPIOCompletionProc(userRoutine) \
804 (IPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppIPIOCompletionProcInfo, GetCurrentArchitecture())
805 #define NewICMPEchoNotifyProc(userRoutine) \
806 (ICMPEchoNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, GetCurrentArchitecture())
807 #define NewTCPNotifyProc(userRoutine) \
808 (TCPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPNotifyProcInfo, GetCurrentArchitecture())
809 #define NewTCPIOCompletionProc(userRoutine) \
810 (TCPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, GetCurrentArchitecture())
811 #define NewUDPNotifyProc(userRoutine) \
812 (UDPNotifyUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPNotifyProcInfo, GetCurrentArchitecture())
813 #define NewUDPIOCompletionProc(userRoutine) \
814 (UDPIOCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, GetCurrentArchitecture())
815 #else
816 #define NewGetIPIOCompletionProc(userRoutine) \
817 ((GetIPIOCompletionUPP) (userRoutine))
818 #define NewIPIOCompletionProc(userRoutine) \
819 ((IPIOCompletionUPP) (userRoutine))
820 #define NewICMPEchoNotifyProc(userRoutine) \
821 ((ICMPEchoNotifyUPP) (userRoutine))
822 #define NewTCPNotifyProc(userRoutine) \
823 ((TCPNotifyUPP) (userRoutine))
824 #define NewTCPIOCompletionProc(userRoutine) \
825 ((TCPIOCompletionUPP) (userRoutine))
826 #define NewUDPNotifyProc(userRoutine) \
827 ((UDPNotifyUPP) (userRoutine))
828 #define NewUDPIOCompletionProc(userRoutine) \
829 ((UDPIOCompletionUPP) (userRoutine))
830 #endif
831
832 #if GENERATINGCFM
833 #define CallGetIPIOCompletionProc(userRoutine, iopb) \
834 CallUniversalProc((UniversalProcPtr)(userRoutine), uppGetIPIOCompletionProcInfo, (iopb))
835 #define CallIPIOCompletionProc(userRoutine, iopb) \
836 CallUniversalProc((UniversalProcPtr)(userRoutine), uppIPIOCompletionProcInfo, (iopb))
837 #define CallICMPEchoNotifyProc(userRoutine, iopb) \
838 CallUniversalProc((UniversalProcPtr)(userRoutine), uppICMPEchoNotifyProcInfo, (iopb))
839 #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg) \
840 CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPNotifyProcInfo, (tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
841 #define CallTCPIOCompletionProc(userRoutine, iopb) \
842 CallUniversalProc((UniversalProcPtr)(userRoutine), uppTCPIOCompletionProcInfo, (iopb))
843 #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg) \
844 CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPNotifyProcInfo, (udpStream), (eventCode), (userDataPtr), (icmpMsg))
845 #define CallUDPIOCompletionProc(userRoutine, iopb) \
846 CallUniversalProc((UniversalProcPtr)(userRoutine), uppUDPIOCompletionProcInfo, (iopb))
847 #else
848 #define CallGetIPIOCompletionProc(userRoutine, iopb) \
849 (*(userRoutine))((iopb))
850 #define CallIPIOCompletionProc(userRoutine, iopb) \
851 (*(userRoutine))((iopb))
852 #define CallICMPEchoNotifyProc(userRoutine, iopb) \
853 (*(userRoutine))((iopb))
854 #define CallTCPNotifyProc(userRoutine, tcpStream, eventCode, userDataPtr, terminReason, icmpMsg) \
855 (*(userRoutine))((tcpStream), (eventCode), (userDataPtr), (terminReason), (icmpMsg))
856 #define CallTCPIOCompletionProc(userRoutine, iopb) \
857 (*(userRoutine))((iopb))
858 #define CallUDPNotifyProc(userRoutine, udpStream, eventCode, userDataPtr, icmpMsg) \
859 (*(userRoutine))((udpStream), (eventCode), (userDataPtr), (icmpMsg))
860 #define CallUDPIOCompletionProc(userRoutine, iopb) \
861 (*(userRoutine))((iopb))
862 #endif
863
864
865 #if PRAGMA_IMPORT_SUPPORTED
866 #pragma import off
867 #endif
868
869 #if PRAGMA_ALIGN_SUPPORTED
870 #pragma options align=reset
871 #endif
872
873 #ifdef __cplusplus
874 }
875 #endif
876
877 #endif /* __MACTCP__ */