<> <> <> <> <> DIRECTORY IO USING [STREAM]; IP: CEDAR DEFINITIONS ~ BEGIN <> maxOptionLength: INT ~ 40; -- Maximum length of internet options. maxDataLength: INT ~ 556; -- In bytes, excluding headers. maxIHL: INT ~ 15; -- Maximum internet header length. minIHL: INT ~ 5; neverTimeout: INT ~ -1; -- timeout value to prevent timing out. Byte: TYPE ~ INT [0..255]; -- One byte field. DByte: TYPE ~ INT [0..65535]; -- Two byte field. Address: TYPE = PACKED ARRAY INT [0..4) OF Byte; -- Internet address format. AddressList: TYPE = LIST OF Address; nullAddress: Address ~ ALL[0]; OptionsArray: TYPE ~ PACKED ARRAY INT [1..maxOptionLength] OF Byte; InternetHeader: TYPE ~ MACHINE DEPENDENT RECORD [ -- Format of internet header. version (0: 0..3): INT [0..15] _ 4, IHL (0: 4..7): INT [0..15], precedence (0: 8..10): INT [0..7] _ 0, delay (0: 11..11): INT [0..1] _ 0, throughput (0: 12..12): INT [0..1] _ 0, reliability (0: 13..13): INT [0..1] _ 0, filler1 (0: 14..15): INT [0..3] _ 0, packetLength (1): DByte, fragmentId (2): DByte _ 0, filler2 (3: 0..0): INT [0..1] _ 0, dontFragment (3: 1..1): BOOL _ FALSE, moreFragments (3: 2..2): BOOL _ FALSE, fragmentOffset (3: 3..15): INT [0..17777B], timeToLive (4: 0..7): Byte, protocol (4: 8..15): Byte, checksum (5): DByte, source (6): Address, destination (8): Address, options (10): OptionsArray]; <> ICMPProtocol: Byte = 1; TCPProtocol: Byte = 6; UDPProtocol: Byte = 17; DataBuffer: TYPE = PACKED ARRAY INT [0..maxDataLength) OF Byte; -- Internet data buffer. Datagram: TYPE = REF DatagramRec; DatagramRec: TYPE = RECORD [ -- Format of internet datagram dataLength: INT, -- data length in bytes optionLength: INT [0..maxOptionLength) _ 0, -- number of bytes of options. inHdr: InternetHeader, -- internet header data: DataBuffer]; -- data buffer DatagramQueue: TYPE ~ LIST OF Datagram; -- ??? <> RequestData: TYPE ~ RECORD [ -- Specify internet packets to receive/send matchProtocol: BOOL, -- true if match internet protocol on packets protocol: Byte, -- protocol value to match matchAddr: BOOL, -- true if match internet address on packets address: Address, -- internet address to match matchLocalAddr: BOOL, -- true if specifying particular local address localAddress: Address, -- local address to match, if matchLocalAddr is false, address in configuration file is used printPkts: BOOL _ FALSE, -- true if print packets for this request logPkts: BOOL _ FALSE]; -- true if log packets for this request InternetHandle: TYPE ~ REF InternetHandleRec; -- "handle" on request, returned by IPRequest for internet process use only. InternetHandleRec: TYPE ~ RECORD [ -- Specify internet packets to receive/send matchProtocol: BOOL, -- true if match internet protocol on packets protocol: Byte, -- protocol value to match matchAddr: BOOL, -- true if match internet address on packets address: Address, -- internet address to match matchLocalAddr: BOOL, -- true if specifying a particular local address localAddress: Address, -- local address to match printPkts: BOOL, -- true if print packets for this request logPkts: BOOL, -- true if log packets for this request waitingDatagrams: DatagramQueue _ NIL, -- unread datagrams lastWaitingElement: DatagramQueue _ NIL, -- points to last CONS cell to make appending fast newDatagram: CONDITION, -- how to wait on new ones handleDestroyed: BOOL _ FALSE]; -- set to tell waiters to give up CreateIPHandle: PROC [requestData: RequestData] RETURNS [handle: InternetHandle]; <> DestroyIPHandle: PROC [handle: InternetHandle]; <> Send: PROC [handle: InternetHandle, data: Datagram]; <> SendSpecific: PROC [data: Datagram]; <> Receive: PROC [handle: InternetHandle, timeout: INT _ neverTimeout] RETURNS [data: Datagram]; <> PrintDatagram: PROC [s: IO.STREAM, data: IP.Datagram]; <> Errorcode: TYPE ~ {handleDestroyed, unknown}; Error: ERROR [type: Errorcode]; END.