<> <> <> <> <> <> <> DIRECTORY BasicTime USING [GetClockPulses, Pulses], IPDefs USING [Byte, Datagram, DByte, Address, maxDataLength], PrincOps USING [zEXCH], TCP USING [Reason, TCPInfo]; TCPOps: CEDAR DEFINITIONS IMPORTS BasicTime ~ BEGIN <> sendBufferLength: INT ~ 4000; -- max bytes of unacked data to queue for transmission or retransmission to net recvBufferLength: INT ~ 4000; tcpHdrWordLength: INT ~ 5; tcpHdrByteLength: INT ~ tcpHdrWordLength*4; maxTCPDataLength: INT ~ IPDefs.maxDataLength - tcpHdrByteLength; ourLocalAddress: IPDefs.Address; defaultReceiveWindow: INT; repacketizing: BOOL; -- TRUE if data to be repacketized when retransmitted tcpSegmentLife: INT ~ 60; -- value for time to live ConnectionState: TYPE = {closed, listen, synSent, synRcvd, established, finWait1, finWait2, closeWait, closing, lastAck, timeWait}; Pair: TYPE = MACHINE DEPENDENT RECORD [a, b: CARDINAL]; -- used for word swap <> TCPHeaderP: TYPE = LONG POINTER TO TCPHeader; TCPHeader: TYPE = MACHINE DEPENDENT RECORD [ sourcePort (0): IPDefs.DByte, -- source port number dstnPort (1): IPDefs.DByte, -- destination port number seqNumber (2): Pair, -- sequence number ackNumber (4): Pair, -- acknowledgement number dataWordOffset (6: 0..3): INT [0..15], -- size of header in 32-bit words unused (6: 4..9): INT [0..63] _ 0, urg (6: 10..10): BOOL _ FALSE, -- control flags, urgent ack (6: 11..11): BOOL _ FALSE, -- acknowledgement psh (6: 12..12): BOOL _ FALSE, -- push rst (6: 13..13): BOOL _ FALSE, -- reset syn (6: 14..14): BOOL _ FALSE, -- syn (first packet on connection) fin (6: 15..15): BOOL _ FALSE, -- fin (last packet on connection) window (7): IPDefs.DByte, -- window of packets to send checksum (8): IPDefs.DByte, -- for header and pseudo header urgentPtr (9): IPDefs.DByte _ 0, -- ptr to byte following urgent data options (10): ARRAY INT [1..40] OF IPDefs.Byte]; -- options <> TCPHandle: TYPE ~ REF TCPHandleRec; TCPHandleRec: TYPE ~ MONITORED RECORD [ localPort: IPDefs.DByte, -- TCP port foreignAddr: IPDefs.Address, -- internet foreign address foreignPort: IPDefs.DByte, -- TCP port matchForeignAddr: BOOL, -- true to use foreign addr matchForeignPort: BOOL, -- true to use foreign port state: ConnectionState, -- state of connection reason: TCP.Reason, -- why we closed this connection active: BOOL, -- active or passive open notListening: CONDITION, -- used to wait for connection when listening maxSegmentSize: INT, -- max bytes we can send in a datagram <> sndUna: INT _ 0, -- oldest unacked seq number sndNxt: INT _ 0, -- next seq number to send sndWnd: INT _ 0, -- send window sndWL1: INT _ 0, -- pkt seq used for last window update sndWL2: INT _ 0, -- pkt ack used for last window update iss: INT _ 0, -- initial send seq number sndUrgent: BOOL _ FALSE, -- true if trying to send urgent data sndUp: INT _ 0, -- where it is in the stream fillSlot: INT [0..sendBufferLength) _ 0, -- for repacketizing sendSlot: INT [0..sendBufferLength) _ 0, -- for repacketizing sendBuffer: ARRAY INT [0..sendBufferLength) OF IPDefs.Byte, -- for repacketizing nBytesToSend: INT [0..sendBufferLength] _ 0, -- number of filled slots in sendBuffer <> rcvNxt: INT _ 0, -- next seq number to receive rcvWnd: INT, -- receive window rcvUp: INT _ 0, -- receive urgent pointer irs: INT _ 0, -- initial receive sequence number urgentMode: BOOL _ FALSE, -- rcvd urgent data and not passed to user <> finSequence: INT _ 0, -- sequence number of fin sent dataTimeout: INT, -- in msecs, time to wait before signalling client timeWaitTime: BasicTime.Pulses, -- when to delete a handle in timeWait state fromNetQueue: LIST OF REF ANY, -- packets received from net (actually TCPRcvBuffers) readyToReadQueue: LIST OF REF ANY, -- packets processed and ready to hand to client (TCPRcvBuffers) currentInputBuffer: REF TCPRcvBuffer, -- buffer for doling out input dataAvailable: CONDITION, -- wait here for incoming data toNetQueue: LIST OF REF ANY, -- packets to send to net (IPDefs.Datagrams) rexmitQueue: LIST OF REF ANY, -- packets to retransmit to net (TCPSendBuffers) currentOutputDatagram: IPDefs.Datagram, -- next block of data to send currentOutputPtr: INT, -- index into currentOutputDatagram for data currentOutputLimit: INT, -- max size of datagram based on maxSegmentSize windowAvailable: CONDITION, -- wait here for quota on other end urgentAvailable: CONDITION]; -- wait here for urgent data <> TCPRcvBuffer: TYPE ~ RECORD [ offsetSeqNo: INT, -- for use by TCP datagramPtr: IPDefs.Datagram, -- datagram received from net dataOffset: INT, -- Byte offset of data from dataPtr^ dataByteCount: INT, -- number of data bytes tcpHdrPtr: TCPHeaderP, -- pointer to TCP header (?) urg: BOOL, -- value of TCP URG field endUrgentData: INT]; -- index of byte following urgent data <> TCPSendBuffer: TYPE ~ RECORD [ dataByteCount: INT, -- count of data sent (not control) rexmitTime: BasicTime.Pulses, -- time to retransmit segment timeoutTime: BasicTime.Pulses, -- time to abort connection if segment not acked datagram: IPDefs.Datagram]; -- datagram sent to net TCPControlSet: TYPE ~ RECORD [ urg, ack, psh, rst, syn, fin: BOOL _ FALSE]; <> pktsSent: INT; pktsRcvd: INT; pktsRexmitted: INT; pktsDuplicate: INT; pktsWithNoConnection: INT; pktsFromFuture: INT; pktsFromPast: INT; pktsWithBadChecksum: INT; <> Open: PROC [tcpInfo: TCP.TCPInfo] RETURNS [handle: TCPHandle]; <> Close: PROC [handle: TCPHandle]; <> Abort: PROC [handle: TCPHandle]; <> WaitForListenerOpen: PROC [handle: TCPHandle, timeout: INT]; <> SendCurrentDatagram: PROC [handle: TCPHandle, push: BOOL]; <> GetNextDatagram: PROC [handle: TCPHandle]; <> SetUrgent: PROC [handle: TCPHandle]; <> WaitForUrgentData: PROC [handle: TCPHandle] RETURNS [urgentIndex: INT]; <> <> <> Flip: PROC [Pair] RETURNS [INT] = TRUSTED MACHINE CODE BEGIN PrincOps.zEXCH; END; Flop: PROC [INT] RETURNS [Pair] = TRUSTED MACHINE CODE BEGIN PrincOps.zEXCH; END; TCPChecksum: PROC [data: IPDefs.Datagram] RETURNS [checksum: IPDefs.DByte]; <> ChecksumsMatch: PROC [c1, c2: IPDefs.DByte] RETURNS [BOOL]; <> SetTimeout: PROC [delta: INT, base: BasicTime.Pulses _ BasicTime.GetClockPulses[]] RETURNS [BasicTime.Pulses]; <> TimedOut: PROC [timeoutTime: BasicTime.Pulses] RETURNS [BOOL]; <> END.