Changeset 18

Show
Ignore:
Timestamp:
06/09/06 18:18:15 (17 years ago)
Author:
andreu
Message:

ajout pour CRIHAN

Location:
trunk
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r17 r18  
    3535                 short *cFId, DatagramPtr pcktPtr, RuleDefPtr *rulesCache, 
    3636                 RulesPtr rlPtr, int myQueue, struct PrefixV4 *V4PTab,  
    37                  size_t nbPV4) 
     37                 size_t nbPV4,  
     38                 struct IPFLowCache *ipCache, struct MPLSFlowCache *mplsCache, 
     39                 unsigned long *ipCounter, unsigned long *mplsCounter) 
    3840{ 
    3941  TplFlowSetPtr tmp; 
     
    6365  struct PrefixV4 prefixKey, *res; /* for bsearch */ 
    6466  struct AggCache agCache; 
     67  struct IPFLowCache ipFirstCache; /* CRI */ 
     68  struct MPLSFlowCache mplsFirstCache; /* CRI */ 
     69  unsigned long firstTime = 0; /* CRI */ 
     70  unsigned long lastTime = 0; /* CRI */ 
    6571  int bool = 0; 
     72 
     73  /* CRI */ 
     74  ipFirstCache.ipProt = 0; 
     75  ipFirstCache.bytes = 0; 
     76  ipFirstCache.pkts = 0; 
     77  ipFirstCache.inSnmp = 0; 
     78  ipFirstCache.outSnmp = 0; 
     79  ipFirstCache.v4AdS = 0; 
     80  ipFirstCache.v4AdD = 0; 
     81  ipFirstCache.tProt = 0; 
     82  ipFirstCache.sPort = 0; 
     83  ipFirstCache.dPort = 0; 
     84  ipFirstCache.maskD = 0; 
     85  ipFirstCache.maskS = 0; 
     86  ipFirstCache.routerAd = 0; 
     87  ipFirstCache.liveTime = 0; 
     88  mplsFirstCache.ipProt = 0; 
     89  mplsFirstCache.v4AdS = 0; 
     90  mplsFirstCache.v4AdD = 0; 
     91  mplsFirstCache.routerAd = 0; 
     92  mplsFirstCache.mplsLabel1 = 0; 
     93  /* CRI */ 
    6694 
    6795  buffer2[1] = *(buf+(*offV9));(*offV9)++; 
     
    88116    } 
    89117    /* aggreg */ 
    90     agCache.routerAd = pcktPtr->ipH->srcAdd; 
     118/*     agCache.routerAd = pcktPtr->ipH->srcAdd; */ 
    91119    /* end aggreg */ 
     120 
     121    /* CRI */ 
     122    ipFirstCache.routerAd = pcktPtr->ipH->srcAdd; 
     123    mplsFirstCache.routerAd = pcktPtr->ipH->srcAdd; 
     124    /* end CRI */ 
     125 
    92126    pftmp = tmp->lastField; 
    93127    secondPftmp = tmp->lastField;     
     
    129163              /* end rule check */ 
    130164              /* aggregation */ 
     165/*            if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 
     166/*              agCache.maskS = *((unsigned char*)&buffer1); */ 
     167/*            } */ 
     168/*            if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 
     169/*              agCache.maskD = *((unsigned char*)&buffer1); */ 
     170/*            } */ 
     171/*            if (pftmp->fieldType==60){ */ 
     172/*              agCache.ipProt = *((unsigned char*)&buffer1); */ 
     173/*            } */ 
     174/*            if (pftmp->fieldType==4){ */ 
     175/*              agCache.tProt = *((unsigned char*)&buffer1); */ 
     176/*            } */ 
     177/*            if (pftmp->fieldType==61){ */ 
     178/*              agCache.sens = *((unsigned char*)&buffer1); */ 
     179/*            } */ 
     180/*            if (pftmp->fieldType==5){ */ 
     181/*              agCache.dscp = *((unsigned char*)&buffer1); */ 
     182/*            } */ 
     183              /* end aggregation */ 
     184              /* CRI */ 
    131185              if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
    132                 agCache.maskS = *((unsigned char*)&buffer1); 
     186                ipFirstCache.maskS = *((unsigned char*)&buffer1); 
    133187              } 
    134188              if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 
    135                 agCache.maskD = *((unsigned char*)&buffer1); 
    136               } 
    137               if (pftmp->fieldType==60){ 
    138                 agCache.ipProt = *((unsigned char*)&buffer1); 
    139               } 
    140               if (pftmp->fieldType==4){ 
    141                 agCache.tProt = *((unsigned char*)&buffer1); 
    142               } 
    143               if (pftmp->fieldType==61){ 
    144                 agCache.sens = *((unsigned char*)&buffer1); 
    145               } 
    146               if (pftmp->fieldType==5){ 
    147                 agCache.dscp = *((unsigned char*)&buffer1); 
    148               } 
    149               /* end aggregation */ 
     189                ipFirstCache.maskD = *((unsigned char*)&buffer1); 
     190              } 
     191              if (pftmp->fieldType==60){  
     192                ipFirstCache.ipProt = *((unsigned char*)&buffer1);  
     193                mplsFirstCache.ipProt = *((unsigned char*)&buffer1);  
     194              } 
     195              if (pftmp->fieldType==4){  
     196                ipFirstCache.tProt = *((unsigned char*)&buffer1);  
     197              } 
     198              /* end CRI */ 
    150199              break; 
    151200            case 2: 
     
    156205                ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 
    157206              /* aggregation */ 
     207/*            if (pftmp->fieldType==10){ */ 
     208/*              agCache.idSnmp = *((unsigned short*)&buffer2); */ 
     209/*            } */ 
     210              /* end aggregation */ 
     211              /* CRI */ 
    158212              if (pftmp->fieldType==10){ 
    159                 agCache.idSnmp = *((unsigned short*)&buffer2); 
    160               } 
    161               /* end aggregation */ 
     213                ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 
     214              } 
     215              if (pftmp->fieldType==14){ 
     216                ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 
     217              } 
     218              if (pftmp->fieldType==7){ 
     219                ipFirstCache.sPort = *((unsigned short*)&buffer2); 
     220              } 
     221              if (pftmp->fieldType==11){ 
     222                ipFirstCache.dPort = *((unsigned short*)&buffer2); 
     223              } 
     224              /* end CRI */  
    162225              break; 
    163226            case 3: 
     
    171234              /* aggregation */ 
    172235              /* end aggregation */ 
     236              /* CRI */ 
     237              if (pftmp->fieldType==70){ 
     238                mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 
     239              } 
     240              /* end CRI */ 
    173241              break; 
    174242            case 4: 
     
    186254              }        
    187255              /* aggregation */ 
    188               if ((pftmp->fieldType==8)){ 
    189                 agCache.v4AdS = *((unsigned long*)&buffer4); 
    190               } 
    191               if ((pftmp->fieldType==12)){ 
    192                 agCache.v4AdD = *((unsigned long*)&buffer4); 
     256/*            if ((pftmp->fieldType==8)){ */ 
     257/*              agCache.v4AdS = *((unsigned long*)&buffer4); */ 
     258/*            } */ 
     259/*            if ((pftmp->fieldType==12)){ */ 
     260/*              agCache.v4AdD = *((unsigned long*)&buffer4); */ 
     261/*            } */ 
     262/*            if (pftmp->fieldType==1){ */ 
     263/*              agCache.bytes = *((unsigned long*)&buffer4); */ 
     264/*            } */ 
     265/*            if (pftmp->fieldType==2){ */ 
     266/*              agCache.pkts = *((unsigned long*)&buffer4); */ 
     267/*            } */ 
     268              /* end aggregation */ 
     269              /* CRI */ 
     270              if (pftmp->fieldType==8){ 
     271                ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 
     272              } 
     273              if (pftmp->fieldType==12){ 
     274                ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 
    193275              } 
    194276              if (pftmp->fieldType==1){ 
    195                 agCache.bytes = *((unsigned long*)&buffer4); 
     277                ipFirstCache.bytes = *((unsigned long*)&buffer4); 
    196278              } 
    197279              if (pftmp->fieldType==2){ 
    198                 agCache.pkts = *((unsigned long*)&buffer4); 
    199               } 
    200               /* end aggregation */ 
     280                ipFirstCache.pkts = *((unsigned long*)&buffer4); 
     281              } 
     282              if (pftmp->fieldType==22){ 
     283                firstTime = *((unsigned long*)&buffer4); 
     284              } 
     285              if (pftmp->fieldType==21){ 
     286                lastTime = *((unsigned long*)&buffer4); 
     287              } 
     288              /* end CRI */ 
    201289              break; 
    202290            case 16: 
     
    351439          buffer1 = *(buf+(*offV9)); (*offV9)++; 
    352440          /* aggregation */ 
     441/*        if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 
     442/*          agCache.maskS = *((unsigned char*)&buffer1); */ 
     443/*        } */ 
     444/*        if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 
     445/*          agCache.maskD = *((unsigned char*)&buffer1); */ 
     446/*        } */ 
     447/*        if (pftmp->fieldType==60){ */ 
     448/*          agCache.ipProt = *((unsigned char*)&buffer1); */ 
     449/*        } */ 
     450/*        if (pftmp->fieldType==4){ */ 
     451/*          agCache.tProt = *((unsigned char*)&buffer1); */ 
     452/*        } */ 
     453/*        if (pftmp->fieldType==61){ */ 
     454/*          agCache.sens = *((unsigned char*)&buffer1); */ 
     455/*        } */ 
     456/*        if (pftmp->fieldType==5){ */ 
     457/*          agCache.dscp = *((unsigned char*)&buffer1); */ 
     458/*        }        */ 
     459          /* end aggregation */ 
     460          /* CRI */ 
    353461          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 
    354             agCache.maskS = *((unsigned char*)&buffer1); 
     462            ipFirstCache.maskS = *((unsigned char*)&buffer1); 
    355463          } 
    356464          if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 
    357             agCache.maskD = *((unsigned char*)&buffer1); 
    358           } 
    359           if (pftmp->fieldType==60){ 
    360             agCache.ipProt = *((unsigned char*)&buffer1); 
    361           } 
    362           if (pftmp->fieldType==4){ 
    363             agCache.tProt = *((unsigned char*)&buffer1); 
    364           } 
    365           if (pftmp->fieldType==61){ 
    366             agCache.sens = *((unsigned char*)&buffer1); 
    367           } 
    368           if (pftmp->fieldType==5){ 
    369             agCache.dscp = *((unsigned char*)&buffer1); 
    370           }        
    371           /* end aggregation */ 
     465            ipFirstCache.maskD = *((unsigned char*)&buffer1); 
     466          } 
     467          if (pftmp->fieldType==60){  
     468            ipFirstCache.ipProt = *((unsigned char*)&buffer1);  
     469            mplsFirstCache.ipProt = *((unsigned char*)&buffer1);  
     470          } 
     471          if (pftmp->fieldType==4){  
     472            ipFirstCache.tProt = *((unsigned char*)&buffer1);  
     473          } 
    372474          break; 
    373475        case 2: 
     
    379481          }        
    380482          /* end aggregation */ 
     483          /* CRI */ 
     484          if (pftmp->fieldType==10){ 
     485            ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 
     486          } 
     487          if (pftmp->fieldType==14){ 
     488            ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 
     489          } 
     490          if (pftmp->fieldType==7){ 
     491            ipFirstCache.sPort = *((unsigned short*)&buffer2); 
     492          } 
     493          if (pftmp->fieldType==11){ 
     494            ipFirstCache.dPort = *((unsigned short*)&buffer2); 
     495          } 
     496          /* end CRI */  
    381497          break; 
    382498        case 3: 
     
    385501          buffer4[1]= *(buf+(*offV9)); (*offV9)++; 
    386502          buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
    387 /*        fprintf(stderr,"L: %lu\n",(*((unsigned long*)&buffer4))); */ 
    388 /*        fprintf(stderr,"L>>4: %lu\n",(*((unsigned long*)&buffer4))>>4); */ 
    389 /*        fprintf(stderr,"L>>1<<29>>29: %lu\n",(*((unsigned long*)&buffer4))>>1<<29>>29); */ 
    390 /*        fprintf(stderr,"L<<31>>31: %lu\n",(*((unsigned long*)&buffer4))<<31>>31); */ 
    391503          /* aggregation */ 
    392504          /* end aggregation */ 
     505          /* CRI */ 
     506          if (pftmp->fieldType==70){ 
     507            mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 
     508          } 
     509          /* end CRI */ 
    393510          break; 
    394511        case 4: 
     
    398515          buffer4[0]= *(buf+(*offV9)); (*offV9)++; 
    399516          /* aggregation */ 
    400           if ((pftmp->fieldType==8)){ 
    401             bool = 1; 
    402             agCache.v4AdS = *((unsigned long*)&buffer4); 
    403           } else if ((pftmp->fieldType==12)){ 
    404             agCache.v4AdD = *((unsigned long*)&buffer4); 
    405           } else if (pftmp->fieldType==1){ 
    406             agCache.bytes = *((unsigned long*)&buffer4); 
    407           } else if (pftmp->fieldType==2){ 
    408             agCache.pkts = *((unsigned long*)&buffer4); 
    409           } 
     517/*        if ((pftmp->fieldType==8)){ */ 
     518/*          bool = 1; */ 
     519/*          agCache.v4AdS = *((unsigned long*)&buffer4); */ 
     520/*        } else if ((pftmp->fieldType==12)){ */ 
     521/*          agCache.v4AdD = *((unsigned long*)&buffer4); */ 
     522/*        } else if (pftmp->fieldType==1){ */ 
     523/*          agCache.bytes = *((unsigned long*)&buffer4); */ 
     524/*        } else if (pftmp->fieldType==2){ */ 
     525/*          agCache.pkts = *((unsigned long*)&buffer4); */ 
     526/*        } */ 
    410527          /* end aggregation */ 
     528          /* CRI */ 
     529          if (pftmp->fieldType==8){ 
     530            ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 
     531          } 
     532          if (pftmp->fieldType==12){ 
     533            ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 
     534          } 
     535          if (pftmp->fieldType==1){ 
     536            ipFirstCache.bytes = *((unsigned long*)&buffer4); 
     537          } 
     538          if (pftmp->fieldType==2){ 
     539            ipFirstCache.pkts = *((unsigned long*)&buffer4); 
     540          } 
     541          if (pftmp->fieldType==22){ 
     542            firstTime = *((unsigned long*)&buffer4); 
     543          } 
     544          if (pftmp->fieldType==21){ 
     545            lastTime = *((unsigned long*)&buffer4); 
     546          } 
     547          /* end CRI */ 
    411548          break; 
    412549        case 16: 
     
    417554            buffer2[0]= *(buf+(*offV9)); (*offV9)++; 
    418555          } 
    419           /* aggregation */ 
    420            
     556          /* aggregation */        
    421557          /* end aggregation */ 
    422558          break; 
     
    432568         * end of one flow (not the flowset)  
    433569         */ 
     570        /* CRI */ 
     571        printf("!"); 
     572        if ( mplsFirstCache.mplsLabel1 == 0 ) { 
     573          (ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt; 
     574          ipFirstCache.ipProt = 0; 
     575          (ipCache+(*ipCounter))->bytes = ipFirstCache.bytes; 
     576          ipFirstCache.bytes = 0; 
     577          (ipCache+(*ipCounter))->pkts = ipFirstCache.pkts; 
     578          ipFirstCache.pkts = 0; 
     579          (ipCache+(*ipCounter))->inSnmp = ipFirstCache.inSnmp; 
     580          ipFirstCache.inSnmp = 0; 
     581          (ipCache+(*ipCounter))->outSnmp = ipFirstCache.outSnmp; 
     582          ipFirstCache.outSnmp = 0; 
     583          (ipCache+(*ipCounter))->v4AdS = ipFirstCache.v4AdS; 
     584          ipFirstCache.outSnmp = 0; 
     585          (ipCache+(*ipCounter))->v4AdD = ipFirstCache.v4AdD; 
     586          ipFirstCache.v4AdD = 0; 
     587          (ipCache+(*ipCounter))->tProt = ipFirstCache.tProt; 
     588          ipFirstCache.tProt = 0; 
     589          (ipCache+(*ipCounter))->sPort = ipFirstCache.sPort; 
     590          ipFirstCache.sPort = 0; 
     591          (ipCache+(*ipCounter))->dPort = ipFirstCache.dPort; 
     592          ipFirstCache.dPort = 0; 
     593          (ipCache+(*ipCounter))->maskD = ipFirstCache.maskD; 
     594          ipFirstCache.maskD = 0; 
     595          (ipCache+(*ipCounter))->maskS = ipFirstCache.maskS; 
     596          ipFirstCache.maskS = 0; 
     597          (ipCache+(*ipCounter))->routerAd = ipFirstCache.routerAd; 
     598          (ipCache+(*ipCounter))->liveTime = lastTime - firstTime; 
     599          firstTime = 0; lastTime = 0; 
     600          (*ipCounter)++; 
     601        } else { 
     602          printf("im\n"); 
     603          (mplsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt; 
     604          mplsFirstCache.ipProt = 0; 
     605          (mplsCache+(*mplsCounter))->v4AdS =  mplsFirstCache.v4AdS; 
     606          mplsFirstCache.v4AdS = 0; 
     607          (mplsCache+(*mplsCounter))->v4AdD =  mplsFirstCache.v4AdD;  
     608          mplsFirstCache.v4AdD = 0; 
     609          (mplsCache+(*mplsCounter))->routerAd =  mplsFirstCache.routerAd; 
     610          (mplsCache+(*mplsCounter))->mplsLabel1 =  mplsFirstCache.mplsLabel1; 
     611          mplsFirstCache.mplsLabel1 = 0; 
     612          (*mplsCounter)++; 
     613        } 
     614        /* CRI */ 
    434615        /* put aggregation cache information to tables */ 
    435616        if (bool == 1){ 
     
    443624         * Redirection if needed  
    444625         * switch the rules definition (check & fieldToRecord),  
    445          * we send the flow or a part of the flow to the msg queue 
     626         * we send the flow or a part of the flow to a remote host or a file 
    446627         */ 
    447628        tmpRuleList = rlPtr; 
  • trunk/src/dataFlowSet.h

    r17 r18  
    3737#include "prefix_mgmt.h" 
    3838 
     39#define MAX_IP_FLOW 1000 
     40#define MAX_MPLS_FLOW 1000 
     41 
     42struct IPFLowCache { 
     43  unsigned char ipProt; /* not write in file, just to know IP version */ 
     44  unsigned long bytes; 
     45  unsigned long pkts; 
     46  unsigned short inSnmp; 
     47  unsigned short outSnmp; 
     48  unsigned long v4AdS; 
     49  unsigned long v4AdD; 
     50  uint32_t tabAdd6S[4]; 
     51  uint32_t tabAdd6D[4]; 
     52  unsigned char tProt; 
     53  unsigned short sPort; 
     54  unsigned short dPort; 
     55  unsigned char maskD; 
     56  unsigned char maskS; 
     57  unsigned long routerAd; 
     58  unsigned long liveTime; 
     59}; 
     60 
     61struct MPLSFlowCache { 
     62  unsigned char ipProt; /* not write in file, just to know IP version */ 
     63  unsigned long routerAd; 
     64  unsigned short mplsLabel1; 
     65  unsigned long v4AdS; 
     66  unsigned long v4AdD; 
     67  uint32_t tabAdd6S[4]; 
     68  uint32_t tabAdd6D[4];   
     69}; 
     70 
    3971struct AggCache { 
    4072  unsigned short mode; 
     
    6193                 unsigned short *, unsigned char *, short *, 
    6294                 short *, DatagramPtr, RuleDefPtr *, RulesPtr, int, 
    63                  struct PrefixV4 *, size_t); 
     95                 struct PrefixV4 *, size_t,  
     96                 struct IPFLowCache *, struct MPLSFlowCache *, 
     97                 unsigned long *, unsigned long *); 
    6498 
    6599#endif /* DATAFLOWSET_H */ 
  • trunk/src/renetcol.c

    r17 r18  
    2525 
    2626#include "renetcol.h" 
     27 
     28/* uptade for CRIHAN -> CRI */ 
     29struct IPFLowCache tabIP[MAX_IP_FLOW], *tabIPPtr = tabIP; 
     30struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW], *tabMPLSPtr = tabMPLS; 
     31unsigned long ipNb = 0; 
     32unsigned long mplsNb = 0; 
     33unsigned long *ipNbPtr = &ipNb; 
     34unsigned long *mplsNbPtr = &mplsNb; 
     35FILE *fIP; 
     36FILE *fMPLS; 
     37/* end */  
    2738 
    2839char *rulesFileName; 
     
    269280 
    270281/* 
    271  * 
     282 * setCache() 
    272283 */ 
    273284void 
     
    320331  short version = 0; 
    321332  int regRouter = 0; 
     333  /* CRI */ 
     334  int iIP, iMPLS; 
     335  /* end CRI */ 
    322336   
    323337  do { 
     
    368382                                   rulesAddressPtr, rulesListPtr, 
    369383                                   myQueue, prefixV4Tab, 
    370                                    (size_t) v4PrefixNb); 
     384                                   (size_t) v4PrefixNb, 
     385                                   tabIPPtr,  
     386                                   tabMPLSPtr,  
     387                                   ipNbPtr, mplsNbPtr); 
    371388        } 
    372389      } 
     
    382399      break; 
    383400    } 
     401 
     402    /* CRI */ 
     403    if ( ipNb > (MAX_IP_FLOW - 50)) { 
     404      if ((fIP = fopen(OUTPUT_IP, "w")) == NULL) { 
     405        syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno)); 
     406      } else { 
     407        for ( iIP = 0; iIP < ipNb; iIP++){ 
     408          printf("ipv4\n"); 
     409          if ( tabIP[iIP].ipProt == 0 ) { 
     410            printf(".\n"); 
     411            fprintf(fIP, "%lu;%lu;%hu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%d;%hu;%hu;%d;%d;%lu.%lu.%lu.%lu;%lu\n", 
     412                    tabIP[iIP].bytes, tabIP[iIP].pkts, 
     413                    tabIP[iIP].inSnmp,  tabIP[iIP].outSnmp, 
     414                    tabIP[iIP].v4AdS>>24, tabIP[iIP].v4AdS<<8>>24, 
     415                    tabIP[iIP].v4AdS<<16>>24, tabIP[iIP].v4AdS<<24>>24, 
     416                    tabIP[iIP].v4AdD>>24, tabIP[iIP].v4AdD<<8>>24, 
     417                    tabIP[iIP].v4AdD<<16>>24, tabIP[iIP].v4AdD<<24>>24, 
     418                    tabIP[iIP].tProt, tabIP[iIP].sPort, 
     419                    tabIP[iIP].dPort, tabIP[iIP].maskD, 
     420                    tabIP[iIP].maskS, tabIP[iIP].routerAd>>24, 
     421                    tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24, 
     422                    tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime 
     423                    ); 
     424          } 
     425        } 
     426        fclose(fIP); 
     427      } 
     428      ipNb = 0; 
     429    } 
     430    if ( mplsNb > (MAX_MPLS_FLOW - 50)) { 
     431      if ((fMPLS = fopen(OUTPUT_MPLS, "w")) == NULL) { 
     432        syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno)); 
     433      } else { 
     434        for ( iMPLS = 0; iMPLS < mplsNb; iMPLS++){ 
     435          if ( tabMPLS[iMPLS].ipProt == 4 ) { 
     436            fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu\n", 
     437                    tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24, 
     438                    tabMPLS[iMPLS].routerAd<<16>>24, 
     439                    tabMPLS[iMPLS].routerAd<<24>>24, 
     440                    tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24, 
     441                    tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24, 
     442                    tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24, 
     443                    tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24, 
     444                    tabMPLS[iMPLS].v4AdD<<24>>24  
     445                    ); 
     446          } 
     447        } 
     448        fclose(fMPLS); 
     449      } 
     450      mplsNb = 0; 
     451    } 
     452    /* end CRI */ 
    384453  } while (1); 
    385454} 
  • trunk/src/renetcol.h

    r8 r18  
    5959#include "rules_mgmt.h" 
    6060#include "msg_mgmt.h" 
     61 
    6162/* #include "mysql_mgmt.h" */ 
    6263 
     
    6667#define RECEPTION_PORT 9999 /* your collector port to recept netflow export */ 
    6768 
    68 #define TIME_OUT 300 /*MAJSCH*/ 
     69#define TIME_OUT 300 /* MAJSCH */ 
    6970 
    7071#define ROUTER_INDEX_MAX 70 
     
    7273#define FIELD_TYPE_NUMBER 89 
    7374#define MAX_RULES_PER_FIELD 10 
     75 
     76#define OUTPUT_IP "/tmp/ipflow.txt" /* CRI */ 
     77#define OUTPUT_MPLS "/tmp/mplsflow.txt" /* CRI */ 
    7478 
    7579void setCache(RulesPtr); 
  • trunk/tool/renetcolGUI_0_0_3.py

    r14 r18  
    6060                    1,0,0,0,0,0,0,1,1,0, 
    6161                    0,0,0,0,0,0,0,0,0,0, 
    62                     0,0,0,0,0,0,0,0,0,0, 
    63                     0,0,0,0,0,0,0,0,0,0, 
    64                     0,0,0,0,0,0,0,0,0,0, 
    65                     0,0,0,0,0,0,0,0,0,0, 
     62                    0,0,0,0,0,0,1,1,0,0, 
     63                    0,0,0,0,0,0,0,0,0,0, 
     64                    0,0,0,0,0,0,0,0,0,0, 
     65                    1,1,1,1,1,1,1,1,1,1, 
    6666                    0,0,0,0,0,0,0,0,0,0 
    6767                    ] 
     
    8686                    0,0,0,0,0,0,0,0,0,0 
    8787                    ] 
    88 fieldsName =     [ "","IN_BYT","IN_PKTS","","PROT","TOS","TCP_FL","S_PORT","IPv4@S","S_MASK", 
    89                    "InSNMP","D_PORT","IPv4@D","D_MASK","OutSNMP","NextHop","S_AS","D_AS","","", 
    90                    "","Time","","","","","","IPv6@S","IPv6@D","", 
    91                    "","","","","","","","","","", 
    92                    "","","","","","","","","","", 
    93                    "","","","","","","","","","", 
    94                    "","","","","","","","","","ROUTER", 
    95                    "","","","","","","","","","", 
    96                    "","","","","","","","","","" 
    97                    ] 
     88fieldsName =  [ "","IN_BYT","IN_PKTS","","PROT","TOS","TCP_FL","S_PORT","IPv4@S","S_MASK", 
     89                "InSNMP","D_PORT","IPv4@D","D_MASK","OutSNMP","NextHop","S_AS","D_AS","","", 
     90                "","Time","","","","","","IPv6@S","IPv6@D","", 
     91                "","","","","","","","","","", 
     92                "","","","","","","M_T_L_T","M_T_L_@","","", 
     93                "","","","","","","","","","", 
     94                "","","","","","","","","","ROUTER", 
     95                "M_L_1","M_L_2","M_L_3","M_L_4","M_L_5","M_L_6","M_L_7","M_L_8","M_L_9","M_L_10", 
     96                "","","","","","","","","","" 
     97                ] 
    9898flowCpt = 0 
    9999mask = [ 0,0,0 ] 
     
    154154        for i in range (0, len(tpl_def[self.flow[0]])): 
    155155            f = tpl_def[self.flow[0]][i][0] 
    156             if ( f==8 or f==12 ) and ( checkUpValues[f]==1 ): 
     156            if ( f==8 or f==12 or f==15 or f==18 or f==47) and ( checkUpValues[f]==1 ): 
    157157                res = res & ( ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f])| ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f]) ) 
    158158            elif ( i==27 or i==28 ): 
     
    186186                        for k in range (0, 40): 
    187187                            underscore_line += "-" 
    188                     elif ( f==8 or f==15 or f==12 ): 
     188                    elif ( f==8 or f==15 or f==12 or f==18 or f==47 ): 
    189189                        strField += str(fieldsName[f]) 
    190190                        l = len(str(fieldsName[f])) 
     
    231231                    for j in range (0, tabNb):  
    232232                        strFlow += "\t" 
    233                 elif ( f==8 or f==12 or f==15 ): 
     233                elif ( f==8 or f==12 or f==15 or f==18 or f==47 ): 
    234234                    strFlow += str(self.flow[1][i]) 
    235235                    l = len(str(self.flow[1][i])) 
     
    329329                            value = struct.unpack('>H',flow[14+index:16+index]) 
    330330                            field_list.insert(i,value[0]) 
     331                        if (tpl_def[mykeystr][i][1]==3): 
     332                            value = struct.unpack('<BBB',flow[14+index:17+index]) 
     333                            valueTmp = struct.pack('<BBBB',value[2],value[1],value[0],0) 
     334                            valueFinal = struct.unpack('<L', valueTmp) 
     335                            valueFinal2 = (valueFinal[0])>>4 
     336                            field_list.insert(i,valueFinal2) 
    331337                        if (tpl_def[mykeystr][i][1]==4): 
    332                             if (tpl_def[mykeystr][i][0]==8 or tpl_def[mykeystr][i][0]==12 or tpl_def[mykeystr][i][0]==15): 
     338                            if (tpl_def[mykeystr][i][0]==8 or tpl_def[mykeystr][i][0]==12 or tpl_def[mykeystr][i][0]==15 or tpl_def[mykeystr][i][0]==18 or tpl_def[mykeystr][i][0]==47): 
    333339                                value = socket.inet_ntoa(flow[14+index:18+index]) 
    334340                                field_list.insert(i,value) 
     
    718724            operator = rule[1] 
    719725            value = rule[2] 
    720             if (field=='8' or field=='12' or field=='15' or field=='18'): 
     726            if (field=='8' or field=='12' or field=='15' or field=='18' or field=='47'): 
    721727                if (re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$',value)): 
    722728                    splitter = value.split('/') 
     
    750756                    is_good = 1 
    751757                ##here, check the prefix value? 
    752             if (field=='60'): 
     758            if (field=='60' or field=='46'): 
    753759                if (int(value) < 256): 
    754760                    is_good = 1 
     
    986992 
    987993    print "---------------------------------------------------------------" 
    988     print "In this version 0.0.2, you can apply rules on the collector based on the following fields:" 
     994    print "In this version 0.0.3, you can apply rules on the collector based on the following fields:" 
    989995    print "IPV4_SRC_ADDR: 8," 
    990996    print "IPV4_DST_ADDR: 12," 
     
    993999    print "IPV6_SRC_ADDR: 27," 
    9941000    print "IPV6_DST_ADDR: 28," 
     1001    print "MPLS_TOP_LABEL_TYPE: 46," 
    9951002    print "IPV6_NEXT_HOP: 62," 
    9961003    print "BPG_IPV6_NEXT_HOP: 63,"