Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking /
Chapter 6 - AppleTalk Transaction Protocol (ATP)


Summary of ATP

Pascal Summary

Constants

CONST
   {csCodes}
   nSendRequest         = 248;         {send request using a specific socket}
   relRspCB             = 249;         {release RspCB}
   closeATPSkt          = 250;         {close ATP socket}
   addResponse          = 251;         {add response}
   sendResponse         = 252;         {send response}
   getRequest           = 253;         {get request}
   openATPSkt           = 254;         {open ATP socket}
   sendRequest          = 255;         {send request}
   relTCB               = 256;         {release TCB}
   killGetReq           = 257;         {kill getRequest}
   killSendReq          = 258;         {kill sendRequest}
   killAllGetReq        = 259;         {kill all getRequests for a socket}
   {ATP flags}
   atpXOvalue              = 32;       {ATP exactly-once bit}
   atpEOMvalue             = 16;       {ATP end-of-message bit}
   atpSTSvalue             = 8;        {ATP send-transmission-status bit}
   atpTIDValidvalue        = 2;        {ATP trans. ID valid bit}
   atpSendChkvalue         = 1;        {ATP send checksum bit}

Data Types

The Buffer Data Structure

TYPE  BDSElement = 
   RECORD
      buffSize:   Integer;
      buffPtr:    Ptr;
      dataSize:   Integer;
      userBytes:  LongInt;
   END;
BDSType = ARRAY[0..7] OF BDSElement;
BDSPtr = ^BDSType;
BitMapType = PACKED ARRAY[0..7] OF Boolean;

The Address Block Record

TYPE AddrBlock = 
   PACKED RECORD
      aNet:          Integer;          {network number}
      aNode:         Byte;             {node ID}
      aSocket:       Byte;             {socket number}
   END;

The ATP Parameter Block

TYPE ATPParamBlock = 
   PACKED RECORD
      qLink:         QElemPtr;         {next queue entry}
      qType:         Integer;          {queue type}
      ioTrap:        Integer;          {routine trap}
      ioCmdAddr:     Ptr;              {routine address}
      ioCompletion:  ProcPtr;          {completion routine}
      ioResult:      OSErr;            {result code}
      userData:      Longint;          {ATP user bytes}
      reqTID:        Integer;          {request transaction ID}
      ioRefNum:      Integer;          {driver reference number}
      csCode:        Integer;          {call command code }
                                       { automatically set}
      atpSocket:     Byte;             {currBitMap or socket number}
      CASE MPPParmType OF 
         SendRequestParm,
         SendResponseParm,
         GetRequestParm,
         AddResponseParm,
         KillSendReqParm:
            (atpFlags:        Byte;    {control information}
            addrBlock:        AddrBlock;  
                                       {source/dest. socket address}
            reqLength:        Integer; {request/response length}
            reqPointer:       Ptr;     {ptr to request/response data}
            bdsPointer:       Ptr;     {ptr to response BDS}
         CASE MPPParmType OF
            SendRequestParm:
               (numOfBuffs:   Byte;    {number of responses expected}
               timeOutVal:    Byte;    {timeout interval}
               numOfResps:    Byte;    {number of responses }
                                       { actually received}
               retryCount:    Byte;    {number of retries}
               intBuff:       Integer; {used internally for PNSendRequest}
               TRelTime:      Byte);   {TRelease time for extended }
                                       { send request}
            SendResponseParm:
               (filler0:      Byte;    {numOfBuffs}
               bdsSize:       Byte;    {number of BDS elements}
               transID:       Integer);{transaction ID}
            GetRequestParm:
               (bitMap:       Byte;    {bitmap}
               filler1:       Byte);
            AddResponseParm:
               (rspNum:       Byte;    {sequence number}
               filler2:       Byte);
            KillSendReqParm:
               (aKillQEl:     Ptr));   {pointer to queue element to cancel}
   END;

ATPPBPtr = ^ATPParamBlock;

Routines

Sending an ATP Request

FUNCTION PSendRequest(thePBPtr: ATPPBPt; async: Boolean): OSErr;
FUNCTION PNSendRequest(thePBPtr: ATPPBPtr; async: Boolean): OSErr;

Opening and Closing an ATP Socket

FUNCTION POpenATPSkt(thePBptr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION PCloseATPSkt(thePBPtr: ATPPBPtr; async: Boolean): OSErr;

Setting Up a Socket to Listen for Requests

FUNCTION PGetRequest(thePBPtr: ATPPBPtr; async: Boolean): OSErr;

Responding to Requests

FUNCTION PSendResponse(thePBPtr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION PAddResponse(thePBPtr: ATPPBPtr; async: Boolean): OSErr;

Canceling Pending ATP Functions

FUNCTION PKillSendReq(thePBPtr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION PRelTCB(thePBPtr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION PKillGetReq(thePBPtr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION ATPKillAllGetReq(thePBPtr: ATPPBPtr; async: Boolean): OSErr;
FUNCTION PRelRspCB(thePBPtr: ATPPBPtr; async: Boolean): OSErr;

Building a Buffer Data Structure

FUNCTION BuildBDS(buffPtr: Ptr; bdsPtr: Ptr; buffSize: Integer): 
Integer;

C Summary

Constants

/*ATP parameter constants*/
#define ATPioCompletion ATP.ioCompletion
#define ATPioResult ATP.ioResult
#define ATPuserData ATP.userData
#define ATPreqTID ATP.reqTID
#define ATPioRefNum ATP.ioRefNum
#define ATPcsCode ATP.csCode
#define ATPatpSocket ATP.atpSocket
#define ATPatpFlags ATP.atpFlags
#define ATPaddrBlock ATP.addrBlock
#define ATPreqLength ATP.reqLength
#define ATPreqPointer ATP.reqPointer
#define ATPbdsPointer ATP.bdsPointer
#define ATPtimeOutVal SREQ.timeOutVal
#define ATPnumOfResps SREQ.numOfResps
#define ATPretryCount SREQ.retryCount
#define ATPnumOfBuffs OTH1.u0.numOfBuffs
#define ATPbitMap OTH1.u0.bitMap
#define ATPrspNum OTH1.u0.rspNum
#define ATPbdsSize OTH2.bdsSize
#define ATPtransID OTH2.transID
#define ATPaKillQEl KILL.aKillQEl



/*csCodes*/
enum {                                 /*csCodes*/
   nSendRequest         = 248,         /*send request using a specific */
                                       /* socket*/
   relRspCB             = 249,         /*release RspCB*/
   closeATPSkt          = 250,         /*close ATP socket*/
   addResponse          = 251,         /*add response*/
   sendResponse         = 252,         /*send response*/
   getRequest           = 253,         /*get request*/
   openATPSkt           = 254,         /*open ATP socket*/
   sendRequest          = 255,         /*send request*/
   relTCB               = 256,         /*release TCB*/
   killGetReq           = 257,         /*kill getRequest*/
   killSendReq          = 258,         /*kill sendRequest*/
   killAllGetReq        = 259};        /*kill all getRequests for */
                                       /* a socket*/
/*ATP flags*/
enum {
   atpXOvalue              = 32,          /*ATP exactly-once bit*/
   atpEOMvalue             = 16,          /*ATP end-of-message bit*/
   atpSTSvalue             = 8,           /*ATP send-transmission-status */
                                          /* bit*/
   atpTIDValidvalue        = 2,           /*ATP trans. ID valid bit*/
   atpSendChkvalue         = 1};          /*ATP send checksum bit*/

Data Types

The Buffer Data Structure

struct   BDSElement {
   short       buffSize;
   Ptr         buffPtr;
   short       dataSize;
   long        userBytes;
};

typedef struct BDSElement BDSElement;
typedef BDSElement BDSType[8];
typedef BDSElement *BDSPtr;
typedef char BitMapType;

The Address Block Record

struct AddrBlock {
   short             aNet;
   unsigned char     aNode;
   unsigned char     aSocket;
};

typedef struct AddrBlock AddrBlock; 

The ATP Parameter Block

#define MPPATPHeader \
   QElem       *qLink;                 /*next queue entry*/\
   short       qType;                  /*queue type*/\
   short       ioTrap;                 /*routine trap*/\
   Ptr         ioCmdAddr;              /*routine address*/\
   ProcPtr     ioCompletion;           /*completion routine*/\
   OSErr       ioResult;               /*result code*/\
   long        userData;               /*command result (ATP user bytes)*/\
   short       reqTID;                 /*request transaction ID*/\
   short       ioRefNum;               /*driver reference number*/\
   short       csCode;                 /*call command code*/

typedef struct {
   MPPATPHeader 
}MPPparms;
#define MOREATPHeader \
   char        atpSocket;              /*currbitmap for requests or ATP */\
                                       /* socket number*/\
   char        atpFlags;               /*control information*/\
   AddrBlock   addrBlock;              /*source/dest. socket address*/\
   short       reqLength;              /*request/response length*/\
   Ptr         reqPointer;             /*pointer to request/response data*/\
   Ptr         bdsPointer;             /*pointer to response BDS*/

typedef struct {
   MPPATPHeader
   MOREATPHeader 
}ATPparms;



typedef struct {
   MPPATPHeader
   MOREATPHeader
   char        filler;                 /*numOfBuffs*/
   char        timeOutVal;             /*timeout interval*/
   char        numOfResps;             /*number of responses actually */
                                       /* received*/
   char        retryCount;             /*number of retries*/
   short       intBuff;                /*used internally for NSendRequest*/
   char        TRelTime;               /*TRelease time for extended send */
                                       /* request*/
}SendReqparms;
typedef struct {
    MPPATPHeader
    MOREATPHeader
   union {
      char     bitMap;                 /*bitmap received*/
      char     numOfBuffs;             /*number of responses being sent*/
      char     rspNum;                 /*sequence number*/
 } u0;
}ATPmisc1;
typedef struct {
   MPPATPHeader
   MOREATPHeader
   char           filler;
   char           bdsSize;             /*number of BDS elements*/
   short          transID;             /*transaction ID*/
}ATPmisc2;
typedef struct {
   MPPATPHeader
   MOREATPHeader
   Ptr            aKillQEl;            /*pointer to i/o queue element to */
                                       /* cancel*/
}Killparms;
union ATPParamBlock {
   ATPparms       ATP;                 /*general ATP parms*/
   SendReqparms   SREQ;                /*send request parms*/
   ATPmisc1       OTH1;                /*miscellaneous parms*/
   ATPmisc2       OTH2;                /*miscellaneous parms*/
   Killparms      KILL;                /*kill request parms*/
};
typedef union ATPParamBlock ATPParamBlock;
typedef ATPParamBlock *ATPPBPtr;

Routines

Sending an ATP Request

pascal OSErr PSendRequest(ATPPBPtr thePBPtr,Boolean async);
pascal OSErr PNSendRequest(ATPPBPtr thePBPtr,Boolean async); 

Opening and Closing an ATP Socket

pascal OSErr POpenATPSkt(ATPPBPtr thePBptr,Boolean async); 
pascal OSErr PCloseATPSkt(ATPPBPtr thePBPtr,Boolean async); 

Setting Up a Socket to Listen for Requests

pascal OSErr PGetRequest(ATPPBPtr thePBPtr,Boolean async);

Responding to Requests

pascal OSErr PSendResponse(ATPPBPtr thePBPtr,Boolean async);
pascal OSErr PAddResponse(ATPPBPtr thePBPtr,Boolean async);

Canceling Pending ATP Functions

pascal OSErr PKillSendReq(ATPPBPtr thePBPtr,Boolean async); 
pascal OSErr PRelTCB(ATPPBPtr thePBPtr,Boolean async);
pascal OSErr PKillGetReq(ATPPBPtr thePBPtr,Boolean async); 
pascal OSErr ATPKillAllGetReq
(ATPPBPtr thePBPtr,Boolean async); 
pascal OSErr PRelRspCB(ATPPBPtr thePBPtr,Boolean async); 

Building a Buffer Data Structure

pascal short BuildBDS(Ptr buffPtr,Ptr bdsPtr,short buffSize); 

Assembly-Language Summary

Constants

ATP Header

atpControl     EQU   0           ;control field (byte)
atpBitmap      EQU   1           ;bitmap (requests only) (byte)
atpRespNo      EQU   1           ;response number (responses only) (byte)
atpTransID     EQU   2           ;transaction ID (word)
atpUserData    EQU   4           ;start of user data (long)
atpHdSz        EQU   8           ;size of ATP header

ATP Control Field

atpReqCode     EQU   $40         ;request code after masking
atpRspCode     EQU   $80         ;response code after masking
atpRelCode     EQU   $C0         ;release code after masking
atpXOBit       EQU   5           ;bit number of exactly-once bit
atpEOMBit      EQU   4           ;bit number of end-of-message bit
atpSTSBit      EQU   3           ;send transmission status bit number
flagMask       EQU   $3F         ;mask for just flags
controlMask    EQU   $F8         ;mask for good control bits

ATP Type Code

atp            EQU   $3          ;ATP type code (in DDP header)

ATP Limits

atpMaxNum      EQU   8           ;maximum number of responses per request
atpMaxData     EQU   $242        ;maximum data size in ATP packet

ATP Command Codes

nSendRequest   EQU   248         ;PNSendRequest code
relRspCB       EQU   249         ;release RspCB
closeATPSkt    EQU   250         ;close ATP socket
addResponse    EQU   251         ;add response code
sendResponse   EQU   252         ;send response code 
getRequest     EQU   253         ;get request code
openATPSkt     EQU   254         ;open ATP socket
sendRequest    EQU   255         ;send request code
relTCB         EQU   256         ;release TCB
killGetReq     EQU   257         ;kill GetRequest
killSendReq    EQU   258         ;kill SendRequest
killAllGetReq  EQU   259         ;kill all getRequests for a socket

ATPQueue Element Standard Structure

;arguments passed in the CSParam area
atpSocket      EQU   $1C         ;socket number is first parameter [byte]
atpFlags       EQU   $1D         ;flag [byte]
addrBlock      EQU   $1E         ;start of address block
reqLength      EQU   $22         ;size of request buffer [word]
reqPointer     EQU   $24         ;pointer to request buffer or data
bdsPointer     EQU   $28         ;pointer to buffer data structure (BDS)
guArea         EQU   $2C         ;start of general-use area
userData       EQU   $12         ;user bytes

ATP Bits

sendCHK        EQU   0           ;bit number of send-checksum bit in flags
tidValid       EQU   1           ;bit set when TID valid in SendRequest

Data Structures

Buffer Data Structure (BDS)

bdsBuffSz      EQU   0           ;send: data length
                                 ; receive: buffer length
bdsBuffAdr     EQU   2           ;send: data address 
                                 ; receive: buffer address
bdsDataSz      EQU   6           ;send: used internally 
                                 ; receive: data length
bdsUserData    EQU   8           ;send: 4 user bytes 
                                 ; receive: 4 user bytes
bdsEntrySz     EQU   12          ;size of a BDS entry

ATP Parameter Block Common Fields
0qLinklongreserved
4qTypewordreserved
6ioTrapwordreserved
8ioCmdAddrlongreserved
12ioCompletionlongaddress of completion routine
16ioResultwordresult code
18userDatalonguser bytes
22reqTIDwordrequest transaction ID
24ioRefNumworddriver reference number
26csCodewordcommand code
28atpSocketbytecurrent bitmap or socket number

SendRequest
26csCodewordcommand code; always sendRequest
28currBitMapbytecurrent bitmap
29atpFlagsbytecontrol information
30addrBlocklongdestination socket address
34reqLengthwordrequest size in bytes
36reqPointerlongpointer to request data
40bdsPointerlongpointer to response BDS
44numOfBuffsbytenumber of responses expected
45timeOutValbytetimeout interval
46numOfRespsbytenumber of responses received
47retryCountbytenumber of retries
50TrelTimebyterelease time for extended send request
Parameter Variant

NSendRequest
22reqTIDwordrequest transaction ID
26csCodewordcommand code; always nSendRequest
29atpFlagsbytecontrol information
30addrBlocklongdestination socket address
34reqLengthwordrequest size in bytes
36reqPointerlongpointer to request data
40bdsPointerlongpointer to response BDS
44numOfBuffsbytenumber of responses expected
45timeOutValbytetimeout interval
46numOfRespsbytenumber of responses received
47retryCountbytenumber of retries
50TrelTimebyterelease time for extended send request
Parameter Variant

OpenATPSkt
26csCodewordcommand code; always openATPSkt
30addrBlocklongsocket request specification
Parameter Variant

CloseATPSkt
26csCodewordcommand code; always closeATPSkt
Parameter Variant

GetRequest
22reqTIDwordrequest transaction ID
26csCodewordcommand code; always getRequest
29atpFlagsbytecontrol information
30addrBlocklongdestination socket address
34reqLengthwordrequest size in bytes
36reqPointerlongpointer to request data
44bitMapbytecurrent bitmap
Parameter Variant

SendResponse
26csCodewordcommand code; always sendResponse
29atpFlagsbytecontrol information
30addrBlocklongdestination socket address
40bdsPointerlongpointer to response BDS
44numOfBuffsbytenumber of responses expected
45bdsSizebyteBDS size in elements
46transIDwordtransaction ID
Parameter Variant

AddResponse
26csCodewordcommand code; always addResponse
29atpFlagsbytecontrol information
30addrBlocklongdestination socket address
34reqLengthwordresponse size in bytes
36reqPointerlongpointer to response data
44rspNumbytesequence number
46transIDwordtransaction ID
Parameter Variant

KillSendReq
26csCodewordcommand code; always killSendReq
44aKillQEllongpointer to queue element of function to be removed
Parameter Variant

RelTCB
26csCodewordcommand code; always relTCB
30addrBlocklongdestination socket address of request
46transIDwordtransaction ID of request to be canceled
Parameter Variant

KillGetReq Parameter Variant
26csCodewordcommand code; always killGetReq
44aKillQEllongpointer to queue element of function to be removed

KillAllGetReq Parameter Variant
26csCodewordcommand code; always killAllGetReq

RelRspCB
26csCodewordcommand code; always relRspCB
30addrBlocklonginternet socket address of the source of the request
46transIDwordtransaction ID of request with which the PSendResponse
function to be canceled is associated
Parameter Variant

Result Codes
noErr0No error
paramErr-50Version number is too high
reqFailed-1096Retry count exceeded
tooManyReqs-1097Too many concurrent requests
tooManySkts-1098Too many responding sockets
badATPSkt-1099Bad responding socket
badBuffNum-1100Sequence number out of range
noRelErr-1101No release received
cbNotFound-1102The aKillQEl parameter does not point to a PSendRequest or PNSendRequest queue element
noSendResp-1103PAddResponse issued before PSendResponse
noDataArea-1104Too many outstanding ATP calls
reqAborted-1105Request canceled


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996