DIRECTORY IO USING [STREAM]; IPDefs: 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: Datagram]; Errorcode: TYPE ~ {handleDestroyed, unknown}; Error: ERROR [type: Errorcode]; END. LCopyright (C) 1983, 1985 by Xerox Corporation. All rights reserved. The following program was created in 1983 but has not been published within the meaning of the copyright law, is furnished under license, and may not be used, copied and/or disclosed except in accordance with the terms of said license. IPDefs.mesa Hal Murray May 16, 1985 2:35:05 am PDT John Larson, April 14, 1986 9:19:44 pm PST Packet format Protocol field values. type of argument to CreateIPHandle Add a new request for incoming packets. Returns a handle on the Internet. If the reqest conflicts with an existing one, then CreateIPHandle returns NIL. Removes the request and flushes all waiting datagrams. Fills in header of datagram from the handle and sends it. Sends a datagram whose header has already been filled in. Waits for a datagram that matches the request that was used to create the handle. Returns the datagram or NIL if timeout milliseconds (?) pass with no packet arriving. A value of neverTimeout for timeout will cause Receive to wait forever. Print a representation of the datagram on the stream. Κš– "cedar" style˜Icode2šœ―™―head™ Icode™&M™*M™šΟk ˜ Kšœœœ˜——šΟnœœ ˜Kšœ˜—™ Kšœœ Οc'˜DKšœœ Ÿ ˜