MacTCP.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:36k
源码类别:

多媒体编程

开发平台:

Visual C++

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