Changeset 22 for trunk/src

Show
Ignore:
Timestamp:
01/17/07 18:37:59 (16 years ago)
Author:
andreu
Message:

aggregation et timer

Location:
trunk/src
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r20 r22  
    11bin_PROGRAMS = renetcol renetcolSender renetcolMsgCtl 
    2 renetcol_SOURCES = renetcol.c template.c V9Header_mgmt.c msg_mgmt.c fields_mgmt.c \ 
    3                 routers_mgmt.c tplflset_mgmt.c headers_mgmt.c renetcol.h template.h \ 
    4                 V9Header_mgmt.h msg_mgmt.h fields_mgmt.h routers_mgmt.h \ 
    5                 tplflset_mgmt.h headers_mgmt.h dataFlowSet.c dataFlowSet.h \ 
    6                 get_conf.c get_conf.h rules_mgmt.c rules_mgmt.h \ 
    7                 remote_output.h remote_output.c 
    8 renetcolSender_SOURCES = renetcolSender.c renetcolSender.h msg_mgmt.h msg_mgmt.c \ 
    9                 rules_mgmt.c rules_mgmt.h remote_output.h remote_output.c \ 
    10                 fields_mgmt.h fields_mgmt.c 
     2renetcol_SOURCES = renetcol.c template.c V9Header_mgmt.c msg_mgmt.c \ 
     3        fields_mgmt.c routers_mgmt.c tplflset_mgmt.c headers_mgmt.c \ 
     4        renetcol.h template.h V9Header_mgmt.h msg_mgmt.h fields_mgmt.h \ 
     5        routers_mgmt.h tplflset_mgmt.h headers_mgmt.h dataFlowSet.c \ 
     6        dataFlowSet.h get_conf.c get_conf.h rules_mgmt.c rules_mgmt.h \ 
     7        remote_output.h remote_output.c prefix_mgmt.h prefix_mgmt.c 
     8renetcolSender_SOURCES = renetcolSender.c renetcolSender.h msg_mgmt.h \ 
     9        msg_mgmt.c rules_mgmt.c rules_mgmt.h remote_output.h \ 
     10        remote_output.c fields_mgmt.h fields_mgmt.c 
    1111renetcolMsgCtl_SOURCES = renetcolMsgCtl.c 
    1212BUILT_SOURCES = renetcol.o renetcolSender.o  
  • trunk/src/dataFlowSet.c

    r20 r22  
    2727 
    2828/* 
    29  * checkDataFlowSet 
     29 * 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 ? 
    3151 */ 
    3252unsigned short  
     
    6585  struct PrefixV4 prefixKey, *res; /* for bsearch */ 
    6686  struct AggCache agCache; 
    67 #ifdef CRIHAN 
    68   struct IPFLowCache ipFirstCache; /* CRI */ 
    69   struct MPLSFlowCache mplsFirstCache; /* CRI */ 
    70   unsigned long firstTime = 0; /* CRI */ 
    71   unsigned long lastTime = 0; /* CRI */ 
    72 #endif /* CRIHAN */ 
    73   int bool = 0; 
     87  int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */ 
     88                /* flow, we test on the field and then put bool at 1 */ 
     89#ifdef CRIHAN 
     90  struct IPFLowCache ipFirstCache; 
     91  struct MPLSFlowCache mplsFirstCache; 
     92  unsigned long firstTime = 0;  
     93  unsigned long lastTime = 0;  
    7494 
    75 #ifdef CRIHAN 
    7695  ipFirstCache.ipProt = 0; 
    7796  ipFirstCache.bytes = 0; 
     
    117136      return (data_length+shift); 
    118137    } 
    119     /* aggreg */ 
    120 /*     agCache.routerAd = pcktPtr->ipH->srcAdd; */ 
    121     /* end aggreg */ 
     138#ifdef IPV4AGG 
     139    agCache.routerAd = pcktPtr->ipH->srcAdd;  
     140#endif 
    122141 
    123142#ifdef CRIHAN 
     
    164183              } 
    165184              /* end rule check */ 
    166               /* aggregation */ 
    167 /*            if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 
    168 /*              agCache.maskS = *((unsigned char*)&buffer1); */ 
    169 /*            } */ 
    170 /*            if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 
    171 /*              agCache.maskD = *((unsigned char*)&buffer1); */ 
    172 /*            } */ 
    173 /*            if (pftmp->fieldType==60){ */ 
    174 /*              agCache.ipProt = *((unsigned char*)&buffer1); */ 
    175 /*            } */ 
    176 /*            if (pftmp->fieldType==4){ */ 
    177 /*              agCache.tProt = *((unsigned char*)&buffer1); */ 
    178 /*            } */ 
    179 /*            if (pftmp->fieldType==61){ */ 
    180 /*              agCache.sens = *((unsigned char*)&buffer1); */ 
    181 /*            } */ 
    182 /*            if (pftmp->fieldType==5){ */ 
    183 /*              agCache.dscp = *((unsigned char*)&buffer1); */ 
    184 /*            } */ 
    185               /* end aggregation */ 
     185#ifdef IPV4AGG 
     186              if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
     187                agCache.maskS = *((unsigned char*)&buffer1); 
     188              } 
     189              if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 
     190                agCache.maskD = *((unsigned char*)&buffer1); 
     191              } 
     192              if (pftmp->fieldType==60){ 
     193                agCache.ipProt = *((unsigned char*)&buffer1); 
     194              } 
     195              if (pftmp->fieldType==4){ 
     196                agCache.tProt = *((unsigned char*)&buffer1); 
     197              } 
     198              if (pftmp->fieldType==61){ 
     199                agCache.sens = *((unsigned char*)&buffer1); 
     200              } 
     201              if (pftmp->fieldType==5){ 
     202                agCache.dscp = *((unsigned char*)&buffer1); 
     203              } 
     204#endif         
    186205#ifdef CRIHAN 
    187206              if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
     
    198217                ipFirstCache.tProt = *((unsigned char*)&buffer1);  
    199218              } 
    200 #endif /* CRIHAN */ 
     219#endif 
    201220              break; 
    202221            case 2: 
     
    206225                  == *((unsigned short*)&buffer2)) 
    207226                ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
    208               /* aggregation */ 
    209 /*            if (pftmp->fieldType==10){ */ 
    210 /*              agCache.idSnmp = *((unsigned short*)&buffer2); */ 
    211 /*            } */ 
    212               /* end aggregation */ 
     227#ifdef IPV4AGG 
     228              if (pftmp->fieldType==10){ 
     229                agCache.idSnmp = *((unsigned short*)&buffer2); 
     230              } 
     231#endif 
    213232#ifdef CRIHAN 
    214233              if (pftmp->fieldType==10){ 
     
    224243                ipFirstCache.dPort = *((unsigned short*)&buffer2); 
    225244              } 
    226 #endif /* CRIHAN */  
     245#endif 
    227246              break; 
    228247            case 3: 
     
    240259                mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 
    241260              } 
    242 #endif /* CRIHAN */ 
     261#endif 
    243262              break; 
    244263            case 4: 
     
    255274                  } 
    256275              }        
    257               /* aggregation */ 
    258 /*            if ((pftmp->fieldType==8)){ */ 
    259 /*              agCache.v4AdS = *((unsigned long*)&buffer4); */ 
    260 /*            } */ 
    261 /*            if ((pftmp->fieldType==12)){ */ 
    262 /*              agCache.v4AdD = *((unsigned long*)&buffer4); */ 
    263 /*            } */ 
    264 /*            if (pftmp->fieldType==1){ */ 
    265 /*              agCache.bytes = *((unsigned long*)&buffer4); */ 
    266 /*            } */ 
    267 /*            if (pftmp->fieldType==2){ */ 
    268 /*              agCache.pkts = *((unsigned long*)&buffer4); */ 
    269 /*            } */ 
    270               /* end aggregation */ 
     276#ifdef IPV4AGG 
     277              if ((pftmp->fieldType==8)){ 
     278                agCache.v4AdS = *((unsigned long*)&buffer4); 
     279              } 
     280              if ((pftmp->fieldType==12)){ 
     281                agCache.v4AdD = *((unsigned long*)&buffer4); 
     282              } 
     283              if (pftmp->fieldType==1){ 
     284                agCache.bytes = *((unsigned long*)&buffer4); 
     285              } 
     286              if (pftmp->fieldType==2){ 
     287                agCache.pkts = *((unsigned long*)&buffer4); 
     288              } 
     289#endif 
    271290#ifdef CRIHAN 
    272291              if (pftmp->fieldType==8){ 
     
    290309                lastTime = *((unsigned long*)&buffer4); 
    291310              } 
    292 #endif /* CRIHAN */ 
     311#endif 
    293312              break; 
    294313            case 16: 
     
    415434              } 
    416435              moreIsNecessary = 1; 
    417               /* aggregation */ 
     436              /* aggregation for IPv6 flows */ 
    418437               
    419438              /* end aggregation */ 
     
    437456      } else { 
    438457        /*  
    439          * no rule within this field type, but we must reading the value  
     458         * no rule within this field type, but we must read the value  
    440459         */ 
    441460        switch (field_size) { 
    442461        case 1: 
    443462          buffer1 = *(buf+(*offV9)); (*offV9)++; 
    444           /* aggregation */ 
    445 /*        if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 
    446 /*          agCache.maskS = *((unsigned char*)&buffer1); */ 
    447 /*        } */ 
    448 /*        if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 
    449 /*          agCache.maskD = *((unsigned char*)&buffer1); */ 
    450 /*        } */ 
    451 /*        if (pftmp->fieldType==60){ */ 
    452 /*          agCache.ipProt = *((unsigned char*)&buffer1); */ 
    453 /*        } */ 
    454 /*        if (pftmp->fieldType==4){ */ 
    455 /*          agCache.tProt = *((unsigned char*)&buffer1); */ 
    456 /*        } */ 
    457 /*        if (pftmp->fieldType==61){ */ 
    458 /*          agCache.sens = *((unsigned char*)&buffer1); */ 
    459 /*        } */ 
    460 /*        if (pftmp->fieldType==5){ */ 
    461 /*          agCache.dscp = *((unsigned char*)&buffer1); */ 
    462 /*        }        */ 
    463           /* end aggregation */ 
     463#ifdef IPV4AGG 
     464          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
     465            agCache.maskS = *((unsigned char*)&buffer1); 
     466          } 
     467          if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 
     468            agCache.maskD = *((unsigned char*)&buffer1); 
     469          } 
     470          if (pftmp->fieldType==60){ 
     471            agCache.ipProt = *((unsigned char*)&buffer1); 
     472          } 
     473          if (pftmp->fieldType==4){ 
     474            agCache.tProt = *((unsigned char*)&buffer1); 
     475          } 
     476          if (pftmp->fieldType==61){ 
     477            agCache.sens = *((unsigned char*)&buffer1); 
     478          } 
     479          if (pftmp->fieldType==5){ 
     480            agCache.dscp = *((unsigned char*)&buffer1); 
     481          }        
     482#endif 
    464483#ifdef CRIHAN 
    465484          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
     
    476495            ipFirstCache.tProt = *((unsigned char*)&buffer1);  
    477496          } 
    478 #endif /* CRIHAN */ 
     497#endif 
    479498          break; 
    480499        case 2: 
    481500          buffer2[1]= *(buf+(*offV9)); (*offV9)++; 
    482501          buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
    483           /* aggregation */ 
     502#ifdef IPV4AGG 
    484503          if (pftmp->fieldType==10){ 
    485504            agCache.idSnmp = *((unsigned short*)&buffer2); 
    486505          }        
    487           /* end aggregation */ 
     506#endif 
    488507#ifdef CRIHAN 
    489508          if (pftmp->fieldType==10){ 
     
    499518            ipFirstCache.dPort = *((unsigned short*)&buffer2); 
    500519          } 
    501 #endif /* CRIHAN */ 
     520#endif 
    502521          break; 
    503522        case 3: 
     
    512531            mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 
    513532          } 
    514 #endif /* CRIHAN */ 
     533#endif 
    515534          break; 
    516535        case 4: 
     
    519538          buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    520539          buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
    521           /* aggregation */ 
    522 /*        if ((pftmp->fieldType==8)){ */ 
    523 /*          bool = 1; */ 
    524 /*          agCache.v4AdS = *((unsigned long*)&buffer4); */ 
    525 /*        } else if ((pftmp->fieldType==12)){ */ 
    526 /*          agCache.v4AdD = *((unsigned long*)&buffer4); */ 
    527 /*        } else if (pftmp->fieldType==1){ */ 
    528 /*          agCache.bytes = *((unsigned long*)&buffer4); */ 
    529 /*        } else if (pftmp->fieldType==2){ */ 
    530 /*          agCache.pkts = *((unsigned long*)&buffer4); */ 
    531 /*        } */ 
    532           /* end aggregation */ 
     540#ifdef IPV4AGG 
     541          if ((pftmp->fieldType==8)){ 
     542            bool = 1; 
     543            agCache.v4AdS = *((unsigned long*)&buffer4); 
     544          } else if ((pftmp->fieldType==12)){ 
     545            agCache.v4AdD = *((unsigned long*)&buffer4); 
     546          } else if (pftmp->fieldType==1){ 
     547            agCache.bytes = *((unsigned long*)&buffer4); 
     548          } else if (pftmp->fieldType==2){ 
     549            agCache.pkts = *((unsigned long*)&buffer4); 
     550          } 
     551#endif 
    533552#ifdef CRIHAN 
    534553          if (pftmp->fieldType==8){ 
     
    552571            lastTime = *((unsigned long*)&buffer4); 
    553572          } 
    554 #endif /* CRIHAN */ 
     573#endif 
    555574          break; 
    556575        case 16: 
     
    561580            buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
    562581          } 
    563           /* aggregation */        
     582          /* aggregation IPv6 */           
    564583          /* end aggregation */ 
    565584          break; 
     
    617636          (*mplsCounter)++; 
    618637        } 
    619 #endif /* CRIHAN */ 
    620         /* put aggregation cache information to tables */ 
    621 /*      if (bool == 1){ */ 
    622 /*        prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); */ 
    623 /*        res = bsearch(&prefixKey, V4PTab, nbPV4,  */ 
    624 /*                      sizeof(struct PrefixV4), prefCmp); */ 
    625 /*      } */ 
    626         bool = 0;     
    627         /* end put */ 
     638#endif  
     639        /* put aggregation cache information to IPv4 Prefixes table */ 
     640#ifdef IPV4AGG 
     641        if (bool == 1){ 
     642          prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); 
     643          res = bsearch(&prefixKey, V4PTab, nbPV4,  
     644                        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) { 
     650            case 1: 
     651              res->icmpBytesNb += agCache.bytes; 
     652              res->icmpPktsNb += agCache.pkts; 
     653              res->icmpFlowNb += 1; 
     654              break; 
     655            case 6: 
     656              res->tcpBytesNb += agCache.bytes; 
     657              res->tcpPktsNb += agCache.pkts; 
     658              res->tcpFlowNb += 1;             
     659              break; 
     660            case 17: 
     661              res->udpBytesNb += agCache.bytes; 
     662              res->udpPktsNb += agCache.pkts; 
     663              res->udpFlowNb += 1; 
     664              break; 
     665            default: 
     666              res->othersBytesNb += agCache.bytes; 
     667              res->othersPktsNb += agCache.pkts; 
     668              res->othersFlowNb += 1;          
     669            } 
     670          } 
     671/*        if (res==NULL){ */ 
     672/*          fprintf(stderr, "IPv4_spoofing? ");  */ 
     673/*        } */ 
     674        } 
     675        bool = 0; 
     676#endif 
    628677        /*  
    629678         * Redirection if needed  
  • trunk/src/dataFlowSet.h

    r20 r22  
    7373  unsigned char tProt; 
    7474  unsigned char ipProt; 
    75   unsigned char sens; /* In/out */ 
     75  unsigned char sens; /* In/out field 61 */ 
    7676  unsigned short idSnmp; 
    7777  unsigned long bytes; 
  • trunk/src/fields_mgmt.c

    r2 r22  
    3434{ 
    3535  FieldPtr tmp = pf; 
    36   fprintf(stderr, "template definition: (field, size)\n"); 
    3736  for (; tmp; tmp=tmp->next) { 
    3837    fprintf(stderr, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength); 
     
    4746{ 
    4847  FieldPtr tmp = pf; 
    49   fprintf(stderr, "fields set (inv): \n"); 
    5048  for (; tmp; tmp=tmp->prev) { 
    5149    fprintf(stderr, " %hu %hu \n", tmp->fieldType, tmp->fieldLength); 
  • trunk/src/get_conf.c

    r17 r22  
    141141  unsigned char buffer4[4]; 
    142142  int i = 0; 
    143   char prefixStrTab[10000][50]; 
     143  char prefixStrTab[MAX_IPV4_PREFIX][50]; 
    144144 
    145145  if (!(prefixFile = fopen(filename, "r"))) { 
     
    151151      strcpy(prefixStrTab[counter], line); 
    152152      counter++; 
    153       if (counter == 10000) { 
     153      if (counter == MAX_IPV4_PREFIX) { 
    154154        fprintf(stderr, "bufferoverflow in getPrefixV4 function (get_conf.c)\ 
    155 change the value of prefixStrTab declaration and recompile \n"); 
     155change the value of MAX_IPV4_PREFIX declaration and recompile \n"); 
    156156        exit(1); 
    157157      } 
     
    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; 
    174185    } 
    175186  if( fclose(prefixFile) == 0) { 
  • trunk/src/get_conf.h

    r17 r22  
    22 * File: get_conf.h 
    33 *  
    4  * Authors: ANDREU François-Xavier  
     4 * Authors: ANDREU Francois-Xavier  
    55 * 
    66 * Copyright (C) 2005 GIP RENATER  
     
    2626#define GET_CONF_H 
    2727 
     28#define MAX_IPV4_PREFIX 10000 
     29 
    2830struct PrefixV4{ 
    29   unsigned long beginning; 
     31  unsigned long beginning; /* FIXME to transform in start */ 
    3032  unsigned long end; 
    31   unsigned short mask; 
    32   unsigned short routerNb; 
     33  unsigned short mask;     /* prefix mask  */ 
     34  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; 
    3350}; 
    3451 
  • trunk/src/renetcol.c

    r20 r22  
    2626#include "renetcol.h" 
    2727 
    28 #ifdef CRIHAN 
     28/* #ifdef CRIHAN */ 
    2929struct IPFLowCache tabIP[MAX_IP_FLOW], *tabIPPtr = tabIP; 
    3030struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW], *tabMPLSPtr = tabMPLS; 
    31 unsigned long ipNb = 0; 
    32 unsigned long mplsNb = 0; 
     31unsigned long ipNb = 0; /* counter of IP flows number */ 
     32unsigned long mplsNb = 0; /* counter of MPLS flow number */ 
    3333unsigned long *ipNbPtr = &ipNb; 
    3434unsigned long *mplsNbPtr = &mplsNb; 
    35 unsigned short currentIPOutputFile = 0; 
    36 unsigned short currentMPLSOutputFile = 0; 
     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]; 
    39 FILE *fIP; 
    40 FILE *fMPLS; 
    41 #endif /* CRIHAN */ 
    42  
    43 char *rulesFileName; 
    44 char *configFileName;  
    45 char *prefixV4FileName;  
    46 struct sigaction myAction; 
    47 sigjmp_buf contextSigalrm; 
    48 /* struct sigaction myAction;  for timer */  
     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/* #endif */ 
     42 
     43char *rulesFileName; /* file name of the rules (like acl) */ 
     44char *configFileName;  /* file name where routers list is */ 
     45char *prefixV4FileName;  /* IPv4 prefix list */ 
     46 
     47struct sigaction myAction; /* handler for renetcolSender communication */ 
     48sigjmp_buf contextSigalrm; /* '' */ 
    4949volatile sig_atomic_t sigusr1Up = 0; 
    50 /* V9 */ 
    51 unsigned short offsetV9 = 0; 
     50/* struct sigaction myAction;  for timer not used in this version */ 
     51 
     52unsigned short currentIntervalle = 0; /* based on 5 min intervalles */  
     53 
     54unsigned short offsetV9 = 0; /* index in a neflow v9 packet */ 
    5255unsigned short *offsetV9Ptr = &offsetV9; 
     56 
    5357unsigned char buffer1; 
    5458unsigned char buffer2[2]; 
    5559unsigned char buffer4[4]; 
    5660unsigned char buffer6[6]; 
     61 
    5762short currentFlowsetNumber; 
    5863short *currentFlowsetNumberPtr = &currentFlowsetNumber; 
    5964short currentFlowsetId; 
    6065short *currentFlowsetIdPtr = &currentFlowsetId; 
    61 TplFlowSetPtr curTplFlSetPtr; 
     66TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */ 
    6267TplOptionPtr curTplOptionPtr; 
    6368RouterPtr routersListPtr; 
     
    6671unsigned long sortedRouterList[ROUTER_INDEX_MAX]; 
    6772unsigned long indexedRouterList[ROUTER_INDEX_MAX]; 
    68 int routerNb = 0; 
    69 unsigned short v4PrefixNb = 0; 
    70 struct PrefixV4 prefixV4Tab[PREFIX_V4_MAX]; 
    71 RulesPtr rulesListPtr; 
     73int routerNb = 0; /* routers number */ 
     74unsigned short v4PrefixNb = 0; /* IPv4 prefix number */ 
     75struct PrefixV4 prefixV4Tab[MAX_IPV4_PREFIX]; /* IPv4 prefix structure */ 
     76RulesPtr rulesListPtr; /* Rules list */ 
    7277NetFlowV9HeaderPtr currentHeaderV9Ptr; 
    73 key_t myKey = 0; 
    74 int myQueue = 0; 
    75 RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD]; 
     78key_t myKey = 0; /* FIXME to delete in futur */ 
     79int myQueue = 0; /* FIXME to delete in futur */ 
     80 
     81/* Next structure used as cache in rules reading */ 
     82RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD];  
    7683RuleDefPtr *rulesAddressPtr; 
     84 
    7785int reInitConf = 0; 
    78 /* ENDV9 */ 
     86 
    7987static unsigned long datagramNumber; 
    80 static time_t now; 
     88 
     89static time_t lastRock; 
     90static struct tm *tmPtr; 
     91 
    8192static unsigned long myHost; /* FIXME to erase */ 
    82 static struct tm *tmPtr; 
    8393extern int errno; 
    8494static int inputSock; 
     
    112122  } 
    113123 
     124#ifdef CRIHAN 
     125  fprintf(stderr, "renetcol compilation with CRIHAN feature enable\n"); 
     126#endif 
     127#ifdef IPV4AGG 
     128  fprintf(stderr, "renetcol compilation and execution with IPv4 Aggregation feature enable\n"); 
     129#endif 
     130   
    114131  openlog(argv[0], LOG_PID, LOG_USER); 
    115  
     132   
    116133  configFileName = (char *) malloc((strlen(argv[1])+1) * sizeof(char)); 
    117134  strcpy (configFileName, argv[1]); 
     
    156173  sigaction (SIGUSR1, &myAction, NULL); 
    157174 
     175  /* Pointer on rules Table */ 
    158176  setCache(rulesListPtr); 
    159177  rulesAddressPtr = (RuleDefPtr *)rulesAddress; 
     
    188206  datagramNumber =0; /* FIXME : ???? */ 
    189207 
    190   now = time((time_t *)NULL); 
    191   tmPtr = localtime(&now); 
    192208  socketLoop(); /* all work on datagram is made here */ 
    193209  closelog(); 
     
    314330{ 
    315331  static unsigned short n0, n1, n2, n3; 
    316    
     332 
    317333  initSocket(); 
    318334  if (sscanf(receptAddress,"%hu.%hu.%hu.%hu",&n0,&n1,&n2,&n3)==0) { 
     
    335351  short version = 0; 
    336352  int regRouter = 0; 
    337   /* CRI */ 
    338353  time_t now = time((time_t *)NULL); 
    339   int iIP, iMPLS; 
     354  int iIP, iMPLS, i; 
    340355  time_t lastIPOutput, lastMPLSOutput; 
    341356  time_t receptionTime; 
    342   /* end */ 
    343357 
    344358  now = time((time_t *)NULL); 
     359  tmPtr = localtime(&now); 
     360  currentIntervalle = tmPtr->tm_min; 
    345361  lastMPLSOutput = now; 
    346362  lastIPOutput = now; 
    347363  do { 
     364    if ( ((tmPtr->tm_min)%2 == 0) && (currentIntervalle != tmPtr->tm_min)){ 
     365      printf("We change the table, min : %d\n", tmPtr->tm_min); 
     366      currentIntervalle = tmPtr->tm_min; 
     367    } 
    348368    if (sigusr1Up == 1){ 
    349369      sigusr1Up = 0; 
     
    379399                                       currentFlowsetNumberPtr, 
    380400                                       myQueue); 
    381 /*        showAllTplFlSet();  */ 
     401          /* FIXME : TplFlSet Def in a file before next release */ 
     402          /* showAllTplFlSet(); */ 
    382403        } else if (currentFlowsetId == 1) { 
    383404          shift = checkTemplateOption(currentRouterPtr, offsetV9Ptr,  
     
    400421      break; 
    401422    default: 
     423      /* FIXME : Uncomment before next release */ 
    402424/*        syslog(LOG_INFO,  */ 
    403425/*           "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", */ 
     
    409431      break; 
    410432    } 
     433/*     for (i=0; i<v4PrefixNb; i++){ */ 
     434/*       fprintf(stderr, "%lu %llu flows\n", */ 
     435/*            prefixV4Tab[i].beginning, */ 
     436/*            prefixV4Tab[i].flowNb); */ 
     437/*     } */ 
    411438 
    412439#ifdef CRIHAN 
     
    493520    } 
    494521#endif /* CRIHAN */ 
     522    now = time((time_t *)NULL); 
     523    tmPtr = localtime(&now); 
    495524  } while (1); 
    496525} 
     
    602631  TplFlowSetPtr tmpFS; 
    603632  TplOptionPtr tmpOP; 
    604   fprintf(stderr,"All template definitions: (field, size) :\n"); 
     633  fprintf(stderr,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n"); 
    605634  for (; tmp; tmp=tmp->next) { 
    606     fprintf(stderr,"router %lu.%lu.%lu.%lu : \n", 
     635    fprintf(stderr,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n", 
    607636            (tmp->IpAddress>>24), 
    608637            (tmp->IpAddress<<8>>24), 
     
    611640    tmpFS =  tmp->tplList; 
    612641    for (; tmpFS; tmpFS=tmpFS->next) { 
    613       fprintf(stderr,"ID %hu: ", tmpFS->templateFlowSetId); 
     642      fprintf(stderr,"TId %hu (sourceId: %lu):\n",  
     643              tmpFS->templateFlowSetId, 
     644              tmpFS->sourceId); 
    614645      printFieldSet(tmpFS->fieldSet); 
    615646      fprintf(stderr,"\n"); 
    616647    } 
    617648    if ((tmpOP = tmp->tplOptList) != NULL){ 
    618       fprintf(stderr,"template option: \n"); 
    619649      for (; tmpOP; tmpOP=tmpOP->next) { 
    620         fprintf(stderr,"ID %hu: ", tmpOP->templateOptionId); 
     650        fprintf(stderr,"OpTId %hu (sourceId: %lu) >\n",  
     651                tmpOP->templateOptionId, 
     652                tmpOP->sourceId); 
    621653        printFieldSet(tmpOP->fieldSet); 
    622654        fprintf(stderr,"\n"); 
  • trunk/src/renetcol.h

    r20 r22  
    7070 
    7171#define ROUTER_INDEX_MAX 70 
    72 #define PREFIX_V4_MAX 4000 
    7372#define FIELD_TYPE_NUMBER 89 
    7473#define MAX_RULES_PER_FIELD 10 
     
    8079#define MAX_IP_OUTPUT_FILES 3 
    8180#define MAX_MPLS_OUTPUT_FILES 3 
    82 #define MAX_IP_FLOW 10000 
    83 #define MAX_MPLS_FLOW 200 
    8481#define IP_TIME_THRESHOLD 60 /* in sec */ 
    8582#define MPLS_TIME_THRESHOLD 60 /* in sec */ 
    8683#endif /* CRIHAN */ 
     84#define MAX_IP_FLOW 10000 
     85#define MAX_MPLS_FLOW 200 
    8786 
    8887void setCache(RulesPtr);