-- Copyright: Mario Schweigler (C) 2005-2006
-- Institution: Computing Laboratory, University of Kent, Canterbury, UK
-- Description: pony internal TCP/IP include file

-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-- MA 02110-1301, USA.

--{{{  Constants
-- File names
VAL []BYTE PONYC.INT.TCPIP.FNAME.ANS IS ".pony.tcpip.ans":
VAL []BYTE PONYC.INT.TCPIP.FNAME.NODE IS ".pony.tcpip.node":
VAL []BYTE PONYC.INT.TCPIP.FNAME.ANSCONF IS ".pony.tcpip.ans-conf":
-- Environment variables
VAL []BYTE PONYC.INT.TCPIP.ENV.HOME IS "HOME":
-- File line prefixes
VAL []BYTE PONYC.INT.TCPIP.PREF.HOST IS "host=":
VAL []BYTE PONYC.INT.TCPIP.PREF.IP IS "ip=":
VAL []BYTE PONYC.INT.TCPIP.PREF.PORT IS "port=":
-- Default port numbers
VAL INT PONYC.INT.TCPIP.DEFAULTPORT.ANS IS 7400:
VAL INT PONYC.INT.TCPIP.DEFAULTPORT.NODE IS 7500:
-- ANS header constants
VAL BYTE PONYC.INT.TCPIP.ANSHEADER.MASTERSHUTDOWN IS 255:
VAL BYTE PONYC.INT.TCPIP.ANSHEADER.DONE IS 0:
VAL BYTE PONYC.INT.TCPIP.ANSHEADER.NOTDONE IS 1:
VAL BYTE PONYC.INT.TCPIP.ANSHEADER.DUPLICATEMASTER IS 2:
VAL BYTE PONYC.INT.TCPIP.ANSHEADER.DUPLICATESLAVE IS 3:
-- Master header constants
VAL BYTE PONYC.INT.TCPIP.MASTERHEADER.OK IS 0:
VAL BYTE PONYC.INT.TCPIP.MASTERHEADER.DUPLICATESLAVE IS 1:
VAL BYTE PONYC.INT.TCPIP.MASTERHEADER.SHUTTINGDOWN IS 2:
-- Link header constants
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTMGR.ALLOC IS 0:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORMAINKERNEL.ALLOCERROR IS 1:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORMAINKERNEL.ALLOCCONFIRM IS 2:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTMGR.MAKECTBNETWORKED IS 3:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORDECHANDLER.MAKECTBNETWORKEDCONFIRM IS 4:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.CLAIMCLI IS 5:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.CLAIMSVR IS 6:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.NEWOTHERENDCONFIRM IS 7:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.RELEASECLI IS 8:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.RELEASESVR IS 9:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORNCTHANDLER.EOIDONE IS 10:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RECLIENTCLAIMCONFIRMNOOTHEREND IS 11:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RESERVERCLAIMCONFIRMNOOTHEREND IS 12:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RECLIENTCLAIMCONFIRMOTHERENDCLAIMED IS 13:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RESERVERCLAIMCONFIRMOTHERENDCLAIMED IS 14:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RECLIENTNEWOTHEREND IS 15:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.FORCTBHANDLER.RESERVERNEWOTHEREND IS 16:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.STARTSESSION IS 17:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.FIRSTCLC IS 18:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.RESTCLCS IS 19:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.ACK IS 20:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.CANCEL IS 21:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.CLOSESESSION IS 22:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.SUSPENDSESSION IS 23:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.INSESSION.SUSPENDSESSIONCONFIRM IS 24:
VAL BYTE PONYC.INT.TCPIP.LINKHEADER.SHUTDOWN IS 25:
--}}}
--{{{  Declarations

--{{{  CHAN TYPE PONY.INT.TCPIP.LINKOUTCHAINHANDLE
-- Link-outputter-chain-handle (chain between link-outputters)
CHAN TYPE PONY.INT.TCPIP.LINKOUTCHAINHANDLE
  MOBILE RECORD
    CHAN BOOL ready?:
:
--}}}

----------------------------------------------------------------------

--{{{  PROTOCOLs PONY.INT.LINKMGRHANDLE.TCPIP.TO.MGR and PONY.INT.LINKMGRHANDLE.TCPIP.FROM.MGR
-- To link-manager
PROTOCOL PONY.INT.LINKMGRHANDLE.TCPIP.TO.MGR
  CASE
    -- Get network-location for a given node-ID
    -- Carrying: node-ID
    get.location; INT
    ----------------------------------------------------------------------
    -- Store network-location for a given node-ID
    -- Carrying: node-ID;
    --           IP address;
    --           port number
    store.location; INT; INT; INT
:

-- From link-manager
PROTOCOL PONY.INT.LINKMGRHANDLE.TCPIP.FROM.MGR
  CASE
    -- Get network-location - confirm
    -- Carrying: IP address;
    --           port number
    get.location.confirm; INT; INT
:
--}}}
--{{{  CHAN TYPE PONY.INT.LINKMGRHANDLE.TCPIP
-- TCP/IP link-manager-handle (link-manager has server-end)
CHAN TYPE PONY.INT.LINKMGRHANDLE.TCPIP
  MOBILE RECORD
    CHAN PONY.INT.LINKMGRHANDLE.TCPIP.TO.MGR to.mgr?:
    CHAN PONY.INT.LINKMGRHANDLE.TCPIP.FROM.MGR from.mgr!:
:
--}}}

--}}}

