Changeset 58

Show
Ignore:
Timestamp:
10/09/07 12:01:26 (15 years ago)
Author:
andreu
Message:

new aggregation method, new configuration files, corrections on the php script for graph generation.

Location:
trunk
Files:
1 added
1 removed
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dataFlowSet.c

    r57 r58  
    153153      field_size = (int) pftmp->fieldLength; 
    154154       
    155       /* special case: check yes on all flows from one router (phantom field nb 0) */ 
     155      /* special case: check yes on all flows from one router */ 
     156      /* (phantom field nb 0) */ 
    156157      /* FIXME : this code is repeated, perhaps past before */ 
    157158      while ( ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j))) != NULL ) { 
     
    222223#ifdef IPV4AGG 
    223224              if (pftmp->fieldType==10){ 
    224                 agCache.idSnmp = *((unsigned short*)&buffer2); 
     225                agCache.inputSnmp = *((unsigned short*)&buffer2); 
     226              } 
     227              if (pftmp->fieldType==14){ 
     228                agCache.outputSnmp = *((unsigned short*)&buffer2); 
    225229              } 
    226230#endif 
     
    472476#ifdef IPV4AGG 
    473477          if (pftmp->fieldType==10){ 
    474             agCache.idSnmp = *((unsigned short*)&buffer2); 
     478            agCache.inputSnmp = *((unsigned short*)&buffer2); 
     479          }        
     480          if (pftmp->fieldType==14){ 
     481            agCache.outputSnmp = *((unsigned short*)&buffer2); 
    475482          }        
    476483#endif 
     
    547554                        sizeof(struct PrefixV4), prefGlobalCmp); 
    548555          if (res!=NULL){ 
    549             if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { 
     556/*          if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { */ 
     557            if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {          
    550558              /* OUT ("traffic from the prefix/subnet")  */ 
    551559              res->bytesNbOUT += agCache.bytes; 
    552560              res->pktsNbOUT += agCache.pkts; 
    553561              (res->flowNbOUT)++; 
     562              if (res->sampling == 0) { 
     563                res->sampling = myPtrs->currentRouterPtr->sampled; 
     564              } else if (res->sampling != myPtrs->currentRouterPtr->sampled) { 
     565                syslog(LOG_INFO, 
     566                       "2 sampling values for 1 subnet: %lu.%lu.%lu.%lu % from router %lu.%lu.%lu.%lu", 
     567                       agCache.v4AdS>>24, 
     568                       agCache.v4AdS<<8>>24, 
     569                       agCache.v4AdS<<16>>24, 
     570                       agCache.v4AdS<<24>>24, 
     571                       (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     572                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     573                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     574                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 
     575              } 
    554576              /* inter-pop matrix Accounting */ 
    555577              prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 
    556578              res2 = bsearch(&prefixKey, V4PTab, nbPV4,  
    557579                            sizeof(struct PrefixV4), prefGlobalCmp); 
    558               if (res2!=NULL){ 
     580              if (res2!=NULL){           
    559581                ((struct POP *)((myPtrs->matrixPOP) 
    560582                                +((res->routerNb)*ROUTER_INDEX_MAX) 
     
    588610            res = bsearch(&prefixKey, V4PTab, nbPV4,  
    589611                          sizeof(struct PrefixV4), prefGlobalCmp); 
    590             if (res!=NULL){  
    591               if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { 
    592                 /* IN ("traffic to the prefix")  */ 
     612            if (res!=NULL){ 
     613              if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1  ) {        
     614                /* IN ("traffic to the prefix/subnet")  */ 
    593615                res->bytesNbIN += agCache.bytes; 
    594616                res->pktsNbIN += agCache.pkts; 
    595                 (res->flowNbIN)++; 
    596               } else { 
     617                (res->flowNbIN)++;       
     618/*            if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) { */ 
     619/*               IN ("traffic to the prefix")  */  
     620/*              res->bytesNbIN += agCache.bytes; */ 
     621/*              res->pktsNbIN += agCache.pkts; */ 
     622/*              (res->flowNbIN)++; */ 
     623/*              if (res->sampling == 0) { */ 
     624/*                res->sampling = myPtrs->currentRouterPtr->sampled; */ 
     625/*              } else if (res->sampling !=  myPtrs->currentRouterPtr->sampled) { */ 
     626/*                syslog(LOG_INFO, */ 
     627/*                       "2 sampling values for 1 /: %lu.%lu.%lu.%lu % from router %lu.%lu.%lu.%lu", */ 
     628/*                       agCache.v4AdS>>24, */ 
     629/*                       agCache.v4AdS<<8>>24, */ 
     630/*                       agCache.v4AdS<<16>>24, */ 
     631/*                       agCache.v4AdS<<24>>24, */ 
     632/*                       (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 
     633/*                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
     634/*                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
     635/*                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); */ 
     636/*              } */ 
     637/*            } else { */ 
    597638                /* doublon or bad reference in prefix list */ 
    598                  
    599 /*              fprintf(stderr, "IN NC: %lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */ 
    600 /*                      (agCache.v4AdS>>24), */ 
    601 /*                      (agCache.v4AdS<<8>>24),  */ 
    602 /*                      (agCache.v4AdS<<16>>24),  */ 
    603 /*                      (agCache.v4AdS<<24>>24),  */ 
    604 /*                      (agCache.maskS),  */ 
    605 /*                      (agCache.v4AdD>>24),  */ 
    606 /*                      (agCache.v4AdD<<8>>24),  */ 
    607 /*                      (agCache.v4AdD<<16>>24),  */ 
    608 /*                      (agCache.v4AdD<<24>>24),  */ 
    609 /*                      (agCache.maskD),  */ 
    610 /*                      (myPtrs->pcktPtr->ipH->srcAdd>>24),  */ 
    611 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 
    612 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 
    613 /*                      (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */ 
    614 /*                      ); */ 
    615639              } 
    616640            } else { 
     
    788812          if (pftmp->fieldType==34){ 
    789813            if ((*((unsigned long*)&buffer4)==1)  
    790                 || (*((unsigned long*)&buffer4)==10)  
     814                || (*((unsigned long*)&buffer4)==10) 
     815                || (*((unsigned long*)&buffer4)==100) 
    791816                || (*((unsigned long*)&buffer4)==1000)) { 
    792817              if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 
     
    795820                        myPtrs->currentRouterPtr->sampled); 
    796821#endif                      
     822                syslog(LOG_INFO,"Sampling value change for router : %lu.%lu.%lu.%lu, old: %lu, new: %lu", 
     823                       (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     824                       (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     825                       (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     826                       (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 
     827                       myPtrs->currentRouterPtr->sampled, 
     828                       *((unsigned long*)&buffer4) 
     829                       ); 
    797830                myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 
    798                 for (i=0; i<nbPV4; i++) { 
    799                   /* we update the PrefixV4 structure with the sampled information */ 
    800                   if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 
    801                     V4PTab[i].sampling = *((unsigned long*)&buffer4); 
    802                     myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4); 
    803                   } 
    804                 } 
    805               } 
     831              } 
     832            }else{ 
     833              syslog(LOG_INFO,"Sampling value not standard for router : %lu.%lu.%lu.%lu", 
     834                     (myPtrs->pcktPtr->ipH->srcAdd>>24), 
     835                     (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 
     836                     (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 
     837                     (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) 
     838                     ); 
    806839            } 
    807840          } 
  • trunk/src/dataFlowSet.h

    r36 r58  
    7575  unsigned char ipProt; 
    7676  unsigned char sens; /* In/out field 61 */ 
    77   unsigned short idSnmp; 
     77  unsigned short inputSnmp; 
     78  unsigned short outputSnmp; 
    7879  unsigned long bytes; 
    7980  unsigned long pkts; 
  • trunk/src/renetcol.c

    r57 r58  
    3636FILE *fIP;                                 /* pointer on the IP output file */ 
    3737FILE *fMPLS;                              /* pointer on the MPLS output file */ 
    38  
    39 char *rulesFileName;                    /* file name of the rules (like acl) */ 
    40 char *configFileName;                   /* file name where routers list is */ 
    41 char *prefixV4FileName;                 /* IPv4 prefix list */ 
    4238 
    4339struct sigaction myAction; /* handler for renetcolSender communication */ 
     
    10197  key_t key; 
    10298  int i,j; 
    103    
    104   if ( argc != 4) { 
    105     fprintf (stderr, 
    106              "%s: Usage: %s <routers file> <prefix IPv4 file> <rules file>\n exp: %s routers.txt IPv4_prefix.txt rules.txt\n",  
    107              argv[0], argv[0], argv[0]); 
    108     exit(1); 
    109   } 
     99  int k; 
    110100 
    111101#ifdef IPV4AGG 
     
    114104   
    115105  openlog(argv[0], LOG_PID, LOG_USER); 
     106 
     107  initCache(); 
     108  /* GET the list of routers who are available to send NDE to the collector */ 
     109  if ( (routerNb = getRegisteredRouters(ROUTERS_LIST,  
     110                                        &sortedRouterList[0],  
     111                                        &indexedRouterList[0])) == -1) { 
     112    fprintf(stderr,  
     113            "ERROR in getRegisteredRouters from file %s\n",  
     114            ROUTERS_LIST); 
     115    exit(-1); 
     116  } 
     117  /* Create the list of routers */ 
     118  for (i=0; i<routerNb; i++){ 
     119    fprintf(stderr, "add router : %lu\n", sortedRouterList[i]); 
     120    routersListPtr = addRouter(routersListPtr, sortedRouterList[i]); 
     121  } 
    116122   
    117   configFileName = (char *) malloc((strlen(argv[1])+1) * sizeof(char)); 
    118   strcpy (configFileName, argv[1]); 
    119   prefixV4FileName = (char *) malloc((strlen(argv[2])+1) * sizeof(char)); 
    120   strcpy (prefixV4FileName, argv[2]); 
    121   rulesFileName = (char *) malloc((strlen(argv[3])+1) * sizeof(char)); 
    122   strcpy (rulesFileName, argv[3]); 
    123  
    124   initCache(); 
    125   routerNb = getRegisteredRouters(configFileName, &sortedRouterList[0],  
    126                                   &indexedRouterList[0]); 
     123  /* Shared memory */ 
    127124  key = 8765; 
    128125  if ((shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666)) < 0) { 
     
    135132  } 
    136133 
    137   if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 
     134  if ( (shmForAgg->v4PrefixNb = getPrefixV4(SUBNETS_LIST, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 
    138135    fprintf(stderr, "renetcol: Error \n"); 
    139136    exit(1); 
    140137  } 
    141   if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 
     138  if ( (shmForAgg->v4PrefixNb = getPrefixV4(SUBNETS_LIST, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 
    142139    fprintf(stderr, "renetcol:  Error \n"); 
    143140    exit(1); 
     
    148145  shmForAgg->readed = 0; 
    149146 
     147  /* get the rules */ 
    150148  myPtrs.rulesListPtr = NULL; 
    151 /*   myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); */ 
    152   myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, rulesFileName); 
     149  myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, RULES_FILE); 
    153150  tmp = myPtrs.rulesListPtr; 
    154151  for ( ; tmp->next; tmp=tmp->next) { 
     
    162159#endif 
    163160 
    164  
     161  /* the fork */ 
    165162  fprintf(stderr, "renetcol: I become a deamon, next messages via syslogd. By.\n"); 
    166163  if (fork () != 0) 
     
    177174  sigaction (SIGUSR1, &myAction, NULL); 
    178175 
    179   /* Pointer on rules Table */ 
     176  /* Cache for fast rules access */ 
    180177  setCache(myPtrs.rulesListPtr); 
    181178  myPtrs.rulesAddressPtr = (RuleDefPtr *)rulesAddress; 
    182179 
    183   /* init IPC messages queue */ 
     180  /* IPC messages queue init */ 
    184181  myKey = createKey(argv[0]); 
    185182  myQueue = createQueue(myKey); 
    186183  sendMyPid(myQueue); 
     184 
     185  /* get SNMP index information */ 
     186  k = getSNMPIndexList(INTERFACES_TYPE_LIST, routersListPtr); 
    187187 
    188188  /* INIT THE CURRENTS VARIABLES*/ 
     
    199199  myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]); 
    200200 
     201  /* INIT MATRIX TABLES */ 
    201202  for (i=0; i<ROUTER_INDEX_MAX; i++){ 
    202203    for (j=0; j<ROUTER_INDEX_MAX; j++) { 
     
    210211  } 
    211212 
     213  /* Checkup */ 
    212214  if (myPtrs.pcktPtr==NULL) { 
    213215    fprintf(stderr, "ERROR in struct Datagram allocation\n"); 
     
    217219    myPtrs.pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader)); 
    218220  } 
    219  
    220221  if (! (myPtrs.ptr_buffer = malloc(sockBufSize)))   
    221222    { 
     
    304305  } 
    305306  myPtrs.rulesListPtr = NULL; 
    306   myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, rulesFileName); 
     307  myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, RULES_FILE); 
    307308  tmp = myPtrs.rulesListPtr; 
    308309  for ( ; tmp; tmp=tmp->next) { 
     
    438439      if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr,  
    439440                                                  myPtrs.pcktPtr->ipH->srcAdd))==NULL) { 
    440         routersListPtr = addRouter(routersListPtr,  
    441                                    myPtrs.pcktPtr->ipH->srcAdd,  
    442                                    (unsigned long) 0, 
    443                                    shmForAgg->prefixV4Tab[shmForAgg->currentTable], 
    444                                    (size_t) shmForAgg->v4PrefixNb, 
    445                                    &myPtrs 
    446                                    ); 
    447441        myPtrs.currentRouterPtr = routersListPtr; 
    448442      } 
  • trunk/src/renetcolAgg.c

    r57 r58  
    2727 * In this file, I use directly the C rrd librairy to create and update 
    2828 * the rrd files which contain the statistique for each subnet. 
    29  * When your system (CPU+MEM+HD) is too fast and the number of your subnet too big 
     29 * When your system is too fast and the number of your subnet too big 
    3030 * (> 1024), the create and update process can be too fast and before the  
    3131 * creation end the maximum number of files which can be opened for one process 
  • trunk/src/renetcolParam.h

    r57 r58  
    3232#define RECEPTION_ADDRESS "" /* your collector address - syntax: 10.0.0.90 */ 
    3333#define RECEPTION_PORT 9999 /* your collector port to recept netflow export */ 
     34#define ROUTER_INDEX_MAX 55 /* routers number + 1 */ 
     35#define ROUTERS_LIST "/home/andreu/renetcol-0.0.12beta/src/routers.txt"     /* FILE with your routers IP address */  
     36#define SUBNETS_LIST "/home/andreu/renetcol-0.0.12beta/src/IPv4_prefix.txt"     /* FILE with your subnets */ 
     37#define RULES_FILE "/home/andreu/renetcol-0.0.12beta/src/rules.txt"       /* FILE for the rules */ 
     38#define INTERFACES_TYPE_LIST "" /* FILE with SNMP index of the interfaces */ 
     39                                /* tagged "C"ustomers or "B"ackbone */ 
     40#define MAX_SNMP_INDEX 900 /* maximum SNMP index for interfaces */ 
     41 
    3442#define STEP 5  /* interval - in min */ 
    35 #define ROUTER_INDEX_MAX 55 /* routers number + 1 */ 
    3643#define FIELD_TYPE_NUMBER 89 
    3744#define MAX_RULES_PER_FIELD 10 /* maximum rules number for one field */ 
  • trunk/src/renetcolSender.c

    r47 r58  
    3131long type; 
    3232RulesPtr rulesListPtr; 
    33 char *rulesFileName; 
    3433char *keyId; 
    3534char *remoteHost; 
     
    7877    if (strncmp("DELETE", buffer, 6)==0){ 
    7978      /* DELETE ALL RULES FROM A REMOTE CLIENT */ 
    80       if (!(ruleFile = fopen(rulesFileName, "r"))) { 
    81         syslog (LOG_ERR, "error during %s opening\n", rulesFileName); 
     79      if (!(ruleFile = fopen(RULES_FILE, "r"))) { 
     80        syslog (LOG_ERR, "error during %s opening\n", RULES_FILE); 
    8281        close(sock); 
    8382        exit(1); 
     
    116115          } 
    117116          fclose(tmpFile); 
    118           if (remove(rulesFileName)!=0){ 
     117          if (remove(RULES_FILE)!=0){ 
    119118            syslog(LOG_ERR, "rules.txt remove pb: %s", strerror(errno)); 
    120119            close(sock); 
    121120            return 1; 
    122121          } 
    123           if (rename(FILE_TEMPO, rulesFileName)!=0){ 
     122          if (rename(FILE_TEMPO, RULES_FILE)!=0){ 
    124123            syslog(LOG_ERR, "rename file pb: %s", strerror(errno)); 
    125124            close(sock); 
     
    139138        return 1; 
    140139      } 
    141       if (!(ruleFile = fopen(rulesFileName, "a"))) { 
    142         syslog (LOG_ERR, "error during %s opening", rulesFileName); 
     140      if (!(ruleFile = fopen(RULES_FILE, "a"))) { 
     141        syslog (LOG_ERR, "error during %s opening", RULES_FILE); 
    143142        close(sock); 
    144143        return 1; 
     
    278277  } 
    279278  rulesListPtr = NULL; 
    280   rulesListPtr = getRules(rulesListPtr, rulesFileName); 
     279  rulesListPtr = getRules(rulesListPtr, RULES_FILE); 
    281280  tmp = rulesListPtr; 
    282281  for ( ; tmp; tmp=tmp->next) { 
     
    300299  pid_t renetcolPID = 0; 
    301300 
    302   if ( argc != 4) { 
     301  if ( argc != 3) { 
    303302    fprintf (stderr, 
    304              "%s: Usage: %s <key> <msg type> <rules file>\n exp: %s renetcol 1 rules.txt\n",  
     303             "%s: Usage: %s <key> <msg type>\n exp: %s renetcol 1 \n",  
    305304             argv[0], argv[0], argv[0]); 
    306305    exit(1); 
     
    314313  keyId = (char *) malloc((strlen(argv[1])+1) * sizeof(char)); 
    315314  strcpy (keyId, argv[1]); 
    316   rulesFileName = (char *) malloc((strlen(argv[3])+1) * sizeof(char)); 
    317   strcpy (rulesFileName, argv[3]); 
    318315  rulesListPtr = NULL; 
    319   rulesListPtr = getRules(rulesListPtr, rulesFileName); 
     316  rulesListPtr = getRules(rulesListPtr, RULES_FILE); 
    320317  /* we delete rules which are not type socket */ 
    321318  tmp = rulesListPtr; 
  • trunk/src/routers_mgmt.c

    r31 r58  
    3333    i++; 
    3434    if ( tmp->IpAddress == address ){ 
    35 /*       fprintf (stderr, "ExistRouter %d parcours %lu.%lu.%lu.%lu\ \n",  */ 
    36 /*             i, */ 
    37 /*             address>>24, */ 
    38 /*             address<<8>>24, */ 
    39 /*             address<<16>>24, */ 
    40 /*             address<<24>>24 */ 
    41 /*             ); */ 
    4235      return tmp; 
    4336    } 
    4437  } 
    45 /*   fprintf (stderr, "notExistRouter %lu.%lu.%lu.%lu\n", */ 
    46 /*         address>>24, */ 
    47 /*         address<<8>>24, */ 
    48 /*         address<<16>>24, */ 
    49 /*         address<<24>>24); */ 
    5038  return NULL; 
    5139} 
    5240 
    53 RouterPtr addRouter(RouterPtr routersList, unsigned long address,  
    54                 unsigned long spled, struct PrefixV4 *V4PTab,  
    55                  size_t nbPV4, struct MyPtrs *myPtrs)  
    56 { 
    57   int i = 0; 
     41RouterPtr addRouter(RouterPtr routersList, unsigned long address)  
     42{ 
    5843  RouterPtr tmp = (RouterPtr) malloc(sizeof(struct Router)); 
    5944  if (tmp==NULL) { 
    60     /* FIXME : syslog here */ 
    61     fprintf(stderr, "ERROR in malloc in add_routers function\n"); 
     45    syslog(LOG_ERR, "ERROR in malloc in add_routers function\n"); 
    6246    exit(1); 
    6347  } else { 
     
    6549    tmp->tplList = NULL; 
    6650    tmp->tplOptList = NULL; 
    67     tmp->sampled = spled; 
     51    tmp->sampled = 1; /* ==1 required in case of no sampling configured */ 
    6852    tmp->next = routersList; 
    6953    if (routersList!=NULL) { routersList->prev = tmp;} 
    7054    tmp->prev = NULL; 
    71     /* initialization of the subnets which depend on this routers, aim: to create the rrd files */ 
    72     for (i=0; i<nbPV4; i++) { 
    73       if ( tmp->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 
    74         V4PTab[i].sampling = 1; 
    75         myPtrs->secondV4Tab[i].sampling = 1;  
    76       } 
    77     } 
    7855    return tmp; 
    7956  } 
     57} 
     58 
     59RouterPtr updateRouter(RouterPtr routersList, unsigned long address,  
     60                       unsigned long spled)  
     61{ 
     62  RouterPtr tmp = NULL; 
     63  if ((tmp = notExistRouter(routersList,  
     64                            address))==NULL) { 
     65    syslog(LOG_INFO,"Router Address not registered : %lu.%lu.%lu.%lu)", 
     66           (address>>24), 
     67           (address<<8>>24), 
     68           (address<<16>>24), 
     69           (address<<24>>24)); 
     70    return routersList; 
     71  } else { 
     72    fprintf(stderr, "\nSAMPLED VALUE: %lu\n", spled); 
     73    tmp->sampled = spled;  
     74    return tmp; 
     75  } 
     76  return NULL; 
    8077} 
    8178 
     
    151148  return NULL; /* FIXME I don't known */ 
    152149} 
     150 
     151int getSNMPIndexList(char *filename, RouterPtr routersListPtr) 
     152{ 
     153  FILE *indexFile = NULL; 
     154  char line[200]; 
     155  int cptLine = 0; 
     156  char tindex[5]; 
     157  char ttoken[2]; 
     158  char tid[2]; 
     159  char tad[16]; 
     160  int index = 0; 
     161  unsigned short n0, n1, n2, n3; 
     162  unsigned char buffer4[4]; 
     163  unsigned long ipAddress; 
     164  RouterPtr routerTmp = NULL; 
     165 
     166  if (!(indexFile = fopen(filename, "r"))) { 
     167    fprintf (stderr, "error during %s opening\n", filename); 
     168    exit(1); 
     169  } 
     170  while ( fgets(line, 200, indexFile) != 0) {     
     171    cptLine++; 
     172    if ( strspn(line, "R") == 1 ) { 
     173      if (sscanf(line, "%s %s\n", 
     174                 ttoken, 
     175                 tad) == 0) { 
     176        fprintf(stderr, "Error in file %s, line %d\n",  
     177                filename, cptLine); 
     178        exit(1); 
     179      } 
     180      if (sscanf(tad,"%hu.%hu.%hu.%hu\n",&n0,&n1,&n2,&n3) == 0){ 
     181        fprintf(stderr, "Address error in file %s, line %d\n",  
     182                filename, cptLine); 
     183        exit(1); 
     184      } 
     185      buffer4[3] = (unsigned char)n0; 
     186      buffer4[2] = (unsigned char)n1; 
     187      buffer4[1] = (unsigned char)n2; 
     188      buffer4[0] = (unsigned char)n3;    
     189      ipAddress = *((unsigned long*)(&buffer4)); 
     190      if ((routerTmp = notExistRouter(routersListPtr, 
     191                                      ipAddress))==NULL){ 
     192        fprintf(stderr, "Error in file %s, line %d : IP unknown : %lu\n", 
     193                filename, cptLine, ipAddress); 
     194        exit(1); 
     195      } 
     196    }else{ 
     197      if ( strspn(line, "I") == 1 ) { 
     198        if (sscanf(line, "%s %s %s\n", 
     199                   ttoken, 
     200                   tindex, 
     201                   tid) == 0) { 
     202          fprintf(stderr, "Error in file %s, line %d\n",  
     203                  filename, cptLine); 
     204          exit(1); 
     205        } 
     206        index = atoi(tindex); 
     207        if ( strcmp(tid, "B") == 0 ) { 
     208          routerTmp->snmpIndexList[index] = 0; 
     209        } else if ( strcmp(tid, "C") == 0 ) { 
     210          routerTmp->snmpIndexList[index] = 1; 
     211        } else { 
     212          fprintf(stderr, "Error in file %s, line %d : bad code B or C \n",  
     213                  filename, cptLine); 
     214          exit(1); 
     215        } 
     216      } else { 
     217        fprintf(stderr, "Error in file %s, line %d : bad index line \n",  
     218                filename, cptLine); 
     219        exit(1); 
     220      } 
     221    } 
     222  } 
     223  return 1; 
     224} 
  • trunk/src/routers_mgmt.h

    r57 r58  
    3232#include <errno.h> 
    3333#include <sys/ioctl.h> 
     34#include <syslog.h> 
    3435 
     36#include "renetcolParam.h" 
    3537#include "tplflset_mgmt.h" 
    3638#include "get_conf.h" 
     
    4244typedef struct Router * RouterPtr; 
    4345typedef struct Router { 
    44   unsigned long IpAddress; 
    45   TplFlowSetPtr tplList; 
    46   TplOptionPtr tplOptList; 
    47   unsigned long sampled; 
     46  unsigned long IpAddress; /* IP address used for NDE (often a loopback) */ 
     47  TplFlowSetPtr tplList;   /* list of the template definition */ 
     48  TplOptionPtr tplOptList; /* list of the optional template definitions */ 
     49  unsigned long sampled; /* sampling value: (one for) 10, 100 or 1(full mode)*/ 
     50  unsigned short snmpIndexList[MAX_SNMP_INDEX]; /* 0:Backbone, 1:Customer */ 
    4851  RouterPtr next; 
    4952  RouterPtr prev; 
     
    6770 
    6871RouterPtr notExistRouter(RouterPtr, unsigned long); 
    69 RouterPtr addRouter(RouterPtr, unsigned long, unsigned long, struct PrefixV4 *, size_t, struct MyPtrs *); 
     72RouterPtr addRouter(RouterPtr, unsigned long); 
     73RouterPtr updateRouter(RouterPtr, unsigned long, unsigned long); 
    7074TplFlowSetPtr newRouterTplList(); 
    7175TplFlowSetPtr deleteTplFlSet(TplFlowSetPtr); 
    7276TplOptionPtr newRouterTplOptList(); 
    7377TplOptionPtr deleteTplOption(TplOptionPtr); 
     78int getSNMPIndexList(char *, RouterPtr); 
    7479 
    7580/*int rm_routers(p_routers, unsigned long); 
  • trunk/tool/renetcolGUI.py

    r57 r58  
    155155        resS = 1 
    156156        resD = 1 
     157        resInIndex = 1 
     158        resOutIndex = 1 
    157159        for i in range (0, len(tpl_def[self.flow[0]])): 
    158160            f = tpl_def[self.flow[0]][i][0] 
     
    166168            elif ( (f==1) and (checkUpValues[f]==1) ): 
    167169                res = res & ( (self.flow[1][i] <= ((firstParseValue[f])+((firstParseValue[f])*5/100))) and ((self.flow[1][i] >= ((firstParseValue[f])-((firstParseValue[f])*5/100)))) ) 
     170            elif ((f==10) and (checkUpValues[f]==1)): 
     171                resInIndex = resInIndex & ( self.flow[1][i] == firstParseValue[f]) 
     172            elif ((f==14) and (checkUpValues[f]==1)): 
     173                resOutIndex = resOutIndex & ( self.flow[1][i] == firstParseValue[f]) 
    168174            elif (checkUpValues[f]==1): 
    169175                res = res & (self.flow[1][i] == firstParseValue[f]) 
    170176        if ( checkUpValues[69]==1 ): 
    171177            res = res & ( (fromRouter == firstParseValue[69]) ) 
    172         res = res & (resS or resD) 
     178        res = res & (resS or resD) & (resInIndex or resOutIndex) 
    173179        return res 
    174180