Changeset 57 for trunk/src/renetcol.c
- Timestamp:
- 09/26/07 14:13:56 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/renetcol.c
r47 r57 29 29 30 30 struct SHMForAgg *shmForAgg; 31 32 struct IPFLowCache tabIP[MAX_IP_FLOW];33 struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW];34 unsigned long ipNb = 0; /* counter of IP flows number */35 unsigned long mplsNb = 0; /* counter of MPLS flow number */36 31 37 32 unsigned short currentIPOutputFile = 0; /* index on the current IP file */ … … 78 73 int reInitConf = 0; 79 74 80 static time_t lastRock;81 75 static struct tm *tmPtr; 82 76 … … 115 109 } 116 110 117 #ifdef CRIHAN118 fprintf(stderr, "renetcol compilation with CRIHAN feature enable\n");119 #endif120 111 #ifdef IPV4AGG 121 112 fprintf(stderr, "renetcol compilation and execution with IPv4 Aggregation feature enable\n"); … … 203 194 myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 204 195 myPtrs.currentFlowsetNumberPtr = ¤tFlowsetNumber; 205 myPtrs.ipNbPtr = &ipNb;206 myPtrs.mplsNbPtr = &mplsNb;207 196 myPtrs.routersID = &indexedRouterList; 208 197 myPtrs.currentV4Tab = shmForAgg->prefixV4Tab[shmForAgg->currentTable]; 209 198 myPtrs.secondV4Tab = shmForAgg->prefixV4Tab[shmForAgg->secondTable]; 210 199 myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]); 211 212 myPtrs.nbFluxSR4 =0;213 myPtrs.nbFluxSE =0;214 myPtrs.nbFluxIR4 =0;215 myPtrs.nbFluxUK = 0;216 myPtrs.nbFluxTT = 0;217 200 218 201 for (i=0; i<ROUTER_INDEX_MAX; i++){ … … 412 395 int regRouter = 0; 413 396 time_t now = time((time_t *)NULL); 414 int iIP, iMPLS, i, z, x;415 397 int loopNb = 0; 416 398 int gardeFou = 0; 417 399 time_t lastIPOutput, lastMPLSOutput; 418 time_t receptionTime;419 400 420 401 now = time((time_t *)NULL); … … 438 419 shmForAgg->readed = 1; 439 420 myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]); 440 fprintf(stderr,"\n\nComptage FLUX:\n SR4: %llu\n SE: %llu\n IR4: %llu\n UK: %llu\n TT: %llu\n",441 myPtrs.nbFluxSR4,442 myPtrs.nbFluxSE,443 myPtrs.nbFluxIR4,444 myPtrs.nbFluxUK,445 myPtrs.nbFluxTT446 );447 myPtrs.nbFluxSR4 =0;448 myPtrs.nbFluxSE =0;449 myPtrs.nbFluxIR4 =0;450 myPtrs.nbFluxUK = 0;451 myPtrs.nbFluxTT = 0;452 421 } 453 422 if (sigusr1Up == 1){ … … 487 456 myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 488 457 if ( currentFlowsetId == 0 ) { 489 if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 490 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 458 if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, 459 myPtrs.offsetV9Ptr, 460 myPtrs.ptr_buffer, 461 myPtrs.currentHeaderV9Ptr, 491 462 curTplFlSetPtr, 492 463 myPtrs.currentFlowsetNumberPtr, … … 499 470 writeAllTplFlSet(); 500 471 } else if (currentFlowsetId == 1) { 501 if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 502 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 503 curTplOptionPtr, 472 if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, 473 myPtrs.offsetV9Ptr, 474 myPtrs.ptr_buffer, 475 myPtrs.currentHeaderV9Ptr, 476 curTplOptionPtr, 504 477 myPtrs.currentFlowsetNumberPtr) ) < 0 ) { 505 478 #ifdef DEBUG … … 549 522 loopNb++; 550 523 551 #ifdef CRIHAN552 now = time((time_t *)NULL);553 receptionTime = now;554 if ( (ipNb > (MAX_IP_FLOW - 50)) ||555 ( (now-lastIPOutput) > IP_TIME_THRESHOLD) ) {556 outputName[0] = '\0';557 sprintf(cof_str, "%d", currentIPOutputFile);558 strcat(outputName, OUTPUT_IP);559 strcat(outputName, cof_str);560 strcat(outputName, EXTENSION);561 if (fopen(outputName, "x") == NULL) {562 currentIPOutputFile = (currentIPOutputFile + 1)%MAX_IP_OUTPUT_FILES;563 outputName[0] = '\0';564 sprintf(cof_str, "%d", currentIPOutputFile);565 strcat(outputName, OUTPUT_IP);566 strcat(outputName, cof_str);567 strcat(outputName, EXTENSION);568 }569 if ((fIP = fopen(outputName, "w")) == NULL) {570 syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno));571 } else {572 for ( iIP = 0; iIP < ipNb; iIP++){573 if ( tabIP[iIP].ipProt == 0 ) {574 fprintf(fIP, "%lu;%lu;%hu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%d;%hu;%hu;%d;%d;%lu.%lu.%lu.%lu;%lu;%d\n",575 tabIP[iIP].bytes, tabIP[iIP].pkts,576 tabIP[iIP].inSnmp, tabIP[iIP].outSnmp,577 tabIP[iIP].v4AdS>>24, tabIP[iIP].v4AdS<<8>>24,578 tabIP[iIP].v4AdS<<16>>24, tabIP[iIP].v4AdS<<24>>24,579 tabIP[iIP].v4AdD>>24, tabIP[iIP].v4AdD<<8>>24,580 tabIP[iIP].v4AdD<<16>>24, tabIP[iIP].v4AdD<<24>>24,581 tabIP[iIP].tProt, tabIP[iIP].sPort,582 tabIP[iIP].dPort, tabIP[iIP].maskD,583 tabIP[iIP].maskS, tabIP[iIP].routerAd>>24,584 tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24,585 tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime,586 receptionTime587 );588 }589 }590 fclose(fIP);591 }592 ipNb = 0;593 lastIPOutput = now;594 }595 now = time((time_t *)NULL);596 if ( mplsNb > (MAX_MPLS_FLOW - 50) ||597 ( (now-lastMPLSOutput) > MPLS_TIME_THRESHOLD) ) {598 outputName[0] = '\0';599 sprintf(cof_str, "%d", currentMPLSOutputFile);600 strcat(outputName, OUTPUT_MPLS);601 strcat(outputName, cof_str);602 strcat(outputName, EXTENSION);603 if (fopen(outputName, "x") == NULL) {604 currentMPLSOutputFile = (currentMPLSOutputFile + 1)%MAX_MPLS_OUTPUT_FILES;605 outputName[0] = '\0';606 sprintf(cof_str, "%d", currentMPLSOutputFile);607 strcat(outputName, OUTPUT_MPLS);608 strcat(outputName, cof_str);609 strcat(outputName, EXTENSION);610 }611 if ((fMPLS = fopen(outputName, "w")) == NULL) {612 syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno));613 } else {614 for ( iMPLS = 0; iMPLS < mplsNb; iMPLS++){615 if ( tabMPLS[iMPLS].ipProt == 0 ) {616 fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu\n",617 tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24,618 tabMPLS[iMPLS].routerAd<<16>>24,619 tabMPLS[iMPLS].routerAd<<24>>24,620 tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24,621 tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24,622 tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24,623 tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24,624 tabMPLS[iMPLS].v4AdD<<24>>24625 );626 }627 }628 fclose(fMPLS);629 }630 mplsNb = 0;631 lastMPLSOutput = now;632 }633 #endif /* CRIHAN */634 524 now = time((time_t *)NULL); 635 525 tmPtr = localtime(&now);