Annotation of 43BSDReno/contrib/isode-beta/rosap/test/rosrtinit.c, revision 1.1.1.1

1.1       root        1: #include <stdio.h>
                      2: #include "generic.h"           /* defines OPERATIONS and ERRORS */
                      3: #include <isode/rtsap.h>
                      4: #include <isode/rosap.h>
                      5: 
                      6: #define error  printf
                      7: 
                      8:                                /* e.g., "directory" */
                      9: static char *myservice = "ROSRTTEST";
                     10: 
                     11:                                /* e.g., "directory services" */
                     12: static char *mycontext = "isode chic read";
                     13: static char *mypci = "isode chic read pci";
                     14: 
                     15: 
                     16: #define INVOKE 1       /* do a RoInvokeRequest */
                     17: #define INTREQ 2       /* do a RoIntrRequest */
                     18: #define INVERR 3       /* request an error */
                     19: #define INVURJ 4       /* request a user reject */
                     20: #define INVPRJ 5       /* request a provider reject */
                     21: 
                     22: #define TIMEOUT        30      /* seconds before RtWait times out */
                     23: 
                     24: main (argc, argv, envp)
                     25: int    argc;
                     26: char  **argv,
                     27:       **envp;
                     28: {
                     29:     int            sd;
                     30:     struct SSAPref sfs;
                     31:     register struct SSAPref *sf;
                     32:     register struct PSAPaddr *pa;
                     33:     struct AcSAPconnect accs;
                     34:     register struct AcSAPconnect   *acc = &accs;
                     35:     struct AcSAPrelease acrs;
                     36:     register struct AcSAPrelease   *acr = &acrs;
                     37:     struct AcSAPindication  acis;
                     38:     register struct AcSAPindication *aci = &acis;
                     39:     register struct AcSAPabort *aca = &aci -> aci_abort;
                     40:     struct RoSAPindication  rois;
                     41:     register struct RoSAPpreject   *rop = &rois.roi_preject;
                     42:     register AEI aei;
                     43:     register OID ctx, pci;
                     44:     struct PSAPctxlist pcs;
                     45:     register struct PSAPctxlist *pc = &pcs;
                     46:     struct RtSAPindication  rtis;
                     47:     register struct RtSAPindication *rti = &rtis;
                     48:     struct RtSAPconnect rtcs;
                     49:     register struct RtSAPconnect   *rtc = &rtcs;
                     50:     register struct RtSAPabort *rta = &rti -> rti_abort;
                     51: 
                     52: 
                     53:     if ((aei = str2aei (argv[1], myservice)) == NULLAEI)
                     54:        error ("%s-%s: unknown application-entity", argv[1], myservice);
                     55:     if ((pa = aei2addr (aei)) == NULLPA)
                     56:        error ("address translation failed");
                     57:     if ((ctx = ode2oid (mycontext)) == NULLOID)
                     58:        error ("%s: unknown object descriptor", mycontext);
                     59:     if ((ctx = oid_cpy (ctx)) == NULLOID)
                     60:        error ("oid_cpy");
                     61:     if ((pci = ode2oid (mypci)) == NULLOID)
                     62:        error ("%s: unknown object descriptor", mypci);
                     63:     if ((pci = oid_cpy (pci)) == NULLOID)
                     64:        error ("oid_cpy");
                     65:     pc -> pc_nctx = 1;
                     66:     pc -> pc_ctx[0].pc_id = 1;
                     67:     pc -> pc_ctx[0].pc_asn = pci;
                     68:     pc -> pc_ctx[0].pc_atn = NULLOID;
                     69: 
                     70: 
                     71:     if ((sf = addr2ref (PLocalHostName ())) == NULL) {
                     72:        sf = &sfs;
                     73:        (void) bzero ((char *) sf, sizeof *sf);
                     74:     }
                     75:     
                     76: 
                     77:     fprintf(stderr, "RT-OPEN.REQUEST:\n");
                     78:     if (RtOpenRequest (RTS_TWA, RTS_INITIATOR, ctx, NULLAEI, NULLAEI,
                     79:        NULLPA, pa, pc, NULLOID, 0, NULLQOS, rtc, rti)
                     80:            == NOTOK)
                     81:        fprintf(stderr, "RT-OPEN.REQUEST: %s", RtErrString (rta -> rta_reason));
                     82: 
                     83:     if (rtc -> rtc_result != RTS_ACCEPT)
                     84:        fprintf(stderr, "association rejected: %s",
                     85:        RtErrString (rta->rta_reason));
                     86: 
                     87:     sd = rtc -> rtc_sd;
                     88:     RTCFREE (rtc);
                     89: 
                     90:     if (RoSetService (sd, RoRtService, &rois) == NOTOK)
                     91:        error ("RoSetService: %s", RoErrString (rop -> rop_reason));
                     92: 
                     93:     invoke (sd, INVOKE);       /* invoke the operations, etc. */
                     94:     
                     95:     invoke (sd, INTREQ);       /* invoke the operations, etc. */
                     96: 
                     97:     invoke (sd, INVERR);       /* invoke the operations, etc. */
                     98: 
                     99:     invoke (sd, INVURJ);       /* invoke the operations, etc. */
                    100: 
                    101:     invoke (sd, INVPRJ);       /* invoke the operations, etc. */
                    102: 
                    103:     /* All this appears to be neccessary because you need the turn to terminate
                    104:      * nicely. But we don't have the turn, I presume the responder has kept it
                    105:      * from when they replyed to our request
                    106:      */
                    107: 
                    108:     if (RtPTurnRequest(sd, 0, &rtis) == NOTOK) {
                    109:        fprintf(stderr, "SEND_PLS:RT-PLEASE-TURN.REQUEST: %s\n",
                    110:            RtErrString (rtis.rti_abort.rta_reason));
                    111:        exit(6);
                    112:     }
                    113:     if (RtWaitRequest(sd, TIMEOUT, &rtis) == NOTOK) {
                    114:        fprintf(stderr, "RtWaitRequest: %s\n",
                    115:            RtErrString (rtis.rti_abort.rta_reason));
                    116:        exit(1);
                    117:     }
                    118:     switch (rtis.rti_type) {
                    119:     case RTI_TURN:
                    120:        /* Okay we got it */
                    121:        break;
                    122: 
                    123:     default:
                    124:        fprintf(stderr, "unexpected response %d\n", rtis.rti_type);
                    125:        exit(6);
                    126:     }
                    127: 
                    128:     /* Now we can close */
                    129:     fprintf (stderr, "RT-CLOSE.REQUEST:\n");
                    130:     if (RtCloseRequest (sd, ACF_NORMAL, NULLPE, acr, &rtis) == NOTOK)
                    131:        fprintf (stderr, "RT-CLOSE.REQUEST: %s\n",
                    132:            RtErrString (rtis.rti_abort.rta_reason));
                    133: 
                    134:     exit (0);
                    135: }
                    136: 
                    137: /*
                    138:  * Test example
                    139:  */
                    140: invoke(sd, type)
                    141: int    sd;
                    142: int    type;   /* of invocation */
                    143: {
                    144:     int        invoke;
                    145:     struct RoSAPindication     rind;
                    146:     int        res;
                    147: 
                    148:     invoke = 1;
                    149: 
                    150:     switch (type) {
                    151:     case INVOKE:
                    152:        res = RoInvokeRequest(sd, APDU_OP1, ROS_SYNC, NULLPE, invoke, NULLIP,
                    153:        ROS_NOPRIO, &rind);
                    154:        break;
                    155: 
                    156:     case INTREQ:
                    157:        res = RoIntrRequest(sd, APDU_OP1, NULLPE, invoke, NULLIP, ROS_NOPRIO,
                    158:        &rind);
                    159:        break;
                    160: 
                    161:     case INVERR:
                    162:        res = RoInvokeRequest(sd, APDU_ERR, ROS_SYNC, NULLPE, invoke, NULLIP,
                    163:        ROS_NOPRIO, &rind);
                    164:        break;
                    165: 
                    166:     case INVURJ:
                    167:        res = RoInvokeRequest(sd, APDU_URJ, ROS_SYNC, NULLPE, invoke, NULLIP,
                    168:        ROS_NOPRIO, &rind);
                    169:        break;
                    170: 
                    171:     case INVPRJ:
                    172:        res = RoInvokeRequest(sd, APDU_PRJ, ROS_SYNC, NULLPE, invoke, NULLIP,
                    173:        ROS_NOPRIO, &rind);
                    174:        break;
                    175: 
                    176:     default:
                    177:        fprintf(stderr, "invoke called with illegal type %d\n", type);
                    178:        exit(1);
                    179: 
                    180:     }
                    181: 
                    182:     switch (res) {
                    183:     case NOTOK:
                    184:        if (rind.roi_type == ROI_PREJECT)
                    185:            error("RO-INVOKE.REQUEST: %s\n",
                    186:                RoErrString(rind.roi_preject.rop_reason));
                    187:        else
                    188:            error("RO-INVOKE.REQUEST:failed: unexpected returned type %d\n",
                    189:                rind.roi_type);
                    190:        exit(1);
                    191:     
                    192:     case OK:
                    193:        break;
                    194: 
                    195:     default:
                    196:        error("RO-INVOKE.REQUEST:failed(%d): unexpected returned type %d\n",
                    197:            res, rind.roi_type);
                    198:        exit(2);
                    199: 
                    200:     }
                    201: 
                    202:     switch (rind.roi_type) {
                    203:     case ROI_RESULT:
                    204:        if (rind.roi_result.ror_id == invoke)
                    205:            printf("Result received\n");
                    206:        else
                    207:            printf("Result for wrong request %d\n", rind.roi_result.ror_id);
                    208:        break;
                    209:     
                    210:     case ROI_ERROR:
                    211:        if (rind.roi_error.roe_id == invoke)
                    212:            printf("Error received\n");
                    213:        else
                    214:            printf("Error for wrong request %d\n", rind.roi_error.roe_id);
                    215:        break;
                    216: 
                    217:     case ROI_UREJECT:
                    218:        if (rind.roi_ureject.rou_id == invoke)
                    219:            printf("User Reject received reason %d\n",
                    220:                rind.roi_ureject.rou_reason);
                    221:        else
                    222:            printf("User Reject for wrong request %d\n",
                    223:                rind.roi_ureject.rou_id);
                    224:        break;
                    225: 
                    226:     case ROI_PREJECT:
                    227:        if (rind.roi_preject.rop_id == invoke)
                    228:            printf("Provider Reject received %s\n",
                    229:            RoErrString(rind.roi_preject.rop_reason));
                    230:        else
                    231:            printf("Provider Reject for wrong request %d\n",
                    232:                rind.roi_preject.rop_id);
                    233:        break;
                    234: 
                    235:     default:
                    236:        printf("Unexpected reply received %d\n", rind.roi_type);
                    237:        break;
                    238:     }
                    239: 
                    240: }

unix.superglobalmegacorp.com

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