Annotation of 43BSDReno/contrib/isode-beta/others/callback/responder.c, revision 1.1.1.1

1.1       root        1: /* responder.c -- responder for callback demo */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/others/callback/RCS/responder.c,v 7.0 89/11/23 21:58:14 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/others/callback/RCS/responder.c,v 7.0 89/11/23 21:58:14 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       responder.c,v $
                     12:  * Revision 7.0  89/11/23  21:58:14  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: #include <stdio.h>
                     29: #include "callback.h"
                     30: 
                     31: /*  */
                     32: 
                     33: /* ARGSUSED */
                     34: 
                     35: main (argc, argv, envp)
                     36: int    argc;
                     37: char  **argv,
                     38:       **envp;
                     39: {
                     40:     struct TSAPaddr tas;
                     41:     struct TSAPaddr *ta = &tas;
                     42:     register struct SSAPaddr *sz;
                     43:     struct SSAPconnect scs;
                     44:     register struct SSAPconnect *sc = &scs;
                     45:     struct SSAPstart sss;
                     46:     register struct SSAPstart *ss = &sss;
                     47:     struct SSAPdata sxs;
                     48:     register struct SSAPdata   *sx = &sxs;
                     49:     struct SSAPrelease  srs;
                     50:     register struct SSAPrelease *sr = &srs;
                     51:     struct SSAPindication sis;
                     52:     register struct SSAPindication *si = &sis;
                     53:     register struct SSAPabort *sa = &si -> si_abort;
                     54:     struct sblk incoming,
                     55:                outgoing;
                     56:     SB     sbi = &incoming,
                     57:            sbo = &outgoing;
                     58: 
                     59:     reportailor (argv[0]);
                     60: 
                     61:        /* S-CONNECT.INDICATION */
                     62:     if (SInit (argc, argv, ss, si) == NOTOK)
                     63:        adios (NULLCP, "S-CONNECT.INDICATION: %s", SErrString (sa -> sa_reason));
                     64:     advise (LLOG_NOTICE, NULLCP,
                     65:            "S-CONNECT.INDICATION: <%d, %s, %s, %s, %s, %ld, %d>",
                     66:            ss -> ss_sd, sprintref (&ss -> ss_connect),
                     67:            saddr2str (&ss -> ss_calling), saddr2str (&ss -> ss_called),
                     68:            sprintb (ss -> ss_requirements, RMASK), ss -> ss_isn,
                     69:            ss -> ss_ssdusize);
                     70: 
                     71:     bzero ((char *) sbi, sizeof *sbi);
                     72:     sbi -> sb_sd = ss -> ss_sd;
                     73:     sbi -> sb_connect = ss -> ss_connect;      /* struct copy */    
                     74:     sbi -> sb_requirements = ss -> ss_requirements & SR_BASUBSET;
                     75:     sbi -> sb_settings = ss -> ss_settings;
                     76: #define dotoken(requires,shift,bit,type) \
                     77: { \
                     78:     if (sbi -> sb_requirements & requires) \
                     79:        switch (sbi -> sb_settings & (ST_MASK << shift)) { \
                     80:            case ST_CALL_VALUE << shift: \
                     81:                sbi -> sb_settings &= ~(ST_MASK << shift); \
                     82:                sbi -> sb_settings |= ST_INIT_VALUE << shift; \
                     83:                break; \
                     84:  \
                     85:            case ST_INIT_VALUE: \
                     86:                break; \
                     87:  \
                     88:            case ST_RESP_VALUE: \
                     89:                sbi -> sb_owned |= bit; \
                     90:                break; \
                     91:  \
                     92:            default: \
                     93:                adios (NULLCP, "%s token: reserved", type); \
                     94:                break; \
                     95:        } \
                     96: }
                     97:     dotokens ();
                     98: #undef dotoken
                     99:     sbi -> sb_ssn = sbi -> sb_isn = ss -> ss_isn;
                    100: 
                    101:     if ((ta = str2taddr (ss -> ss_data)) == NULLTA)
                    102:        adios (NULLCP, "str2taddr failed");
                    103: 
                    104:     SSFREE (ss);
                    105: 
                    106:     if (SConnResponse (sbi -> sb_sd, &sbi -> sb_connect, NULLSA, SC_ACCEPT,
                    107:            sbi -> sb_requirements, sbi -> sb_settings, sbi -> sb_isn,
                    108:            NULLCP, 0, si) == NOTOK)
                    109:        adios (NULLCP, "S-CONNECT.RESPONSE: %s", SErrString (sa -> sa_reason));
                    110: 
                    111:        /* we use the transport address passed in via the initial user data,
                    112:           along with our our session selector */
                    113:     sz = &ss -> ss_called;
                    114:     sz -> sa_addr = *ta;       /* struct copy */
                    115: 
                    116:     bzero ((char *) sbo, sizeof *sbo);
                    117:     sbo -> sb_requirements = SR_BASUBSET;
                    118:     sbo -> sb_settings = 0;
                    119: #define dotoken(requires,shift,bit,type) \
                    120: { \
                    121:     if (sbo -> sb_requirements & requires) \
                    122:            sbo -> sb_settings |= ST_INIT_VALUE << shift; \
                    123: }
                    124:     dotokens ();
                    125: #undef  dotoken
                    126:     sbo -> sb_isn = SERIAL_NONE;
                    127: 
                    128:        /* make the callback */
                    129:     if (SConnRequest (&sbo -> sb_connect, NULLSA, sz, sbo -> sb_requirements,
                    130:            sbo -> sb_settings, sbo -> sb_isn, NULLCP, 0, NULLQOS, sc, si)
                    131:            == NOTOK)
                    132:        adios (NULLCP, "S-CONNECT.REQUEST: %s", SErrString (sa -> sa_reason));
                    133:     if (sc -> sc_result != SC_ACCEPT)
                    134:        adios (NULLCP, "connection rejected by peer: %s",
                    135:                SErrString (sc -> sc_result));
                    136:     advise (LLOG_NOTICE, NULLCP,
                    137:            "S-CONNECT.RESPONSE: <%d, %s, %s, %s, %ld, %d>",
                    138:            sc -> sc_sd, sprintref (&sc -> sc_connect),
                    139:            saddr2str (&sc -> sc_responding),
                    140:            sprintb (sc -> sc_requirements, RMASK), sc -> sc_isn,
                    141:            sc -> sc_ssdusize);
                    142: 
                    143:     sbo -> sb_sd = sc -> sc_sd;
                    144:     sbo -> sb_requirements = sc -> sc_requirements;
                    145:     sbo -> sb_settings = sc -> sc_settings;
                    146: #define dotoken(requires,shift,bit,type) \
                    147: { \
                    148:     if (sbo -> sb_requirements & requires) \
                    149:        if ((sbo -> sb_settings & (ST_MASK << shift)) == ST_INIT_VALUE) \
                    150:            sbo -> sb_owned |= bit; \
                    151: }
                    152:     dotokens ();
                    153: #undef  dotoken
                    154:     sbo -> sb_ssn = sbo -> sb_isn = sc -> sc_isn;
                    155: 
                    156:     SCFREE (sc);
                    157: 
                    158: /* do work here */
                    159: 
                    160:     switch (SReadRequest (sbi -> sb_sd, sx, NOTOK, si)) {
                    161:        case NOTOK:
                    162:            adios (NULLCP, "S-READ.REQUEST: %s", SErrString (sa -> sa_reason));
                    163: 
                    164:        case OK:
                    165:            adios (NULLCP, "not expecting DATA indication 0x%x", sx -> sx_type);
                    166: 
                    167:        case DONE:
                    168:            if (si -> si_type != SI_FINISH)
                    169:                adios (NULLCP, "not expecting indication 0x%x", si -> si_type);
                    170:            if (SRelResponse (sbi -> sb_sd, SC_ACCEPT, NULLCP, 0, si) == NOTOK)
                    171:                adios (NULLCP, "S-RELEASE.RESPONSE: %s", SErrString (sa -> sa_reason));
                    172:            break;
                    173:     }
                    174: 
                    175:     if (SRelRequest (sbo -> sb_sd, NULLCP, 0, NOTOK, sr, si) == NOTOK)
                    176:        adios (NULLCP, "S-RELEASE.REQUEST: %s", SErrString (sa -> sa_reason));
                    177:     if (!sr -> sr_affirmative)
                    178:        adios (NULLCP, "release rejected by peer");
                    179: 
                    180:     exit (0);
                    181: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.