ISODE: A simple client



next up previous
Next: ISODE: A Simple Up: An ISODE example Previous: An ISODE example

ISODE: A simple client

 

    /* Client Side */
#include <stdio.h>
#include "/opt/sun4/isode-7.0/h/rosap.h"

static char *myservice = "mytest";
static char *mycontext = "isode mytest";
static char *mypci = "isode mytest pci";

main(argc,argv,envp)
int argc;
char **argv, **envp;
{
int sd;
struct SSAPref sfs;
register struct PSAPaddr *pa;
register struct SSAPref *sf;
struct AcSAPconnect accs;
register struct AcSAPconnect *acc = &accs;
struct AcSAPrelease acrs;
register struct AcSAPrelease *acr = &acrs;
struct AcSAPindication acis;
register struct AcSAPindication *aci = &acis;
register struct AcSAPabort *aca = &aci -> aci_abort;
struct RoSAPindication rois;
register struct RoSAPpreject *rop = &rois.roi_preject;
register AEI aei;
register OID ctx, pci;
struct PSAPctxlist pcs;
register struct PSAPctxlist *pc = &pcs;
char *data;

if(argc==1) {
    printf("Usage: %s hostname\n", argv[0]);
    exit(-1);
}
   % str2aei converts the parameter values into the corresponding
   % object identifier in the isode database
if((aei = str2aei(argv[1],myservice)) == NULLAEI)
    printf("%s-%s: unknown application entity",argv[1],myservice);
if((pa = aei2addr(aei)) == NULLPA)
    printf("address translation failed\n");
if((ctx = ode2oid(mycontext)) == NULLOID)
    printf("%s: unknown obj descriptor\n",mycontext);
if((ctx = oid_cpy(ctx)) == NULLOID)
    printf("error oid_cpy\n");
if((pci = ode2oid(mypci)) == NULLOID)
    printf("%s: unknown obj desc pci\n",mypci);
if((pci = oid_cpy(pci)) == NULLOID)
    printf("error oid_cpy pci\n ");

pc -> pc_nctx = 1;
pc -> pc_ctx[0].pc_id = 1;
pc -> pc_ctx[0].pc_asn = pci;
pc -> pc_ctx[0].pc_atn = NULLOID;

if((sf = addr2ref(PLocalHostName())) == NULL) {
    sf = &sfs;
    (void) bzero((char *)sf,sizeof *sf);
}
printf("Enter the data\n");
scanf("%s",&data);
printf("%s\n",&data);
printf("Before assoc request\n ");
if(AcAssocRequest(ctx,NULLAEI,aei,NULLPA,pa,pc,NULLOID,0,
   ROS_MYREQUIRE,SERIAL_NONE,0,sf,NULLPEP,0,NULLQOS,acc,aci)
            ==  NOTOK)
    printf("A-ASSOCIATE.REQUEST: %s\n",AcErrString(aca -> aca_reason));

if(acc -> acc_result != ACS_ACCEPT)
    printf("association rejected: %s\n",AcErrString(aca -> aca_reason));


sd = acc -> acc_sd;
ACCFREE(acc);
if (RoSetService(sd,RoPService,&rois) == NOTOK)
    printf("RoSetService rejected: %s\n",RoErrString(rop -> rop_reason));
/* here invoke operation */

if(AcRelRequest(sd,ACF_NORMAL,NULLPEP,0,30,acr,aci) == NOTOK)
    printf("A-RELEASE.REQ: %s\n",AcErrString(aca -> aca_reason));
if(!acr -> acr_affirmative) {
    /* Association is still there */
    (void) AcUAbortRequest(sd,NULLPEP,0,aci);
    printf("release rejected by peer: %s\n",acr -> acr_reason);
}
ACRFREE(acr);
exit(0);
}



boots cassel
Wed Feb 7 10:22:57 EST 1996