Changeset 29 for trunk/src/dataFlowSet.c

Show
Ignore:
Timestamp:
04/13/07 17:40:49 (16 years ago)
Author:
andreu
Message:

sampling information in rrd filename - optional template first step

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r28 r29  
    3939{ 
    4040  TplFlowSetPtr tmp; 
     41  TplOptionPtr tmpOpt; 
    4142  FieldPtr pftmp; 
    4243  FieldPtr secondPftmp; 
     
    103104  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
    104105  data_length = *((unsigned short*)&buffer2); 
    105   if ((tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
    106                       (*myPtrs->currentFlowsetIdPtr)))!=NULL) { 
     106  if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
     107                      (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 
     108#ifdef DEBUG 
     109      fprintf(stderr,"{d"); 
     110#endif 
    107111    pftmp = tmp->lastField; 
    108112    for (; pftmp; pftmp = pftmp->prev) { 
     
    143147    while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) {  
    144148      /*  
    145        * progression in a flow Set  
     149       * progression in a data flow Set  
    146150       * notes: 
    147151       *   48=header ip + header netf 
     
    282286                    ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    283287                  } 
    284               }        
     288              } 
    285289#ifdef IPV4AGG 
    286290              if ((pftmp->fieldType==8)){ 
     
    805809        pftmp = pftmp->prev; 
    806810      } 
    807     } /* end of the while on one flow record */     
     811    } /* end of the while on one flow record */ 
     812#ifdef DEBUG 
     813    fprintf(stderr,"}"); 
     814#endif 
    808815  }else{ 
    809     /*  
    810      * template unknown, we skip this all the data  
    811      */ 
    812     (*myPtrs->offsetV9Ptr)+=(data_length-4); 
    813     (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
     816      /*  
     817       * Optional template 
     818       */ 
    814819#ifdef DEBUG 
    815     fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu", 
    816             (myPtrs->pcktPtr->ipH->srcAdd>>24), 
    817             (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
    818             (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
    819             (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
    820             myPtrs->currentHeaderV9Ptr->sourceId,  
    821             (*myPtrs->currentFlowsetIdPtr) 
    822             ); 
    823 #endif 
     820    fprintf(stderr,"<d"); 
     821#endif 
     822    if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
     823                              (*myPtrs->currentFlowsetIdPtr)))!=NULL) {         
     824             
     825      for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ 
     826        /* FIXME : today we skip the scope fields, it's bad :( */  
     827        if (pftmp=tmpOpt->lastField) { 
     828          for (j=0; j<pftmp->fieldLength; j++) { 
     829            (*myPtrs->offsetV9Ptr)++;  
     830          } 
     831          pftmp = pftmp->prev; 
     832        } 
     833      } 
     834      while (pftmp != NULL) { 
     835        if (pftmp->fieldLength==1){  
     836          buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     837        } 
     838        if (pftmp->fieldLength==2){  
     839          buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     840          buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     841        } 
     842        if (pftmp->fieldLength==4){  
     843          buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     844          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     845          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     846          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     847          if (pftmp->fieldType==34){ 
     848            if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 
     849              myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 
     850              for (i=0; i<nbPV4; i++) { 
     851                /* we update the PrefixV4 structure with the sampled information */ 
     852                if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 
     853                  V4PTab[i].sampling = *((unsigned long*)&buffer4); 
     854                  myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4);  
     855#ifdef DEBUGAGG 
     856                  fprintf(stderr," SV %lu ", *((unsigned long*)&buffer4)); 
     857#endif             
     858                } 
     859              } 
     860            } 
     861          } 
     862        }        
     863        pftmp = pftmp->prev; 
     864      } 
     865      if ( pftmp == NULL ) { 
     866        while ((*myPtrs->offsetV9Ptr)%4 != 0) { 
     867          (*myPtrs->offsetV9Ptr)++; 
     868        } 
     869      } else { 
     870        fprintf(stderr,"PB "); 
     871      } 
     872#ifdef DEBUG 
     873      fprintf(stderr,">"); 
     874#endif 
     875      /*       (*myPtrs->offsetV9Ptr)+=(data_length-4); */ 
     876      /*       (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; */       
     877    } else { 
     878      /*  
     879       * template unknown, we skip this all the data  
     880       */ 
     881      (*myPtrs->offsetV9Ptr)+=(data_length-4); 
     882      (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
     883#ifdef DEBUG 
     884      fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu", 
     885              (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     886              (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     887              (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     888              (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
     889              myPtrs->currentHeaderV9Ptr->sourceId,  
     890              (*myPtrs->currentFlowsetIdPtr) 
     891              ); 
     892#endif 
     893    } 
    824894  } 
    825895  while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 
     
    839909  } 
    840910#ifdef DEBUG 
    841   if (crazyCounter != 0){ 
    842     fprintf(stderr," crazyCounter: %d ", crazyCounter); 
    843   } 
     911  if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); } 
    844912#endif 
    845913  if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);}