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
0 | qLink | long | reserved |
4 | qType | word | reserved |
6 | ioTrap | word | reserved |
8 | ioCmdAddr | long | reserved |
12 | ioCompletion | long | address of completion routine |
16 | ioResult | word | result code |
18 | userData | long | user bytes |
22 | reqTID | word | request transaction ID |
24 | ioRefNum | word | driver reference number |
26 | csCode | word | command code |
28 | atpSocket | byte | current bitmap or socket number |
SendRequest
26 | csCode | word | command code; always sendRequest |
28 | currBitMap | byte | current bitmap |
29 | atpFlags | byte | control information |
30 | addrBlock | long | destination socket address |
34 | reqLength | word | request size in bytes |
36 | reqPointer | long | pointer to request data |
40 | bdsPointer | long | pointer to response BDS |
44 | numOfBuffs | byte | number of responses expected |
45 | timeOutVal | byte | timeout interval |
46 | numOfResps | byte | number of responses received |
47 | retryCount | byte | number of retries |
50 | TrelTime | byte | release time for extended send request |
Parameter Variant
NSendRequest
22 | reqTID | word | request transaction ID |
26 | csCode | word | command code; always nSendRequest |
29 | atpFlags | byte | control information |
30 | addrBlock | long | destination socket address |
34 | reqLength | word | request size in bytes |
36 | reqPointer | long | pointer to request data |
40 | bdsPointer | long | pointer to response BDS |
44 | numOfBuffs | byte | number of responses expected |
45 | timeOutVal | byte | timeout interval |
46 | numOfResps | byte | number of responses received |
47 | retryCount | byte | number of retries |
50 | TrelTime | byte | release time for extended send request |
Parameter Variant
OpenATPSkt
26 | csCode | word | command code; always openATPSkt |
30 | addrBlock | long | socket request specification |
Parameter Variant
CloseATPSkt
26 | csCode | word | command code; always closeATPSkt |
Parameter Variant
GetRequest
22 | reqTID | word | request transaction ID |
26 | csCode | word | command code; always getRequest |
29 | atpFlags | byte | control information |
30 | addrBlock | long | destination socket address |
34 | reqLength | word | request size in bytes |
36 | reqPointer | long | pointer to request data |
44 | bitMap | byte | current bitmap |
Parameter Variant
SendResponse
26 | csCode | word | command code; always sendResponse |
29 | atpFlags | byte | control information |
30 | addrBlock | long | destination socket address |
40 | bdsPointer | long | pointer to response BDS |
44 | numOfBuffs | byte | number of responses expected |
45 | bdsSize | byte | BDS size in elements |
46 | transID | word | transaction ID |
Parameter Variant
AddResponse
26 | csCode | word | command code; always addResponse |
29 | atpFlags | byte | control information |
30 | addrBlock | long | destination socket address |
34 | reqLength | word | response size in bytes |
36 | reqPointer | long | pointer to response data |
44 | rspNum | byte | sequence number |
46 | transID | word | transaction ID |
Parameter Variant
KillSendReq
26 | csCode | word | command code; always killSendReq |
44 | aKillQEl | long | pointer to queue element of function to be removed |
Parameter Variant
RelTCB
26 | csCode | word | command code; always relTCB |
30 | addrBlock | long | destination socket address of request |
46 | transID | word | transaction ID of request to be canceled |
Parameter Variant
KillGetReq Parameter Variant
26 | csCode | word | command code; always killGetReq |
44 | aKillQEl | long | pointer to queue element of function to be removed |
KillAllGetReq Parameter Variant
26 | csCode | word | command code; always killAllGetReq |
RelRspCB
26 | csCode | word | command code; always relRspCB |
30 | addrBlock | long | internet socket address of the source of the request |
46 | transID | word | transaction ID of request with which the PSendResponse function to be canceled is associated |
Parameter Variant
Result Codes
noErr | 0 | No error |
paramErr | -50 | Version number is too high |
reqFailed | -1096 | Retry count exceeded |
tooManyReqs | -1097 | Too many concurrent requests |
tooManySkts | -1098 | Too many responding sockets |
badATPSkt | -1099 | Bad responding socket |
badBuffNum | -1100 | Sequence number out of range |
noRelErr | -1101 | No release received |
cbNotFound | -1102 | The aKillQEl parameter does not point to a PSendRequest or PNSendRequest queue element |
noSendResp | -1103 | PAddResponse issued before PSendResponse |
noDataArea | -1104 | Too many outstanding ATP calls |
reqAborted | -1105 | Request canceled |