// IfsNameServ.decl -- internal definitions
// Copyright Xerox Corporation 1979, 1981

// Last modified December 5, 1981  2:28 PM by Taft

// Requires previous get of Ifs.decl, Pup0.decl, and Pup1.decl
get "IfsMisc.decl"
get "IfsName.decl"

manifest nameStatsVersion = 1

//----------------------------------------------------------------------------
structure Stats:
//----------------------------------------------------------------------------
[
version word		// = nameStatsVersion
nameReqs word 2		// number of requests for name lookup
dirReqs word 2		// number of requests to send directory
cacheHits word 2	// number of name cache hits
cacheMisses word 2	// number of name cache misses
]

//----------------------------------------------------------------------------
structure NS:		// 'global frame' for Name Server
//----------------------------------------------------------------------------
[
stats @Stats

globalLocks word =
   externalLock word	// set by ptNameLockRequest

bcstTimer word		// counts 5-minute intervals
bcstInterval word	// dir bcst interval in units of 5 minutes
ctx word		// -> NameCtx for SendNetDir or ReceiveNetDir

version word		// current network directory version
tree word		// -> network directory B-tree (0 => none)
treeLock @Lock		// controls access to the B-tree
]
manifest lenNS = size NS/16

//----------------------------------------------------------------------------
structure Hdr:		// Network directory header
//----------------------------------------------------------------------------
[
numNames word
firstName word
numAddrs word
firstAddr word
sizeEntrySpace word
firstEntry word
version word		// version number
]
manifest lenHdr = size Hdr/16

//----------------------------------------------------------------------------
structure Attr:		// Network directory attribute block
//----------------------------------------------------------------------------
[
name word		// -> string
value word		// -> string
]

//----------------------------------------------------------------------------
structure Entry:	// Network directory entry block
//----------------------------------------------------------------------------
[
nameListHdr word
addrListHdr word
numAttrs word
attr↑1,1 @Attr
]

//----------------------------------------------------------------------------
structure Addr:		// Network directory address block
//----------------------------------------------------------------------------
[
link word
entry word
port @Port
numAttrs word
attr↑1,1 @Attr
]

//----------------------------------------------------------------------------
structure Name:		// Network directory name block
//----------------------------------------------------------------------------
[
link word
entry word
string @String
]

// The directory tree is divided into two parts.  In the first part,
// the tree is organized by name, and in the second part by address.
// All names are "less than" all addresses.

//----------------------------------------------------------------------------
structure NDTE:		// Network Directory Tree Entry
//----------------------------------------------------------------------------
[
type byte		// dteTypeName or dteTypeAddress
length byte		// in words
name:			// ndteTypeName variant
   [
   string @String	// name key
   ports↑1,1 @Port	// corresponding addresses -- starts after string
   ] =
address:		// ndteTypeAddress variant
   [
   port @Port		// address key
   string @String	// corresponding name
   ]
]

manifest
[
ndteTypeName = 1
ndteTypeAddress = 2

nameTreePages = 100	// max number of pages in network directory

maxNPorts = 20		// max number of addresses per name
]