Changeset 30

Show
Ignore:
Timestamp:
04/20/07 16:31:36 (16 years ago)
Author:
andreu
Message:

bug of "template fantom" correction

Location:
trunk
Files:
1 added
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r29 r30  
    3838                 ) 
    3939{ 
    40   TplFlowSetPtr tmp; 
    41   TplOptionPtr tmpOpt; 
    42   FieldPtr pftmp; 
    43   FieldPtr secondPftmp; 
     40  TplFlowSetPtr tmp = NULL; 
     41  TplOptionPtr tmpOpt = NULL; 
     42  FieldPtr pftmp = NULL; 
     43  FieldPtr secondPftmp = NULL; 
    4444  unsigned short data_length = 0; 
    4545  unsigned short flow_size = 0; 
     
    104104  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
    105105  data_length = *((unsigned short*)&buffer2); 
     106 
    106107  if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
    107108                      (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 
    108109#ifdef DEBUG 
    109       fprintf(stderr,"{d"); 
     110    fprintf(stderr,"{d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 
     111    if ( (*myPtrs->currentFlowsetIdPtr) > 270 ) { 
     112/*      fprintf(stderr,"Bad TID from router: %lu.%lu.%lu.%lu\n", */ 
     113/*              (*myPtrs->currentFlowsetIdPtr), */ 
     114/*              (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 
     115/*              (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
     116/*              (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
     117/*              (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); */ 
     118/*      fprintf(stderr," Bytes : \n"); */ 
     119/*      while ( ( myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr) ) > (myPtrs->ptr_buffer+1416) ){ */ 
     120/*        buffer1= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; */ 
     121/*        tmp = *((unsigned char*)&buffer1); */ 
     122/*        fprintf (stderr, " %s ", tmp); */ 
     123/*      } */ 
     124/*      exit(-1); */ 
     125      return (data_length+shift); 
     126    } 
    110127#endif 
    111128    pftmp = tmp->lastField; 
     
    741758        tmpRuleList = myPtrs->rulesListPtr; 
    742759        while (tmpRuleList){ 
    743           RulesPtr tmpRuleList_for_to = myPtrs->rulesListPtr; 
     760/*        RulesPtr tmpRuleList_for_to = myPtrs->rulesListPtr; */ 
    744761          RuleDefPtr tmpRuleDefList = tmpRuleList->def; 
    745762          unsigned short check = 1; 
    746           int s=0; 
     763/*        int s=0; */ 
    747764          secondOffset = secondOldOffset; 
    748765          while (tmpRuleDefList){ 
     
    810827      } 
    811828    } /* end of the while on one flow record */ 
     829 
     830    /* new place */ 
     831     
     832    while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 
     833      (*myPtrs->offsetV9Ptr)++; /* if padding */ 
     834      paddingCounter++; 
     835      if ( paddingCounter > 8 ) { 
     836#ifdef DEBUG 
     837        fprintf(stderr," padding too high: %d ", paddingCounter); 
     838#endif 
     839        syslog(LOG_INFO,"padding too high: %d ", paddingCounter); 
     840        return (-1); 
     841      } 
     842    } 
     843    while ( (*myPtrs->offsetV9Ptr)-48-shift > data_length ) {  
     844      (*myPtrs->offsetV9Ptr)--; /* crazy loop (when bug appears in template def) */ 
     845      crazyCounter++; 
     846    } 
     847#ifdef DEBUG 
     848    if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); } 
     849#endif 
     850    if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);} 
     851     
    812852#ifdef DEBUG 
    813853    fprintf(stderr,"}"); 
    814854#endif 
     855 
     856    return (data_length+shift); 
     857    /* end new place */ 
     858     
    815859  }else{ 
    816       /*  
    817        * Optional template 
    818        */ 
    819 #ifdef DEBUG 
    820     fprintf(stderr,"<d"); 
    821 #endif 
     860    /* 
     861     * 
     862     * 
     863     *       Optional template 
     864     * 
     865     * 
     866     */ 
    822867    if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
    823868                              (*myPtrs->currentFlowsetIdPtr)))!=NULL) {         
    824              
     869#ifdef DEBUG 
     870      fprintf(stderr,"<d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 
     871#endif       
    825872      for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ 
    826873        /* FIXME : today we skip the scope fields, it's bad :( */  
    827         if (pftmp=tmpOpt->lastField) { 
     874        if ((pftmp=tmpOpt->lastField)!=NULL) { 
    828875          for (j=0; j<pftmp->fieldLength; j++) { 
    829876            (*myPtrs->offsetV9Ptr)++;  
     
    847894          if (pftmp->fieldType==34){ 
    848895            if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 
     896#ifdef DEBUGAGG 
     897              fprintf(stderr,"SV (p) %lu != %lu (r)\n", *((unsigned long*)&buffer4), 
     898                      myPtrs->currentRouterPtr->sampled); 
     899#endif                      
    849900              myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 
    850901              for (i=0; i<nbPV4; i++) { 
     
    853904                  V4PTab[i].sampling = *((unsigned long*)&buffer4); 
    854905                  myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4);  
    855 #ifdef DEBUGAGG 
    856                   fprintf(stderr," SV %lu ", *((unsigned long*)&buffer4)); 
    857 #endif             
    858906                } 
    859907              } 
     
    866914        while ((*myPtrs->offsetV9Ptr)%4 != 0) { 
    867915          (*myPtrs->offsetV9Ptr)++; 
     916#ifdef DEBUG 
     917          fprintf(stderr," p "); 
     918#endif 
    868919        } 
    869920      } else { 
     
    873924      fprintf(stderr,">"); 
    874925#endif 
    875       /*       (*myPtrs->offsetV9Ptr)+=(data_length-4); */ 
    876       /*       (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; */       
     926      return (data_length+shift); 
    877927    } else { 
    878928      /*  
     
    891941              ); 
    892942#endif 
     943      return (data_length+shift); 
    893944    } 
    894945  } 
    895   while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 
    896     (*myPtrs->offsetV9Ptr)++; /* if padding */ 
    897     paddingCounter++; 
    898     if ( paddingCounter > 8 ) { 
    899 #ifdef DEBUG 
    900     fprintf(stderr," padding too high: %d ", paddingCounter); 
    901 #endif 
    902       syslog(LOG_INFO,"padding too high: %d ", paddingCounter); 
    903       return (-1); 
    904     } 
    905   } 
    906   while ( (*myPtrs->offsetV9Ptr)-48-shift > data_length ) {  
    907     (*myPtrs->offsetV9Ptr)--; /* crazy loop (when bug appears in template def) */ 
    908     crazyCounter++; 
    909   } 
    910 #ifdef DEBUG 
    911   if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); } 
    912 #endif 
    913   if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);} 
    914   return (data_length+shift); 
     946  /* old place */ 
     947 
    915948} 
  • trunk/src/renetcol.c

    r29 r30  
    442442                                             myPtrs.currentFlowsetNumberPtr, 
    443443                                             myQueue)) < 0 ) { 
    444 #ifdef DEBUG     
     444#ifdef DEBUG 
    445445            fprintf (stderr, "w>\n"); 
    446446#endif 
     
    453453                                      curTplOptionPtr, 
    454454                                            myPtrs.currentFlowsetNumberPtr) ) < 0 ) { 
    455 #ifdef DEBUG     
     455#ifdef DEBUG 
    456456            fprintf (stderr, "wo>\n"); 
    457 #endif 
     457#endif  
    458458            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
    459459          } 
    460         } else { 
     460        } else if (currentFlowsetId > 255) { 
    461461          if ( (shift = checkDataFlowSet(shift, 
    462462                                         &myPtrs, 
     
    470470            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
    471471          } 
     472        } else { 
     473#ifdef DEBUG     
     474          fprintf (stderr, "1<<255\n"); 
     475#endif 
     476          currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
    472477        } 
    473478        if ( gardeFou > 200) { exit(-1); } 
  • trunk/src/renetcolAgg.c

    r29 r30  
    9595          for (j=0; j<strlen(buf); j++) {buf[j] = '\0';} 
    9696          strcat(name, RRD_LOCATION); 
    97           fprintf(stderr," SPL : %lu\n ",shmForAgg->prefixV4Tab[index][i].sampling); 
    9897          sprintf(ipStr, "%lu_%lu_%lu_%lu_%hu_%lu",  
    9998                  shmForAgg->prefixV4Tab[index][i].beginning>>24, 
     
    107106          strcat(name, RRD_EXTENSION); 
    108107          if ( (fp=fopen(name,"r")) == NULL ){ 
    109 #ifdef DEBUGAGG 
    110             fprintf(stderr, "Creation %s ... ", name);  
    111 #endif 
    112108            opt[0]= (char *) malloc((strlen(RRD_PARAM_0) + 1) * sizeof(char)); 
    113109            strcpy(opt[0], RRD_PARAM_0); 
     
    176172              opt[j] = NULL; 
    177173            } 
    178 #ifdef DEBUGAGG 
    179             fprintf(stderr, "end creation \n", name);  
    180 #endif 
    181174          }else{  
    182175            fclose(fp); 
    183 #ifdef DEBUGAGG 
    184             fprintf(stderr, "Update %s \n", name);  
    185 #endif 
    186176            rrd_already_created_ct++; 
    187177            snprintf(buf,  
  • trunk/src/renetcolSender.c

    r28 r30  
    309309  strcpy (rulesFileName, argv[3]); 
    310310  rulesListPtr = NULL; 
    311   fprintf(stderr, "renetcolSender: reading the rules...\n"); 
    312311  rulesListPtr = getRules(rulesListPtr, rulesFileName); 
    313   fprintf(stderr, "renetcolSender: OK\n"); 
    314312  /* we delete rules which are not type socket */ 
    315313  tmp = rulesListPtr; 
  • trunk/src/routers_mgmt.c

    r28 r30  
    7575  TplFlowSetPtr tmp = (TplFlowSetPtr) malloc(sizeof(struct TemplateFlowSet)); 
    7676  tmp->sourceId = 0; 
    77   tmp->templateFlowSetId = 0; 
     77  tmp->templateFlowSetId = 99; 
    7878  tmp->fieldCount = 0; 
    7979  tmp->fieldSet = NULL; 
     
    8989  if (ptpl) { 
    9090    while ( ptpl->fieldSet != NULL ){ 
    91 /*       fprintf(stderr, "deleteTplFlSet\n"); */ 
    9291      if (!(ptpl->lastField->prev)) { 
    9392        freeField(ptpl->lastField); 
     
    104103    ptpl = NULL; 
    105104  } 
    106   return NULL; /* FIXME I don't known */ 
     105  return NULL; 
    107106} 
    108107 
     
    111110  TplOptionPtr tmp = (TplOptionPtr) malloc(sizeof(struct TemplateOption)); 
    112111  tmp->sourceId = 0; 
    113   tmp->templateOptionId = 0; 
     112  tmp->templateOptionId = 66; 
    114113  tmp->length = 0; 
    115114  tmp->optionScopeLg = 0; 
     
    127126  if (ptplo) { 
    128127    while ( ptplo->fieldSet != NULL ){ 
    129 /*       fprintf(stderr, "deleteTplFlSet\n"); */ 
    130128      if (!(ptplo->lastField->prev)) { 
    131129        freeField(ptplo->lastField); 
  • trunk/src/template.c

    r29 r30  
    6767  unsigned char buffer2[2]; 
    6868  unsigned short tmp = 0; 
    69   unsigned short getFlowsetId = 0; 
     69  unsigned short flowsetId = 0; 
    7070  unsigned short length = 0; 
    7171  TplFlowSetPtr ptpltmp = NULL; 
     
    7777  unsigned short badFieldNumber = 0; 
    7878  unsigned short badFieldLength = 0; 
     79  unsigned short badFieldCount = 0; 
    7980 
    8081  buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    8182  buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    82   getFlowsetId = *((unsigned short*)&buffer2); 
     83  flowsetId = *((unsigned short*)&buffer2); 
    8384  buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    8485  buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
     
    9091    badFieldNumber = 0; 
    9192    badFieldLength = 0; 
     93    badFieldCount = 0; 
    9294    buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    9395    buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
     
    103105      buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    104106      buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    105       cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 
     107      if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 
     108        badFieldCount = 1; 
     109        ptpltmp = cTFSPtr; 
     110        if (ptpltmp->prev == NULL) { 
     111          cr->tplList = ptpltmp->next; 
     112          if (cr->tplList) { 
     113            cr->tplList->prev = NULL; 
     114          } 
     115        } else { 
     116          ptpltmp->prev->next = ptpltmp->next; 
     117          if (ptpltmp->next) { 
     118            ptpltmp->next->prev = ptpltmp->prev; 
     119          } 
     120        } 
     121        deleteTplFlSet(ptpltmp); 
     122        cTFSPtr = NULL; 
     123        return (-1); 
     124      } 
    106125      cpt_fields = 0; 
    107126      for ( i=0; i<cTFSPtr->fieldCount; i++) { 
     
    125144        } 
    126145        cpt_fields++; 
    127         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { /* FIXME : constante pour cela */ 
     146        if ( (cTFSPtr->templateFlowSetId < 256 )  
     147             || (cpt_fields > 40)  
     148             || (badFieldNumber == 1)  
     149             || badFieldLength == 1  
     150             || (badFieldCount == 1)) { 
    128151          fprintf(stderr,"\n IP: %lu.%lu.%lu.%lu, %d,%d\n", 
    129152                  cr->IpAddress>>24, 
     
    177200      } 
    178201      deleteTplFlSet(ptpltmp); 
     202      ptpltmp = NULL; 
    179203      cTFSPtr = NULL; 
    180204      cTFSPtr = newRouterTplList(); 
     
    186210      buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    187211      buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 
    188       cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 
     212      if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 
     213        badFieldCount = 1; 
     214        ptpltmp = cTFSPtr; 
     215        if (ptpltmp->prev == NULL) { 
     216          cr->tplList = ptpltmp->next; 
     217          if (cr->tplList) { 
     218            cr->tplList->prev = NULL; 
     219          } 
     220        } else { 
     221          ptpltmp->prev->next = ptpltmp->next; 
     222          if (ptpltmp->next) { 
     223            ptpltmp->next->prev = ptpltmp->prev; 
     224          } 
     225        } 
     226        deleteTplFlSet(ptpltmp); 
     227        cTFSPtr = NULL; 
     228        return (-1); 
     229      } 
    189230      cpt_fields = 0; 
    190231      for ( i=0; i<cTFSPtr->fieldCount; i++) { 
     
    210251        } 
    211252        cpt_fields++; 
    212         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { /* FIXME : declarer une constante pour cela */ 
     253        if ( (cTFSPtr->templateFlowSetId < 256 )  
     254             || (cpt_fields > 40)  
     255             || (badFieldNumber == 1)  
     256             || badFieldLength == 1  
     257             || (badFieldCount == 1)) { 
    213258          while ( ((*offV9))> (index)){ 
    214259            buffer2[1]= *(buf+index); index++; 
     
    355400        } 
    356401        cpt_fields++; 
    357         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
     402        if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
    358403          syslog (LOG_INFO,  
    359404                  "in option template function: too many fields, bug collector or wrong template def in template update"); 
     
    430475        } 
    431476        cpt_fields++; 
    432         if ( (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
     477        if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 
    433478          syslog (LOG_INFO,  
    434479                  "in update option tpl function: too many fields, bug collector or wrong template def in template update");