static char *rcsid
= "$Header: /f/osi/vt/RCS/vtpm.c,v 7.1 91/02/22 09:48:30 mrose Interim $";
* $Header: /f/osi/vt/RCS/vtpm.c,v 7.1 91/02/22 09:48:30 mrose Interim $
* Revision 7.1 91/02/22 09:48:30 mrose
* Revision 7.0 89/11/23 22:31:57 mrose
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
extern int sd
; /*Session descriptor for this association*/
struct AcSAPconnect accs
;
struct AcSAPconnect
*acc
;
struct AcSAPrelease acrs
;
struct AcSAPrelease
*acr
;
struct AcSAPindication acis
;
struct AcSAPindication
*aci
;
struct PSAPindication pi
;
/****************************************************************************/
/* GET EVENT - attempt to read a PDU from the presentation connection */
/* designated by "sd", determine */
/* which imcoming event has ocurred, */
/* and process the event with "do_event" */
/* A non-blocking read is done and OK is returned if there */
/* is nothing to read. */
/* FD - the presentation ID for the connection to read from */
/* PE - a pointer to the presentation element that is read */
/* (note that what is passed is a pointer to a pointer to */
/* data structure so that the address of the PE */
/* that is read can be returned in this parameter) */
/* RETURNS - the number of the incoming event associated with reading */
/* this PE from the network */
/****************************************************************************/
result
= PReadRequest(dd
, &px
, OK
, &pi
);
advise(LLOG_EXCEPTIONS
,NULLCP
, "P-READ REQUEST returned NOTOK");
if (pi
.pi_type
== PI_FINISH
) {
else if(pi
.pi_type
== PI_SYNC
)
return( pn_ind(dd
, &pi
.pi_sync
)) ;
adios(NULLCP
, "PReadRequest returned DONE, but event unknown (%d)",pi
.pi_type
);
adios(NULLCP
, "read more than one PE from network!\n");
/* we are assuming here that you can only get one PDU per P-DATA.
PLOG (vt_log
, print_VT_PDUs
, *pe
, NULLCP
, 1);
if ((*pe
)->pe_class
!= PE_CLASS_CONT
)
adios(NULLCP
,"read pe of class %d", (*pe
)->pe_class
);
advise(LLOG_DEBUG
,NULLCP
, "got ASQ_PDU");
advise(LLOG_DEBUG
,NULLCP
, "got ASR_PDU");
advise(LLOG_DEBUG
,NULLCP
, "got AUQ_PDU");
advise(LLOG_DEBUG
,NULLCP
, "got DAQ_PDU");
advise(LLOG_DEBUG
,NULLCP
, "got DLQ_PDU");
advise(LLOG_DEBUG
,NULLCP
, "got NDQ_PDU");
event
= NDQ_tr
; /*See comment below*/
/* We're supposed to find out if the NDQ contains an
update to a triggered control object or not to determine
what kind of event we have. Right now we'll assume that
we do have such an update in all cases. Note that this may
be a problem if we use quarantine delivery control in the
for each update, find out if the update is for a display object
or for a control object. if it's a control object get the name
of it and find out if it has a trigger
if(debug
) advise(LLOG_NOTICE
,NULLCP
,"Got HDQ");
adios(NULLCP
,"unknown PDU type %d", (*pe
)->pe_id
);
return(do_event(event
,*pe
));
/* number of states in each sector */
unsigned max_state
[SECTORS
] = { 0, 13, 0, 0, 0, 10};
s1_01
, /* states in the first sector */
int ((**sectors
[])()) = {s0
, s1
, s2
, s3
, s4
, s5
};
advise(LLOG_DEBUG
,NULLCP
,
"in do_event, sector is %d, state is %d, event is %d (%s)",
&& event
< sizeof eventname
/sizeof eventname
[0]
? eventname
[event
] : "INVALID");
if (sector
>= SECTORS
|| state
>= max_state
[sector
])
return(sectors
[sector
][state
](event
, pe
));
pn_ind(dd
, psync
) /* sync indications */
advise(LLOG_DEBUG
,NULLCP
, "vt: got SN_MAJORIND");
advise(LLOG_DEBUG
,NULLCP
, "vt: got SN_MAJORCNF");
advise(LLOG_DEBUG
,NULLCP
, "vt: got SN_MINORIND");
advise(LLOG_DEBUG
,NULLCP
, "vt: got SN_MINORCNF");
/* advise(LLOG_DEBUG,NULLCP, "vt: resetind: SN_RESETIND"); */
if(psync
->pn_options
!= SYNC_RESTART
)
adios(NULLCP
,"resetind: bad options params");
return( do_event(BKQ
,psync
->pn_info
[0]));
else return( do_event(BKQ
,NULLPE
));
/* advise(LLOG_DEBUG,NULLCP, "vt: got SN_RESETCNF\n"); */
if(psync
->pn_options
!= SYNC_RESTART
)
adios(NULLCP
,"resetind: bad options params");
return( do_event(BKR
,psync
->pn_info
[0]));
else return( do_event(BKR
,NULLPE
));
adios(NULLCP
,"received bad sync type");
/*****************************************************************************/
/* P_DATA - send a PDU via PDataRequest */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_DATA) */
/*****************************************************************************/
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PDataRequest(sd
, &pdu
, 1, &pi
) != OK
)
ps_adios (&pi
.pi_abort
, "P-DATA.REQUEST");
/****************************************************************************/
/* P_MAJOR_SYNC.REQUEST - send a PDU via PMajSyncRequest */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_MAJOR_SYNC.REQUEST) */
/****************************************************************************/
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PMajSyncRequest(sd
, &ssn
, &pdu
, 1, &pi
) != OK
)
ps_adios (&pi
.pi_abort
, "P-MAJOR-SYNC.REQUEST");
/****************************************************************************/
/* P_MAJOR_SYNC.RESPONSE - send a PDU via PMajSyncResponse */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_MAJOR_SYNC.RESPONSE)*/
/****************************************************************************/
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PMajSyncResponse(sd
, &pdu
, 1, &pi
) != OK
)
ps_adios (&pi
.pi_abort
, "P-MAJOR-SYNC.RESPONSE");
/***************************************************************************/
/* P_TYPED_DATA - send a PDU via PTypedRequest */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_TYPED_DATA) */
/***************************************************************************/
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PTypedRequest(sd
, &pdu
, 1, &pi
) != OK
)
ps_adios (&pi
.pi_abort
, "P-TYPED-DATA.REQUEST");
/*****************************************************************************/
/* P_RESYNCHRONIZE.REQUEST - send a PDU via PReSyncRequest */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the (break) PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_RESYNC.REQUEST) */
/*****************************************************************************/
long ssn
= 0; /* should be made a global at some time */
int settings
= ST_INIT_VALUE
;
#define VTKP_REQ 0x00 /* setting values, see ssap.h */
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PReSyncRequest(sd
, type
, ssn
, settings
, &pdu
, 1, &pi
) != OK
)
/* if (PReSyncRequest(sd, type, 0, 0, (PE *)NULL, 0, &pi) != OK) */
ps_adios (&pi
.pi_abort
, "P-RESYNCHRONIZE.REQUEST");
/****************************************************************************/
/* P_RESYNC.RESPONSE - send a PDU via PReSyncResponse */
/* RETURNS - OK or exits on error */
/* PDU - a PE containing the PDU to be sent */
/* CLASSIFICATION - utility function for VTPM (used only in processing */
/* outgoing events that are mapped to P_RESYNC.RESPONSE) */
/****************************************************************************/
long ssn
= 0; /* should be made a global at some time */
int settings
= ST_INIT_VALUE
;
PLOG (vt_log
, print_VT_PDUs
, pdu
, NULLCP
, 0);
if (PReSyncResponse(sd
, ssn
, settings
, &pdu
, 1, &pi
) != OK
)
ps_adios (&pi
.pi_abort
, "P-RESYNCHRONIZE.RESPONSE");
/****************************************************************************/
/* ASR - generate an ASR event. (that is send an ASR PDU which is */
/* passed in as a parameter as user data on the AcAssocResponse.)*/
/* PARAMETERS: PE - a vt ASR PDU */
/* status (SUCCESS or FAILURE) */
/****************************************************************************/
/* include "pe" as user data on the AcAssocResponse
struct PSAPctxlist
*pl
= &ps
->ps_ctxlist
;
for(i
=0; i
<pl
->pc_nctx
; i
++)
advise(LLOG_DEBUG
,NULLCP
," ctx %d: %d %s %d",
i
,pl
->pc_ctx
[i
].pc_id
,sprintoid(pl
->pc_ctx
[i
].pc_asn
),
pl
->pc_ctx
[i
].pc_result
);
advise(LLOG_DEBUG
,NULLCP
, "in asr.\n");
advise(LLOG_DEBUG
,NULLCP
, "about to call AcAssocResp, sd is %d, pe->pe_id is %d\n", sd
, pe
->pe_id
);
reason
= ACS_USER_NOREASON
;
s_requirements
= SR_DUPLEX
| SR_RESYNC
| SR_TYPEDATA
;
if (AcAssocResponse (sd
, status
, reason
, NULLOID
, NULLAEI
,
ps
->ps_defctxresult
, ps
->ps_prequirements
, s_requirements
,isn
,
ps
->ps_settings
, &ps
->ps_connect
, &pe
, 1, aci
) == NOTOK
)
acs_adios (aca
, "A-ASSOCIATE.RESPONSE");
advise(LLOG_DEBUG
,NULLCP
, "sent AcAssociate Response\n");
send_bad_asr(reason
) /*Compose and send ASR with result = failure. Encode
ASR-FailureReason using the reason parameter
bzero ((char *) &ud
, sizeof ud
);
ud
.reason
.provider_reason
= reason
;
else ud
.valid_reason
= 0;
ud
.result
= 0; /*Failure code*/
ud
.version
.bitstring
= 0x00;
if(build_ASRPDU_ASRpdu(&asr_pe
,1,NULL
,NULLCP
,(PEPYPARM
)&ud
) == NOTOK
)
adios (NULLCP
, "ASR build failure (%s)", PY_pepy
);
return(asr(asr_pe
,FAILURE
)); /*Send the PDU thru Association control*/
send_rlr(pe
) /*Send RLR (Release Response) PDU to peer. The RLR is
built by vrelrsp(). It is sent by a call to Association
if(AcRelResponse(sd
,ACS_ACCEPT
,ACR_NORMAL
,&pe
,1,aci
) == NOTOK
)
acs_adios (&aci
->aci_abort
, "A-RELEASE.RESPONSE");
clear_vte() /*Clear VT Environment. */
/*Nothing to do for now since we have no formalized environment
and we exit VTP when association ends.
vgvt_ind() /*Indication to User that peer has given the token*/
/*Don't know how to indicate this to user yet*/
vrtq_ind() /*Indicate to User that peer has requested token*/
/*Don't know how to give indication to user.
Synchronous? Asynch interrupt??? */
give_token() /*Transfer Token to peer. For VTP, all tokens are given
at once so no need to discriminate between them.
struct PSAPindication vt_pi
;
vt_tokens
= ST_RLS_TOKEN
;
if(PGTokenRequest(sd
,vt_tokens
,&vt_pi
) == NOTOK
&& vt_pi
.pi_abort
.pa_reason
!= PC_OPERATION
)
ps_adios (&vt_pi
.pi_abort
, "P-GIVE-TOKENS.REQUEST");
request_token() /*Request Tokens from peer*/
struct PSAPindication vt_pi
;
vt_tokens
= ST_RLS_TOKEN
;
if(PPTokenRequest(sd
,vt_tokens
,NULLPEP
,0,&vt_pi
) == NOTOK
&& vt_pi
.pi_abort
.pa_reason
!= PC_OPERATION
)
ps_adios (&vt_pi
.pi_abort
, "P-PLEASE-TOKENS.REQUEST");
send_all() /*TEMP -- Should be supplied by Sector 5 actions*/
advise(LLOG_DEBUG
,NULLCP
, "send_all dummy routine");
void acs_adios (aa
, event
)
register struct AcSAPabort
*aa
;
static void acs_advise (aa
, event
)
register struct AcSAPabort
*aa
;
(void) sprintf (buffer
, "[%s] %*.*s",
AcErrString (aa
-> aca_reason
),
aa
-> aca_cc
, aa
-> aca_cc
, aa
-> aca_data
);
(void) sprintf (buffer
, "[%s]", AcErrString (aa
-> aca_reason
));
advise (LLOG_NOTICE
,NULLCP
, "%s: %s (source %d)", event
, buffer
,
static void ps_adios (pab
, event
)
register struct PSAPabort
*pab
;
static void ps_advise (pab
, event
)
register struct PSAPabort
*pab
;
(void) sprintf (buffer
, "[%s] %*.*s",
PErrString (pab
-> pa_reason
),
pab
-> pa_cc
, pab
-> pa_cc
, pab
-> pa_data
);
(void) sprintf (buffer
, "[%s]", PErrString (pab
-> pa_reason
));
advise (LLOG_NOTICE
,NULLCP
, "%s: %s%s", event
, buffer
,
pab
-> pa_peer
? " (peer initiated)" : "");