Changeset 27 for trunk/src/renetcol.c

Show
Ignore:
Timestamp:
04/05/07 18:10:36 (16 years ago)
Author:
andreu
Message:

explicite output to find wrong definition bug - memory leak in renetcolAgg find

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/renetcol.c

    r25 r27  
    6969unsigned long indexedRouterList[ROUTER_INDEX_MAX]; 
    7070int routerNb = 0;                                  /* routers number */ 
    71 /* unsigned short v4PrefixNb = 0;                      IPv4 prefix number */  
    72 /* struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX];       IPv4 prefix structure */ 
     71/* unsigned short v4PrefixNb = 0;                    IPv4 prefix number */  
     72/* struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX];  IPv4 prefix structure */ 
    7373 
    7474 
     
    208208  myPtrs.ipNbPtr =  &ipNb; 
    209209  myPtrs.mplsNbPtr =  &mplsNb; 
    210    
     210  myPtrs.routersID = &indexedRouterList; 
     211  
    211212  if (myPtrs.pcktPtr==NULL) { 
    212213    fprintf(stderr, "ERROR in struct Datagram allocation\n"); 
     
    378379socketLoop() 
    379380{ 
    380   unsigned short shift; 
     381  short shift; 
    381382  short version = 0; 
    382383  int regRouter = 0; 
     
    384385  int iIP, iMPLS, i; 
    385386  int loopNb = 0; 
     387  int gardeFou = 0; 
    386388  time_t lastIPOutput, lastMPLSOutput; 
    387389  time_t receptionTime; 
     
    393395  lastIPOutput = now; 
    394396  do { 
     397    fprintf (stderr, "socket loop \n"); 
    395398    if ( ((tmPtr->tm_min)%STEP == 0) && (currentIntervalle != tmPtr->tm_min)){ 
    396399      currentIntervalle = tmPtr->tm_min; 
     
    401404      } 
    402405      shmForAgg->readed = 1; 
    403       printf("We change the table, min : %d, ct: %hu\n", tmPtr->tm_min, 
    404              shmForAgg->currentTable); 
    405406    } 
    406407    if (sigusr1Up == 1){ 
     
    429430      currentFlowsetNumber = 0; 
    430431      shift = 0; 
     432      gardeFou=0; 
    431433      while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)) { 
     434        gardeFou++; 
    432435        curTplFlSetPtr = NULL; 
    433436        currentFlowsetId=getFlowsetId(currentFlowsetNumber,  
    434437                                      myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 
    435438        if ( currentFlowsetId == 0 ) { 
    436           shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
    437                                        myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 
    438                                        curTplFlSetPtr, 
    439                                        myPtrs.currentFlowsetNumberPtr, 
    440                                        myQueue); 
     439          if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
     440                                             myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 
     441                                             curTplFlSetPtr, 
     442                                             myPtrs.currentFlowsetNumberPtr, 
     443                                             myQueue)) < 0 ) { 
     444            fprintf(stderr, "\nShift < 0 \n"); 
     445            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
     446          }; 
     447          writeAllTplFlSet(); 
    441448        } else if (currentFlowsetId == 1) { 
    442           shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
     449          if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
    443450                                      myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 
    444451                                      curTplOptionPtr, 
    445                                       myPtrs.currentFlowsetNumberPtr); 
     452                                            myPtrs.currentFlowsetNumberPtr) ) < 0 ) { 
     453            fprintf(stderr, "\nShift Option < 0 \n"); 
     454            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
     455          } 
    446456        } else { 
    447           shift = checkDataFlowSet(shift, 
    448                                    &myPtrs, 
    449                                    myQueue,  
    450                                    shmForAgg->prefixV4Tab[shmForAgg->currentTable], 
    451                                    (size_t) shmForAgg->v4PrefixNb 
    452                                    ); 
     457          if ( (shift = checkDataFlowSet(shift, 
     458                                         &myPtrs, 
     459                                         myQueue,  
     460                                         shmForAgg->prefixV4Tab[shmForAgg->currentTable], 
     461                                         (size_t) shmForAgg->v4PrefixNb 
     462                                         ) ) < 0 ) { 
     463            fprintf(stderr, "\nShift check < 0 \n"); 
     464            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
     465          } 
    453466        } 
     467        if ( gardeFou > 200) { exit(-1); } 
    454468      } /* end while flowset exist */ 
    455469      break; 
     
    467481      /* FIXME perhaps call this function via the compilation options */ 
    468482      writeAllTplFlSet(); 
    469 /*       for (i=0; i<shmForAgg->v4PrefixNb; i++){ */ 
    470 /*      fprintf(stderr, "%lu \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n", */ 
    471 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].beginning, */ 
    472 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].flowNbIN, */ 
    473 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].bytesNbIN, */ 
    474 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].pktsNbIN, */ 
    475 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpPktsNbIN, */ 
    476 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpPktsNbIN, */ 
    477 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpPktsNbIN, */ 
    478 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersPktsNbIN, */ 
    479 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpBytesNbIN, */ 
    480 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpBytesNbIN, */ 
    481 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpBytesNbIN, */ 
    482 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersBytesNbIN, */ 
    483 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpFlowNbIN, */ 
    484 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpFlowNbIN, */ 
    485 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpFlowNbIN, */ 
    486 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersFlowNbIN, */ 
    487 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].flowNbOUT, */ 
    488 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].bytesNbOUT, */ 
    489 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].pktsNbOUT, */ 
    490 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpPktsNbOUT, */ 
    491 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpPktsNbOUT, */ 
    492 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpPktsNbOUT, */ 
    493 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersPktsNbOUT, */ 
    494 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpBytesNbOUT, */ 
    495 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpBytesNbOUT, */ 
    496 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpBytesNbOUT, */ 
    497 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersBytesNbOUT, */ 
    498 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].udpFlowNbOUT, */ 
    499 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].tcpFlowNbOUT, */ 
    500 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].icmpFlowNbOUT, */ 
    501 /*              shmForAgg->prefixV4Tab[shmForAgg->currentTable][i].othersFlowNbOUT */ 
    502 /*              ); */ 
    503 /*       } */ 
     483      fprintf(stderr, " loop %d \n", loopNb); 
    504484      loopNb = 0; 
    505485    } 
     
    763743    if ((tmpOP = tmp->tplOptList) != NULL){ 
    764744      for (; tmpOP; tmpOP=tmpOP->next) { 
    765         fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) >\n",  
     745        fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) >\n lg: %hu, opScopeLg: %hu, opLg: %hu\n",  
    766746                tmpOP->templateOptionId, 
    767                 tmpOP->sourceId); 
     747                tmpOP->sourceId, 
     748                tmpOP->length, 
     749                tmpOP->optionScopeLg, 
     750                tmpOP->optionLg); 
    768751        printFieldSet(TPLFILE, tmpOP->fieldSet); 
    769752        fprintf(TPLFILE,"\n"); 
     
    773756  } 
    774757  fclose(TPLFILE); 
    775 } 
     758  fprintf (stderr, "end write file def template \n"); 
     759}