#define lmax 600 #define ladat 600+posin #define americano 0 /// arreglo especial /// VERSION 334 /// sika #define europeo 1 // CYT #define posin 18 #define estac 0 +posin // callingPartyNumber #define linea 0 +posin #define durac 0 +posin //duracion #define hor 0 +posin //dateTimeOrigination #define fech 44 +posin //dateTimeOrigination #define tranf 0 + posin #define numero 0 +posin //callingPartyNumber #define ccost 0 #define proye 0 +posin //authCodeDescription #define cuenta 0 #define pulsos 0 #define ruta 0 #define prinum 15 +posin //origNodeId #define ring 0+posin //dateTimeConnect #define antran 0 //anexo transferido (pendiente) #define fofech europeo extern char rgua[]; void in_central() { rgua[0]='\0'; } void fi_central() { } extern void gua_rut(char *buf); char temp_tandem[100]; char temp_numero[60]; char temp_resto[200]; int j,i,t,x, k,m,q1,q2,q3,largo1,largo2,encuentra,h,d,n,envi; char reg[250][lmax],vtipo; m= 0; envi=0; void busca_reg(char *buf, int vtranf, int destLegIdentifier,int origLegCallIdentifier,int globalCallID_callId) { //lr, posicion de ruta+linea en registro m=t;j=0; while (m>-1){ int contconf1,contconf2,contconf3,contconf4, contleg1, contleg2, contleg3 , contleg4 ,contglobalid; contconf1=0 ; contconf2=0; contconf3=0; contconf4=0; contleg1 = 0; contleg2 = 0; contleg3 = 0; contleg4 = 0; contglobalid=0; for(j=0;j<=12; j++) if ( reg[m][globalCallID_callId+j] == buf[globalCallID_callId+j] ) contglobalid++; // compara con globalid for(j=0;j<=12; j++) if ( reg[m][origLegCallIdentifier+j] == buf[origLegCallIdentifier+j] ) contleg1++; // transferecias for(j=0;j<=12; j++) if ( reg[m][origLegCallIdentifier+j] == buf[destLegIdentifier+j] ) contleg2++; for(j=0;j<=12; j++) if ( reg[m][destLegIdentifier+j] == buf[origLegCallIdentifier+j] ) contleg3++; for(j=0;j<=12; j++) if ( reg[m][destLegIdentifier+j] == buf[destLegIdentifier+j] ) contleg4++; if ( contglobalid >12|| contleg1>12 || contleg2>12 || contleg3>12 || contleg4>12 ) // tranferencias {encuentra=1; vtipo=reg[m][2]; h=strlen(reg[m]);return;} m--; } } void add_reg(char *buf, int vtranf,int destLegIdentifier,int origLegCallIdentifier, int globalCallID_callId) { busca_reg(buf,vtranf,destLegIdentifier,origLegCallIdentifier,globalCallID_callId); if (!encuentra) {m=t; if (t>=200) { n=t-2; for(j=0;j<=n;j++) { for(d=0;d<=ladat-1;d++) { reg[j][d]=reg[j+1][d]; } } for(j=0;j<=ladat-1;j++) reg[m-1][j]=buf[j]; } else { t++; for(j=0;j<=i;j++) // agrega { reg[m][j]=buf[j]; } } } } void borrar_reg (char *buf) { for(j=m;j<=t;j++) for(d=0;d<=ladat-1;d++) reg[j][d]=reg[j+1][d]; t--; } calculo_trafico (int paq_out_pos, int oct_out_pos, int paq_in_pos, int oct_in_pos,int paq_per_pos,int jitter_pos, int latencia_pos, char *buf, char *tel) { char paq_perd[10],paq_out[10],paq_in[10],oct_in[10],oct_out[10], PORC_perdida[5], bytes_IN[10], bytes_OUT[10]; int porcent_perdida, bytes_in , bytes_out , paquetes_perdidas , paquetes_out , paquetes_in, octetos_in, octetos_out; porcent_perdida=0; bytes_in=0; bytes_out=0; paquetes_perdidas=0; paquetes_out = 0; paquetes_in =0; octetos_in = 0; octetos_out =0 ; for(j=0;buf[paq_per_pos+j]!=',';j++) paq_perd[j] = buf[paq_per_pos+j]; for(j=0;buf[paq_out_pos+j]!=',';j++) paq_out[j] = buf[paq_out_pos+j]; for(j=0;buf[paq_in_pos+j]!=',';j++) paq_in[j] = buf[paq_in_pos+j]; for(j=0;buf[paq_out_pos+j]!=',';j++) paq_out[j] = buf[paq_out_pos+j]; for(j=0;buf[oct_in_pos+j]!=',';j++) oct_in[j] = buf[oct_in_pos+j]; for(j=0;buf[oct_out_pos+j]!=',';j++) oct_out[j] = buf[oct_out_pos+j]; paquetes_perdidas = atoi(paq_perd,10); paquetes_out = atoi(paq_out,10); paquetes_in = atoi(paq_in,10); octetos_in= atoi(oct_in,10); octetos_out= atoi(oct_out,10); if ( (paquetes_out + paquetes_in) > 0 ) porcent_perdida = ( ( (paquetes_perdidas * 10000 ) / ( paquetes_out + paquetes_in ) ) ) ; else porcent_perdida = 0; itoa(porcent_perdida,PORC_perdida,10); for (j=0;isdigit(PORC_perdida[j]) && j<5 ;j++) tel[k++]= PORC_perdida[j]; tel[k++]= ' '; // PORCENTAJE PERDIDA bytes_in = (paquetes_in * 4 ) + octetos_in; itoa(bytes_in,bytes_IN,10); for (j=0;isdigit(bytes_IN[j]) && j<10 ;j++) tel[k++]= bytes_IN[j]; tel[k++]=' '; // BYTES IN bytes_out = (paquetes_out * 4 ) + octetos_out; itoa(bytes_out,bytes_OUT,10); for (j=0;isdigit(bytes_OUT[j]) && j<10 ;j++) tel[k++]= bytes_OUT[j]; // BYTES OUT } //tranforma segundos dede 01/01/1970 a fecha y hora Aqct setenta_to_time(char *buf, char *tel, int vfech) { char tiempo_ori[10], *tiempo_str; long tiempo_seg; for(j=0;j<=10 ;j++) tiempo_ori[j] =' '; for(j=0;j<=10 || buf[vfech+j]!=',';j++) if (isdigit(buf[vfech+j])) { tiempo_ori[j] = buf[vfech+j];} // tiempo_seg = atoi(tiempo_ori)+10800; //+3horas tiempo_seg = atoi(tiempo_ori); //+3horas tiempo_str = ctime(&tiempo_seg); //Wed Jan 02 02:03:55 1980 tel[k++]=tiempo_str[11]; tel[k++]=tiempo_str[12]; tel[k++]=tiempo_str[13]; tel[k++]=tiempo_str[14]; tel[k++]=tiempo_str[15]; tel[k++]=' '; if (tiempo_str[4]=='J' && tiempo_str[5]=='a') {tel[k++]='0'; tel[k++]='1';} else if (tiempo_str[4]=='F') {tel[k++]='0'; tel[k++]='2';} else if (tiempo_str[4]=='M' && tiempo_str[5]=='a' && tiempo_str[6]=='r') {tel[k++]='0'; tel[k++]='3';} else if (tiempo_str[4]=='A' && tiempo_str[5]=='p') {tel[k++]='0'; tel[k++]='4';} else if (tiempo_str[4]=='M' && tiempo_str[5]=='a' && tiempo_str[6]=='y') {tel[k++]='0'; tel[k++]='5';} else if (tiempo_str[4]=='J' && tiempo_str[5]=='u' && tiempo_str[6]=='n') {tel[k++]='0'; tel[k++]='6';} else if (tiempo_str[4]=='J' && tiempo_str[5]=='u' && tiempo_str[6]=='l') {tel[k++]='0'; tel[k++]='7';} else if (tiempo_str[4]=='A' && tiempo_str[5]=='u') {tel[k++]='0'; tel[k++]='8';} else if (tiempo_str[4]=='S') {tel[k++]='0'; tel[k++]='9';} else if (tiempo_str[4]=='O') {tel[k++]='1'; tel[k++]='0';} else if (tiempo_str[4]=='N') {tel[k++]='1'; tel[k++]='1';} else if (tiempo_str[4]=='D') {tel[k++]='1'; tel[k++]='2';} tel[k++]='/'; tel[k++]=tiempo_str[8]; tel[k++]=tiempo_str[9]; tel[k++]='/'; tel[k++]=tiempo_str[22]; tel[k++]=tiempo_str[23]; } // Driver Propiamente tal. Las posiciones de los campos se // ingresan como parámetros, lo que permite modificar desde // Aplicación de Tarificación la posición de estos en el // Registro de Llamados. void DatCentral(char *buf, char *tel, int vestac, int vlinea,int vdurac,int vhor, int vfech, int vtranf, int vnumero, int vccost,int vproye, int vcuenta, int vpulsos, int vruta, int vprinum, int vring, int vantran, int vfofech) { int cont , contr, num, dn,tr,hunt,fcn; int dur_val, minu, segu, hora, ringueo, dn_en_dn, dn_en_num , dn_en_dnx, dn_en_numx; int causa_ori, causa_des,poracod , b_de_conf_fcn,b_de_conf_ori; int cdrRecordType,origLegCallIdentifier,dateTimeOrigination,origIpAddr,origIpPort,callingPartyNumber; int origCause_Value ,destLegIdentifier,destNodeId,destSpan,destIpAddr,destIpPort; int originalCalledPartyNumber,finalCalledPartyNumber,destCause_value,destCause_location,destMediaTransportAddress_IP; int lastRedirectDnPartition,duration; int origDeviceName,destDeviceName,joinOnBehalfOf,authCodeDescription,authorizationLevel; int concoma, max_ip,largo_anexo=5,conforigvalue=0, confdestvalue=0,globalCallID_callId ,dateTimeConnect; int origIpPort_es_1720, destIpPort_es_1720; int idateTimeConnect,idateTimeOrigination,iring ; int paq_out_pos,oct_out_pos,paq_in_pos,oct_in_pos,paq_per_pos,jitter_pos,latencia_pos; int latencia, jitter, perdida , bytes_in , bytes_out ; char cIp_Destino[12], eIp_Destino[12], cdateTimeConnect[12] ; char edateTimeOrigination[12], cdateTimeOrigination[12]; char aux, seg[5], tipo_llamada,servicio; strcpy(temp_tandem,""); strcpy(temp_numero, ""); strcpy(temp_resto, ""); i=strlen(buf); aux=0; cont=0; ringueo=0; num=0, dn=0; dn_en_dn=0; dn_en_num=0,tr=0,hunt=0,dn_en_dnx=0; dn_en_numx=0; causa_ori=0; causa_des=0;concoma = 0 ; globalCallID_callId=0; cdrRecordType=0;origLegCallIdentifier=0; dateTimeOrigination=0;origIpAddr=0; origIpPort=0;callingPartyNumber=0; origCause_Value=0;destLegIdentifier=0; destNodeId=0;destSpan=0; destIpAddr=0;destIpPort=0; originalCalledPartyNumber=0; finalCalledPartyNumber=0;destCause_location=0; destCause_value=0;destMediaTransportAddress_IP=0; lastRedirectDnPartition=0;duration=0; origDeviceName=0;destDeviceName=0; joinOnBehalfOf=0; fcn=0; authCodeDescription=0;authorizationLevel=0; dateTimeConnect=0; conforigvalue=0; confdestvalue=0; encuentra=0; b_de_conf_ori=0; poracod=0; b_de_conf_fcn=0; envi=0; origIpPort_es_1720=0; destIpPort_es_1720=0; if ( i>400 ) { for(j=0;j400 && concoma>49) { k = 0 ; for (j=0; (buf[callingPartyNumber+j])!=',';j++){if(isdigit(buf[callingPartyNumber+j])) num++;} //cuenta dígitos en el campo número for (j=0; (buf[originalCalledPartyNumber+j])!=',' ;j++){if(isdigit(buf[originalCalledPartyNumber+j])) dn++ ;} //cuenta dígitos en el campo anexo for (j=0; (buf[finalCalledPartyNumber+j])!=',';j++){if(isdigit(buf[finalCalledPartyNumber+j])) fcn++;} //cuenta dígitos en el campo número for (j=0; (buf[origIpPort+j+3])!=',' && (origIpPort+j+3) largo_anexo && num > largo_anexo ) // anexo { if (reg[m][1]== 'I') { for(j=0; reg[m][originalCalledPartyNumber+j]!=',';j++) { if (isdigit(reg[m][originalCalledPartyNumber+j])) { tel[k++]=reg[m][originalCalledPartyNumber+j];cont++;} } } if (reg[m][1]== 'O') { for(j=0; reg[m][callingPartyNumber+j]!=',';j++) { if (isdigit(reg[m][callingPartyNumber+j])) { tel[k++]=reg[m][callingPartyNumber+j];cont++;} } } } else if (dn_en_num && num< largo_anexo ) for(j=0; buf[callingPartyNumber+j]!=',' ;j++) { if (isdigit(buf[callingPartyNumber+j])) { tel[k++]=buf[callingPartyNumber+j];cont++;} } else if (dn_en_dn && dn < largo_anexo && !b_de_conf_fcn && fcn< largo_anexo ) for(j=0; buf[finalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[finalCalledPartyNumber+j])) { tel[k++]=buf[finalCalledPartyNumber+j];cont++;} } else if (dn_en_dn && dn < largo_anexo ) for(j=0; buf[originalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[originalCalledPartyNumber+j])) { tel[k++]=buf[originalCalledPartyNumber+j];cont++;} } else {tel[k++]='*'; cont++;} if (cont==0) tel[k++] = '*'; tel[k++] = ' ' ; cont=0; cIp_Destino[0]='\0';eIp_Destino[0]='\0'; if (tipo_llamada == 'I' && encuentra) //linea { for(j=0; reg[m][origIpAddr+j]!=',';j++) { if (isdigit(reg[m][origIpAddr+j])) { cIp_Destino[cont]=reg[m][origIpAddr+j];cont++;} } cIp_Destino[cont] = '\0'; itoa(atoi(cIp_Destino), eIp_Destino,16); max_ip = strlen(eIp_Destino); for (j=0;j<= max_ip ;j++) if (isalnum(eIp_Destino[j])) tel[k++] = eIp_Destino[j]; } else if (tipo_llamada == 'O' && encuentra) { for(j=0;reg[m][destIpAddr+j]!=',';j++) { if (isdigit(reg[m][destIpAddr+j])) { cIp_Destino[cont]=reg[m][destIpAddr+j];cont++;} } cIp_Destino[cont] = '\0'; itoa(atoi(cIp_Destino), eIp_Destino,16); max_ip = strlen(eIp_Destino); for (j=0;j<= max_ip;j++) if (isalnum(eIp_Destino[j])) tel[k++] = eIp_Destino[j]; } else if (dn_en_dn && tipo_llamada != 'T') { for(j=0; buf[origIpAddr+j]!=',';j++) { if (isdigit(buf[origIpAddr+j])) { cIp_Destino[cont]=buf[origIpAddr+j];cont++;} } cIp_Destino[cont] = '\0'; itoa(atoi(cIp_Destino), eIp_Destino,16); max_ip = strlen(eIp_Destino); for (j=0;j<= max_ip ;j++) if (isalnum(eIp_Destino[j])) tel[k++] = eIp_Destino[j]; } else if (dn_en_num && tipo_llamada != 'T') { for(j=0;buf[destIpAddr+j]!=',';j++) { if (isdigit(buf[destIpAddr+j])) { cIp_Destino[cont]=buf[destIpAddr+j];cont++;} } cIp_Destino[cont] = '\0'; itoa(atoi(cIp_Destino), eIp_Destino,16); max_ip = strlen(eIp_Destino); for (j=0;j<= max_ip;j++) if (isalnum(eIp_Destino[j])) tel[k++] = eIp_Destino[j]; } if (cont==0) tel[k++] = '*'; tel[k++] = ' ' ; for (j=0;j<5;j++) { seg[j]=' ';} cont=0; for(j=0;cont<=5 || buf[duration+j]!=',';j++) { seg[j]=buf[duration+j];cont++;} dur_val=(atoi(seg)); segu=(dur_val)%60; //segundos minu=((dur_val)%3600)/60; //minutos hora=(dur_val)/3600; //hora tel[k++]=(hora/10)+'0'; tel[k++]=(hora%10)+'0'; tel[k++]=':'; tel[k++]=(minu/10)+'0'; tel[k++]=(minu%10)+'0'; tel[k++]=':'; tel[k++]=(segu/10)+'0'; tel[k++]=(segu%10)+'0'; tel[k++] = ' ' ; setenta_to_time(buf, tel, dateTimeOrigination ); //tranforma segundos dede 01/01/1970 a fecha y hora Aqct tel[k++] = ' '; tel[k++] = tipo_llamada; tel[k++] = ' '; cont=0; if( origIpPort_es_1720 && destIpPort_es_1720 && fcn>largo_anexo && dn>largo_anexo && num>largo_anexo && !b_de_conf_fcn && !b_de_conf_ori && encuentra && tipo_llamada=='O') { q1 =k; for (j=0;jlargo_anexo && dn>largo_anexo && num>largo_anexo && !b_de_conf_fcn && !b_de_conf_ori && encuentra && tipo_llamada=='O') for(j=0; buf[originalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[originalCalledPartyNumber+j])) { tel[k++]=buf[originalCalledPartyNumber+j];cont++;} } else if (dn_en_dn && dn<=largo_anexo) for(j=0; buf[callingPartyNumber+j]!=',';j++) { if (isdigit(buf[callingPartyNumber+j])) { tel[k++]=buf[callingPartyNumber+j];cont++;} } else if (dn_en_num && num<=largo_anexo && !b_de_conf_fcn) for(j=0; buf[originalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[originalCalledPartyNumber+j])) { tel[k++]=buf[originalCalledPartyNumber+j];cont++;} } else if ( dn >largo_anexo && num >largo_anexo && servicio== 'C' ) for(j=0; buf[callingPartyNumber+j]!=',';j++) { if (isdigit(buf[callingPartyNumber+j])) { tel[k++]=buf[callingPartyNumber+j];cont++;} } else if (dn> largo_anexo && num>largo_anexo ) { if (dn < num ) { for(j=0; buf[callingPartyNumber+j]!=',';j++) { if (isdigit(buf[callingPartyNumber+j])) { tel[k++]=buf[callingPartyNumber+j];cont++;} }} else { for(j=0; buf[originalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[originalCalledPartyNumber+j])) { tel[k++]=buf[originalCalledPartyNumber+j];cont++;} }} } else if (dn > num && (b_de_conf_fcn) && !(b_de_conf_ori) ) for(j=0; buf[originalCalledPartyNumber+j]!=',';j++) { if (isdigit(buf[originalCalledPartyNumber+j])) { tel[k++]=buf[originalCalledPartyNumber+j];cont++;} } else {tel[k++]='*' ; cont++;} if (cont==0 ) { tel[k++]='*';} q2 = k; tel[k++] = ' ' ; tel[k++] = '*';tel[k++] = '*';tel[k++] = '*'; //centro costo tel[k++] = ' ' ; cont=0; /*if ( authCodeDescription+50 ) for(j=0;j<8 && (buf[authCodeDescription+j])!=',' && authCodeDescription+j0 && idateTimeOrigination>0 && idateTimeConnect>idateTimeOrigination ) iring = idateTimeConnect - idateTimeOrigination; else iring = 0; if (iring > 0) { segu=(iring)%60; //segundos /// TIEMPO DE RING minu=((iring)%3600)/60; //minutos tel[k++]=(minu/10)+'0'; tel[k++]=(minu%10)+'0'; tel[k++]=':'; tel[k++]=(segu/10)+'0'; tel[k++]=(segu%10)+'0'; } else { tel[k++]='0'; tel[k++]='0'; tel[k++]=':'; tel[k++]='0'; tel[k++]='0';} // t ring tel[k++] = ' ' ; contr=0; if ( (servicio == 'C' || servicio=='T') && encuentra && !conforigvalue && !confdestvalue ) /// anexo que transfiere { if ( tipo_llamada =='I') { for(j=0; reg[m][originalCalledPartyNumber+j]!=',' ;j++) if (isdigit(reg[m][originalCalledPartyNumber+j])) contr++; if (contr<5) { for(j=0; reg[m][originalCalledPartyNumber+j]!=',' ;j++) if (isdigit(reg[m][originalCalledPartyNumber+j])) {tel[k++]=reg[m][originalCalledPartyNumber+j];cont++;} } } if ( tipo_llamada == 'O') { for(j=0; reg[m][callingPartyNumber+j]!=',' ;j++) if (isdigit(reg[m][callingPartyNumber+j])) contr++; if (contr<5) { for(j=0;reg[m][callingPartyNumber+j]!=',';j++) if (isdigit(reg[m][callingPartyNumber+j])) {tel[k++]=reg[m][callingPartyNumber+j];cont++;} } } } else { tel[k++] = '*' ; cont++;} // anexo transferido if (cont==0) tel[k++]='*'; tel[k++] = ' ' ; if (dur_val==0 && tipo_llamada=='I' ) servicio= 'A'; else if (dur_val==0 && tipo_llamada=='O' ) servicio= 'N'; tel[k++] = servicio; if (buf[paq_out_pos+1]!=',' && buf[oct_out_pos+1]!=',' && buf[paq_in_pos+1]!=',') { tel[k++] = ' '; // ADICIONAL TRAFICO // LATENCIA for (j=0;buf[latencia_pos+j]!=',';j++) if (isdigit(buf[latencia_pos+j])) tel[k++]= buf[latencia_pos+j]; tel[k++]=' '; // JITTER for (j=0;buf[jitter_pos+j]!=',';j++) if (isdigit(buf[jitter_pos+j])) tel[k++]= buf[jitter_pos+j]; tel[k++]=' '; // PERDIDA --- BYTES_IN ---- BYTES_OUT calculo_trafico (paq_out_pos,oct_out_pos,paq_in_pos,oct_in_pos,paq_per_pos,jitter_pos,latencia_pos,buf,tel); } q3= k; if (encuentra && !conforigvalue && !confdestvalue ) borrar_reg(buf); tel[k++] = '\r' ; tel[k++] = '\n' ; tel[k++] = '\0' ; if (origIpPort_es_1720 && destIpPort_es_1720 && fcn>largo_anexo && dn>largo_anexo && num>largo_anexo && !b_de_conf_fcn && !b_de_conf_ori && encuentra && tipo_llamada=='O') { cont=0; for (j=0;buf[callingPartyNumber+j]!=',' && j<26;j++) if ( isdigit(buf[callingPartyNumber+j]) ) temp_numero[cont++] = buf[callingPartyNumber+j]; temp_numero[cont++]='\0'; q1= q1 + cont; for (j=0;j<(q3-q2+1);j++) { temp_resto[j]= tel[q2+j] ;cont=q1+j;} temp_resto[j++]= '\r'; temp_resto[j++] = '\n' ; temp_resto[j++] = '\0' ; strcpy(rgua, temp_tandem); strcat(rgua, temp_numero); strcat(rgua, temp_resto); } } }