- Timestamp:
- 09/26/07 14:13:56 (15 years ago)
- Location:
- trunk/src
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dataFlowSet.c
r55 r57 63 63 msgType myMsg; 64 64 char *msgTextIndex; 65 char *msgToSend; 65 66 66 unsigned short tplMsgType = 11; 67 67 struct PrefixV4 prefixKey, *res, *res2; /* for bsearch */ … … 73 73 int crazyCounter = 0; 74 74 75 #ifdef CRIHAN 76 struct IPFLowCache ipFirstCache; 77 struct MPLSFlowCache mplsFirstCache; 78 unsigned long firstTime = 0; 79 unsigned long lastTime = 0; 80 81 ipFirstCache.ipProt = 0; 82 ipFirstCache.bytes = 0; 83 ipFirstCache.pkts = 0; 84 ipFirstCache.inSnmp = 0; 85 ipFirstCache.outSnmp = 0; 86 ipFirstCache.v4AdS = 0; 87 ipFirstCache.v4AdD = 0; 88 ipFirstCache.tProt = 0; 89 ipFirstCache.sPort = 0; 90 ipFirstCache.dPort = 0; 91 ipFirstCache.maskD = 0; 92 ipFirstCache.maskS = 0; 93 ipFirstCache.routerAd = 0; 94 ipFirstCache.liveTime = 0; 95 mplsFirstCache.ipProt = 0; 96 mplsFirstCache.v4AdS = 0; 97 mplsFirstCache.v4AdD = 0; 98 mplsFirstCache.routerAd = 0; 99 mplsFirstCache.mplsLabel1 = 0; 100 #endif /* CRIHAN */ 101 102 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 103 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 75 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 76 (*myPtrs->offsetV9Ptr)++; 77 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 78 (*myPtrs->offsetV9Ptr)++; 104 79 (*myPtrs->currentFlowsetIdPtr) = *((unsigned short*)&buffer2); 105 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 106 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 80 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 81 (*myPtrs->offsetV9Ptr)++; 82 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 83 (*myPtrs->offsetV9Ptr)++; 107 84 data_length = *((unsigned short*)&buffer2); 108 85 109 if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId, 110 (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 86 if ( (tmp=existTplId(myPtrs->currentRouterPtr, 87 myPtrs->currentHeaderV9Ptr->sourceId, 88 (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 111 89 #ifdef DEBUG 112 fprintf(stderr,"{d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 90 fprintf(stderr, 91 "{d id: %hu, lg %hu", 92 (*myPtrs->currentFlowsetIdPtr), 93 data_length); 113 94 if ( (*myPtrs->currentFlowsetIdPtr) > TRESHOLD_TEMPLATE_ID ) { 114 95 /* fprintf(stderr,"Bad TID from router: %lu.%lu.%lu.%lu\n", */ … … 155 136 #endif 156 137 157 #ifdef CRIHAN158 ipFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;159 mplsFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;160 #endif /* CRIHAN */161 162 138 pftmp = tmp->lastField; 163 139 secondPftmp = tmp->lastField; 164 140 secondOffset = *myPtrs->offsetV9Ptr; 165 141 secondOldOffset = secondOffset; 166 while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) { 142 while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) 143 && (overflow!=1) ) { 167 144 /* 168 145 * progression in a data flow Set … … 179 156 /* FIXME : this code is repeated, perhaps past before */ 180 157 while ( ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j))) != NULL ) { 181 if 158 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j)))->value->stor.lvalue) 182 159 == myPtrs->pcktPtr->ipH->srcAdd ) 183 160 { … … 206 183 switch (field_size) { 207 184 case 1: 208 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 185 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 186 (*myPtrs->offsetV9Ptr)++; 209 187 /* rule check */ 210 188 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.cvalue … … 233 211 } 234 212 #endif 235 #ifdef CRIHAN236 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){237 ipFirstCache.maskS = *((unsigned char*)&buffer1);238 }239 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){240 ipFirstCache.maskD = *((unsigned char*)&buffer1);241 }242 if (pftmp->fieldType==60){243 ipFirstCache.ipProt = *((unsigned char*)&buffer1);244 mplsFirstCache.ipProt = *((unsigned char*)&buffer1);245 }246 if (pftmp->fieldType==4){247 ipFirstCache.tProt = *((unsigned char*)&buffer1);248 }249 #endif250 213 break; 251 214 case 2: 252 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 253 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 215 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 216 (*myPtrs->offsetV9Ptr)++; 217 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 218 (*myPtrs->offsetV9Ptr)++; 254 219 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue 255 220 == *((unsigned short*)&buffer2)) … … 260 225 } 261 226 #endif 262 #ifdef CRIHAN263 /* FIXME : add this two following bloc in the case N = 4 */264 if (pftmp->fieldType==10){265 ipFirstCache.inSnmp = *((unsigned short*)&buffer2);266 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue)267 == (*((unsigned short*)&buffer2))268 )269 {270 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;271 }272 }273 if (pftmp->fieldType==14){274 ipFirstCache.outSnmp = *((unsigned short*)&buffer2);275 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue)276 == (*((unsigned short*)&buffer2))277 )278 {279 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;280 }281 }282 if (pftmp->fieldType==7){283 ipFirstCache.sPort = *((unsigned short*)&buffer2);284 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue)285 == (*((unsigned short*)&buffer2))286 )287 {288 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;289 }290 }291 if (pftmp->fieldType==11){292 ipFirstCache.dPort = *((unsigned short*)&buffer2);293 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue)294 == (*((unsigned short*)&buffer2))295 )296 {297 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;298 }299 }300 #endif301 227 break; 302 228 case 3: 303 229 buffer4[3]= 0; 304 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 305 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 306 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 230 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 231 (*myPtrs->offsetV9Ptr)++; 232 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 233 (*myPtrs->offsetV9Ptr)++; 234 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 235 (*myPtrs->offsetV9Ptr)++; 307 236 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue 308 237 == *((unsigned long*)&buffer4)) … … 313 242 isMplsFlow = 1; 314 243 } 315 #ifdef CRIHAN316 if (pftmp->fieldType==70){317 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4;318 }319 #endif320 244 break; 321 245 case 4: 322 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 323 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 324 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 325 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 246 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 247 (*myPtrs->offsetV9Ptr)++; 248 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 249 (*myPtrs->offsetV9Ptr)++; 250 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 251 (*myPtrs->offsetV9Ptr)++; 252 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 253 (*myPtrs->offsetV9Ptr)++; 326 254 /* FIXME : here , add a check on the field type */ 327 255 if ((pftmp->fieldType==8)||(pftmp->fieldType==12)){ … … 360 288 } 361 289 #endif 362 #ifdef CRIHAN363 if (pftmp->fieldType==8){364 ipFirstCache.v4AdS = *((unsigned long*)&buffer4);365 mplsFirstCache.v4AdS = *((unsigned long*)&buffer4);366 }367 if (pftmp->fieldType==12){368 ipFirstCache.v4AdD = *((unsigned long*)&buffer4);369 mplsFirstCache.v4AdD = *((unsigned long*)&buffer4);370 }371 if (pftmp->fieldType==1){372 ipFirstCache.bytes = *((unsigned long*)&buffer4);373 }374 if (pftmp->fieldType==2){375 ipFirstCache.pkts = *((unsigned long*)&buffer4);376 }377 if (pftmp->fieldType==22){378 firstTime = *((unsigned long*)&buffer4);379 }380 if (pftmp->fieldType==21){381 lastTime = *((unsigned long*)&buffer4);382 }383 #endif384 290 break; 385 291 case 16: 386 292 for (i=0; i<4; i++) { 387 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 388 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 389 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 390 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 293 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 294 (*myPtrs->offsetV9Ptr)++; 295 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 296 (*myPtrs->offsetV9Ptr)++; 297 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 298 (*myPtrs->offsetV9Ptr)++; 299 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 300 (*myPtrs->offsetV9Ptr)++; 391 301 if (1==moreIsNecessary){ 392 302 switch(i){ … … 532 442 switch (field_size) { 533 443 case 1: 534 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 444 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 445 (*myPtrs->offsetV9Ptr)++; 535 446 #ifdef IPV4AGG 536 447 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ … … 553 464 } 554 465 #endif 555 #ifdef CRIHAN556 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){557 ipFirstCache.maskS = *((unsigned char*)&buffer1);558 }559 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){560 ipFirstCache.maskD = *((unsigned char*)&buffer1);561 }562 if (pftmp->fieldType==60){563 ipFirstCache.ipProt = *((unsigned char*)&buffer1);564 mplsFirstCache.ipProt = *((unsigned char*)&buffer1);565 }566 if (pftmp->fieldType==4){567 ipFirstCache.tProt = *((unsigned char*)&buffer1);568 }569 #endif570 466 break; 571 467 case 2: 572 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 573 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 468 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 469 (*myPtrs->offsetV9Ptr)++; 470 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 471 (*myPtrs->offsetV9Ptr)++; 574 472 #ifdef IPV4AGG 575 473 if (pftmp->fieldType==10){ … … 577 475 } 578 476 #endif 579 #ifdef CRIHAN580 if (pftmp->fieldType==10){581 ipFirstCache.inSnmp = *((unsigned short*)&buffer2);582 }583 if (pftmp->fieldType==14){584 ipFirstCache.outSnmp = *((unsigned short*)&buffer2);585 }586 if (pftmp->fieldType==7){587 ipFirstCache.sPort = *((unsigned short*)&buffer2);588 }589 if (pftmp->fieldType==11){590 ipFirstCache.dPort = *((unsigned short*)&buffer2);591 }592 #endif593 477 break; 594 478 case 3: 595 479 buffer4[3]= 0; 596 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 597 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 598 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 480 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 481 (*myPtrs->offsetV9Ptr)++; 482 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 483 (*myPtrs->offsetV9Ptr)++; 484 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 485 (*myPtrs->offsetV9Ptr)++; 599 486 /* aggregation */ 600 487 /* end aggregation */ … … 602 489 isMplsFlow = 1; 603 490 } 604 #ifdef CRIHAN605 if (pftmp->fieldType==70){606 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4;607 }608 #endif609 491 break; 610 492 case 4: 611 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 612 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 613 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 614 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 493 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 494 (*myPtrs->offsetV9Ptr)++; 495 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 496 (*myPtrs->offsetV9Ptr)++; 497 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 498 (*myPtrs->offsetV9Ptr)++; 499 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 500 (*myPtrs->offsetV9Ptr)++; 615 501 #ifdef IPV4AGG 616 502 if ((pftmp->fieldType==8)){ … … 625 511 } 626 512 #endif 627 #ifdef CRIHAN628 if (pftmp->fieldType==8){629 ipFirstCache.v4AdS = *((unsigned long*)&buffer4);630 mplsFirstCache.v4AdS = *((unsigned long*)&buffer4);631 }632 if (pftmp->fieldType==12){633 ipFirstCache.v4AdD = *((unsigned long*)&buffer4);634 mplsFirstCache.v4AdD = *((unsigned long*)&buffer4);635 }636 if (pftmp->fieldType==1){637 ipFirstCache.bytes = *((unsigned long*)&buffer4);638 }639 if (pftmp->fieldType==2){640 ipFirstCache.pkts = *((unsigned long*)&buffer4);641 }642 if (pftmp->fieldType==22){643 firstTime = *((unsigned long*)&buffer4);644 }645 if (pftmp->fieldType==21){646 lastTime = *((unsigned long*)&buffer4);647 }648 #endif649 513 break; 650 514 case 16: 651 515 for (i=0; i<4; i++) { 652 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 653 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 654 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 655 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 516 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 517 (*myPtrs->offsetV9Ptr)++; 518 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 519 (*myPtrs->offsetV9Ptr)++; 520 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 521 (*myPtrs->offsetV9Ptr)++; 522 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); 523 (*myPtrs->offsetV9Ptr)++; 656 524 } 657 525 /* aggregation IPv6 */ … … 669 537 * end of one flow (not the flowset) 670 538 */ 671 #ifdef CRIHAN 672 if ( mplsFirstCache.mplsLabel1 == 0 ) { 673 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->ipProt = ipFirstCache.ipProt; 674 ipFirstCache.ipProt = 0; 675 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->bytes = ipFirstCache.bytes; 676 ipFirstCache.bytes = 0; 677 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->pkts = ipFirstCache.pkts; 678 ipFirstCache.pkts = 0; 679 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->inSnmp = ipFirstCache.inSnmp; 680 ipFirstCache.inSnmp = 0; 681 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->outSnmp = ipFirstCache.outSnmp; 682 ipFirstCache.outSnmp = 0; 683 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdS = ipFirstCache.v4AdS; 684 ipFirstCache.outSnmp = 0; 685 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdD = ipFirstCache.v4AdD; 686 ipFirstCache.v4AdD = 0; 687 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->tProt = ipFirstCache.tProt; 688 ipFirstCache.tProt = 0; 689 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->sPort = ipFirstCache.sPort; 690 ipFirstCache.sPort = 0; 691 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->dPort = ipFirstCache.dPort; 692 ipFirstCache.dPort = 0; 693 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskD = ipFirstCache.maskD; 694 ipFirstCache.maskD = 0; 695 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskS = ipFirstCache.maskS; 696 ipFirstCache.maskS = 0; 697 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->routerAd = ipFirstCache.routerAd; 698 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->liveTime = lastTime - firstTime; 699 firstTime = 0; lastTime = 0; 700 (*myPtrs->ipNbPtr)++; 701 } else { 702 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->ipProt = mplsFirstCache.ipProt; 703 mplsFirstCache.ipProt = 0; 704 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdS = mplsFirstCache.v4AdS; 705 mplsFirstCache.v4AdS = 0; 706 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdD = mplsFirstCache.v4AdD; 707 mplsFirstCache.v4AdD = 0; 708 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->routerAd = mplsFirstCache.routerAd; 709 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->mplsLabel1 = mplsFirstCache.mplsLabel1; 710 mplsFirstCache.mplsLabel1 = 0; 711 (*myPtrs->mplsNbPtr)++; 712 } 713 #endif 539 714 540 /* put aggregation cache information to IPv4 Prefixes table */ 715 541 /* Aggregation mode must be enable in ./configure options */ 716 542 /* first we must know if the address belong to our prefix */ 717 myPtrs->nbFluxTT++;718 543 #ifdef IPV4AGG 719 544 if ( (bool == 1) && (isMplsFlow == 0) ){ … … 723 548 if (res!=NULL){ 724 549 if ( myPtrs->routersID[res->routerNb] == agCache.routerAd ) { 725 myPtrs->nbFluxSR4++;726 550 /* OUT ("traffic from the prefix/subnet") */ 727 551 res->bytesNbOUT += agCache.bytes; … … 733 557 sizeof(struct PrefixV4), prefGlobalCmp); 734 558 if (res2!=NULL){ 735 myPtrs->nbFluxIR4++;736 559 ((struct POP *)((myPtrs->matrixPOP) 737 560 +((res->routerNb)*ROUTER_INDEX_MAX) … … 744 567 +((res2->routerNb))))->flowNb++; 745 568 } else { 746 myPtrs->nbFluxSE++;747 569 ( 748 570 ((struct POP *)(myPtrs->matrixPOP) … … 799 621 /* - prefix not referenced but not allowed to be routed */ 800 622 /* - spoofing */ 801 myPtrs->nbFluxUK++;802 623 #ifdef PRINTUNKNOWNSUBNET 803 624 fprintf(stderr, "%lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu (R:%lu.%lu.%lu.%lu) \n", … … 869 690 ); 870 691 myMsg.type = 1; 871 /* OLD transfert type */ 872 /* msgSend( myQueue, myMsg); */ 692 693 873 694 /* NEW transfert type */ 874 695 for ( ; tmpRL; tmpRL=tmpRL->next){ -
trunk/src/renetcol.c
r47 r57 29 29 30 30 struct SHMForAgg *shmForAgg; 31 32 struct IPFLowCache tabIP[MAX_IP_FLOW];33 struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW];34 unsigned long ipNb = 0; /* counter of IP flows number */35 unsigned long mplsNb = 0; /* counter of MPLS flow number */36 31 37 32 unsigned short currentIPOutputFile = 0; /* index on the current IP file */ … … 78 73 int reInitConf = 0; 79 74 80 static time_t lastRock;81 75 static struct tm *tmPtr; 82 76 … … 115 109 } 116 110 117 #ifdef CRIHAN118 fprintf(stderr, "renetcol compilation with CRIHAN feature enable\n");119 #endif120 111 #ifdef IPV4AGG 121 112 fprintf(stderr, "renetcol compilation and execution with IPv4 Aggregation feature enable\n"); … … 203 194 myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 204 195 myPtrs.currentFlowsetNumberPtr = ¤tFlowsetNumber; 205 myPtrs.ipNbPtr = &ipNb;206 myPtrs.mplsNbPtr = &mplsNb;207 196 myPtrs.routersID = &indexedRouterList; 208 197 myPtrs.currentV4Tab = shmForAgg->prefixV4Tab[shmForAgg->currentTable]; 209 198 myPtrs.secondV4Tab = shmForAgg->prefixV4Tab[shmForAgg->secondTable]; 210 199 myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]); 211 212 myPtrs.nbFluxSR4 =0;213 myPtrs.nbFluxSE =0;214 myPtrs.nbFluxIR4 =0;215 myPtrs.nbFluxUK = 0;216 myPtrs.nbFluxTT = 0;217 200 218 201 for (i=0; i<ROUTER_INDEX_MAX; i++){ … … 412 395 int regRouter = 0; 413 396 time_t now = time((time_t *)NULL); 414 int iIP, iMPLS, i, z, x;415 397 int loopNb = 0; 416 398 int gardeFou = 0; 417 399 time_t lastIPOutput, lastMPLSOutput; 418 time_t receptionTime;419 400 420 401 now = time((time_t *)NULL); … … 438 419 shmForAgg->readed = 1; 439 420 myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]); 440 fprintf(stderr,"\n\nComptage FLUX:\n SR4: %llu\n SE: %llu\n IR4: %llu\n UK: %llu\n TT: %llu\n",441 myPtrs.nbFluxSR4,442 myPtrs.nbFluxSE,443 myPtrs.nbFluxIR4,444 myPtrs.nbFluxUK,445 myPtrs.nbFluxTT446 );447 myPtrs.nbFluxSR4 =0;448 myPtrs.nbFluxSE =0;449 myPtrs.nbFluxIR4 =0;450 myPtrs.nbFluxUK = 0;451 myPtrs.nbFluxTT = 0;452 421 } 453 422 if (sigusr1Up == 1){ … … 487 456 myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 488 457 if ( currentFlowsetId == 0 ) { 489 if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 490 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 458 if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, 459 myPtrs.offsetV9Ptr, 460 myPtrs.ptr_buffer, 461 myPtrs.currentHeaderV9Ptr, 491 462 curTplFlSetPtr, 492 463 myPtrs.currentFlowsetNumberPtr, … … 499 470 writeAllTplFlSet(); 500 471 } else if (currentFlowsetId == 1) { 501 if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 502 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 503 curTplOptionPtr, 472 if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, 473 myPtrs.offsetV9Ptr, 474 myPtrs.ptr_buffer, 475 myPtrs.currentHeaderV9Ptr, 476 curTplOptionPtr, 504 477 myPtrs.currentFlowsetNumberPtr) ) < 0 ) { 505 478 #ifdef DEBUG … … 549 522 loopNb++; 550 523 551 #ifdef CRIHAN552 now = time((time_t *)NULL);553 receptionTime = now;554 if ( (ipNb > (MAX_IP_FLOW - 50)) ||555 ( (now-lastIPOutput) > IP_TIME_THRESHOLD) ) {556 outputName[0] = '\0';557 sprintf(cof_str, "%d", currentIPOutputFile);558 strcat(outputName, OUTPUT_IP);559 strcat(outputName, cof_str);560 strcat(outputName, EXTENSION);561 if (fopen(outputName, "x") == NULL) {562 currentIPOutputFile = (currentIPOutputFile + 1)%MAX_IP_OUTPUT_FILES;563 outputName[0] = '\0';564 sprintf(cof_str, "%d", currentIPOutputFile);565 strcat(outputName, OUTPUT_IP);566 strcat(outputName, cof_str);567 strcat(outputName, EXTENSION);568 }569 if ((fIP = fopen(outputName, "w")) == NULL) {570 syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno));571 } else {572 for ( iIP = 0; iIP < ipNb; iIP++){573 if ( tabIP[iIP].ipProt == 0 ) {574 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",575 tabIP[iIP].bytes, tabIP[iIP].pkts,576 tabIP[iIP].inSnmp, tabIP[iIP].outSnmp,577 tabIP[iIP].v4AdS>>24, tabIP[iIP].v4AdS<<8>>24,578 tabIP[iIP].v4AdS<<16>>24, tabIP[iIP].v4AdS<<24>>24,579 tabIP[iIP].v4AdD>>24, tabIP[iIP].v4AdD<<8>>24,580 tabIP[iIP].v4AdD<<16>>24, tabIP[iIP].v4AdD<<24>>24,581 tabIP[iIP].tProt, tabIP[iIP].sPort,582 tabIP[iIP].dPort, tabIP[iIP].maskD,583 tabIP[iIP].maskS, tabIP[iIP].routerAd>>24,584 tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24,585 tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime,586 receptionTime587 );588 }589 }590 fclose(fIP);591 }592 ipNb = 0;593 lastIPOutput = now;594 }595 now = time((time_t *)NULL);596 if ( mplsNb > (MAX_MPLS_FLOW - 50) ||597 ( (now-lastMPLSOutput) > MPLS_TIME_THRESHOLD) ) {598 outputName[0] = '\0';599 sprintf(cof_str, "%d", currentMPLSOutputFile);600 strcat(outputName, OUTPUT_MPLS);601 strcat(outputName, cof_str);602 strcat(outputName, EXTENSION);603 if (fopen(outputName, "x") == NULL) {604 currentMPLSOutputFile = (currentMPLSOutputFile + 1)%MAX_MPLS_OUTPUT_FILES;605 outputName[0] = '\0';606 sprintf(cof_str, "%d", currentMPLSOutputFile);607 strcat(outputName, OUTPUT_MPLS);608 strcat(outputName, cof_str);609 strcat(outputName, EXTENSION);610 }611 if ((fMPLS = fopen(outputName, "w")) == NULL) {612 syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno));613 } else {614 for ( iMPLS = 0; iMPLS < mplsNb; iMPLS++){615 if ( tabMPLS[iMPLS].ipProt == 0 ) {616 fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu\n",617 tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24,618 tabMPLS[iMPLS].routerAd<<16>>24,619 tabMPLS[iMPLS].routerAd<<24>>24,620 tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24,621 tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24,622 tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24,623 tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24,624 tabMPLS[iMPLS].v4AdD<<24>>24625 );626 }627 }628 fclose(fMPLS);629 }630 mplsNb = 0;631 lastMPLSOutput = now;632 }633 #endif /* CRIHAN */634 524 now = time((time_t *)NULL); 635 525 tmPtr = localtime(&now); -
trunk/src/renetcolAgg.c
r47 r57 48 48 int rrd_create_er_ct = 0; 49 49 int rrd_create_ok_ct = 0; 50 int rrd_ct = 0;51 50 int isFirstUpdate = 1; 52 51 key_t key; … … 58 57 char *opt[27]; 59 58 char *optUpdate[3]; 60 int res_rrd = 0;61 59 FILE *fp; 62 60 static time_t now, now2; 63 struct shmid_ds shminfo;64 61 65 62 key = 8765; … … 338 335 /* END MATRIX INTER POP ACC */ 339 336 now2 = time((time_t *)NULL); 340 /* #ifdef DEBUGAGG */ 337 #ifdef DEBUGAGG 341 338 fprintf(stderr, "IPv4 subnet managment (rrd update) : \n %d sec, %d files updated, %d errors, total %d\n %d rrd file already created, %d errors in creation, %d new rrd file creations", 342 now2-now,339 (int)now2-now, 343 340 rrd_update_ok_ct, 344 341 rrd_update_er_ct, … … 347 344 rrd_create_er_ct, 348 345 rrd_create_ok_ct); 349 /* #endif */ 346 #endif 350 347 rrd_update_ok_ct = 0; 351 348 rrd_update_er_ct = 0; -
trunk/src/renetcolParam.h
r36 r57 36 36 #define FIELD_TYPE_NUMBER 89 37 37 #define MAX_RULES_PER_FIELD 10 /* maximum rules number for one field */ 38 #define MAX_IP_FLOW 1000039 #define MAX_MPLS_FLOW 20040 38 #define SHMSIZE 33554432 41 39 #define SOCKET_BUFFER_SIZE 1500 42 40 #define TIME_OUT 300 43 44 #ifdef CRIHAN45 #define OUTPUT_IP "/tmp/ipflow"46 #define EXTENSION ".txt"47 #define OUTPUT_MPLS "/tmp/mplsflow"48 #define MAX_IP_OUTPUT_FILES 349 #define MAX_MPLS_OUTPUT_FILES 350 #define IP_TIME_THRESHOLD 60 /* in sec */51 #define MPLS_TIME_THRESHOLD 60 /* in sec */52 #endif /* CRIHAN */53 41 54 42 /* -
trunk/src/routers_mgmt.h
r36 r57 60 60 RuleDefPtr *rulesAddressPtr; 61 61 RulesPtr rulesListPtr; /* Rules list */ 62 struct IPFLowCache *tabIPPtr;63 struct MPLSFlowCache *tabMPLSPtr;64 unsigned long *ipNbPtr;65 unsigned long *mplsNbPtr;66 62 unsigned long *routersID; 67 63 struct PrefixV4 *currentV4Tab; 68 64 struct PrefixV4 *secondV4Tab; 69 65 struct POP *matrixPOP; 70 unsigned long long nbFluxSR4;71 unsigned long long nbFluxSE;72 unsigned long long nbFluxIR4;73 unsigned long long nbFluxUK;74 unsigned long long nbFluxTT;75 66 }; 76 67