Changeset 22 for trunk/src/renetcol.c

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

aggregation et timer

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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");