#include #include #include #include #include "lmgr.h" #define DEMETERSERVER "saentis.ccs.neu.edu" void fail(d) int d; { fprintf(stderr,"Unable to connet to %s for the Demeter licence manager.\n",DEMETERSERVER); switch(d) { case 0: fprintf(stderr,"Failed to find the licence server.\n"); break; case 1: fprintf(stderr,"Faild to talk to the licence server.\n"); break; case 2: fprintf(stderr,"Cannot get data from the licence server.\n"); break; case 3: fprintf(stderr,"Cannot talk to the licence server.\n"); break; } /* clnt_pcreateerror(DEMETERSERVER); */ exit(1); } void verify(p) packet* p; { if (p->data1 != p->data2) { fail(3); } } int genData(d) int d; { return d; } void genPasswd(passwd, linfo) licenceinfo* linfo; char * passwd; { char *k = "demeter@saentis:: "; char info[2048]; int l; register int i; sprintf(info,"%d%s%s%s",linfo->lc,linfo->sname,linfo->iname,linfo->ip); l = strlen(info); for (i = 0; i < 30; i++) { if (i+3 < l) passwd[i] = (k[i] + k[i+2] + info[i] + info[i+3]) / 4; else if ( i < l ) passwd[i] = (k[i] + k[i+2] + info[i] + info[l - i]) / 4; else passwd[i] = (k[i] + k[i+2] + info[i] + info[i - l]) / 4; if (!isascii(passwd[i])) passwd[i] = 'D'; } passwd[30] = '\0'; } void verifyPasswd(linfo) licenceinfo* linfo; { char passwd[512]; genPasswd(passwd,linfo); if (strcmp(passwd,linfo->passwd)) { fprintf(stderr,"Licence data is not valid. Check the Demeter installation guide.\n"); exit(1); } }