Changeset 19 for trunk/src

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

last changes for Crihan -> 0.0.5

Location:
trunk/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r18 r19  
    8989  mplsFirstCache.v4AdS = 0; 
    9090  mplsFirstCache.v4AdD = 0; 
     91  mplsFirstCache.outSnmp = 0; 
     92  mplsFirstCache.inSnmp = 0; 
    9193  mplsFirstCache.routerAd = 0; 
    9294  mplsFirstCache.mplsLabel1 = 0; 
     95 
    9396  /* CRI */ 
    9497 
     
    196199                ipFirstCache.tProt = *((unsigned char*)&buffer1);  
    197200              } 
     201/*            if (pftmp->fieldType==46){  */ 
     202/*              mplsFirstCache.topLabelType = *((unsigned char*)&buffer1);  */ 
     203/*            } */ 
    198204              /* end CRI */ 
    199205              break; 
     
    212218              if (pftmp->fieldType==10){ 
    213219                ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 
     220                mplsFirstCache.inSnmp = *((unsigned short*)&buffer2); 
    214221              } 
    215222              if (pftmp->fieldType==14){ 
    216223                ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 
     224                mplsFirstCache.outSnmp = *((unsigned short*)&buffer2); 
    217225              } 
    218226              if (pftmp->fieldType==7){ 
     
    270278              if (pftmp->fieldType==8){ 
    271279                ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 
     280                mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); 
    272281              } 
    273282              if (pftmp->fieldType==12){ 
    274283                ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 
     284                mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); 
    275285              } 
    276286              if (pftmp->fieldType==1){ 
     
    472482            ipFirstCache.tProt = *((unsigned char*)&buffer1);  
    473483          } 
     484/*        if (pftmp->fieldType==46){  */ 
     485/*          mplsFirstCache.topLabelType = *((unsigned char*)&buffer1);  */ 
     486/*        } */ 
    474487          break; 
    475488        case 2: 
     
    484497          if (pftmp->fieldType==10){ 
    485498            ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 
     499            mplsFirstCache.inSnmp = *((unsigned short*)&buffer2); 
    486500          } 
    487501          if (pftmp->fieldType==14){ 
    488502            ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 
     503            mplsFirstCache.outSnmp = *((unsigned short*)&buffer2); 
    489504          } 
    490505          if (pftmp->fieldType==7){ 
     
    529544          if (pftmp->fieldType==8){ 
    530545            ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 
     546            mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); 
    531547          } 
    532548          if (pftmp->fieldType==12){ 
    533549            ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 
     550            mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); 
    534551          } 
    535552          if (pftmp->fieldType==1){ 
     
    569586         */ 
    570587        /* CRI */ 
    571         printf("!"); 
    572588        if ( mplsFirstCache.mplsLabel1 == 0 ) { 
    573589          (ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt; 
     
    600616          (*ipCounter)++; 
    601617        } else { 
    602           printf("im\n"); 
    603618          (mplsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt; 
    604619          mplsFirstCache.ipProt = 0; 
     620/*        (mplsCache+(*mplsCounter))->topLabelType = mplsFirstCache.topLabelType; */ 
     621/*        mplsFirstCache.topLabelType = 0; */ 
    605622          (mplsCache+(*mplsCounter))->v4AdS =  mplsFirstCache.v4AdS; 
    606623          mplsFirstCache.v4AdS = 0; 
    607624          (mplsCache+(*mplsCounter))->v4AdD =  mplsFirstCache.v4AdD;  
    608625          mplsFirstCache.v4AdD = 0; 
     626          (mplsCache+(*mplsCounter))->inSnmp =  mplsFirstCache.inSnmp; 
     627          mplsFirstCache.inSnmp = 0; 
     628          (mplsCache+(*mplsCounter))->outSnmp =  mplsFirstCache.outSnmp;  
     629          mplsFirstCache.outSnmp = 0; 
    609630          (mplsCache+(*mplsCounter))->routerAd =  mplsFirstCache.routerAd; 
    610631          (mplsCache+(*mplsCounter))->mplsLabel1 =  mplsFirstCache.mplsLabel1; 
     
    612633          (*mplsCounter)++; 
    613634        } 
    614         /* CRI */ 
     635        /* end CRI */ 
    615636        /* put aggregation cache information to tables */ 
    616637        if (bool == 1){ 
  • trunk/src/dataFlowSet.h

    r18 r19  
    3737#include "prefix_mgmt.h" 
    3838 
    39 #define MAX_IP_FLOW 1000 
    40 #define MAX_MPLS_FLOW 1000 
    41  
    4239struct IPFLowCache { 
    4340  unsigned char ipProt; /* not write in file, just to know IP version */ 
     
    6562  unsigned long v4AdS; 
    6663  unsigned long v4AdD; 
     64  unsigned short inSnmp; 
     65  unsigned short outSnmp; 
    6766  uint32_t tabAdd6S[4]; 
    6867  uint32_t tabAdd6D[4];   
  • trunk/src/renetcol.c

    r18 r19  
    3333unsigned long *ipNbPtr = &ipNb; 
    3434unsigned long *mplsNbPtr = &mplsNb; 
     35unsigned short currentIPOutputFile = 0; 
     36unsigned short currentMPLSOutputFile = 0; 
     37char outputName[256]; 
     38char cof_str[20]; 
    3539FILE *fIP; 
    3640FILE *fMPLS; 
    37 /* end */  
     41/* end */ 
    3842 
    3943char *rulesFileName; 
     
    332336  int regRouter = 0; 
    333337  /* CRI */ 
     338  time_t now = time((time_t *)NULL); 
    334339  int iIP, iMPLS; 
    335   /* end CRI */ 
    336    
     340  time_t lastIPOutput, lastMPLSOutput; 
     341  time_t receptionTime; 
     342  /* end */ 
     343 
     344  now = time((time_t *)NULL); 
     345  lastMPLSOutput = now; 
     346  lastIPOutput = now; 
    337347  do { 
    338348    if (sigusr1Up == 1){ 
     
    401411 
    402412    /* CRI */ 
    403     if ( ipNb > (MAX_IP_FLOW - 50)) { 
    404       if ((fIP = fopen(OUTPUT_IP, "w")) == NULL) { 
     413    now = time((time_t *)NULL); 
     414    receptionTime = now; 
     415    if ( (ipNb > (MAX_IP_FLOW - 50)) ||  
     416         ( (now-lastIPOutput) > IP_TIME_THRESHOLD) ) { 
     417      outputName[0] = '\0'; 
     418      sprintf(cof_str, "%d", currentIPOutputFile); 
     419      strcat(outputName, OUTPUT_IP); 
     420      strcat(outputName, cof_str); 
     421      strcat(outputName, EXTENSION); 
     422      if (fopen(outputName, "x") == NULL) { 
     423        currentIPOutputFile = (currentIPOutputFile + 1)%MAX_IP_OUTPUT_FILES; 
     424        outputName[0] = '\0'; 
     425        sprintf(cof_str, "%d", currentIPOutputFile); 
     426        strcat(outputName, OUTPUT_IP); 
     427        strcat(outputName, cof_str); 
     428        strcat(outputName, EXTENSION); 
     429      }  
     430      if ((fIP = fopen(outputName, "w")) == NULL) { 
    405431        syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno)); 
    406432      } else { 
    407433        for ( iIP = 0; iIP < ipNb; iIP++){ 
    408           printf("ipv4\n"); 
    409434          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", 
     435            fprintf(fIP, "%lu;%lu;%hu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%d;%hu;%hu;%d;%d;%lu.%lu.%lu.%lu;%lu;%d\n", 
    412436                    tabIP[iIP].bytes, tabIP[iIP].pkts, 
    413437                    tabIP[iIP].inSnmp,  tabIP[iIP].outSnmp, 
     
    420444                    tabIP[iIP].maskS, tabIP[iIP].routerAd>>24, 
    421445                    tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24, 
    422                     tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime 
     446                    tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime, 
     447                    receptionTime 
    423448                    ); 
    424449          } 
     
    427452      } 
    428453      ipNb = 0; 
    429     } 
    430     if ( mplsNb > (MAX_MPLS_FLOW - 50)) { 
    431       if ((fMPLS = fopen(OUTPUT_MPLS, "w")) == NULL) { 
     454      lastIPOutput = now; 
     455    } 
     456    now = time((time_t *)NULL); 
     457    if ( mplsNb > (MAX_MPLS_FLOW - 50) ||  
     458         ( (now-lastMPLSOutput) > MPLS_TIME_THRESHOLD) ) { 
     459      outputName[0] = '\0'; 
     460      sprintf(cof_str, "%d", currentMPLSOutputFile); 
     461      strcat(outputName, OUTPUT_MPLS); 
     462      strcat(outputName, cof_str); 
     463      strcat(outputName, EXTENSION); 
     464      if (fopen(outputName, "x") == NULL) { 
     465        currentMPLSOutputFile = (currentMPLSOutputFile + 1)%MAX_MPLS_OUTPUT_FILES; 
     466        outputName[0] = '\0'; 
     467        sprintf(cof_str, "%d", currentMPLSOutputFile); 
     468        strcat(outputName, OUTPUT_MPLS); 
     469        strcat(outputName, cof_str); 
     470        strcat(outputName, EXTENSION); 
     471      } 
     472      if ((fMPLS = fopen(outputName, "w")) == NULL) { 
    432473        syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno)); 
    433474      } else { 
    434475        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", 
     476          if ( tabMPLS[iMPLS].ipProt == 0 ) { 
     477            fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%hu;%hu;%d\n", 
    437478                    tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24, 
    438479                    tabMPLS[iMPLS].routerAd<<16>>24, 
    439480                    tabMPLS[iMPLS].routerAd<<24>>24, 
    440                     tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24, 
     481                    tabMPLS[iMPLS].mplsLabel1, 
     482                    tabMPLS[iMPLS].v4AdS>>24, 
    441483                    tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24, 
    442484                    tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24, 
    443485                    tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24, 
    444                     tabMPLS[iMPLS].v4AdD<<24>>24  
     486                    tabMPLS[iMPLS].v4AdD<<24>>24, 
     487                    tabMPLS[iMPLS].inSnmp,tabMPLS[iMPLS].outSnmp, 
     488                    receptionTime 
    445489                    ); 
    446490          } 
     
    449493      } 
    450494      mplsNb = 0; 
     495      lastMPLSOutput = now; 
    451496    } 
    452497    /* end CRI */ 
  • trunk/src/renetcol.h

    r18 r19  
    7474#define MAX_RULES_PER_FIELD 10 
    7575 
    76 #define OUTPUT_IP "/tmp/ipflow.txt" /* CRI */ 
    77 #define OUTPUT_MPLS "/tmp/mplsflow.txt" /* CRI */ 
     76 /* CRI */ 
     77#define OUTPUT_IP "/tmp/ipflow" 
     78#define EXTENSION ".txt"  
     79#define OUTPUT_MPLS "/tmp/mplsflow" 
     80#define MAX_IP_OUTPUT_FILES 3 
     81#define MAX_MPLS_OUTPUT_FILES 3 
     82#define MAX_IP_FLOW 1000 
     83#define MAX_MPLS_FLOW 200 
     84#define IP_TIME_THRESHOLD 60 /* in sec */ 
     85#define MPLS_TIME_THRESHOLD 60 /* in sec */ 
     86/* end CRI */ 
    7887 
    7988void setCache(RulesPtr);