xcsenv;

(************************************************************)
(*                                                          *)
(*     External environment of the                          *)
(*                                                          *)
(*        PAXNET/RC3502 COMMUNICATION SERVICE (CS)          *)
(*       --------------------------------------------       *)
(*                                                          *)
(* The PAXNET/RC3502 Communication Service (CS) forms a     *)
(* general service, which will exist as a supporting sub-   *)
(* service to a wide range of specific PAXNET communica-    *)
(* tion services.                                           *)
(*                                                          *)
(* The PAXNET/RC3502 CS contains constants, types and rou-  *)
(* tines for handling                                       *)
(*                                                          *)
(*    1) the process to process communication between       *)
(*       a user-process and a server-process, and           *)
(*                                                          *)
(*    2) the general administration of Service Access       *)
(*       Points (SAPs) within the PAXNET environment.       *)
(*                                                          *)
(* The handling of connection-specific actions is outside   *)
(* the scope of the PAXNET CS.                              *)
(*                                                          *)
(* Specific PAXNET communication services will to some ex-  *)
(* tend (and maybe completely) encapsulate the CS with      *)
(* service-specific constant, type and routine definitions. *)
(* In this way, only a subset of the CS definitions will be *)
(* referred directly by the user-process, while the encap-  *)
(* sulated part of the CS definitions will be referred di-  *)
(* rectly by the server.                                    *)
(*                                                          *)
(************************************************************)

(************************************************************

Revision history:

date    init     description
-------------------------------------------------------------
831216  uh/tsg   first version
840104  uh/tsg   minor changes
840106  tsg      minor changes (cszone-def.(a name), sap-def.).
------  ---      new procedure cs-error-disc
840111  tsg      minor changes (sap_act_prms change (max_conn), and
------  ---      cssap_act params). (Param-name in cs_ih_return).
840124  tsg      type-lengths and exception-code(s) inserted,
------  ---      new routine 'cssap-exec-indic' inserted.
840210  tsg      rearrangements, ex-server-status renamed.
840213  tsg      cssap-exec-indic changed, usergr. in cszone,
------  ---      new severity-t, (name-change in sap-prms-types).
840216  tsg      param-type changes in cszone-open and cspool.
840314  tsg      'packed' removed from types: logic-id-t, access-
------  ---      ctr-t, pr-opt-t, pr-id-t, qos-t, qos-fr-t.
------  ---      new value of def-access-ctr and max-pr-opts.
840323  tsg      new qos-constants (default values).
840329  tsg      no-pr-ids 0 inst. of 1 in sap-act-prms and sap-req-prms
840402  tsg      helptype inserted in logic-id-t.
840406  tsg      new procedure, lcp sense cszone.
841011  tsg      new procedure, cs_exch_lcp
860114  oer      SAP constants, sap_adr_t and logic_id_t moved to NETENV
860926  tsg      secret types opened (icsenv dropped)
870702  tsg      new constants for default sap parameters:
------  ---        qosfr-sap-any, accpm-sap-any and
------  ---        qosfr-term-min, accpm-term-min  defined.



*************************************************************)

(*---------------------------------------------------*)
(*    Basic constant definitions                     *)
(*---------------------------------------------------*)

const
account_lgt   = 8;     (* length of account number *)
max_pr_ids    = 4;     (* max no of protocol ids for one SAP *)
max_pr_opts   = 15;    (* max no of options in one protocol id *)

(*-----------------------------------*)
(* Commonly used exception codes     *)
(*-----------------------------------*)

ex_inv_fln    = #hf1;  (* invalid fln-value(s) *)
(* interval #h f00 - fff reserved for server status (u2) *)
ex_serv_stat  = #hf00; (* unexpected server status (+ u2) *)

type

(*------------------------------------*)
(* Various CS subtype definitions     *)
(*------------------------------------*)

(* Validation types   *)

access_ctr_t = record
lprio,
mask    : byte;
low,
upp     : integer;
end;

pr_opt_t = set of 0 .. max_pr_opts;

pr_id_t = record
layer       : byte;
basic_type  : integer;  (* basic protocol type *)
sub_type    : byte;
options     : pr_opt_t; (* protocol options *)
end;

pr_id_array_t = array (1 .. max_pr_ids) of pr_id_t;

(* QoS types        *)

qos_t = record
prio      : byte;
av_thrp   : byte;    (* average throughput *)
pk_thrp   : byte;    (* peak throughput *)
t_delay   : byte;    (* transit delay demand *)
rsp_delay : byte;    (* response delay demand *)
end;

qos_fr_t = record
lower,
upper   : qos_t;   (* qos frame bounds *)
end;

(* Account parameter type *)

account_type = packed array (1 .. account_lgt) of hex_digit;

(* Definitions for severity (of diagnostic etc.) *)

severity_t = (success, warning, ?, failure);

(*---------------------------------*)
(* CS procedure parameter types    *)
(*---------------------------------*)

(* CS pool functions  *)

pool_func_t = (cspool_init, cspool_incr, cspool_decr, cspool_sense);

(* SAP activation prms   *)

sap_act_prms = record
fixed_adr   : boolean;
anonymous   : boolean;
min_conn,
max_conn    : 0 .. maxint;
qos_frame   : qos_fr_t;
access_prms : access_ctr_t;
no_pr_ids   : 0 .. max_pr_ids;
pr_id       : pr_id_array_t;
id_record   : logic_id_t;
sap_adr     : sap_adr_t;
end;

(* SAP conn.req. prms  *)

sap_req_prms = record
qos_frame   : qos_fr_t;
access_prms : access_ctr_t;
no_pr_ids   : 0 .. max_pr_ids;
pr_id       : pr_id_array_t;
id_record   : logic_id_t;
end;

(*------------------------------------------------*)
(*    Various constant definitions                *)
(*------------------------------------------------*)

const

(*------------------------------------*)
(* default values for various types   *)
(*------------------------------------*)

def_account_no  = account_type (:account_lgt *** 0:);
min_qos         = qos_t (:0,0,0,0,0:);
max_qos         = qos_t (:255,255,255,255,255:);
batch_qos       = min_qos;
interact_qos    = qos_t (:128,1,0,0,0:);
def_pr_id       = pr_id_t (:0,0,0,(..):);

(* default values for service SAPs open to all terminals *)
qosfr_sap_any   = qos_fr_t (:min_qos, max_qos:);
accpm_sap_any   = access_ctr_t (:0, 255, 0, maxint:);

(* default values for terminal SAPs with minimum access rights *)
qosfr_term_min  = qos_fr_t (:min_qos, min_qos:);
accpm_term_min  = access_ctr_t (:0, 1, 0, 1:);

(* old default values, should not be used *)
def_qos_fr      = qos_fr_t (:min_qos,batch_qos:);
def_access_ctr  = access_ctr_t (:255,255,0,maxint:);

(*----------------------------------*)
(* protocol identification values   *)
(*----------------------------------*)

(* transport layer specifications *)

t_layer         = 4;

(* transport layer basic types *)

t_not_spec      = 0;
t_ecma72tsp     = 1;
t_isotsp        = 2;

(* transport layer subtypes *)

(* t-ecma72-tsp subtypes *)
te72_rc        = 1;
te72_hwb       = 2;
te72_cr        = 3;

(* session layer specifications *)

s_layer         = 5;

(* session layer basic types *)

s_not_spec      = 0;
s_ecma75sl      = 1;
s_isosl         = 2;

(* presentation layer specifications *)

p_layer         = 6;

(* presentation layer basic types *)

p_not_spec      = 0;
p_ecma88vtp     = 1;
p_ecma84dpp     = 2;
p_paxnmcp       = 3;
p_paxxfcp       = 4;

(* application layer specifications *)

a_layer         = 7;

(* application layer basic types *)

a_not_spec      = 0;
a_ecma85ftamp   = 1;

(*-------------------------------------------*)
(* sizes of cs defined types                 *)
(*-------------------------------------------*)

pr_id_sz        = 6;    (* size of pr-id-t *)
qos_fr_sz       = 10;   (* size of qos-fr-t *)
access_ctr_sz   = 6;    (* size of access-ctr-t *)
pr_id_array_sz  = max_pr_ids * pr_id_sz;  (* size of pr-id-array-t *)
logic_id_sz     = logic_id_lgt + 1;  (* size of logic-id-t *)
sap_adr_sz      = (sap_adr_lgt + 1) div 2;  (* size of sap-adr-t *)
account_sz      = (account_lgt + 1) div 2;  (* size of account-type *)

(* size of sap-act-prms *)
sap_act_sz      = 1 + 1 + 2 + 2 + qos_fr_sz + access_ctr_sz
  + 1 + pr_id_array_sz + logic_id_sz + sap_adr_sz;

(* size of sap-req-prms *)
sap_req_sz      = qos_fr_sz + access_ctr_sz + 1
  + pr_id_array_sz + logic_id_sz;


(*% Declarations for direct users (may be removed by others) *)

type

(*-------------------------------------*)
(* The CS zone definition              *)
(*-------------------------------------*)

cszone_type = record
cs_ix              :  byte;        (* int. zone ident. *)
server_pt          : ^mailbox;     (* server sempointer *)
out_sem            : mailbox;      (* headers or outqueue *)
out_count          :  integer;     (* count on out-sem *)
help_ref           : reference;    (* for int. use *)
help_sem           : mailbox;      (* for int. answers *)
except_head        : reference;    (* exception header *)
help_pool          : pool;         (* for int. allocs.*)
no_pools           :  byte;        (* no. of pools *)
sharing            :  boolean;     (* sharing user indic. *)
usergr             :  integer;     (* usergroup ident. *)
inhd_return        :  boolean;     (* header follows ia *)
i_stream           :  byte;        (* u4 of input ans. *)
o_stream           :  byte;        (* u4 of output ans. *)
end;

(*----------------------------------*)
(* The SAP definition               *)
(*----------------------------------*)

sap_states    = (sap_idle, sap_w_act, sap_w_pass, sap_active);

sap_desc_type = record
sap_state   :  sap_states;
cs_ix       :  1 .. 255;
usap_ix,
cssap_ix    :  0 .. maxint;
min_conn,
max_conn    :  0 .. maxint;
anonymous   :  boolean;
end;

(******************************************************)
(*                                                    *)
(*         THE CS PROCEDURES AND FUNCTIONS            *)
(*         -------------------------------            *)
(*                                                    *)
(*  The CS zone administration:                       *)
(*  ---------------------------                       *)
(*    function  cszone-open                           *)
(*    procedure cszone-close                          *)
(*                                                    *)
(*  The buffer pool administration:                   *)
(*  -------------------------------                   *)
(*    function  cspool                                *)
(*                                                    *)
(*  The CS SAP administration:                        *)
(*  --------------------------                        *)
(*    procedure cssap-init                            *)
(*    procedure cssap-act                             *)
(*    procedure cssap-pass                            *)
(*    function  cssap-exec-indic                      *)
(*                                                    *)
(*  The buffer flow administration:                   *)
(*  -------------------------------                   *)
(*    procedure cs-ia                                 *)
(*    function  cs-oa                                 *)
(*    procedure cs-om                                 *)
(*    procedure cs-ih-return                          *)
(*    procedure cs-error-disc                         *)
(*                                                    *)
(*  For the purpose of LCP operations:                *)
(*  ----------------------------------                *)
(*    procedure cszone-sense                          *)
(*    procedure cs-exch-lcp                           *)
(*                                                    *)
(******************************************************)


function cszone_open (
var cszone        : cszone_type;
var server_sem    : mailbox;
var answ_sem      : mailbox;
i_str,
o_str             : byte;
var no_of_pools   : byte;
no_of_outhds      : 0 .. maxint;
no_of_inhds       : 0 .. maxint;
no_of_ctrbufs     : 0 .. maxint;
inhd_ret          : boolean;
shar              : boolean;
usergr_id         : integer        ): byte;
external;


procedure cszone_close (
var cszone        : cszone_type);
external;


function cspool (
var cszone        : cszone_type;
pool_no           : 1..255;
pool_func         : pool_func_t;
no_of_bufs        : 0..maxint;
var sdu_size      : integer        ): integer;
external;


procedure cssap_init (
var sap           : sap_desc_type;
usap_ix           : 1..maxint);
external;


procedure cssap_act (
var cszone        : cszone_type;
var buf           : reference;
var sap           : sap_desc_type;
sap_prms          : sap_act_prms);
external;


procedure cssap_pass (
var cszone        : cszone_type;
var buf           : reference;
var sap           : sap_desc_type);
external;


function cssap_exec_indic (
var cszone        : cszone_type;
var buf           : reference;
var sap           : sap_desc_type;
var severity      : severity_t;
var reason        : integer        ): boolean;
external;


procedure cs_ia (
var cszone        : cszone_type;
var buf           : reference);
external;


function cs_oa (
var cszone        : cszone_type;
var buf           : reference;
var help_r        : reference      ): boolean;
external;


procedure cs_om (
var cszone        : cszone_type;
var buf           : reference;
u1                : byte);
external;


procedure cs_ih_return (
var cszone        : cszone_type;
var ia_buf        : reference);
external;


procedure cs_error_disc (
var cszone        : cszone_type;
var ia_buf        : reference);
external;


procedure cszone_sense (
var cszone        : cszone_type;
var supmsg        : reference;
var sp_bcnt       : integer;
ix                : integer);
external;


procedure cs_exch_lcp (
var cszone        : cszone_type;
u_lcpid           : integer;
var s_lcpid       : integer);
external;


.
