/* responder.c -- responder for callback demo */
static char *rcsid
= "$Header: /f/osi/others/callback/RCS/responder.c,v 7.1 91/02/22 09:26:42 mrose Interim $";
* $Header: /f/osi/others/callback/RCS/responder.c,v 7.1 91/02/22 09:26:42 mrose Interim $
* Revision 7.1 91/02/22 09:26:42 mrose
* Revision 7.0 89/11/23 21:58:14 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
struct TSAPaddr
*ta
= &tas
;
register struct SSAPaddr
*sz
;
register struct SSAPconnect
*sc
= &scs
;
register struct SSAPstart
*ss
= &sss
;
register struct SSAPdata
*sx
= &sxs
;
register struct SSAPrelease
*sr
= &srs
;
struct SSAPindication sis
;
register struct SSAPindication
*si
= &sis
;
register struct SSAPabort
*sa
= &si
-> si_abort
;
/* S-CONNECT.INDICATION */
if (SInit (argc
, argv
, ss
, si
) == NOTOK
)
adios (NULLCP
, "S-CONNECT.INDICATION: %s", SErrString (sa
-> sa_reason
));
advise (LLOG_NOTICE
, NULLCP
,
"S-CONNECT.INDICATION: <%d, %s, %s, %s, %s, %ld, %d>",
ss
-> ss_sd
, sprintref (&ss
-> ss_connect
),
saddr2str (&ss
-> ss_calling
), saddr2str (&ss
-> ss_called
),
sprintb (ss
-> ss_requirements
, RMASK
), ss
-> ss_isn
,
bzero ((char *) sbi
, sizeof *sbi
);
sbi
-> sb_sd
= ss
-> ss_sd
;
sbi
-> sb_connect
= ss
-> ss_connect
; /* struct copy */
sbi
-> sb_requirements
= ss
-> ss_requirements
& SR_BASUBSET
;
sbi
-> sb_settings
= ss
-> ss_settings
;
#define dotoken(requires,shift,bit,type) \
if (sbi -> sb_requirements & requires) \
switch (sbi -> sb_settings & (ST_MASK << shift)) { \
case ST_CALL_VALUE << shift: \
sbi -> sb_settings &= ~(ST_MASK << shift); \
sbi -> sb_settings |= ST_INIT_VALUE << shift; \
sbi -> sb_owned |= bit; \
adios (NULLCP, "%s token: reserved", type); \
sbi
-> sb_ssn
= sbi
-> sb_isn
= ss
-> ss_isn
;
if ((ta
= str2taddr (ss
-> ss_data
)) == NULLTA
)
adios (NULLCP
, "str2taddr failed");
if (SConnResponse (sbi
-> sb_sd
, &sbi
-> sb_connect
, NULLSA
, SC_ACCEPT
,
sbi
-> sb_requirements
, sbi
-> sb_settings
, sbi
-> sb_isn
,
adios (NULLCP
, "S-CONNECT.RESPONSE: %s", SErrString (sa
-> sa_reason
));
/* we use the transport address passed in via the initial user data,
along with our our session selector */
sz
-> sa_addr
= *ta
; /* struct copy */
bzero ((char *) sbo
, sizeof *sbo
);
sbo
-> sb_requirements
= SR_BASUBSET
;
#define dotoken(requires,shift,bit,type) \
if (sbo -> sb_requirements & requires) \
sbo -> sb_settings |= ST_INIT_VALUE << shift; \
sbo
-> sb_isn
= SERIAL_NONE
;
if (SConnRequest (&sbo
-> sb_connect
, NULLSA
, sz
, sbo
-> sb_requirements
,
sbo
-> sb_settings
, sbo
-> sb_isn
, NULLCP
, 0, NULLQOS
, sc
, si
)
adios (NULLCP
, "S-CONNECT.REQUEST: %s", SErrString (sa
-> sa_reason
));
if (sc
-> sc_result
!= SC_ACCEPT
)
adios (NULLCP
, "connection rejected by peer: %s",
SErrString (sc
-> sc_result
));
advise (LLOG_NOTICE
, NULLCP
,
"S-CONNECT.RESPONSE: <%d, %s, %s, %s, %ld, %d>",
sc
-> sc_sd
, sprintref (&sc
-> sc_connect
),
saddr2str (&sc
-> sc_responding
),
sprintb (sc
-> sc_requirements
, RMASK
), sc
-> sc_isn
,
sbo
-> sb_sd
= sc
-> sc_sd
;
sbo
-> sb_requirements
= sc
-> sc_requirements
;
sbo
-> sb_settings
= sc
-> sc_settings
;
#define dotoken(requires,shift,bit,type) \
if (sbo -> sb_requirements & requires) \
if ((sbo -> sb_settings & (ST_MASK << shift)) == ST_INIT_VALUE) \
sbo -> sb_owned |= bit; \
sbo
-> sb_ssn
= sbo
-> sb_isn
= sc
-> sc_isn
;
switch (SReadRequest (sbi
-> sb_sd
, sx
, NOTOK
, si
)) {
adios (NULLCP
, "S-READ.REQUEST: %s", SErrString (sa
-> sa_reason
));
adios (NULLCP
, "not expecting DATA indication 0x%x", sx
-> sx_type
);
if (si
-> si_type
!= SI_FINISH
)
adios (NULLCP
, "not expecting indication 0x%x", si
-> si_type
);
if (SRelResponse (sbi
-> sb_sd
, SC_ACCEPT
, NULLCP
, 0, si
) == NOTOK
)
adios (NULLCP
, "S-RELEASE.RESPONSE: %s", SErrString (sa
-> sa_reason
));
if (SRelRequest (sbo
-> sb_sd
, NULLCP
, 0, NOTOK
, sr
, si
) == NOTOK
)
adios (NULLCP
, "S-RELEASE.REQUEST: %s", SErrString (sa
-> sa_reason
));
if (!sr
-> sr_affirmative
)
adios (NULLCP
, "release rejected by peer");