Annotation of 43BSDReno/contrib/isode-beta/dsap/net/dsapbind1.c, revision 1.1

1.1     ! root        1: /* dsapbind1.c - DSAP : Bind for Directory protocols DAP, DSP and QSP */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/dsap/net/RCS/dsapbind1.c,v 7.0 90/07/26 14:45:49 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/dsap/net/RCS/dsapbind1.c,v 7.0 90/07/26 14:45:49 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       dsapbind1.c,v $
        !            12:  * Revision 7.0  90/07/26  14:45:49  mrose
        !            13:  * *** empty log message ***
        !            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: /* LINTLIBRARY */
        !            29: 
        !            30: #include <stdio.h>
        !            31: #include "logger.h"
        !            32: #include "quipu/dsap.h"
        !            33: 
        !            34: extern  OID     acse_pci;
        !            35: extern  OID     x500_da_ac;
        !            36: extern  OID     x500_ds_ac;
        !            37: extern  OID     quipu_ds_ac;
        !            38: extern  OID     x500_da_as;
        !            39: extern  OID     x500_ds_as;
        !            40: extern  OID     quipu_ds_as;
        !            41: extern  struct PSAPctxlist      * x500_da_pcdl;
        !            42: extern  struct PSAPctxlist      * x500_ds_pcdl;
        !            43: extern  struct PSAPctxlist      * quipu_ds_pcdl;
        !            44: 
        !            45: extern LLog    * log_dsap;
        !            46: 
        !            47: 
        !            48: int      DspAsynBindReqAux (callingtitle, calledtitle, callingaddr,
        !            49:                calledaddr, prequirements, srequirements, isn, settings,
        !            50:                sf, bindarg, qos, dc, di, async)
        !            51: AEI                      callingtitle;
        !            52: AEI                      calledtitle;
        !            53: struct PSAPaddr                * callingaddr;
        !            54: struct PSAPaddr                * calledaddr;
        !            55: int                      prequirements;
        !            56: int                      srequirements;
        !            57: long                     isn;
        !            58: int                      settings;
        !            59: struct SSAPref         * sf;
        !            60: struct ds_bind_arg     * bindarg;
        !            61: struct QOStype         * qos;
        !            62: struct DSAPconnect     * dc;
        !            63: struct DSAPindication  * di;
        !            64: int                      async;
        !            65: {
        !            66:        int                       result;
        !            67:        OID                       app_ctx;
        !            68:        struct PSAPctxlist      * pcl;
        !            69:        OID                       def_ctx;
        !            70:        PE                        bindargpe;
        !            71:        struct RoNOTindication    rni_s;
        !            72:        struct RoNOTindication  * rni = &(rni_s);
        !            73:        struct AcSAPconnect     * acc = &(dc->dc_connect);
        !            74: 
        !            75:        app_ctx = x500_ds_ac;
        !            76:        def_ctx = x500_ds_as;
        !            77: 
        !            78:         pcl = (struct PSAPctxlist *) smalloc(sizeof(struct PSAPctxlist));
        !            79: 
        !            80:        (*pcl) = (*(x500_ds_pcdl)); /* struct copy */
        !            81: 
        !            82:        if (encode_DAS_DirectoryBindArgument (&bindargpe, 1, 0, NULLCP, bindarg) != OK)
        !            83:        {
        !            84:                return (dsaplose (di, DA_ARG_ENC, NULLCP, "DSP BIND REQUEST"));
        !            85:        }
        !            86:        bindargpe->pe_context = DIR_SYSTEM_PC_ID;
        !            87: 
        !            88:        result = RoAsynBindRequest (app_ctx, callingtitle, calledtitle,
        !            89:                        callingaddr, calledaddr, pcl, def_ctx, prequirements,
        !            90:                        srequirements, isn, settings, sf, bindargpe, qos,
        !            91:                        acc, rni, async);
        !            92: 
        !            93:        if (bindargpe != NULLPE)
        !            94:                pe_free (bindargpe);
        !            95:        free ((char *) pcl);
        !            96: 
        !            97:        if (result == NOTOK)
        !            98:        {
        !            99:                return (ronot2dsaplose (di, "DSP-BIND.REQUEST", rni));
        !           100:        }
        !           101: 
        !           102:        dc->dc_sd = acc->acc_sd;
        !           103: 
        !           104:        if (((!async) && (result == OK)) || (async && (result == DONE)))
        !           105:        {
        !           106:                if (DBindDecode (acc, dc) != OK)
        !           107:                {
        !           108:                        return (dsaplose (di, DA_RES_DEC, NULLCP, "DSP BIND REQUEST"));
        !           109:                }
        !           110:        }
        !           111: 
        !           112:        return (result);
        !           113: }
        !           114: 
        !           115: int      DspAsynBindRequest (calledaddr, bindarg, qos_maxtime, dc, di, async)
        !           116: struct PSAPaddr                * calledaddr;
        !           117: struct ds_bind_arg     * bindarg;
        !           118: int                      qos_maxtime;
        !           119: struct DSAPconnect     * dc;
        !           120: struct DSAPindication  * di;
        !           121: int                      async;
        !           122: {
        !           123:        struct SSAPref            sf_s;
        !           124:        struct SSAPref          * sf = &(sf_s);
        !           125:        struct QOStype            qos;
        !           126: 
        !           127:        if ((sf = addr2ref (PLocalHostName ())) == NULL)
        !           128:        {
        !           129:                sf = &sf_s;
        !           130:                (void) bzero ((char *) sf, sizeof *sf);
        !           131:        }
        !           132: 
        !           133:        (void) bzero ((char *) &qos, sizeof qos);
        !           134:        qos.qos_sversion = NOTOK;       /* Negotiate highest session */
        !           135:        qos.qos_maxtime = qos_maxtime;
        !           136: 
        !           137:        return (DspAsynBindReqAux (NULLAEI, NULLAEI, NULLPA, calledaddr,
        !           138:                        PR_MYREQUIRE, ROS_MYREQUIRE, SERIAL_NONE, 0, sf,
        !           139:                        bindarg, &qos, dc, di, async));
        !           140: }
        !           141: 
        !           142: int      QspAsynBindReqAux (callingtitle, calledtitle, callingaddr,
        !           143:                calledaddr, prequirements, srequirements, isn, settings,
        !           144:                sf, bindarg, qos, dc, di, async)
        !           145: AEI                      callingtitle;
        !           146: AEI                      calledtitle;
        !           147: struct PSAPaddr                * callingaddr;
        !           148: struct PSAPaddr                * calledaddr;
        !           149: int                      prequirements;
        !           150: int                      srequirements;
        !           151: long                     isn;
        !           152: int                      settings;
        !           153: struct SSAPref         * sf;
        !           154: struct ds_bind_arg     * bindarg;
        !           155: struct QOStype         * qos;
        !           156: struct DSAPconnect     * dc;
        !           157: struct DSAPindication  * di;
        !           158: int                      async;
        !           159: {
        !           160:        int                       result;
        !           161:        OID                       app_ctx;
        !           162:        struct PSAPctxlist      * pcl;
        !           163:        OID                       def_ctx;
        !           164:        PE                        bindargpe;
        !           165:        struct RoNOTindication    rni_s;
        !           166:        struct RoNOTindication  * rni = &(rni_s);
        !           167:        struct AcSAPconnect     * acc = &(dc->dc_connect);
        !           168: 
        !           169:        app_ctx = quipu_ds_ac;
        !           170:        def_ctx = quipu_ds_as;
        !           171: 
        !           172:         pcl = (struct PSAPctxlist *) smalloc(sizeof(struct PSAPctxlist));
        !           173: 
        !           174:        (*pcl) = (*(quipu_ds_pcdl)); /* struct copy */
        !           175: 
        !           176:        /* Encode Bind Argument */
        !           177:        if (encode_DAS_DirectoryBindArgument (&bindargpe, 1, 0, NULLCP, bindarg) != OK)
        !           178:        {
        !           179:                return (dsaplose (di, DA_ARG_ENC, NULLCP, "QSP BIND REQUEST"));
        !           180:        }
        !           181:        bindargpe->pe_context = DIR_SYSTEM_PC_ID;
        !           182: 
        !           183:        result = RoAsynBindRequest (app_ctx, callingtitle, calledtitle,
        !           184:                        callingaddr, calledaddr, pcl, def_ctx, prequirements,
        !           185:                        srequirements, isn, settings, sf, bindargpe,
        !           186:                        qos, acc, rni, async);
        !           187: 
        !           188:        if (bindargpe != NULLPE)
        !           189:                pe_free (bindargpe);
        !           190:        free ((char *) pcl);
        !           191: 
        !           192:        if (result == NOTOK)
        !           193:        {
        !           194:                /* Have an RoSAPindication, need to return DSAPindication */
        !           195:                return (ronot2dsaplose (di, "QSP-BIND.REQUEST", rni));
        !           196:        }
        !           197: 
        !           198:        dc->dc_sd = acc->acc_sd;
        !           199: 
        !           200:        if (((!async) && (result == OK)) || (async && (result == DONE)))
        !           201:        {
        !           202:                if (DBindDecode (acc, dc) != OK)
        !           203:                {
        !           204:                        return (dsaplose (di, DA_RES_DEC, NULLCP, "QSP BIND REQUEST"));
        !           205:                }
        !           206:        }
        !           207: 
        !           208:        return (result);
        !           209: }
        !           210: 
        !           211: int      QspAsynBindRequest (calledaddr, bindarg, qos_maxtime, dc, di, async)
        !           212: struct PSAPaddr                * calledaddr;
        !           213: struct ds_bind_arg     * bindarg;
        !           214: int                      qos_maxtime;
        !           215: struct DSAPconnect     * dc;
        !           216: struct DSAPindication  * di;
        !           217: int                      async;
        !           218: {
        !           219:        struct SSAPref            sf_s;
        !           220:        struct SSAPref          * sf = &(sf_s);
        !           221:        struct QOStype            qos;
        !           222: 
        !           223:        if ((sf = addr2ref (PLocalHostName ())) == NULL)
        !           224:        {
        !           225:                sf = &sf_s;
        !           226:                (void) bzero ((char *) sf, sizeof *sf);
        !           227:        }
        !           228: 
        !           229:        (void) bzero ((char *) &qos, sizeof qos);
        !           230:        qos.qos_sversion = NOTOK;       /* Negotiate highest session */
        !           231:        qos.qos_maxtime = qos_maxtime;
        !           232: 
        !           233:        /*
        !           234:        * The quipu system application context can assume that
        !           235:        * the remote DSA is a Quipu DSA and can take certain actions
        !           236:        * that are not generally available, such as refusing a
        !           237:        * connection release request. To do this, session negotiated
        !           238:        * release appears to be necessary, so SR_NEGOTIATED is
        !           239:        * is included in the session requirements here.
        !           240:        */
        !           241: 
        !           242:        return (QspAsynBindReqAux (NULLAEI, NULLAEI, NULLPA,
        !           243:                        calledaddr, PR_MYREQUIRE,
        !           244:                        ROS_MYREQUIRE | SR_NEGOTIATED, SERIAL_NONE, 0, sf,
        !           245:                        bindarg, &qos, dc, di, async));
        !           246: }
        !           247: 
        !           248: int      DspAsynBindRetry (sd, do_next_nsap, dc, di)
        !           249: int                      sd;
        !           250: int                      do_next_nsap;
        !           251: struct DSAPconnect     * dc;
        !           252: struct DSAPindication  * di;
        !           253: {
        !           254:        int                       result;
        !           255:        struct RoNOTindication    rni_s;
        !           256:        struct RoNOTindication  * rni = &(rni_s);
        !           257:        struct AcSAPconnect     * acc = &(dc->dc_connect);
        !           258: 
        !           259:        result = RoAsynBindRetry (sd, do_next_nsap, acc, rni);
        !           260: 
        !           261:        if (result == NOTOK)
        !           262:        {
        !           263:                return (ronot2dsaplose (di, "DAP-BIND.RETRY", rni));
        !           264:        }
        !           265: 
        !           266:        if (result == DONE)
        !           267:        {
        !           268:                if (DBindDecode (acc, dc) != OK)
        !           269:                {
        !           270:                        return (dsaplose (di, DA_RES_DEC, NULLCP, "DSP BIND RETRY"));
        !           271:                }
        !           272:        }
        !           273: 
        !           274:        return (result);
        !           275: }
        !           276: 
        !           277: int      QspAsynBindRetry (sd, do_next_nsap, dc, di)
        !           278: int                      sd;
        !           279: int                      do_next_nsap;
        !           280: struct DSAPconnect     * dc;
        !           281: struct DSAPindication  * di;
        !           282: {
        !           283:        int                       result;
        !           284:        struct RoNOTindication    rni_s;
        !           285:        struct RoNOTindication  * rni = &(rni_s);
        !           286:        struct AcSAPconnect     * acc = &(dc->dc_connect);
        !           287: 
        !           288:        result = RoAsynBindRetry (sd, do_next_nsap, acc, rni);
        !           289: 
        !           290:        if (result == NOTOK)
        !           291:        {
        !           292:                return (ronot2dsaplose (di, "DAP-BIND.RETRY", rni));
        !           293:        }
        !           294: 
        !           295:        if (result == DONE)
        !           296:        {
        !           297:                if (DBindDecode (acc, dc) != OK)
        !           298:                {
        !           299:                        return (dsaplose (di, DA_RES_DEC, NULLCP, "QSP BIND RETRY"));
        !           300:                }
        !           301:        }
        !           302: 
        !           303:        return (result);
        !           304: }
        !           305: 
        !           306: int      DBindDecode (acc, dc)
        !           307: struct AcSAPconnect    * acc;
        !           308: struct DSAPconnect     * dc;
        !           309: {
        !           310:     struct ds_bind_arg  * bind_res;
        !           311:     struct ds_bind_error        * bind_err;
        !           312: 
        !           313:     switch(acc->acc_result)
        !           314:     {
        !           315:        case ACS_ACCEPT:
        !           316:            DLOG(log_dsap, LLOG_NOTICE, ("DBindDecode ACCEPT"));
        !           317:            bind_res = &(dc->dc_un.dc_bind_res);
        !           318:            if ((acc->acc_ninfo == 1) && (acc->acc_info[0] != NULLPE))
        !           319:            {
        !           320:                if(decode_DAS_DirectoryBindResult(acc->acc_info[0], 1, NULLIP, NULLVP, bind_res) != OK)
        !           321:                {
        !           322:                    LLOG (log_dsap,LLOG_EXCEPTIONS,( "Unable to parse DirectoryBindResult"));
        !           323:                    dc->dc_result = DS_REJECT;
        !           324:                    return (NOTOK);
        !           325:                }
        !           326:                dc->dc_result = DS_RESULT;
        !           327:            }
        !           328:            else
        !           329:            {
        !           330:                LLOG(log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindResult"));
        !           331:                dc->dc_result = DS_REJECT;
        !           332:                return (NOTOK);
        !           333:            }
        !           334:            break;
        !           335: 
        !           336:        case ACS_PERMANENT:
        !           337:            /*
        !           338:            * Get the DirectoryBindError
        !           339:            */
        !           340:            DLOG(log_dsap, LLOG_NOTICE, ("DBindDecode PERMANENT"));
        !           341:            bind_err = &(dc->dc_un.dc_bind_err);
        !           342:            if ((acc->acc_ninfo == 1) && (acc->acc_info[0] != NULLPE))
        !           343:            {
        !           344:                if(decode_DAS_DirectoryBindError(acc->acc_info[0], 1, NULLIP, NULLVP, bind_err) != OK)
        !           345:                {
        !           346:                    LLOG(log_dsap, LLOG_EXCEPTIONS, ("Unable to decode DirectoryBindError"));
        !           347:                    dc->dc_result = DS_REJECT;
        !           348:                    return (NOTOK);
        !           349:                }
        !           350:                dc->dc_result = DS_ERROR;
        !           351:            }
        !           352:            else
        !           353:            {
        !           354:                LLOG(log_dsap, LLOG_EXCEPTIONS, ("No DirectoryBindError"));
        !           355:                dc->dc_result = DS_REJECT;
        !           356:                return (NOTOK);
        !           357:            }
        !           358:            break;
        !           359: 
        !           360:        default:
        !           361:            DLOG(log_dsap, LLOG_NOTICE, ("DBindDecode OTHER"));
        !           362:            LLOG (log_dsap,LLOG_EXCEPTIONS,( "Association rejected: [%s]",
        !           363:              AcErrString(acc->acc_result)));
        !           364:            dc->dc_result = DS_REJECT;
        !           365:            return (NOTOK);
        !           366: 
        !           367:     } /* switch acc->acc_result */
        !           368: 
        !           369:     return(OK);
        !           370: }
        !           371: 

unix.superglobalmegacorp.com

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