- Timestamp:
- 09/25/06 18:21:02 (17 years ago)
- Location:
- trunk/src
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dataFlowSet.c
r18 r19 89 89 mplsFirstCache.v4AdS = 0; 90 90 mplsFirstCache.v4AdD = 0; 91 mplsFirstCache.outSnmp = 0; 92 mplsFirstCache.inSnmp = 0; 91 93 mplsFirstCache.routerAd = 0; 92 94 mplsFirstCache.mplsLabel1 = 0; 95 93 96 /* CRI */ 94 97 … … 196 199 ipFirstCache.tProt = *((unsigned char*)&buffer1); 197 200 } 201 /* if (pftmp->fieldType==46){ */ 202 /* mplsFirstCache.topLabelType = *((unsigned char*)&buffer1); */ 203 /* } */ 198 204 /* end CRI */ 199 205 break; … … 212 218 if (pftmp->fieldType==10){ 213 219 ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 220 mplsFirstCache.inSnmp = *((unsigned short*)&buffer2); 214 221 } 215 222 if (pftmp->fieldType==14){ 216 223 ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 224 mplsFirstCache.outSnmp = *((unsigned short*)&buffer2); 217 225 } 218 226 if (pftmp->fieldType==7){ … … 270 278 if (pftmp->fieldType==8){ 271 279 ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 280 mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); 272 281 } 273 282 if (pftmp->fieldType==12){ 274 283 ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 284 mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); 275 285 } 276 286 if (pftmp->fieldType==1){ … … 472 482 ipFirstCache.tProt = *((unsigned char*)&buffer1); 473 483 } 484 /* if (pftmp->fieldType==46){ */ 485 /* mplsFirstCache.topLabelType = *((unsigned char*)&buffer1); */ 486 /* } */ 474 487 break; 475 488 case 2: … … 484 497 if (pftmp->fieldType==10){ 485 498 ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 499 mplsFirstCache.inSnmp = *((unsigned short*)&buffer2); 486 500 } 487 501 if (pftmp->fieldType==14){ 488 502 ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 503 mplsFirstCache.outSnmp = *((unsigned short*)&buffer2); 489 504 } 490 505 if (pftmp->fieldType==7){ … … 529 544 if (pftmp->fieldType==8){ 530 545 ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 546 mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); 531 547 } 532 548 if (pftmp->fieldType==12){ 533 549 ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 550 mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); 534 551 } 535 552 if (pftmp->fieldType==1){ … … 569 586 */ 570 587 /* CRI */ 571 printf("!");572 588 if ( mplsFirstCache.mplsLabel1 == 0 ) { 573 589 (ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt; … … 600 616 (*ipCounter)++; 601 617 } else { 602 printf("im\n");603 618 (mplsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt; 604 619 mplsFirstCache.ipProt = 0; 620 /* (mplsCache+(*mplsCounter))->topLabelType = mplsFirstCache.topLabelType; */ 621 /* mplsFirstCache.topLabelType = 0; */ 605 622 (mplsCache+(*mplsCounter))->v4AdS = mplsFirstCache.v4AdS; 606 623 mplsFirstCache.v4AdS = 0; 607 624 (mplsCache+(*mplsCounter))->v4AdD = mplsFirstCache.v4AdD; 608 625 mplsFirstCache.v4AdD = 0; 626 (mplsCache+(*mplsCounter))->inSnmp = mplsFirstCache.inSnmp; 627 mplsFirstCache.inSnmp = 0; 628 (mplsCache+(*mplsCounter))->outSnmp = mplsFirstCache.outSnmp; 629 mplsFirstCache.outSnmp = 0; 609 630 (mplsCache+(*mplsCounter))->routerAd = mplsFirstCache.routerAd; 610 631 (mplsCache+(*mplsCounter))->mplsLabel1 = mplsFirstCache.mplsLabel1; … … 612 633 (*mplsCounter)++; 613 634 } 614 /* CRI */635 /* end CRI */ 615 636 /* put aggregation cache information to tables */ 616 637 if (bool == 1){ -
trunk/src/dataFlowSet.h
r18 r19 37 37 #include "prefix_mgmt.h" 38 38 39 #define MAX_IP_FLOW 100040 #define MAX_MPLS_FLOW 100041 42 39 struct IPFLowCache { 43 40 unsigned char ipProt; /* not write in file, just to know IP version */ … … 65 62 unsigned long v4AdS; 66 63 unsigned long v4AdD; 64 unsigned short inSnmp; 65 unsigned short outSnmp; 67 66 uint32_t tabAdd6S[4]; 68 67 uint32_t tabAdd6D[4]; -
trunk/src/renetcol.c
r18 r19 33 33 unsigned long *ipNbPtr = &ipNb; 34 34 unsigned long *mplsNbPtr = &mplsNb; 35 unsigned short currentIPOutputFile = 0; 36 unsigned short currentMPLSOutputFile = 0; 37 char outputName[256]; 38 char cof_str[20]; 35 39 FILE *fIP; 36 40 FILE *fMPLS; 37 /* end */ 41 /* end */ 38 42 39 43 char *rulesFileName; … … 332 336 int regRouter = 0; 333 337 /* CRI */ 338 time_t now = time((time_t *)NULL); 334 339 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; 337 347 do { 338 348 if (sigusr1Up == 1){ … … 401 411 402 412 /* 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) { 405 431 syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno)); 406 432 } else { 407 433 for ( iIP = 0; iIP < ipNb; iIP++){ 408 printf("ipv4\n");409 434 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", 412 436 tabIP[iIP].bytes, tabIP[iIP].pkts, 413 437 tabIP[iIP].inSnmp, tabIP[iIP].outSnmp, … … 420 444 tabIP[iIP].maskS, tabIP[iIP].routerAd>>24, 421 445 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 423 448 ); 424 449 } … … 427 452 } 428 453 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) { 432 473 syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno)); 433 474 } else { 434 475 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", 437 478 tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24, 438 479 tabMPLS[iMPLS].routerAd<<16>>24, 439 480 tabMPLS[iMPLS].routerAd<<24>>24, 440 tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24, 481 tabMPLS[iMPLS].mplsLabel1, 482 tabMPLS[iMPLS].v4AdS>>24, 441 483 tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24, 442 484 tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24, 443 485 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 445 489 ); 446 490 } … … 449 493 } 450 494 mplsNb = 0; 495 lastMPLSOutput = now; 451 496 } 452 497 /* end CRI */ -
trunk/src/renetcol.h
r18 r19 74 74 #define MAX_RULES_PER_FIELD 10 75 75 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 */ 78 87 79 88 void setCache(RulesPtr);