atsenv; (*-----------------------------------------------------------------*) (* *) (* address translation environment *) (* *) (* description: *) (* the atsenv defines the most common used constants, types and *) (* routines used by modules using address translation facilities. *) (* *) (* ver. date init changes *) (* -------------------------------------------------------------- *) (* - - 891203 oer initial version *) (* - - 900809 phk added ats_read_zone procedure *) (* - - 900810 oer ats_options extended with mess_req_bufs *) (* - - 901113 oer mega compiler option changed to target *) (* - - 910125 phk added ats_pnic_activate, ats_get_subaddress*) (* routines and defined new result from *) (* ats_receive_answer: ats_answered, ats_busy,*) (* ats_sub_failure, ats_pnic_failure, *) (* ats_link_failure *) (*-----------------------------------------------------------------*) (*-------------------------------------*) (* Version of atsenv *) (*-------------------------------------*) type ats_version_type = record version : byte; release : byte; end; const atsenv_version = ats_version_type(: 1, 0 :); (*--------------------------------------*) (* Options in the use of ats-routines *) (*--------------------------------------*) type ats_options_type = packed record ats_optional : boolean; -- true if module may run without ats soft_init : boolean; -- no hard_wait in ats_initialize user_req : boolean; -- all requests are given to user abort_return : boolean; -- user want ats_abort to return ?,?,?,? : boolean; -- ffu mess_req_bufs : byte; -- number of request message headers end; const ats_options = ats_options_type(: false, -- ats_optional false, -- soft init false, -- oper_types true, -- abort_return false, -- ffu1 false, false, false, 1 :); max_ats_query_bufs = 255; -- same as mess_req_bufs const ats_break_excep = pax_break_code + 1; (*---------------------------------------------------*) (* ats parameter types *) (*---------------------------------------------------*) type pnic_type = packed3502 array(1..4) of hex_digit; const nil_pnic = pnic_type(: 4 *** 0:); type net_iaddr_type = record net : byte; reg : byte; node : byte; ext : integer; end; const nil_addr = net_iaddr_type(: 0, 0, 0, 0:); const max_dte_cifs = 15; type x25_addr_val = packed3502 array(1..max_dte_cifs) of hex_digit; type $if target=rc5000 ats_qoper_type = ( x0,x1,x2,x3,x4,x5, ats_getroute_query, -- only ats_called has a value ( an ixi addr value) ats_validate_query, -- only ats_calling has a value ( an xxx addr value) x8,x9,x10,x11,x12,x13,x14,x15); --for compatibility with mega $else ats_qoper_type = ( ats_validate_query, -- only ats_calling has a value ( an xxx addr value) ats_getroute_query, -- only ats_called has a value ( an ixi addr value) x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15); --for compatibility with mega $endif ats_oper_set_type = set of ats_qoper_type; type dte_addr_type = packed3502 record l : byte; v : x25_addr_val; end; const max_nsap_cifs = 40; type nsap_addr_val = packed3502 array(1..max_nsap_cifs) of hex_digit; nsap_addr_type = packed3502 record tl : byte; v : nsap_addr_val; end; const nil_dte_addr = dte_addr_type(: 0, x25_addr_val(: max_dte_cifs *** 0:):); nil_nsap_addr = nsap_addr_type(: 0, nsap_addr_val(: max_nsap_cifs *** 0:):); max_addr_length = 21; type addr_kind_type = ( ak_null, ak_dte, ak_nsap); addr_type = array(1..max_addr_length) of byte; gen_addr_type = packed3502 record addr_kind : addr_kind_type; addr : addr_type; end; type ats_user_id_type = record pnic : pnic_type; addr : net_iaddr_type; dce_addr : dte_addr_type; end; const nil_user_id = ats_user_id_type(: nil_pnic, nil_addr, nil_dte_addr:); type ats_answer_type = packed3502 record calling_dte : dte_addr_type; called_dte : dte_addr_type; called_net : net_iaddr_type; end; const ats_min_buf_lgt = 300; (*-------------------------------------*) (* ats zone type *) (*-------------------------------------*) type ats_a_type = -- the assignable part of zone record env_version : ats_version_type; -- the version of the ats zone lib_version : ats_version_type; -- the version of the procedures options : ats_options_type; -- the options assigned to the zone ats_name : alfa; -- the incarnation name of server ats_user_id : ats_user_id_type; -- identification of the ats user ats_user_ix : integer; -- the ats user index of the zone no_of_updates : integer; -- no of updates generated no_of_answers_upd : integer; -- no of answers received on updates no_of_queries : integer; -- no of queries generated no_of_answers_qry : integer; -- no of answers received on queries ats_calling_dte : dte_addr_type; -- calling dte addr used in last query ats_calling_nsap : nsap_addr_type; -- calling nsap addr user in last query ats_called_dte : dte_addr_type; -- called dte addr used in last query ats_called_nsap : nsap_addr_type; -- called nsap addr user in last query ats_candidates : integer; -- no of candidates in query answer ats_stream : byte; -- stream number for ats transactions end; ats_b_type = -- buffer management part of zone record ats : sempointer; -- main mailbox for the ats main : sempointer; -- main mailbox for the module request_ref : reference; request_sem : mailbox; -- mailbox for free request buffers answer_ref : reference; answer_sem : mailbox; -- answer mailbox for requests request_pool : pool; header_pool : pool; help_ref : reference; calling_dte_cache : reference; calling_nsap_cache : reference; called_dte_cache : reference; called_nsap_cache : reference; end; ats_zone_type = record a : ats_a_type; b : ats_b_type; end; (*--------------------------------------------------------*) (* Inclusion and Exclusion of Address Translation Service *) (*--------------------------------------------------------*) type ats_init_result = ( (* 0 *) ats_init_ok, (* 1 *) ats_init_no_ats, (* 2 *) ats_init_no_buf, (* 3 *) ats_init_no_incl, (* 4 *) ats_init_few_headers); function ats_initialize( var ats_zone : ats_zone_type; -- the ats zone to be intiated ats_user_id : ats_user_id_type; -- identification of the user ats_server_inc : integer; -- the incarnation number of server var ats_answ_sem : sempointer; -- the answer mailbox of the buffers ats_stream : byte; -- the u4 val of the input answers ats_options : ats_options_type; -- options for configuration ats_version : ats_version_type) -- taken from this environment : ats_init_result; -- result external; (*----------------------------------------------------------*) (* The ATS_INITIALIZE procedure prepares the ats_zone for *) (* use by initializing the zone variable and by making *) (* the corresponding module a user of the Addresss Trans- *) (* lation Service. *) (* The recommended options for configurating the ats_zone is*) (* given in this environment in ATS_OPTIONS. *) (* Other options should only be used in special cases. *) (* *) (* The function shall be called before the process is able *) (* to use the Address Translation Service, and it may be *) (* called in the initialization part of the module. *) (* *) (* The following results may be given : *) (* *) (* 0 :- ats_init_ok *) (* 1 :- ats_init_no_ats *) (* 2 :- ats_init_no_buf *) (* 3 :- ats_init_no_incl *) (* 4 :- ats_init_few_headers *) (* *) (*----------------------------------------------------------*) function ats_init_answer( var ats_zone : ats_zone_type; var help_ref : reference): ats_init_result; external; (*-----------------------------------------------------------------------*) (* The ATS_INITIALIZE_ANSWER procedure handles the answer from ATS on *) (* an include user message. *) (* This procedure shall not be used if ats_option soft_init has not been *) (* chosen. *) (*-----------------------------------------------------------------------*) procedure ats_terminate( var ats_zone : ats_zone_type; cause : integer ); external; (*----------------------------------------------------------------*) (* The ATS_TERMINATE procedure executes an orderly termination of *) (* the ats activities in the module,ie the procedure excludes the *) (* module from using the Address Translation Service and closes *) (* the ats zone. *) (*----------------------------------------------------------------*) (*----------------------------------------*) (* Sending requests and receiving Answers *) (*----------------------------------------*) type ats_query_result = ( ats_query_ok, ats_query_no_buf, ats_ill_calling_nsap, ats_ill_called_nsap, ats_query_ffu_error); function ats_query( var ats_zone : ats_zone_type; -- the ats zone ats_oper_set : ats_oper_set_type; -- operation set ats_user_ref : integer; -- users ref to the operation ats_called : gen_addr_type; -- dte or nsap addr ats_calling : gen_addr_type) -- dte or nsap addr : ats_query_result; external; (*-------------------------------------------------------*) (* The ATS_QUERY procedure forms a query *) (* message and sends this to the Address Translation *) (* Service. *) (*-------------------------------------------------------*) const ats_st_no_free_res = 128; -- no free resources available ats_st_out_of_range = 32; -- out of range ats_st_illegal_state = 16; -- illegal state ats_st_data_error = 8; -- error found in supervisor data ats_st_obj_unknown = 4; -- object type unknown ats_st_ill_ats_oper = 2; -- illegal ats_oper ats_st_successed = 0; -- the operation was executed sucessfully type ats_panswer_type = ( ats_ok, -- the operation was executed successfully ats_error, -- error in answer from ats, see ats_result and ats_reason ats_format_error, -- format error in the message ats_no_message, -- no message received ats_buf_rejected, -- the buffer has been rejected by ats ats_u2_error, -- u2 <> ok in the answer from ats ats_initialized, -- (soft-init only) the ats_zone is ready ats_terminated, -- the ats_zone cannot be made ready ats_answered, -- the ats_zone has taken aktion ats_busy, -- the ats has rejected the query because of a busy condition ats_sub_failure, -- subaddress handling failed ats_pnic_failure, -- the query failed because of a missing pnic ats_link_failure); -- the connection to a master ATS/dis has failed function ats_receive_answer( var ats_zone : ats_zone_type; var ats_msg : reference; -- the buffer received var ats_user_ref : integer; -- user ref to the answer var ats_oper_set : ats_oper_set_type;-- operation codes var ats_answer : ats_answer_type; var ats_result : severity_t; -- the result of the ats operation var ats_reason : integer) -- the reason to the specified result : ats_panswer_type; external; (*-------------------------------------------------------------*) (* The ATS_RECEIVE_ANSWER handles the receivement of answers *) (* from the Address Translation Server. *) (* *) (* The answer to a previous ats_query call is given in *) (* ats_answer_type : *) (* *) (* calling_dte : dte_addr_type -- xxx or nsap query *) (* called_dte : dte_addr_type -- ixi or nsap query *) (* called_net : net_iaddr_type -- pnic query *) (* *) (* The value of ats_result is set to ats_st_successed if ok. *) (* *) (* The following results/actions may occur: *) (* *) (* ats_format_error : should be ignored *) (* ats_break : the module must call the exception *) (* procedure or the ats_terminate *) (* ats_initialized : (soft-init only) the ats_zone is ready *) (* ats_terminated : the module may stop execution *) (* *) (*-------------------------------------------------------------*) procedure ats_read_zone( var ats_zone : ats_zone_type; var ref : reference; offset : integer; var sp_bcnt : integer; var sp_st : integer); external; (*-------------------------------------------------------------*) (* The ATS_READ_ZONE reads the zone variables into the lcp *) (* message starting from offset *) (*-------------------------------------------------------------*) function ats_pnic_activate( var ats_zone : ats_zone_type; upload : boolean; var pnic : pnic_type) : boolean; external; (*-------------------------------------------------------------*) (* The ATS_PNIC_ACTIVATE uploads or removes the pnic defined *) (* in the ATS zone currently. If the result is false this is *) (* either because of lack of ats buffers or because of a *) (* initialization of the zone. On return the variable pnic *) (* holds a copy of the pnic in question *) (*-------------------------------------------------------------*) function ats_get_subaddress( var ats_zone : ats_zone_type; var dte_addr : dte_addr_type; var gen_addr : gen_addr_type) : boolean; external; (*-------------------------------------------------------------*) (* The ATS_GET_SUBADDRESS retrieves the subaddress from the *) (* gen_addr parameter and inserts it in the dte_addr parameter *) (* The routine returns false if there is no room in the *) (* dte_addr parameter for the subaddress, otherwise true *) (*-------------------------------------------------------------*) (*------------------------------------------------------------*) (* *) (* end of Address Translation environment *) (* *) (*------------------------------------------------------------*) .