Changeset 60 for trunk/src/dataFlowSet.c
- Timestamp:
- 10/25/07 07:23:46 (15 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dataFlowSet.c
r59 r60 66 66 unsigned short tplMsgType = 11; 67 67 struct PrefixV4 prefixKey, *res, *res2; /* for bsearch */ 68 #if defined(IPV4AGGIDSNMP) 69 struct PrefixV4 *res3; 70 #endif 71 #ifdef ASACC 72 struct AS asKey, *asres; /* for bsearch */ 73 #endif 68 74 struct AggCache agCache; 69 75 int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */ … … 229 235 } 230 236 #endif 237 #ifdef ASACC 238 if (pftmp->fieldType==16){ 239 agCache.asS = *((unsigned short*)&buffer2); 240 } 241 if (pftmp->fieldType==17){ 242 agCache.asD = *((unsigned short*)&buffer2); 243 } 244 #endif 231 245 break; 232 246 case 3: … … 482 496 } 483 497 #endif 498 #ifdef ASACC 499 if (pftmp->fieldType==16){ 500 agCache.asS = *((unsigned short*)&buffer2); 501 } 502 if (pftmp->fieldType==17){ 503 agCache.asD = *((unsigned short*)&buffer2); 504 } 505 #endif 484 506 break; 485 507 case 3: … … 548 570 /* Aggregation mode must be enable in ./configure options */ 549 571 /* first we must know if the address belong to our prefix */ 572 /* 573 * AS ACCOUNTING 574 */ 575 #if defined(ASACC) && defined(IPV4AGGIDSNMP) 576 if ( (bool == 1) && (isMplsFlow == 0) ){ 577 asKey.as = agCache.asS; 578 asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 579 if (asres != NULL) { 580 if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1 ) { 581 if (myPtrs->currentRouterPtr->sampled != 0 ){ 582 /* OUT ("traffic from the AS") */ 583 asres->bytesNbOUT += agCache.bytes; 584 asres->pktsNbOUT += agCache.pkts; 585 (asres->flowNbOUT)++; 586 } 587 if (asres->sampling == 0 588 && myPtrs->currentRouterPtr->sampled != 0){ 589 asres->sampling = myPtrs->currentRouterPtr->sampled; 590 } 591 asres = NULL; 592 asKey.as = agCache.asD; 593 asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 594 if (asres!=NULL){ 595 if (myPtrs->currentRouterPtr->sampled != 0 ){ 596 /* IN ("traffic to the AS") */ 597 asres->bytesNbIN += agCache.bytes; 598 asres->pktsNbIN += agCache.pkts; 599 (asres->flowNbIN)++; 600 } 601 if (asres->sampling == 0 602 && myPtrs->currentRouterPtr->sampled != 0){ 603 asres->sampling = myPtrs->currentRouterPtr->sampled; 604 } 605 asres = NULL; 606 } 607 } 608 } else { 609 asres = NULL; 610 asKey.as = agCache.asD; 611 asres = bsearch(&asKey, myPtrs->currentASTab, myPtrs->asNb, sizeof(struct AS), asGlobalCmp); 612 if (asres!=NULL){ 613 if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1 ) { 614 if (myPtrs->currentRouterPtr->sampled != 0 ){ 615 /* IN ("traffic to the AS") */ 616 asres->bytesNbIN += agCache.bytes; 617 asres->pktsNbIN += agCache.pkts; 618 (asres->flowNbIN)++; 619 } 620 if (asres->sampling == 0 621 && myPtrs->currentRouterPtr->sampled != 0){ 622 asres->sampling = myPtrs->currentRouterPtr->sampled; 623 } 624 } 625 } 626 } 627 } 628 #endif 629 /* 630 * PREFIX &/or MATRIX ACCOUNTING 631 */ 550 632 #if defined(IPV4AGGIDR) || defined(IPV4AGGIDSNMP) 551 633 if ( (bool == 1) && (isMplsFlow == 0) ){ … … 569 651 res->sampling = myPtrs->currentRouterPtr->sampled; 570 652 } 653 #if defined(IPV4AGGIDSNMP) 654 prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 655 res3 = bsearch(&prefixKey, V4PTab, nbPV4, 656 sizeof(struct PrefixV4), prefGlobalCmp); 657 if (res3!=NULL){ 658 if (myPtrs->currentRouterPtr->sampled != 0 ){ 659 /* IN ("traffic to the prefix/subnet") */ 660 res3->bytesNbIN += agCache.bytes; 661 res3->pktsNbIN += agCache.pkts; 662 (res3->flowNbIN)++; 663 } 664 if (res3->sampling == 0 665 && myPtrs->currentRouterPtr->sampled != 0){ 666 res3->sampling = myPtrs->currentRouterPtr->sampled; 667 } 668 } 669 #endif 571 670 #if defined(MATRIX) && defined(IPV4AGGIDR) 572 671 /* inter-pop matrix Accounting */ … … 603 702 /* doublon or bad reference in prefix list */ 604 703 } 605 } else { 704 } else { /* the prefix in source don't exist in your prefix list */ 606 705 prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 607 706 res = bsearch(&prefixKey, V4PTab, nbPV4, 608 707 sizeof(struct PrefixV4), prefGlobalCmp); 609 708 if (res!=NULL){ 610 if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1 ) { 709 if ( myPtrs->currentRouterPtr->snmpIndexList[agCache.inputSnmp] == 1 ) { 611 710 if (myPtrs->currentRouterPtr->sampled != 0 ){ 612 711 /* IN ("traffic to the prefix/subnet") */ … … 628 727 res->sampling = myPtrs->currentRouterPtr->sampled; 629 728 } 630 /* } else { */ 729 } else { 631 730 /* doublon or bad reference in prefix list */ 632 731 } 633 732 } else { 733 /* UNKNOW SUBNET CASE */ 734 /* */ 634 735 /* HERE : we are in the cases of the address/mask don't */ 635 736 /* belong to a prefix listed in the IPv4 prefix file */ … … 663 764 #endif /* (IPV4AGGIDR) || (IPV4AGGIDSNMP) */ 664 765 /* 665 * Redirection if needed 766 * 767 * SOCKET OUTPUT TO A REMOTE CLIENT 768 * 666 769 * switch the rules definition (check & fieldToRecord), 667 770 * we send the flow or a part of the flow to a remote host or a file. … … 772 875 * 773 876 * 774 * Optional template877 * OPTIONAL TEMPLATE 775 878 * 776 879 *