Changeset 23

Show
Ignore:
Timestamp:
02/05/07 17:50:16 (16 years ago)
Author:
andreu
Message:

optimization : new param : myPtrs in checkdataflowset function

Location:
trunk/src
Files:
2 added
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r22 r23  
    2929 * Check Data FlowSet  
    3030 * 
    31  * @param shift Shift 
    32  * @param cr Current router pointer 
    33  * @param v9Ptr Pointer in the datagram ?? 
    34  * @param offv9 index in the datagram 
    35  * @param buf Pointer to the buffer 
    36  * @param cFNPtr Pointer on the current flowset number 
    37  * @param cFId Pointer on the current flowset ID 
    38  * @param pcktPtr Pointer on the datagram buffer 
    39  * @param rulesCache Pointer on the rules table (cache for the next param) 
    40  * @param rlPtr Pointer on the rules list 
    41  * @param myQueue FIXME : to erase/delete/suppress 
    42  * @param V4PTab Pointer on the IPv4 Prefix Table 
    43  * @param nbPV4 Previous table size 
    44  * @param ipCache Cache for all IP flow (for CRIHAN compilation option) 
    45  * @param mplsCache Cache for all MPLS flow (for CRIHAN compilation option) 
    46  * @param ipCounter Param to defined IP Cache size 
    47  * @param mplsCounter Param to defined MPLS Cache size  
    48  * @return shift (index in the datagram) FIXME  
    49  *  
    50  * FIXME to tune : just a param like a table ? 
    5131 */ 
    5232unsigned short  
    53 checkDataFlowSet(unsigned short shift, RouterPtr cr, NetFlowV9HeaderPtr v9Ptr, 
    54                  unsigned short *offV9, unsigned char *buf, short *cFNPtr, 
    55                  short *cFId, DatagramPtr pcktPtr, RuleDefPtr *rulesCache, 
    56                  RulesPtr rlPtr, int myQueue, struct PrefixV4 *V4PTab,  
    57                  size_t nbPV4,  
    58                  struct IPFLowCache *ipCache, struct MPLSFlowCache *mplsCache, 
    59                  unsigned long *ipCounter, unsigned long *mplsCounter) 
     33checkDataFlowSet(unsigned short shift,  
     34                 struct MyPtrs *myPtrs, 
     35                 int myQueue,  
     36                 struct PrefixV4 *V4PTab,  
     37                 size_t nbPV4 
     38                 ) 
    6039{ 
    6140  TplFlowSetPtr tmp; 
     
    6443  unsigned short data_length = 0; 
    6544  unsigned short flow_size = 0; 
    66   unsigned short oldOffset = *offV9; 
     45  unsigned short oldOffset = *myPtrs->offsetV9Ptr; 
    6746  unsigned short secondOffset = 0; 
    6847  unsigned short secondOldOffset = 0; 
     
    7958  unsigned char buffer2[2]; 
    8059  unsigned char buffer4[4]; 
    81   RulesPtr tmpRuleList = rlPtr; 
     60  RulesPtr tmpRuleList = myPtrs->rulesListPtr; 
    8261  msgType myMsg; 
    8362  char *msgTextIndex; 
     
    11493#endif /* CRIHAN */ 
    11594 
    116   buffer2[1] = *(buf+(*offV9));(*offV9)++; 
    117   buffer2[0] = *(buf+(*offV9));(*offV9)++; 
    118   (*cFId) = *((unsigned short*)&buffer2); 
    119   buffer2[1] = *(buf+(*offV9));(*offV9)++; 
    120   buffer2[0] = *(buf+(*offV9));(*offV9)++; 
     95  buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
     96  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
     97  (*myPtrs->currentFlowsetIdPtr) = *((unsigned short*)&buffer2); 
     98  buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
     99  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 
    121100  data_length = *((unsigned short*)&buffer2); 
    122   if ((tmp=existTplId(cr, v9Ptr->sourceId,  
    123                       (*cFId)))!=NULL) { 
     101  if ((tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,  
     102                      (*myPtrs->currentFlowsetIdPtr)))!=NULL) { 
    124103    pftmp = tmp->lastField; 
    125104    for (; pftmp; pftmp = pftmp->prev) { 
     
    127106    } 
    128107    if ( data_length%flow_size >= 9 ) { 
    129       (*cFNPtr) = v9Ptr->count; 
     108      (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
    130109      syslog(LOG_INFO, "data flowset length not match with length from template definition, wrong template definition suspected; all next informations of this data flowset are not considered! flowset ID: %hu, from router: %lu.%lu.%lu.%lu", 
    131              (*cFId), 
    132              (pcktPtr->ipH->srcAdd>>24), 
    133              (pcktPtr->ipH->srcAdd<<8>>24), 
    134              (pcktPtr->ipH->srcAdd<<16>>24), 
    135              (pcktPtr->ipH->srcAdd<<24>>24)); 
     110             (*myPtrs->currentFlowsetIdPtr), 
     111             (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     112             (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     113             (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     114             (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 
    136115      return (data_length+shift); 
    137116    } 
    138117#ifdef IPV4AGG 
    139     agCache.routerAd = pcktPtr->ipH->srcAdd;  
     118    agCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;  
    140119#endif 
    141120 
    142121#ifdef CRIHAN 
    143     ipFirstCache.routerAd = pcktPtr->ipH->srcAdd; 
    144     mplsFirstCache.routerAd = pcktPtr->ipH->srcAdd; 
     122    ipFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; 
     123    mplsFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; 
    145124#endif /* CRIHAN */ 
    146125 
    147126    pftmp = tmp->lastField; 
    148127    secondPftmp = tmp->lastField;     
    149     secondOffset = *offV9; 
     128    secondOffset = *myPtrs->offsetV9Ptr; 
    150129    secondOldOffset = secondOffset; 
    151     while ( (((*offV9)-48-shift) <= data_length) && (overflow!=1) ) {  
     130    while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) {  
    152131      /*  
    153132       * progression in a flow Set  
     
    164143       * ... if one rule exist 
    165144       */ 
    166       if (((RuleDefPtr)(*(rulesCache+pos))) != NULL) { 
    167         oldOffset = *offV9; 
    168         while (((RuleDefPtr)(*(rulesCache+pos))) != NULL){ 
     145      if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL) { 
     146        oldOffset = *myPtrs->offsetV9Ptr; 
     147        while (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL){ 
    169148          /*  
    170149           * while on one cache table line 
    171150           */ 
    172           *offV9 = oldOffset; 
     151          *myPtrs->offsetV9Ptr = oldOffset; 
    173152          switch ((int) 
    174                   (((RuleDefPtr)(*(rulesCache+pos)))->operator)){ 
     153                  (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)){ 
    175154          case 2: 
    176155            switch (field_size) { 
    177156            case 1: 
    178               buffer1 = *(buf+(*offV9)); (*offV9)++; 
     157              buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    179158              /* rule check */ 
    180               if (((RuleDefPtr)(*(rulesCache+pos)))->value->stor.cvalue  
     159              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.cvalue  
    181160                  == *((unsigned char*)&buffer1)) { 
    182                 ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     161                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    183162              } 
    184163              /* end rule check */ 
     
    220199              break; 
    221200            case 2: 
    222               buffer2[1]= *(buf+(*offV9)); (*offV9)++; 
    223               buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
    224               if (((RuleDefPtr)(*(rulesCache+pos)))->value->stor.svalue  
     201              buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     202              buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     203              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue  
    225204                  == *((unsigned short*)&buffer2)) 
    226                 ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     205                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    227206#ifdef IPV4AGG 
    228207              if (pftmp->fieldType==10){ 
     
    247226            case 3: 
    248227              buffer4[3]= 0; 
    249               buffer4[2]= *(buf+(*offV9)); (*offV9)++; 
    250               buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    251               buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
    252               if (((RuleDefPtr)(*(rulesCache+pos)))->value->stor.lvalue  
     228              buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     229              buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     230              buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     231              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue  
    253232                  == *((unsigned long*)&buffer4)) 
    254                 ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     233                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    255234              /* aggregation */ 
    256235              /* end aggregation */ 
     
    262241              break; 
    263242            case 4: 
    264               buffer4[3]= *(buf+(*offV9)); (*offV9)++; 
    265               buffer4[2]= *(buf+(*offV9)); (*offV9)++; 
    266               buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    267               buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
     243              buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     244              buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     245              buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     246              buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    268247              /* FIXME : here , add a check on the field type */ 
    269248              if ((pftmp->fieldType==8)||(pftmp->fieldType==12)){ 
    270                 if ((((RuleDefPtr)(*(rulesCache+pos)))->value->stor.lvalue)  
    271                     == (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)<<(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) ) 
     249                if ((((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue)  
     250                    == (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) ) 
    272251                  { 
    273                     ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     252                    ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    274253                  } 
    275254              }        
     
    313292            case 16: 
    314293              for (i=0; i<4; i++) { 
    315                 buffer4[3]= *(buf+(*offV9)); (*offV9)++; 
    316                 buffer4[2]= *(buf+(*offV9)); (*offV9)++; 
    317                 buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    318                 buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
     294                buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     295                buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     296                buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     297                buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    319298                if (1==moreIsNecessary){ 
    320299                  switch(i){ 
    321300                  case 0: 
    322                     if (((RuleDefPtr)(*(rulesCache+pos)))->value->mask <= 32){ 
    323                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     301                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 32){ 
     302                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    324303                          ==  
    325                           (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)<<(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) 
     304                          (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 
    326305                          ) 
    327306                        { 
    328                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     307                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    329308                          moreIsNecessary = 0; 
    330309                        } else { 
    331                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     310                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    332311                          moreIsNecessary = 0; 
    333312                        } 
    334313                    } else { 
    335                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     314                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    336315                          ==  
    337316                          (*((unsigned long*)&buffer4)) 
    338317                          ) 
    339318                        { 
    340                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
     319                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 
    341320                        } else { 
    342                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     321                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    343322                          moreIsNecessary = 0; 
    344323                        } 
     
    346325                    break; 
    347326                  case 1: 
    348                     if (((RuleDefPtr)(*(rulesCache+pos)))->value->mask <= 64){ 
    349                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     327                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 64){ 
     328                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    350329                          ==  
    351                           (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)<<(64-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) 
     330                          (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 
    352331                          ) 
    353332                        { 
    354                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 
    355                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     333                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 
     334                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    356335                          moreIsNecessary = 0; 
    357336                        } else { 
    358                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     337                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    359338                          moreIsNecessary = 0; 
    360339                        } 
    361340                    } else { 
    362                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     341                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    363342                          ==  
    364343                          (*((unsigned long*)&buffer4)) 
    365344                          ) 
    366345                        { 
    367                           ((RuleDefPtr)(*(rulesCache+pos)))->check =  
    368                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     346                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =  
     347                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    369348                        } else { 
    370                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     349                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    371350                          moreIsNecessary = 0; 
    372351                        } 
     
    374353                    break; 
    375354                  case 2: 
    376                     if (((RuleDefPtr)(*(rulesCache+pos)))->value->mask <= 96){ 
    377                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     355                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 96){ 
     356                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    378357                          ==  
    379                           (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)<<(96-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) 
     358                          (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 
    380359                          ) 
    381360                        { 
    382                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 
    383                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     361                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 
     362                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    384363                          moreIsNecessary = 0; 
    385364                        } else { 
    386                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     365                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    387366                          moreIsNecessary = 0; 
    388367                        } 
    389368                    } else { 
    390                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     369                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    391370                          ==  
    392371                          (*((unsigned long*)&buffer4)) 
    393372                          ) 
    394373                        { 
    395                           ((RuleDefPtr)(*(rulesCache+pos)))->check =  
    396                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     374                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =  
     375                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    397376                        } else { 
    398                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     377                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    399378                          moreIsNecessary = 0; 
    400379                        } 
     
    402381                    break; 
    403382                  case 3: 
    404                     if (((RuleDefPtr)(*(rulesCache+pos)))->value->mask <= 128){ 
    405                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     383                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 128){ 
     384                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    406385                          ==  
    407                           (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)<<(128-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) 
     386                          (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 
    408387                          ) 
    409388                        { 
    410                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 
    411                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     389                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 
     390                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    412391                        } else { 
    413                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     392                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    414393                          moreIsNecessary = 0; 
    415394                        } 
    416395                    } else { 
    417                       if (ntohl(((RuleDefPtr)(*(rulesCache+pos)))->value->stor.tabAdd6[i])  
     396                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])  
    418397                          ==  
    419398                          (*((unsigned long*)&buffer4)) 
    420399                          ) 
    421400                        { 
    422                           ((RuleDefPtr)(*(rulesCache+pos)))->check =  
    423                             ((RuleDefPtr)(*(rulesCache+pos)))->check && 1; 
     401                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =  
     402                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 
    424403                        } else { 
    425                           ((RuleDefPtr)(*(rulesCache+pos)))->check = 0; 
     404                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 
    426405                          moreIsNecessary = 0; 
    427406                        } 
     
    441420              syslog(LOG_INFO, "Field size not known: %d\n", field_size);  
    442421              for (i=0; i<field_size; i++){ 
    443                 (*offV9)++; 
     422                (*myPtrs->offsetV9Ptr)++; 
    444423              } 
    445424              break; 
     
    448427          default: 
    449428            syslog(LOG_INFO, "Operator not known: %d\n", 
    450                    (int)(((RuleDefPtr)(*(rulesCache+pos)))->operator)); 
     429                   (int)(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)); 
    451430            break; 
    452431          } 
    453432          j++; 
    454433          pos = (pftmp->fieldType)*10+j; 
    455         } /* end while rulesCache */ 
     434        } /* end while myPtrs->rulesAddressPtr */ 
    456435      } else { 
    457436        /*  
     
    460439        switch (field_size) { 
    461440        case 1: 
    462           buffer1 = *(buf+(*offV9)); (*offV9)++; 
     441          buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    463442#ifdef IPV4AGG 
    464443          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
     
    498477          break; 
    499478        case 2: 
    500           buffer2[1]= *(buf+(*offV9)); (*offV9)++; 
    501           buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
     479          buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     480          buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    502481#ifdef IPV4AGG 
    503482          if (pftmp->fieldType==10){ 
     
    522501        case 3: 
    523502          buffer4[3]= 0; 
    524           buffer4[2]= *(buf+(*offV9)); (*offV9)++; 
    525           buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    526           buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
     503          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     504          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     505          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    527506          /* aggregation */ 
    528507          /* end aggregation */ 
     
    534513          break; 
    535514        case 4: 
    536           buffer4[3]= *(buf+(*offV9)); (*offV9)++; 
    537           buffer4[2]= *(buf+(*offV9)); (*offV9)++; 
    538           buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    539           buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
     515          buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     516          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     517          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     518          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    540519#ifdef IPV4AGG 
    541520          if ((pftmp->fieldType==8)){ 
     
    575554        case 16: 
    576555          for (i=0; i<4; i++) { 
    577             buffer2[1]= *(buf+(*offV9)); (*offV9)++; 
    578             buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
    579             buffer2[1]= *(buf+(*offV9)); (*offV9)++; 
    580             buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
     556            buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     557            buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     558            buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
     559            buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 
    581560          } 
    582561          /* aggregation IPv6 */           
     
    586565          syslog(LOG_INFO,"UNKNOWN FIELDS LENGTH: %d ", field_size); 
    587566          for (i=0; i<field_size; i++){ 
    588             (*offV9)++; 
     567            (*myPtrs->offsetV9Ptr)++; 
    589568          } 
    590569        } 
     
    596575#ifdef CRIHAN 
    597576        if ( mplsFirstCache.mplsLabel1 == 0 ) { 
    598           (ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt; 
     577          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->ipProt = ipFirstCache.ipProt; 
    599578          ipFirstCache.ipProt = 0; 
    600           (ipCache+(*ipCounter))->bytes = ipFirstCache.bytes; 
     579          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->bytes = ipFirstCache.bytes; 
    601580          ipFirstCache.bytes = 0; 
    602           (ipCache+(*ipCounter))->pkts = ipFirstCache.pkts; 
     581          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->pkts = ipFirstCache.pkts; 
    603582          ipFirstCache.pkts = 0; 
    604           (ipCache+(*ipCounter))->inSnmp = ipFirstCache.inSnmp; 
     583          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->inSnmp = ipFirstCache.inSnmp; 
    605584          ipFirstCache.inSnmp = 0; 
    606           (ipCache+(*ipCounter))->outSnmp = ipFirstCache.outSnmp; 
     585          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->outSnmp = ipFirstCache.outSnmp; 
    607586          ipFirstCache.outSnmp = 0; 
    608           (ipCache+(*ipCounter))->v4AdS = ipFirstCache.v4AdS; 
     587          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdS = ipFirstCache.v4AdS; 
    609588          ipFirstCache.outSnmp = 0; 
    610           (ipCache+(*ipCounter))->v4AdD = ipFirstCache.v4AdD; 
     589          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdD = ipFirstCache.v4AdD; 
    611590          ipFirstCache.v4AdD = 0; 
    612           (ipCache+(*ipCounter))->tProt = ipFirstCache.tProt; 
     591          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->tProt = ipFirstCache.tProt; 
    613592          ipFirstCache.tProt = 0; 
    614           (ipCache+(*ipCounter))->sPort = ipFirstCache.sPort; 
     593          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->sPort = ipFirstCache.sPort; 
    615594          ipFirstCache.sPort = 0; 
    616           (ipCache+(*ipCounter))->dPort = ipFirstCache.dPort; 
     595          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->dPort = ipFirstCache.dPort; 
    617596          ipFirstCache.dPort = 0; 
    618           (ipCache+(*ipCounter))->maskD = ipFirstCache.maskD; 
     597          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskD = ipFirstCache.maskD; 
    619598          ipFirstCache.maskD = 0; 
    620           (ipCache+(*ipCounter))->maskS = ipFirstCache.maskS; 
     599          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskS = ipFirstCache.maskS; 
    621600          ipFirstCache.maskS = 0; 
    622           (ipCache+(*ipCounter))->routerAd = ipFirstCache.routerAd; 
    623           (ipCache+(*ipCounter))->liveTime = lastTime - firstTime; 
     601          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->routerAd = ipFirstCache.routerAd; 
     602          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->liveTime = lastTime - firstTime; 
    624603          firstTime = 0; lastTime = 0; 
    625           (*ipCounter)++; 
     604          (*myPtrs->ipNbPtr)++; 
    626605        } else { 
    627           (mplsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt; 
     606          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->ipProt = mplsFirstCache.ipProt; 
    628607          mplsFirstCache.ipProt = 0; 
    629           (mplsCache+(*mplsCounter))->v4AdS =  mplsFirstCache.v4AdS; 
     608          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdS =  mplsFirstCache.v4AdS; 
    630609          mplsFirstCache.v4AdS = 0; 
    631           (mplsCache+(*mplsCounter))->v4AdD =  mplsFirstCache.v4AdD;  
     610          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdD =  mplsFirstCache.v4AdD;  
    632611          mplsFirstCache.v4AdD = 0; 
    633           (mplsCache+(*mplsCounter))->routerAd =  mplsFirstCache.routerAd; 
    634           (mplsCache+(*mplsCounter))->mplsLabel1 =  mplsFirstCache.mplsLabel1; 
     612          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->routerAd =  mplsFirstCache.routerAd; 
     613          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->mplsLabel1 =  mplsFirstCache.mplsLabel1; 
    635614          mplsFirstCache.mplsLabel1 = 0; 
    636           (*mplsCounter)++; 
     615          (*myPtrs->mplsNbPtr)++; 
    637616        } 
    638617#endif  
    639618        /* put aggregation cache information to IPv4 Prefixes table */ 
     619        /* Aggregation mode must be enable in ./configure options   */ 
     620        /* first we must know if the address belong to our prefix   */ 
    640621#ifdef IPV4AGG 
    641622        if (bool == 1){ 
     
    643624          res = bsearch(&prefixKey, V4PTab, nbPV4,  
    644625                        sizeof(struct PrefixV4), prefCmp); 
    645           if (res!=NULL){ 
    646             res->bytesNb += agCache.bytes; 
    647             res->pktsNb += agCache.pkts; 
    648             res->flowNb += 1; 
    649             switch (agCache.ipProt) { 
     626          if (res!=NULL){ /* OUT ("traffic from the prefix")  */ 
     627            res->bytesNbOUT += agCache.bytes; 
     628            res->pktsNbOUT += agCache.pkts; 
     629            (res->flowNbOUT)++; 
     630            switch (agCache.tProt) { 
    650631            case 1: 
    651               res->icmpBytesNb += agCache.bytes; 
    652               res->icmpPktsNb += agCache.pkts; 
    653               res->icmpFlowNb += 1; 
     632              res->icmpBytesNbOUT += agCache.bytes; 
     633              res->icmpPktsNbOUT += agCache.pkts; 
     634              (res->icmpFlowNbOUT)++; 
    654635              break; 
    655636            case 6: 
    656               res->tcpBytesNb += agCache.bytes; 
    657               res->tcpPktsNb += agCache.pkts; 
    658               res->tcpFlowNb += 1;             
     637              res->tcpBytesNbOUT += agCache.bytes; 
     638              res->tcpPktsNbOUT += agCache.pkts; 
     639              (res->tcpFlowNbOUT)++;           
    659640              break; 
    660641            case 17: 
    661               res->udpBytesNb += agCache.bytes; 
    662               res->udpPktsNb += agCache.pkts; 
    663               res->udpFlowNb += 1; 
     642              res->udpBytesNbOUT += agCache.bytes; 
     643              res->udpPktsNbOUT += agCache.pkts; 
     644              (res->udpFlowNbOUT)++; 
    664645              break; 
    665646            default: 
    666               res->othersBytesNb += agCache.bytes; 
    667               res->othersPktsNb += agCache.pkts; 
    668               res->othersFlowNb += 1;          
     647              res->othersBytesNbOUT += agCache.bytes; 
     648              res->othersPktsNbOUT += agCache.pkts; 
     649              (res->othersFlowNbOUT)++; 
    669650            } 
    670           } 
    671 /*        if (res==NULL){ */ 
    672 /*          fprintf(stderr, "IPv4_spoofing? ");  */ 
    673 /*        } */ 
     651          } else { 
     652            prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
     653            res = bsearch(&prefixKey, V4PTab, nbPV4,  
     654                          sizeof(struct PrefixV4), prefCmp); 
     655            if (res!=NULL){ /* IN ("traffic to the prefix")  */ 
     656              res->bytesNbIN += agCache.bytes; 
     657              res->pktsNbIN += agCache.pkts; 
     658              (res->flowNbIN)++; 
     659              switch (agCache.tProt) { 
     660              case 1: 
     661                res->icmpBytesNbIN += agCache.bytes; 
     662                res->icmpPktsNbIN += agCache.pkts; 
     663                (res->icmpFlowNbIN)++; 
     664                break; 
     665              case 6: 
     666                res->tcpBytesNbIN += agCache.bytes; 
     667                res->tcpPktsNbIN += agCache.pkts; 
     668                (res->tcpFlowNbIN)++; 
     669                break; 
     670              case 17: 
     671                res->udpBytesNbIN += agCache.bytes; 
     672                res->udpPktsNbIN += agCache.pkts; 
     673                (res->udpFlowNbIN)++; 
     674                break; 
     675              default: 
     676                res->othersBytesNbIN += agCache.bytes; 
     677                res->othersPktsNbIN += agCache.pkts; 
     678                (res->othersFlowNbIN)++; 
     679              } 
     680            } else { 
     681              /* HERE : we are in the cases of the address/mask don't      */ 
     682              /*        belong to a prefix listed in the IPv4 prefix file  */ 
     683              /* possibilities :                                           */ 
     684              /*     -  prefix not referenced but allowed to be routed     */ 
     685              /*     -  prefix not referenced but not allowed to be routed */ 
     686              /*     -  spoofing                                           */ 
     687/*            fprintf(stderr, "%lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */ 
     688/*                    (agCache.v4AdS>>24), */ 
     689/*                    (agCache.v4AdS<<8>>24),  */ 
     690/*                    (agCache.v4AdS<<16>>24),  */ 
     691/*                    (agCache.v4AdS<<24>>24),  */ 
     692/*                    (agCache.maskS),  */ 
     693/*                    (agCache.v4AdD>>24),  */ 
     694/*                    (agCache.v4AdD<<8>>24),  */ 
     695/*                    (agCache.v4AdD<<16>>24),  */ 
     696/*                    (agCache.v4AdD<<24>>24),  */ 
     697/*                    (agCache.maskD),  */ 
     698/*                    (myPtrs->pcktPtr->ipH->srcAdd>>24),  */ 
     699/*                    (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
     700/*                    (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
     701/*                    (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */ 
     702/*                    ); */ 
     703            } 
     704          } 
    674705        } 
    675706        bool = 0; 
     
    680711         * we send the flow or a part of the flow to a remote host or a file 
    681712         */ 
    682         tmpRuleList = rlPtr; 
     713        tmpRuleList = myPtrs->rulesListPtr; 
    683714        while (tmpRuleList){ 
    684715          unsigned short check = 1; 
     
    693724            /* msg building */ 
    694725            secondPftmp = tmp->lastField; 
    695 /*          memcpy(myMsg.text, (char*)(buf+secondOffset),flow_size); */ 
     726/*          memcpy(myMsg.text, (char*)(myPtrs->ptr_buffer+secondOffset),flow_size); */ 
    696727            msgTextIndex = mempcpy(mempcpy(mempcpy(myMsg.text,  
    697728                                                   &tplMsgType,  
     
    701732                                           sizeof(tmpRuleList->id) 
    702733                                           ), 
    703                                    &cr->IpAddress,  
     734                                   &myPtrs->currentRouterPtr->IpAddress,  
    704735                                   sizeof(unsigned long)  
    705736                                   ); 
     
    711742                                           sizeof(tmp->templateFlowSetId)  
    712743                                           ),  
    713                                    buf+secondOffset,  
     744                                   myPtrs->ptr_buffer+secondOffset,  
    714745                                   flow_size 
    715746                                   );  
     
    725756         * end redirection  
    726757         */ 
    727         secondOffset = *offV9; 
     758        secondOffset = *myPtrs->offsetV9Ptr; 
    728759        secondOldOffset = secondOffset; 
    729760        pftmp = tmp->lastField; 
    730761        cpt=0; 
    731         (*cFNPtr)++; /* pointer on the flows number */ 
    732         if (((*offV9)-48-shift+flow_size) > data_length){ 
     762        (*myPtrs->currentFlowsetNumberPtr)++; /* pointer on the flows number */ 
     763        if (((*myPtrs->offsetV9Ptr)-48-shift+flow_size) > data_length){ 
    733764          overflow = 1; /* buffer index not correct */ 
    734765        } 
     
    742773     * template unknown, we skip this all the data  
    743774     */ 
    744     (*offV9)+=(data_length-4); 
    745     (*cFNPtr) = v9Ptr->count; 
     775    (*myPtrs->offsetV9Ptr)+=(data_length-4); 
     776    (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 
    746777  } 
    747   while ( ((*offV9)-48-shift) < data_length ) { 
    748     (*offV9)++; /* if padding */ 
     778  while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 
     779    (*myPtrs->offsetV9Ptr)++; /* if padding */ 
    749780  } 
    750   while ( (*offV9)-48-shift > data_length ) {  
    751     (*offV9)--; /* crazy loop (when bug appears in template def) */ 
     781  while ( (*myPtrs->offsetV9Ptr)-48-shift > data_length ) {  
     782    (*myPtrs->offsetV9Ptr)--; /* crazy loop (when bug appears in template def) */ 
    752783  } 
    753784  return (data_length+shift); 
  • trunk/src/dataFlowSet.h

    r22 r23  
    8686}; 
    8787 
     88struct MyPtrs { 
     89  RouterPtr currentRouterPtr; 
     90  NetFlowV9HeaderPtr currentHeaderV9Ptr; 
     91  unsigned short *offsetV9Ptr; 
     92  unsigned char *ptr_buffer; 
     93  short *currentFlowsetNumberPtr; 
     94  short *currentFlowsetIdPtr; 
     95  DatagramPtr pcktPtr; 
     96  RuleDefPtr *rulesAddressPtr; 
     97  RulesPtr rulesListPtr;                             /* Rules list */ 
     98  struct IPFLowCache *tabIPPtr; 
     99  struct MPLSFlowCache *tabMPLSPtr; 
     100  unsigned long *ipNbPtr; 
     101  unsigned long *mplsNbPtr; 
     102}; 
     103 
    88104unsigned short  
    89 checkDataFlowSet(unsigned short, RouterPtr, NetFlowV9HeaderPtr, 
    90                  unsigned short *, unsigned char *, short *, 
    91                  short *, DatagramPtr, RuleDefPtr *, RulesPtr, int, 
    92                  struct PrefixV4 *, size_t,  
    93                  struct IPFLowCache *, struct MPLSFlowCache *, 
    94                  unsigned long *, unsigned long *); 
     105checkDataFlowSet(unsigned short,  
     106                 struct MyPtrs *, 
     107                 int, 
     108                 struct PrefixV4 *, size_t 
     109                 ); 
    95110 
    96111#endif /* DATAFLOWSET_H */ 
  • trunk/src/fields_mgmt.c

    r22 r23  
    3131 * print_fields_set 
    3232 */ 
    33 void printFieldSet(FieldPtr pf) 
     33void printFieldSet(FILE *file, FieldPtr pf) 
    3434{ 
    3535  FieldPtr tmp = pf; 
    3636  for (; tmp; tmp=tmp->next) { 
    37     fprintf(stderr, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength); 
     37    fprintf(file, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength); 
    3838  } 
    39   fprintf(stderr,"\n"); 
     39  fprintf(file,"\n"); 
    4040} 
    4141 
  • trunk/src/fields_mgmt.h

    r2 r23  
    2626#define FIELDS_MGMT_H 
    2727 
     28#include <stdio.h> 
     29 
    2830typedef struct Field * FieldPtr; 
    2931typedef struct Field { 
     
    3638FieldPtr addField (FieldPtr, unsigned short, unsigned short); 
    3739int delField(unsigned short, unsigned short); 
    38 void printFieldSet(FieldPtr); 
     40void printFieldSet(FILE *, FieldPtr); 
    3941void invPrintFieldSet(FieldPtr); 
    4042void freeField(FieldPtr); 
  • trunk/src/get_conf.c

    r22 r23  
    172172      pV4TabPtr[i].mask = n4; 
    173173      pV4TabPtr[i].routerNb = n5; 
    174       pV4TabPtr[i].flowNb = 0; 
    175       pV4TabPtr[i].bytesNb = 0; 
    176       pV4TabPtr[i].pktsNb = 0; 
    177       pV4TabPtr[i].udpPktsNb = 0; 
    178       pV4TabPtr[i].tcpPktsNb = 0; 
    179       pV4TabPtr[i].icmpPktsNb = 0; 
    180       pV4TabPtr[i].othersPktsNb = 0; 
    181       pV4TabPtr[i].udpBytesNb = 0; 
    182       pV4TabPtr[i].tcpBytesNb = 0; 
    183       pV4TabPtr[i].icmpBytesNb = 0; 
    184       pV4TabPtr[i].othersBytesNb = 0; 
     174      pV4TabPtr[i].flowNbIN = 0; 
     175      pV4TabPtr[i].bytesNbIN = 0; 
     176      pV4TabPtr[i].pktsNbIN = 0; 
     177      pV4TabPtr[i].udpPktsNbIN = 0; 
     178      pV4TabPtr[i].tcpPktsNbIN = 0; 
     179      pV4TabPtr[i].icmpPktsNbIN = 0; 
     180      pV4TabPtr[i].othersPktsNbIN = 0; 
     181      pV4TabPtr[i].udpBytesNbIN = 0; 
     182      pV4TabPtr[i].tcpBytesNbIN = 0; 
     183      pV4TabPtr[i].icmpBytesNbIN = 0; 
     184      pV4TabPtr[i].othersBytesNbIN = 0; 
     185      pV4TabPtr[i].udpFlowNbIN = 0; 
     186      pV4TabPtr[i].tcpFlowNbIN = 0; 
     187      pV4TabPtr[i].icmpFlowNbIN = 0; 
     188      pV4TabPtr[i].othersFlowNbIN = 0; 
     189      pV4TabPtr[i].flowNbOUT = 0; 
     190      pV4TabPtr[i].bytesNbOUT = 0; 
     191      pV4TabPtr[i].pktsNbOUT = 0; 
     192      pV4TabPtr[i].udpPktsNbOUT = 0; 
     193      pV4TabPtr[i].tcpPktsNbOUT = 0; 
     194      pV4TabPtr[i].icmpPktsNbOUT = 0; 
     195      pV4TabPtr[i].othersPktsNbOUT = 0; 
     196      pV4TabPtr[i].udpBytesNbOUT = 0; 
     197      pV4TabPtr[i].tcpBytesNbOUT = 0; 
     198      pV4TabPtr[i].icmpBytesNbOUT = 0; 
     199      pV4TabPtr[i].othersBytesNbOUT = 0; 
     200      pV4TabPtr[i].udpFlowNbOUT = 0; 
     201      pV4TabPtr[i].tcpFlowNbOUT = 0; 
     202      pV4TabPtr[i].icmpFlowNbOUT = 0; 
     203      pV4TabPtr[i].othersFlowNbOUT = 0; 
    185204    } 
    186205  if( fclose(prefixFile) == 0) { 
  • trunk/src/get_conf.h

    r22 r23  
    3333  unsigned short mask;     /* prefix mask  */ 
    3434  unsigned short routerNb; /* router ID */ 
    35   unsigned long long flowNb; /* flow number accounting */ 
    36   unsigned long long bytesNb; /* bytes number accounting */ 
    37   unsigned long long pktsNb; /* packets number accounting */ 
    38   unsigned long long udpPktsNb; 
    39   unsigned long long tcpPktsNb; 
    40   unsigned long long icmpPktsNb; 
    41   unsigned long long othersPktsNb; 
    42   unsigned long long udpBytesNb; 
    43   unsigned long long tcpBytesNb; 
    44   unsigned long long icmpBytesNb; 
    45   unsigned long long othersBytesNb; 
    46   unsigned long long udpFlowNb; 
    47   unsigned long long tcpFlowNb; 
    48   unsigned long long icmpFlowNb; 
    49   unsigned long long othersFlowNb; 
     35  unsigned long long flowNbIN;  
     36  unsigned long long bytesNbIN;  
     37  unsigned long long pktsNbIN;  
     38  unsigned long long udpPktsNbIN;   /* WARNING !!! */ 
     39  unsigned long long tcpPktsNbIN;   /* Here, IN means "to the prefix" */ 
     40  unsigned long long icmpPktsNbIN;  /* or "prefix in destination address */ 
     41  unsigned long long othersPktsNbIN; 
     42  unsigned long long udpBytesNbIN; 
     43  unsigned long long tcpBytesNbIN; 
     44  unsigned long long icmpBytesNbIN; 
     45  unsigned long long othersBytesNbIN; 
     46  unsigned long long udpFlowNbIN; 
     47  unsigned long long tcpFlowNbIN; 
     48  unsigned long long icmpFlowNbIN; 
     49  unsigned long long othersFlowNbIN; 
     50  unsigned long long flowNbOUT;  /* WARNING !!! */ 
     51  unsigned long long bytesNbOUT;  /* Here, OUT means "from the prefix" */ 
     52  unsigned long long pktsNbOUT;  /* or "prefix in source address */ 
     53  unsigned long long udpPktsNbOUT; 
     54  unsigned long long tcpPktsNbOUT; 
     55  unsigned long long icmpPktsNbOUT; 
     56  unsigned long long othersPktsNbOUT; 
     57  unsigned long long udpBytesNbOUT; 
     58  unsigned long long tcpBytesNbOUT; 
     59  unsigned long long icmpBytesNbOUT; 
     60  unsigned long long othersBytesNbOUT; 
     61  unsigned long long udpFlowNbOUT; 
     62  unsigned long long tcpFlowNbOUT; 
     63  unsigned long long icmpFlowNbOUT; 
     64  unsigned long long othersFlowNbOUT; 
    5065}; 
    5166 
  • trunk/src/renetcol.c

    r22 r23  
    2626#include "renetcol.h" 
    2727 
    28 /* #ifdef CRIHAN */ 
    29 struct IPFLowCache tabIP[MAX_IP_FLOW], *tabIPPtr = tabIP; 
    30 struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW], *tabMPLSPtr = tabMPLS; 
    31 unsigned long ipNb = 0; /* counter of IP flows number */ 
    32 unsigned long mplsNb = 0; /* counter of MPLS flow number */ 
    33 unsigned long *ipNbPtr = &ipNb; 
    34 unsigned long *mplsNbPtr = &mplsNb; 
    35 unsigned short currentIPOutputFile = 0; /* index on the current IP file */ 
    36 unsigned short currentMPLSOutputFile = 0; /* index on the current MPLS file */ 
     28struct MyPtrs myPtrs; /* defined in dataflowset.h */ 
     29 
     30struct IPFLowCache tabIP[MAX_IP_FLOW]; 
     31struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW]; 
     32unsigned long ipNb = 0;                     /* counter of IP flows number */ 
     33unsigned long mplsNb = 0;                   /* counter of MPLS flow number */ 
     34 
     35unsigned short currentIPOutputFile = 0;    /* index on the current IP file */ 
     36unsigned short currentMPLSOutputFile = 0;  /* index on the current MPLS file */ 
    3737char outputName[256]; 
    38 char cof_str[20]; /* current ouput file name */ 
    39 FILE *fIP; /* pointer on the IP output file */ 
    40 FILE *fMPLS; /* pointer on the MPLS output file */ 
    41 /* #endif */ 
    42  
    43 char *rulesFileName; /* file name of the rules (like acl) */ 
    44 char *configFileName;  /* file name where routers list is */ 
    45 char *prefixV4FileName;  /* IPv4 prefix list */ 
     38char cof_str[20];                          /* current ouput file name */ 
     39FILE *fIP;                                 /* pointer on the IP output file */ 
     40FILE *fMPLS;                              /* pointer on the MPLS output file */ 
     41 
     42char *rulesFileName;                    /* file name of the rules (like acl) */ 
     43char *configFileName;                   /* file name where routers list is */ 
     44char *prefixV4FileName;                 /* IPv4 prefix list */ 
    4645 
    4746struct sigaction myAction; /* handler for renetcolSender communication */ 
     
    5049/* struct sigaction myAction;  for timer not used in this version */ 
    5150 
    52 unsigned short currentIntervalle = 0; /* based on 5 min intervalles */  
    53  
    54 unsigned short offsetV9 = 0; /* index in a neflow v9 packet */ 
    55 unsigned short *offsetV9Ptr = &offsetV9; 
     51unsigned short currentIntervalle = 0;        /* based on 5 min intervalles */  
     52 
     53unsigned short offsetV9 = 0;                 /* index in a neflow v9 packet */ 
    5654 
    5755unsigned char buffer1; 
     
    6159 
    6260short currentFlowsetNumber; 
    63 short *currentFlowsetNumberPtr = &currentFlowsetNumber; 
    6461short currentFlowsetId; 
    65 short *currentFlowsetIdPtr = &currentFlowsetId; 
    6662TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */ 
    6763TplOptionPtr curTplOptionPtr; 
    68 RouterPtr routersListPtr; 
    69 RouterPtr currentRouterPtr; 
    70 DatagramPtr pcktPtr; 
     64RouterPtr routersListPtr;  
     65 
    7166unsigned long sortedRouterList[ROUTER_INDEX_MAX]; 
    7267unsigned long indexedRouterList[ROUTER_INDEX_MAX]; 
    73 int routerNb = 0; /* routers number */ 
    74 unsigned short v4PrefixNb = 0; /* IPv4 prefix number */ 
    75 struct PrefixV4 prefixV4Tab[MAX_IPV4_PREFIX]; /* IPv4 prefix structure */ 
    76 RulesPtr rulesListPtr; /* Rules list */ 
    77 NetFlowV9HeaderPtr currentHeaderV9Ptr; 
     68int routerNb = 0;                                  /* routers number */ 
     69unsigned short v4PrefixNb = 0;                     /* IPv4 prefix number */ 
     70struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX];      /* IPv4 prefix structure */ 
     71unsigned short indexForShmTable = 0; 
     72 
    7873key_t myKey = 0; /* FIXME to delete in futur */ 
    7974int myQueue = 0; /* FIXME to delete in futur */ 
     
    8176/* Next structure used as cache in rules reading */ 
    8277RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD];  
    83 RuleDefPtr *rulesAddressPtr; 
    8478 
    8579int reInitConf = 0; 
    86  
    87 static unsigned long datagramNumber; 
    8880 
    8981static time_t lastRock; 
    9082static struct tm *tmPtr; 
    9183 
    92 static unsigned long myHost; /* FIXME to erase */ 
    9384extern int errno; 
    9485static int inputSock; 
     
    10091/* static unsigned short flowNumber; */ 
    10192static unsigned short receptPort = RECEPTION_PORT; 
    102 static unsigned char *ptr_buffer; 
     93/* static unsigned char *ptr_buffer; */ 
    10394static char *receptAddress = RECEPTION_ADDRESS; 
    10495static struct sockaddr_in name; 
     
    139130 
    140131  initCache(); 
    141   fprintf(stderr, "reading the routers list\n"); 
     132  fprintf(stderr, "renetcol: reading the routers list...\n"); 
    142133  routerNb = getRegisteredRouters(configFileName, &sortedRouterList[0],  
    143134                                  &indexedRouterList[0]); 
    144   fprintf(stderr, "reading the IPv4 prefix\n"); 
     135  fprintf(stderr, "renetcol: OK\n"); 
     136  fprintf(stderr, "renetcol: reading the IPv4 prefix...\n"); 
    145137  if ( (v4PrefixNb = getPrefixV4(prefixV4FileName, &prefixV4Tab[0])) < 1){ 
    146     fprintf(stderr, "Error during prefix v4 reading\n"); 
     138    fprintf(stderr, "renetcol:  Error \n"); 
    147139    exit(1); 
    148   } 
    149   rulesListPtr = NULL; 
    150   fprintf(stderr, "reading the rules\n"); 
    151   rulesListPtr = getLightRules(rulesListPtr, rulesFileName); 
    152   tmp = rulesListPtr; 
     140  } else { 
     141    fprintf(stderr, "renetcol:  OK \n"); 
     142  } 
     143  myPtrs.rulesListPtr = NULL; 
     144  fprintf(stderr, "renetcol: reading the rules...\n"); 
     145  myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 
     146  fprintf(stderr, "renetcol : OK \n"); 
     147  tmp = myPtrs.rulesListPtr; 
    153148  for ( ; tmp->next; tmp=tmp->next) { 
    154149    if (tmp->type != 2) { 
    155       rulesListPtr = delRule(tmp, rulesListPtr); 
     150      myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 
    156151    } 
    157152  } 
     
    159154/*   exit(1); */ 
    160155 
    161   fprintf(stderr, "I become a deamon, next messages via syslogd.\n"); 
     156  fprintf(stderr, "renetcol: I become a deamon, next messages via syslogd. By.\n"); 
    162157  if (fork () != 0) 
    163158    exit (0); 
     
    174169 
    175170  /* Pointer on rules Table */ 
    176   setCache(rulesListPtr); 
    177   rulesAddressPtr = (RuleDefPtr *)rulesAddress; 
     171  setCache(myPtrs.rulesListPtr); 
     172  myPtrs.rulesAddressPtr = (RuleDefPtr *)rulesAddress; 
    178173 
    179174  /* init IPC messages queue */ 
     
    183178 
    184179  /* INIT THE CURRENTS VARIABLES*/ 
    185   currentRouterPtr = routersListPtr; 
    186   currentHeaderV9Ptr = (NetFlowV9HeaderPtr) 
     180  myPtrs.currentRouterPtr = routersListPtr; 
     181  myPtrs.currentHeaderV9Ptr = (NetFlowV9HeaderPtr) 
    187182    malloc(sizeof(struct NetFlowV9Header)); 
    188   pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 
    189   if (pcktPtr==NULL) { 
     183  myPtrs.offsetV9Ptr = &offsetV9; 
     184  myPtrs.currentFlowsetIdPtr = &currentFlowsetId; 
     185  myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 
     186  myPtrs.currentFlowsetNumberPtr = &currentFlowsetNumber; 
     187  myPtrs.ipNbPtr =  &ipNb; 
     188  myPtrs.mplsNbPtr =  &mplsNb; 
     189   
     190  if (myPtrs.pcktPtr==NULL) { 
    190191    fprintf(stderr, "ERROR in struct Datagram allocation\n"); 
    191192    exit(1); 
    192193  } else { 
    193     pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader)); 
    194     pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader)); 
    195   } 
    196  
    197   if (! (ptr_buffer = malloc(sockBufSize)))   
     194    myPtrs.pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader)); 
     195    myPtrs.pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader)); 
     196  } 
     197 
     198  if (! (myPtrs.ptr_buffer = malloc(sockBufSize)))   
    198199    { 
    199200      printf("ERROR during socket buffer allocation\n"); 
     
    204205  initStream(); 
    205206 
    206   datagramNumber =0; /* FIXME : ???? */ 
    207  
    208207  socketLoop(); /* all work on datagram is made here */ 
     208 
    209209  closelog(); 
     210 
    210211  fprintf(stderr, "END\n"); 
     212 
    211213  return (0); 
    212214} 
    213215 
    214216/* 
    215  * 
    216  */ 
    217 void sendMyPid(int queueID) 
     217 * send his PID to another program via IPC message queue 
     218 * 
     219 * @param queueID the IPC queue ident 
     220 * 
     221 */ 
     222void  
     223sendMyPid(int queueID) 
    218224{ 
    219225  msgType myMsg; 
     
    235241 
    236242/* 
     243 * Send the "read rules list" message to another program 
     244 * 
     245 * @param queueID the IPC queue ident 
    237246 * 
    238247 */ 
     
    252261 
    253262/* 
    254  * 
    255  */ 
    256 void sigusr1Mgmt(int num) 
     263 *  
     264 */ 
     265void  
     266sigusr1Mgmt(int num) 
    257267{ 
    258268  sigusr1Up = 1; 
     
    260270 
    261271/* 
    262  * 
     272 * init the rule structure 
    263273 */ 
    264274void  
     
    267277  RulesPtr tmp = NULL; 
    268278  initCache(); 
    269   tmp = rulesListPtr; 
     279  tmp = myPtrs.rulesListPtr; 
    270280  for ( ; tmp; tmp=tmp->next) { 
    271     rulesListPtr = delRule(tmp, rulesListPtr); 
    272   } 
    273   rulesListPtr = NULL; 
    274   rulesListPtr = getLightRules(rulesListPtr, rulesFileName); 
    275   tmp = rulesListPtr; 
     281    myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 
     282  } 
     283  myPtrs.rulesListPtr = NULL; 
     284  myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 
     285  tmp = myPtrs.rulesListPtr; 
    276286  for ( ; tmp; tmp=tmp->next) { 
    277287    if (tmp->type != 2) { 
    278       rulesListPtr = delRule(tmp, rulesListPtr); 
     288      myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 
    279289    } 
    280290  } 
    281291  tmp = NULL; 
    282292  initCache(); 
    283   setCache(rulesListPtr); 
     293  setCache(myPtrs.rulesListPtr); 
    284294  sendReadRulesSignal(myQueue); 
    285295} 
    286296 
    287297/* 
    288  * 
     298 * init cache table 
    289299 */ 
    290300void 
     
    339349  buffer4[2] = (unsigned char)n1; 
    340350  buffer4[3] = (unsigned char)n0; 
    341   myHost = *((unsigned long*)&buffer4[0]); 
    342351} 
    343352 
     
    353362  time_t now = time((time_t *)NULL); 
    354363  int iIP, iMPLS, i; 
     364  int loopNb = 0; 
    355365  time_t lastIPOutput, lastMPLSOutput; 
    356366  time_t receptionTime; 
     
    371381    }  
    372382    socketReading(); 
    373     getIpHeader(pcktPtr, ptr_buffer); 
    374     regRouter = checkIpHeader(pcktPtr, &sortedRouterList[0], routerNb); 
    375     getUdpHeader(pcktPtr, ptr_buffer); 
    376     checkUdpHeader(pcktPtr, regRouter, receptPort); 
     383    getIpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 
     384    regRouter = checkIpHeader(myPtrs.pcktPtr, &sortedRouterList[0], routerNb); 
     385    getUdpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 
     386    if ( checkUdpHeader(myPtrs.pcktPtr, regRouter, receptPort) == 1 ){ 
     387      continue; 
     388    } 
    377389     
    378390    switch( version =  
    379             getNetFlowHeader(pcktPtr, ptr_buffer,  
    380                              currentHeaderV9Ptr, offsetV9Ptr)){ 
     391            getNetFlowHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer,  
     392                             myPtrs.currentHeaderV9Ptr, myPtrs.offsetV9Ptr)){ 
    381393    case 9: 
    382       if ((currentRouterPtr=notExistRouter(routersListPtr,  
    383                                            pcktPtr->ipH->srcAdd))==NULL) { 
     394      if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr,  
     395                                                  myPtrs.pcktPtr->ipH->srcAdd))==NULL) { 
    384396        routersListPtr = addRouter(routersListPtr,  
    385                                    pcktPtr->ipH->srcAdd,  
     397                                   myPtrs.pcktPtr->ipH->srcAdd,  
    386398                                   (unsigned long) 0); 
    387         currentRouterPtr = routersListPtr; 
     399        myPtrs.currentRouterPtr = routersListPtr; 
    388400      } 
    389401      currentFlowsetNumber = 0; 
    390402      shift = 0; 
    391       while ((currentFlowsetNumber < currentHeaderV9Ptr->count)) { 
     403      while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)) { 
    392404        curTplFlSetPtr = NULL; 
    393405        currentFlowsetId=getFlowsetId(currentFlowsetNumber,  
    394                                       offsetV9Ptr, ptr_buffer); 
     406                                      myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 
    395407        if ( currentFlowsetId == 0 ) { 
    396           shift = checkTemplateFlowSet(currentRouterPtr, offsetV9Ptr,  
    397                                        ptr_buffer, currentHeaderV9Ptr, 
     408          shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
     409                                       myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 
    398410                                       curTplFlSetPtr, 
    399                                        currentFlowsetNumberPtr, 
     411                                       myPtrs.currentFlowsetNumberPtr, 
    400412                                       myQueue); 
    401           /* FIXME : TplFlSet Def in a file before next release */ 
    402           /* showAllTplFlSet(); */ 
    403413        } else if (currentFlowsetId == 1) { 
    404           shift = checkTemplateOption(currentRouterPtr, offsetV9Ptr,  
    405                                       ptr_buffer, currentHeaderV9Ptr, 
     414          shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr,  
     415                                      myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 
    406416                                      curTplOptionPtr, 
    407                                       currentFlowsetNumberPtr); 
     417                                      myPtrs.currentFlowsetNumberPtr); 
    408418        } else { 
    409           shift = checkDataFlowSet(shift, currentRouterPtr, 
    410                                    currentHeaderV9Ptr, offsetV9Ptr, 
    411                                    ptr_buffer, currentFlowsetNumberPtr, 
    412                                    currentFlowsetIdPtr, pcktPtr, 
    413                                    rulesAddressPtr, rulesListPtr, 
    414                                    myQueue, prefixV4Tab, 
    415                                    (size_t) v4PrefixNb, 
    416                                    tabIPPtr,  
    417                                    tabMPLSPtr,  
    418                                    ipNbPtr, mplsNbPtr); 
     419          shift = checkDataFlowSet(shift, 
     420                                   &myPtrs, 
     421                                   myQueue,  
     422                                   prefixV4Tab, 
     423                                   (size_t) v4PrefixNb 
     424                                   ); 
    419425        } 
    420       } 
     426      } /* end while flowset exist */ 
    421427      break; 
    422428    default: 
    423       /* FIXME : Uncomment before next release */ 
    424 /*        syslog(LOG_INFO,  */ 
    425 /*           "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", */ 
    426 /*           (unsigned short) version, */ 
    427 /*           (pcktPtr->ipH->srcAdd>>24), */ 
    428 /*           (pcktPtr->ipH->srcAdd<<8>>24), */ 
    429 /*           (pcktPtr->ipH->srcAdd<<16>>24), */ 
    430 /*           (pcktPtr->ipH->srcAdd<<24>>24));  */ 
     429      syslog(LOG_INFO,  
     430             "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", 
     431             (unsigned short) version, 
     432             (myPtrs.pcktPtr->ipH->srcAdd>>24), 
     433             (myPtrs.pcktPtr->ipH->srcAdd<<8>>24), 
     434             (myPtrs.pcktPtr->ipH->srcAdd<<16>>24), 
     435             (myPtrs.pcktPtr->ipH->srcAdd<<24>>24));  
    431436      break; 
    432437    } 
    433 /*     for (i=0; i<v4PrefixNb; i++){ */ 
    434 /*       fprintf(stderr, "%lu %llu flows\n", */ 
    435 /*            prefixV4Tab[i].beginning, */ 
    436 /*            prefixV4Tab[i].flowNb); */ 
    437 /*     } */ 
     438    if (loopNb  > 100 ){ 
     439      /* FIXME perhaps call this function via the compilation options */ 
     440      writeAllTplFlSet(); 
     441      for (i=0; i<v4PrefixNb; i++){ 
     442        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", 
     443                prefixV4Tab[i].beginning, 
     444                prefixV4Tab[i].flowNbIN, 
     445                prefixV4Tab[i].bytesNbIN, 
     446                prefixV4Tab[i].pktsNbIN, 
     447                prefixV4Tab[i].udpPktsNbIN, 
     448                prefixV4Tab[i].tcpPktsNbIN, 
     449                prefixV4Tab[i].icmpPktsNbIN, 
     450                prefixV4Tab[i].othersPktsNbIN, 
     451                prefixV4Tab[i].udpBytesNbIN, 
     452                prefixV4Tab[i].tcpBytesNbIN, 
     453                prefixV4Tab[i].icmpBytesNbIN, 
     454                prefixV4Tab[i].othersBytesNbIN, 
     455                prefixV4Tab[i].udpFlowNbIN, 
     456                prefixV4Tab[i].tcpFlowNbIN, 
     457                prefixV4Tab[i].icmpFlowNbIN, 
     458                prefixV4Tab[i].othersFlowNbIN, 
     459                prefixV4Tab[i].flowNbOUT, 
     460                prefixV4Tab[i].bytesNbOUT, 
     461                prefixV4Tab[i].pktsNbOUT, 
     462                prefixV4Tab[i].udpPktsNbOUT, 
     463                prefixV4Tab[i].tcpPktsNbOUT, 
     464                prefixV4Tab[i].icmpPktsNbOUT, 
     465                prefixV4Tab[i].othersPktsNbOUT, 
     466                prefixV4Tab[i].udpBytesNbOUT, 
     467                prefixV4Tab[i].tcpBytesNbOUT, 
     468                prefixV4Tab[i].icmpBytesNbOUT, 
     469                prefixV4Tab[i].othersBytesNbOUT, 
     470                prefixV4Tab[i].udpFlowNbOUT, 
     471                prefixV4Tab[i].tcpFlowNbOUT, 
     472                prefixV4Tab[i].icmpFlowNbOUT, 
     473                prefixV4Tab[i].othersFlowNbOUT 
     474                ); 
     475      } 
     476      loopNb = 0; 
     477    } 
     478    loopNb++; 
    438479 
    439480#ifdef CRIHAN 
     
    558599    } 
    559600  /* Here socket DGRAM creation, only to not have a unreachable service */ 
     601  /* message in return */ 
    560602  inputSock2 = socket(AF_INET, SOCK_DGRAM, 0);  
    561603  if (inputSock2 < 0) 
     
    597639 
    598640  sockNameFromlg = sizeof(fromName); 
    599   rcv = recvfrom(inputSock, ptr_buffer, sockBufSize, 0, 
     641  rcv = recvfrom(inputSock, myPtrs.ptr_buffer, sockBufSize, 0, 
    600642                 (struct sockaddr *)(&fromName), 
    601643                 (socklen_t *)&sockNameFromlg);    
     
    613655  
    614656/*  
    615  * check up flow datagramme  
     657 * check up flow datagramme   
    616658 */ 
    617659short  
    618660checkFlow(short flowNumber) 
    619661{ 
    620   return(0); 
     662  return(0); /* FIXME : why this function ??? */ 
    621663} 
    622664 
     
    624666 * showAllTplFlSet 
    625667 * 
     668 * to use only in debug mode 
    626669 */ 
    627670void  
     
    643686              tmpFS->templateFlowSetId, 
    644687              tmpFS->sourceId); 
    645       printFieldSet(tmpFS->fieldSet); 
     688      printFieldSet(stderr, tmpFS->fieldSet); 
    646689      fprintf(stderr,"\n"); 
    647690    } 
     
    651694                tmpOP->templateOptionId, 
    652695                tmpOP->sourceId); 
    653         printFieldSet(tmpOP->fieldSet); 
     696        printFieldSet(stderr, tmpOP->fieldSet); 
    654697        fprintf(stderr,"\n"); 
    655698      } 
     
    658701  } 
    659702} 
     703 
     704 
     705/*  
     706 * writeAllTplFlSet 
     707 * 
     708 */ 
     709void  
     710writeAllTplFlSet() 
     711{ 
     712 
     713  RouterPtr tmp = routersListPtr; 
     714  TplFlowSetPtr tmpFS; 
     715  TplOptionPtr tmpOP; 
     716  FILE *TPLFILE; 
     717  if (!(TPLFILE = fopen("/tmp/TemplateDef.txt", "w"))) { 
     718    syslog (LOG_ERR, "error during %s opening", "/tmp/TemplateDef.txt"); 
     719  } 
     720  fprintf(TPLFILE,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n"); 
     721  for (; tmp; tmp=tmp->next) { 
     722    fprintf(TPLFILE,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n", 
     723            (tmp->IpAddress>>24), 
     724            (tmp->IpAddress<<8>>24), 
     725            (tmp->IpAddress<<16>>24), 
     726            (tmp->IpAddress<<24>>24)); 
     727    tmpFS =  tmp->tplList; 
     728    for (; tmpFS; tmpFS=tmpFS->next) { 
     729      fprintf(TPLFILE,"TId %hu (sourceId: %lu):\n",  
     730              tmpFS->templateFlowSetId, 
     731              tmpFS->sourceId); 
     732      printFieldSet(TPLFILE, tmpFS->fieldSet); 
     733      fprintf(TPLFILE,"\n"); 
     734    } 
     735    if ((tmpOP = tmp->tplOptList) != NULL){ 
     736      for (; tmpOP; tmpOP=tmpOP->next) { 
     737        fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) >\n",  
     738                tmpOP->templateOptionId, 
     739                tmpOP->sourceId); 
     740        printFieldSet(TPLFILE, tmpOP->fieldSet); 
     741        fprintf(TPLFILE,"\n"); 
     742      } 
     743      fprintf(TPLFILE,"\n"); 
     744    } 
     745  } 
     746  fclose(TPLFILE); 
     747} 
  • trunk/src/renetcol.h

    r22 r23  
    8282#define MPLS_TIME_THRESHOLD 60 /* in sec */ 
    8383#endif /* CRIHAN */ 
     84 
    8485#define MAX_IP_FLOW 10000 
    8586#define MAX_MPLS_FLOW 200 
     87 
     88/* struct SHMForAgg { */ 
     89/*   struct PrefixV4 prefixV4Tab[MAX_IPV4_PREFIX]; */ 
     90/* } */ 
     91 
    8692 
    8793void setCache(RulesPtr); 
     
    100106short checkFlow(short); 
    101107void showAllTplFlSet(); 
     108void writeAllTplFlSet(); 
    102109 
  • trunk/src/renetcolSender.c

    r20 r23  
    299299  } 
    300300  if (sscanf (argv[2], "%ld", &type) != 1){ 
    301     fprintf(stderr, "Invalid type\n"); 
     301    fprintf(stderr, "renetcolSender: Error, Invalid message type in command\n"); 
    302302    exit(1); 
    303303  }   
     
    309309  strcpy (rulesFileName, argv[3]); 
    310310  rulesListPtr = NULL; 
     311  fprintf(stderr, "renetcolSender: reading the rules...\n"); 
    311312  rulesListPtr = getRules(rulesListPtr, rulesFileName); 
     313  fprintf(stderr, "renetcolSender: OK\n"); 
    312314  /* we delete rules which are not type socket */ 
    313315  tmp = rulesListPtr; 
     
    329331 
    330332/*   chdir ("/"); */ 
    331   fprintf(stderr, "I become a deamon, next messages via syslogd.\n"); 
     333  fprintf(stderr, "renetcolSender: I become a deamon, next messages via syslogd. By.\n"); 
    332334  if (fork () != 0) 
    333335    exit (0); 
  • trunk/src/template.c

    r16 r23  
    126126          syslog (LOG_INFO,  
    127127                  "fields nb too large, bug collector or wrong template def");  
    128           exit(1); 
     128          cTFSPtr = deleteTplFlSet(cTFSPtr); 
    129129        } 
    130130      } 
     
    181181          syslog (LOG_INFO,  
    182182                  "fields nb too large, bug collector or wrong template def");  
    183           exit(1); 
     183          cTFSPtr = deleteTplFlSet(cTFSPtr); 
    184184        } 
    185185      } 
     
    194194/*          ( cr->IpAddress)<<24>>24); */ 
    195195/*     fprintf(stderr,"%lu %d\n", cTFSPtr->sourceId, sizeof(cTFSPtr->sourceId)); */ 
     196    /* FIXME HERE don't send an wrong def if error detected */ 
    196197    msgTextIndex = mempcpy(mempcpy(mempcpy(mempcpy(mempcpy(myMsg.text,  
    197198                                                           &tplMsgType,