Changeset 30 for trunk/src/dataFlowSet.c

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

bug of "template fantom" correction

Files:
1 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}