ArpaUDPBuf.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Demers, July 24, 1987 7:41:42 pm PDT
DIRECTORY
ArpaBuf USING[Hdr, maxBodyBytes],
Basics USING [FWORD, HWORD],
CommBuffer USING [Overhead];
ArpaUDPBuf:
CEDAR
DEFINITIONS ~ {
HWORD: TYPE ~ Basics.HWORD;
FWORD: TYPE ~ Basics.FWORD;
maxBytes: CARDINAL ~ ArpaBuf.maxBodyBytes;
Header
Port: TYPE ~ HWORD;
nullPort: Port ~ [0, 0];
Hdr:
TYPE ~
MACHINE
DEPENDENT
RECORD [
sourcePort: Port ← nullPort,
destPort: Port,
length: HWORD,
checksum: HWORD ← [0, 0]
];
hdrBytes: CARDINAL ~ BYTES[Hdr];
Body
Body:
TYPE ~
MACHINE
DEPENDENT
RECORD [
SELECT
OVERLAID *
FROM
bytes => [bytes: PACKED ARRAY [0..maxBodyBytes) OF BYTE],
chars => [chars: PACKED ARRAY [0..maxBodyChars) OF CHAR],
hWords => [hWords: PACKED ARRAY [0..maxBodyHWords) OF HWORD],
fWords => [fWords: PACKED ARRAY [0..maxBodyFWords) OF FWORD]
ENDCASE
];
maxBodyBytes: CARDINAL ~ maxBytes - hdrBytes;
maxBodyChars: CARDINAL ~ maxBodyBytes;
maxBodyHWords: CARDINAL ~ maxBodyBytes/BYTES[HWORD];
maxBodyFWords: CARDINAL ~ maxBodyBytes/BYTES[FWORD];
Packet
Packet: TYPE ~ REF PacketObject;
PacketObject:
TYPE ~
MACHINE
DEPENDENT
RECORD [
hdr: Hdr,
body: Body];
Buffer
All buffers start out as Driver.Buffer's. Clients may SmashType between Driver.Buffer and ArpaBuf.Buffer, so the "right" module gets to do finalization. This is VERY delicate.
Buffer: TYPE ~ REF BufferObject;
BufferObject:
TYPE ~
MACHINE
DEPENDENT
RECORD [
ovh: CommBuffer.Overhead,
hdr1: ArpaBuf.Hdr,
hdr2: Hdr,
body: Body];
}.