!  File  NMOUSE:2MEG.INC

! Interface to 2 meg ether handler.

%recordformat ether stats fm(%integer -
 this station,
 buffer low water,
 unrecognised control,
 inbound packets,
 inbound bytes,
 outbound packets,
 outbound bytes,
 dud destinations,
 dud types,
 old inbound packets,
 old outbound packets,
 old inbound no takers,
 old retransmits,
 old ACK timeouts,
 old user timeouts,
 old defines,
 old redefines,
 old undefines,
 old reads,
 old writes,
 pended DTX,
 packets dropped,
 pendings discarded)

%constinteger -
  min offset      = -256,
  def offset      = 0,
  max offset      = 1599

! The packet data normally start at _data(0), but for convenience, they
! may start anywhere within the above offset limits, so that headers and
! trailers may be manipulated without copying the bulk of the data around.

%recordformat ether buffer fm(%record(message fm) system part %or-
       %bytearray message header(1:message header size),
       %integer code, tag, timeout, status,
                type, context, bytes, offset,
                ra, rp, la, lp,
       %bytearray data(minoffset:maxoffset))

%conststring(23) ether mailbox name = "SLOW_ETHER_REQUESTS"

%constinteger ether old operation   = 16_10
%constinteger ether old define      = 16_11
%constinteger ether old redefine    = 16_12
%constinteger ether old undefine    = 16_13
%constinteger ether old read        = 16_14
%constinteger ether old write       = 16_15
%constinteger ether old register0   = 16_16
%constinteger ether old unregister0 = 16_17
%constinteger ether old write read  = 16_18

%constinteger ether operation  = 16_20
%constinteger ether register   = 16_21
%constinteger ether unregister = 16_22
%constinteger ether read       = 16_23
%constinteger ether write      = 16_24

%constinteger ether stats      = 16_41
%constinteger ether station    = 16_42

%constinteger ether success               =  0
%constinteger ether operation undefined   = -1
%constinteger ether dud destination       = -2
%constinteger ether no free slots         = -3
%constinteger ether dud context           = -4
%constinteger ether operation aborted     = -5
%constinteger ether read timeout          = -6
%constinteger ether write timeout         = -7

%conststring(27)%array ether errors(-7:-1) =
      "Ether write timeout",
      "Ether read timeout",
      "Ether operation aborted",
      "Dud ether type/context",
      "No free ether slots",
      "Dud ether destination",
      "Undefined ether operation"

%externalrecord(ether buffer fm)%mapspec acquire packet buffer
%externalroutinespec discard packet buffer(%record(ether buffer fm)%name buf)
%externalroutinespec ether request(%record(ether buffer fm)%name req)
%externalrecord(ether buffer fm)%mapspec ether reply

%externalroutinespec ether close port(%integer c)
%externalintegerfnspec ether open port(%integer ra,rp)
%externalroutinespec ether reopen port(%integer c,rp)
%externalroutinespec ether transmit block(%integer c,bytes,%name buffer)
%externalintegerfnspec ether receive block(%integer c,maxbytes,%name buffer)
%externalintegerfnspec ether station address
%externalroutinespec show 2meg stats
