Naming
This module implements the XNSName address translation interface.
A fully specified address string is of the form
<netNumber>.<hostNumber>.<socketNumber> or
<netNumber>#<hostNumber>#<socketNumber>
A number can have one of several forms:
1) Decimal: a sequence of characters in ['0..'9] optionally followed by 'D or 'd. The string may also have '- characters embedded, implying product format. A leading '- is not allowed.
2) Octal: a sequence of characters in ['0..'7] followed by 'B or 'b.
3) Hex: a sequence of characters in {in['0..'9], in ['A..'F], in['a..'f]} beginning with a digit and optionally followed by 'H or 'h.
Several additional forms are allowed for nostNumber:
4) The special string "ME" (in upper case), which is equivalent to specifing the Processor ID (XNS Host number) of the host where the code is running.
5) The special string "*", which is equivalent to specifing the broadcast XNS Host number.
6) A nonempty string not in any of the above formats, which we try to interpret as a Clearinghouse distinguished name:
The string is broken into its local, domain, and organization (org) components by looking for either ': or '@ characters. Both separators are not allowed in the same string. Clients are advised to only use ': as separator characters. If the string does not contain a domain and/or org field, default values for those fields will be supplied. See the documentation for exact details.
The resulting Clearinghouse name is looked up in the CH. The name must denote (or be an alias for) one of a specific set of CH objects for the lookup to succeed. Refer to the release documentation for the currently supported set of allowed CH objects.
The hostNumber must always be supplied. Both netNumber and socketNumber can be defaulted.
The translation routine will translate any string that is well formed and unambiguous.
Acceptable examples:
74B#25200000016#2
Lassen:OSBU North
25200000016
60.Lassen
ME
*
74.*.
#Lassen:Bayhill:Xerox#2B
#25200000016#2
Ambiguous (because pair could mean net#host or host#socket):
74#2
Local name
MyAddress:
PROC
RETURNS [Address];
Return best address for this machine.
Socket will be unknownSocket.
MyName:
PROC
RETURNS [Name];
Tries to get a human-readable name for the local machine, e.g "Shark".
This is hard to do in the XNS world, so for now it just calls MyRope.
MyRope:
PROC [format: Format ← productSoftware]
RETURNS [
ROPE];
Returns a ROPE of the form "3.313.".
There are no possible errors. NIL might happen if there are no drivers active.
Name/Address translation
The implementation might use a local cache, so all those sorts of problems can happen. The servers already have a cache, and the Dicentras sometimes don't notice updates as fast as they should, so local caching shouldn't make things much more complicated.
AddressFromName:
PROC [name: Name, default: Socket ←
XNS.unknownSocket]
RETURNS [Address];
Returns the best address for this machine to use when contacting the specified target. (Remember, it might have more than one interface.)
"ME" (must be upper case) is a special hack for the local machine.
The Clearinghouse won't be contacted if the string is a valid address constant; AddressFromRope[name] will be called instead.
ERRORs: Error - noRoute, noResponse, errorFromServer. BUT NONE OF THESE CAN HAPPEN YET!! ???
If name (or the database) doesn't specify any socket number, then default will be used. The idea is that programs like Chat will call NameLookup["Ivy", XNSWKS.telnet]. That lets a wizard use things like "Chat Ivy+1000" to specify a special socket number for debugging.
AddressFromRope:
PROC [rope:
ROPE, default: Socket ←
XNS.unknownSocket]
RETURNS [Address];
An alias for AddressFromName.
AddressesFromName:
PROC [name: Name, default: Socket ←
XNS.unknownSocket]
RETURNS [
LIST
OF Address];
Like AddressFromName, except it returns all the addresses, closest first.
Format:
TYPE ~ { octal, hex, productSoftware };
Controls the format in which a network address gets expanded by RopeFromAddress or NameFromAddress. "Octal" and "hex" do the obvious; "productSoftware" converts each field to decimal and inserts a '-' every 3 digits, starting from the right.
RopeFromAddress:
PROC [address: Address, format: Format ← productSoftware]
RETURNS [
ROPE];
Returns a ROPE of the form "1.12.123".
Hack: unknownSocket => "1.12." (no trailing 0).
NameFromAddress:
PROC [address: Address, ignoreSocket:
BOOL ←
TRUE]
RETURNS [Name];
This is hard to do in the XNS world. For now it just calls RopeFromAddress.
If ignoreSocket is TRUE, then unknownSocket is used in place of address.socket.
NetFromRope: PROC [rope: ROPE] RETURNS [Net];
HostFromRope: PROC [rope: ROPE] RETURNS [Host];
SocketFromRope: PROC [rope: ROPE] RETURNS [Socket];
RopeFromNet: PROC [net: Net, format: Format ← productSoftware] RETURNS [ROPE];
RopeFromHost: PROC [host: Host, format: Format ← productSoftware] RETURNS [ROPE];
RopeFromSocket: PROC [socket: Socket, format: Format ← productSoftware] RETURNS [ROPE];
Errors
ErrorCode:
TYPE = { syntax, noResponse, errorFromServer, other };
For now we're not using Clearinghouse, so most of these "can't happen".
Error: ERROR [code: ErrorCode, text: ROPE];
}.