DIRECTORY ArpaBuf USING [Protocol], CommDriver USING [Buffer], Rope USING [ROPE] ; ArpaIP: CEDAR DEFINITIONS ~ { Handle: TYPE ~ REF Object; Object: TYPE; Buffer: TYPE ~ CommDriver.Buffer; Buffers: TYPE ~ CommDriver.Buffer; RouteHint: TYPE ~ REF; CreateHandle: PROC [protocol: Protocol, recvProc: RecvProc, clientData: REF, acceptLongDatagrams: BOOL _ FALSE] RETURNS [handle: Handle]; DestroyHandle: PROC [handle: Handle]; RecvProc: TYPE ~ PROC [b: Buffers, clientData: REF] RETURNS [rB: Buffers]; FreeBuffers: PROC [b: Buffers]; GetUserBytes: PROC [b: Buffer] RETURNS [bodyBytes: CARD, optionsBytes: CARD]; AllocBuffer: PROC RETURNS [Buffer]; SetUserBytes: PROC [b: Buffer, bodyBytes: CARD, optionsBytes: CARD _ 0]; Send: PROC [h: Handle, b: Buffers, hint: RouteHint _ NIL] RETURNS [newHint: RouteHint]; FetchOptionAddress: PROC [b: Buffer, pos: CARD] RETURNS [address: Address]; FetchOptionH: PROC [b: Buffer, pos: CARD] RETURNS [value: CARD16]; FetchOptionF: PROC [b: Buffer, pos: CARD] RETURNS [value: CARD32]; StoreOptionAddress: PROC [b: Buffer, pos: CARD, address: Address]; StoreOptionH: PROC [b: Buffer, pos: CARD, value: CARD16]; StoreOptionF: PROC [b: Buffer, pos: CARD, value: CARD32]; Error: ERROR [code: ATOM]; }... ˜ArpaIP.mesa Demers, August 19, 1987 1:25:31 am PDT Types To look at the IP header, use aB: ArpaBuf.Buffer _ LOOPHOLE[b]; Chain of buffers (linked together by b.ovh.next) containing a single IP datagram. If the datagram fits in a single buffer, that's the way it's represented; otherwise it's kept as a list of (long) fragments. Cached routing information used by Send. Registration Register self as protocol module for given protocol. If acceptLongDatagrams is FALSE, chains of fragments will not be presented to the recvProc or accepted on output. ! Error[$protocolAlreadyRegistered] Unregister this protocol module. Beware: there's a race that can cause recvProc to be called after the handle has been destroyed. ! Error[$handleDestroyed] Receiving A RecvProc gets called with every received IP datagram. The datagram has been reassembled into a single buffer if it fits; otherwise it is represented as (large) fragments in a chain of buffers. A RecvProc also gets called with certain ICMP datagrams. See ArpaICMP for details. The result buffer list rB is returned to the CommDriver buffer pool. It needn't be the same as b, and may be NIL. Free a chain of buffers. Not equivalent to CommDriver.FreeBuffer. Return the number of bytes in the datagram (fragment) contained in b^. The fixed part of the IP header is not counted, and IP options are counted separately. Note the TCP or UDP header is counted in bodyBytes. Sending Allocate a buffer. Set the length of the datagram (fragment) body and options. The fixed part of the IP header isn't counted in bodyBytes, but the UDP or TCP header is. Send chain of buffers. The length field must be correct in each fragment in the chain. Fragmentation control fields will be filled in automatically. Options from the first fragment will be copied to the remaining ones as appropriate. The hint / newHint is a performance hack for cacheing of routes. ! Error[$longDatagram] There must be others?! Options See option type description in ArpaBuf.mesa. In each case the position argument is 0-relative to the beginning of the entire options field, not the individual option. Errors The error codes that can occur: $protocolAlreadyRegistered : we only allow one protocol module per protocol. $handleDestroyed : you can't send on a handle after calling Destroy. $longDatagram : attempt to send a long datagram on a handle created with acceptLongDatagrams = FALSE. others as they become necessary. ΚΌ˜code™ K™&K™—šΟk ˜ Kšœœ ˜Kšœ œ ˜Kšœœœ˜K˜—K˜šΟnœœ œ˜K˜head™Kšœœœ˜Kšœœ˜ K˜šœœ˜!K™?—K˜šœ œ˜"K™Ο—K˜šœ œœ˜K™(—K˜—™ š ž œœ6œœœ˜oKšœ˜K™4Kšœq™qK™#K˜—šž œœ˜%K™ K™`K™—K˜—™ š žœœœœœ˜JKšœΓ™ΓKšœS™SK™rK˜—šž œœ˜K™BK˜—š ž œœ œ œœ˜MK™Σ——™K˜šž œœœ ˜#K™K˜—šž œœœœ˜HKšœ–™–K˜—šžœœ+œœ˜WK™λK™@K™.—K˜—™K™,K™K™yK˜Kšžœœœœ˜KK˜š ž œœœœ œ˜BK˜—Kš ž œœœœ œ˜BK˜Kšžœœœ˜BK˜šž œœœ œ˜9K˜—Kšž œœœ œ˜9—™Kšžœœœ˜K˜™K™LK™DK™eK™ ——K˜——…—δ8