Changeset 113 for trunk/src/renetcol.c

Show
Ignore:
Timestamp:
06/23/09 17:42:00 (13 years ago)
Author:
andreu
Message:

ticket#27 : new global structure for counters.
some bug correction in renetcol.c

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/renetcol.c

    r111 r113  
    5555TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */ 
    5656TplOptionPtr curTplOptionPtr; 
    57 RouterPtr routersListPtr;  
     57RouterPtr routersListPtr; 
     58NDEEnginePtr enginePtrTmp; 
    5859 
    5960unsigned long sortedRouterList[ROUTER_INDEX_MAX]; 
     
    278279  myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 
    279280  myPtrs.currentFlowsetNumberPtr = &currentFlowsetNumber; 
     281  myPtrs.currentMIB = shmForAgg->myMIB[shmForAgg->currentTable]; 
     282  myPtrs.secondMIB = shmForAgg->myMIB[shmForAgg->secondTable]; 
     283  if (initMIB(myPtrs.currentMIB)!=1) { 
     284    fprintf(stderr, "ERROR in MIB initialisation\n");  
     285    exit(1);} 
     286  if (initMIB(myPtrs.secondMIB)!=1) { 
     287    fprintf(stderr, "ERROR in second MIB initialisation\n");  
     288    exit(1);} 
    280289#ifdef IPV4AGGIDR 
    281290  myPtrs.routersID = &indexedRouterList; 
     
    561570      } 
    562571      shmForAgg->readed = 1; 
     572      myPtrs.currentMIB = shmForAgg->myMIB[shmForAgg->currentTable]; 
     573      myPtrs.secondMIB = shmForAgg->myMIB[shmForAgg->secondTable]; 
    563574#ifdef ASACC 
    564575      myPtrs.currentASTab = shmForAgg->ASTab[shmForAgg->currentTable]; 
     
    570581      myPtrs.currentV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->currentTable][0][0]); 
    571582      myPtrs.secondV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->secondTable][0][0]); 
     583      /* FIXME : to delete : */ 
    572584      if (!(TPLFILE = fopen("/tmp/IPV6LINKAGG.txt", "w"))) { 
    573585        syslog (LOG_ERR, "error during %s opening", "/tmp/IPV6LINKAGG.txt"); 
     
    596608        } 
    597609      } 
    598       fclose(TPLFILE); 
     610      fclose(TPLFILE); /* <-- */ 
    599611#endif 
    600612    } 
     
    610622    getIpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 
    611623    regRouter = checkIpHeader(myPtrs.pcktPtr, &sortedRouterList[0], routerNb); 
     624    myPtrs.currentMIB->ipPacketNb += 1; 
    612625    getUdpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 
    613626    if ( checkUdpHeader(myPtrs.pcktPtr, regRouter, receptPort) == 1 ){ 
    614627      continue; 
    615628    } 
    616      
     629    myPtrs.currentMIB->udpPacketNb += 1; 
    617630    switch( version =  
    618631            getNetFlowHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer,  
     
    625638               myPtrs.currentHeaderV9Ptr->package_sequence); 
    626639#endif 
     640      myPtrs.currentMIB->v9PacketNb += 1; 
     641      myPtrs.currentMIB->flowNb += myPtrs.currentHeaderV9Ptr->count; 
    627642      if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr,  
    628643                                                  myPtrs.pcktPtr->ipH->srcAdd))==NULL) { 
    629644        myPtrs.currentRouterPtr = routersListPtr; 
    630645      } 
     646      if ((enginePtrTmp = existEngId(myPtrs.currentRouterPtr,myPtrs.currentHeaderV9Ptr->sourceId))==NULL) { 
     647        /* add new engineID */ 
     648        enginePtrTmp = newRouterEngineList(); 
     649        enginePtrTmp->next = myPtrs.currentRouterPtr->engineList; 
     650        if (myPtrs.currentRouterPtr->engineList!=NULL) { 
     651          myPtrs.currentRouterPtr->engineList->prev=enginePtrTmp;} 
     652        myPtrs.currentRouterPtr->engineList = enginePtrTmp; 
     653        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId; 
     654        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence; 
     655      } else { 
     656        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId; 
     657        if (enginePtrTmp->package_sequence != (myPtrs.currentHeaderV9Ptr->package_sequence-1)) { 
     658          myPtrs.currentMIB->v9UnSeqNb += 1; 
     659        } 
     660        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence; 
     661      } 
    631662      currentFlowsetNumber = 0; 
    632663      shift = 0; 
    633664      gardeFou=0; 
    634       while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count) && (shift <= 1456)) { 
     665      while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)  
     666             && (shift+48 < myPtrs.pcktPtr->udp_header->length)) { 
    635667        gardeFou++; 
    636668        curTplFlSetPtr = NULL; 
    637669        currentFlowsetId=getFlowsetId(currentFlowsetNumber,  
    638670                                      myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 
     671        myPtrs.currentMIB->flowSetNb += 1; 
    639672        if ( currentFlowsetId == 0 ) { 
    640           if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr,  
     673          if ( (shift = checkTemplateFlowSet(shift, myPtrs.currentRouterPtr, 
     674                                             myPtrs.currentMIB, 
    641675                                             myPtrs.offsetV9Ptr,  
    642676                                             myPtrs.ptr_buffer,  
     
    649683#endif 
    650684            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 
    651           }; 
    652           writeAllTplFlSet(); 
     685          } 
     686          /* writeAllTplFlSet(); */ 
    653687        } else if (currentFlowsetId == 1) { 
    654           if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr,  
     688          if ( (shift = checkTemplateOption(shift, myPtrs.currentRouterPtr, 
     689                                            myPtrs.currentMIB, 
    655690                                            myPtrs.offsetV9Ptr,  
    656691                                            myPtrs.ptr_buffer,  
     
    714749#ifdef DEBUG     
    715750    fprintf (stderr, "]\n"); 
     751    fprintf (stderr, "IP: %llu , UDP: %llu, NDEv9: %llu, drops: %llu, FS: %llu, Flows: %llu, realFl: %llu Diff:%llu\n", 
     752             myPtrs.currentMIB->ipPacketNb, 
     753             myPtrs.currentMIB->udpPacketNb, 
     754             myPtrs.currentMIB->v9PacketNb, 
     755             myPtrs.currentMIB->v9UnSeqNb, 
     756             myPtrs.currentMIB->flowSetNb, 
     757             myPtrs.currentMIB->flowNb, 
     758             myPtrs.currentMIB->realFlowNb, 
     759             myPtrs.currentMIB->flowNb - myPtrs.currentMIB->realFlowNb 
     760             ); 
    716761#endif 
    717762  } while (1); 
     
    929974  fclose(TPLFILE); 
    930975} 
     976 
     977/* 
     978 * initMIB 
     979 */ 
     980int initMIB(struct RenetcolMIB *theMIB) 
     981{ 
     982  theMIB->ipPacketNb = 0; 
     983  theMIB->udpPacketNb = 0; 
     984  theMIB->v9PacketNb = 0; 
     985  theMIB->v9UnSeqNb = 0; 
     986  theMIB->flowSetNb = 0; 
     987  theMIB->dataFlowSetNb = 0; 
     988  theMIB->defFlowSetNb = 0; 
     989  theMIB->optDataFlowSetNb = 0; 
     990  theMIB->optDefFlowSetNb = 0; 
     991  theMIB->flowNb = 0;           
     992  theMIB->realFlowNb = 0;  
     993  theMIB->ipv4BytesIn = 0; 
     994  theMIB->ipv4BytesOut = 0; 
     995  theMIB->ipv4PcktsIn = 0; 
     996  theMIB->ipv4PcktsOut = 0; 
     997  theMIB->ipv4FlowIn = 0; 
     998  theMIB->ipv4FlowOut = 0;     
     999  theMIB->ipv4IcmpFlowNb = 0; 
     1000  theMIB->ipv4IcmpBytesNb = 0; 
     1001  theMIB->ipv4IcmpPktsNb = 0; 
     1002  theMIB->ipv4UDPFlowNb = 0; 
     1003  theMIB->ipv4UDPBytesNb = 0; 
     1004  theMIB->ipv4UDPPktsNb = 0; 
     1005  theMIB->ipv4TCPFlowNb = 0; 
     1006  theMIB->ipv4TCPBytesNb = 0; 
     1007  theMIB->ipv4TCPPktsNb = 0; 
     1008  theMIB->ipv4OthersFlowNb = 0; 
     1009  theMIB->ipv4OthersBytesNb = 0; 
     1010  theMIB->ipv4OthersPktsNb = 0; 
     1011  theMIB->ipv4FlowSizePcktsE1 = 0;    
     1012  theMIB->ipv4FlowSizePcktsLT10 = 0;  
     1013  theMIB->ipv4FlowSizePcktsLT100 = 0; 
     1014  theMIB->ipv4FlowSizePcktsLT1k = 0;  
     1015  theMIB->ipv4FlowSizePcktsLT10k = 0; 
     1016  theMIB->ipv4FlowSizePcktsMT10k = 0; 
     1017  theMIB->ipv4FlowSizeBytesLT50 = 0;  
     1018  theMIB->ipv4FlowSizeBytesLT100 = 0; 
     1019  theMIB->ipv4FlowSizeBytesLT1k = 0;  
     1020  theMIB->ipv4FlowSizeBytesLT10k = 0; 
     1021  theMIB->ipv4FlowSizeBytesLT100k = 0; 
     1022  theMIB->ipv4FlowSizeBytesLT1M = 0;   
     1023  theMIB->ipv4FlowSizeBytesLT10M = 0;  
     1024  theMIB->ipv4FlowSizeBytesLT100M = 0;  
     1025  theMIB->ipv4FlowSizeBytesMT100M = 0;  
     1026  theMIB->ipv4WebBytesNb = 0; 
     1027  theMIB->ipv4WebPcktsNb = 0; 
     1028  theMIB->ipv4WebFlowNb = 0; 
     1029  theMIB->ipv4DNSBytesNb = 0; 
     1030  theMIB->ipv4DNSPcktsNb = 0; 
     1031  theMIB->ipv4DNSFlowNb = 0; 
     1032  theMIB->ipv4OthersApBytesNb = 0; 
     1033  theMIB->ipv4OthersApPcktsNb = 0; 
     1034  theMIB->ipv4OthersApFlowNb = 0; 
     1035  theMIB->ipv6BytesIn = 0; 
     1036  theMIB->ipv6BytesOut = 0; 
     1037  theMIB->ipv6PcktsIn = 0; 
     1038  theMIB->ipv6PcktsOut = 0; 
     1039  theMIB->ipv6FlowIn = 0; 
     1040  theMIB->ipv6FlowOut = 0; 
     1041  theMIB->ipv6IcmpFlowNb = 0; 
     1042  theMIB->ipv6IcmpBytesNb = 0; 
     1043  theMIB->ipv6IcmpPktsNb = 0; 
     1044  theMIB->ipv6UDPFlowNb = 0; 
     1045  theMIB->ipv6UDPBytesNb = 0; 
     1046  theMIB->ipv6UDPPktsNb = 0; 
     1047  theMIB->ipv6TCPFlowNb = 0; 
     1048  theMIB->ipv6TCPBytesNb = 0; 
     1049  theMIB->ipv6TCPPktsNb = 0; 
     1050  theMIB->ipv6OthersFlowNb = 0; 
     1051  theMIB->ipv6OthersBytesNb = 0; 
     1052  theMIB->ipv6OthersPktsNb = 0; 
     1053  theMIB->ipv6FlowSizePcktsE1 = 0;      
     1054  theMIB->ipv6FlowSizePcktsLT10 = 0;    
     1055  theMIB->ipv6FlowSizePcktsLT100 = 0;   
     1056  theMIB->ipv6FlowSizePcktsLT1k = 0;    
     1057  theMIB->ipv6FlowSizePcktsLT10k = 0;   
     1058  theMIB->ipv6FlowSizePcktsMT10k = 0;   
     1059  theMIB->ipv6FlowSizeBytesLT50 = 0;    
     1060  theMIB->ipv6FlowSizeBytesLT100 = 0;   
     1061  theMIB->ipv6FlowSizeBytesLT1k = 0;    
     1062  theMIB->ipv6FlowSizeBytesLT10k = 0;   
     1063  theMIB->ipv6FlowSizeBytesLT100k = 0;  
     1064  theMIB->ipv6FlowSizeBytesLT1M = 0;    
     1065  theMIB->ipv6FlowSizeBytesLT10M = 0;   
     1066  theMIB->ipv6FlowSizeBytesLT100M = 0;  
     1067  theMIB->ipv6FlowSizeBytesMT10M = 0;   
     1068  theMIB->ipv6WebBytesNb = 0; 
     1069  theMIB->ipv6WebPcktsNb = 0; 
     1070  theMIB->ipv6WebFlowNb = 0; 
     1071  theMIB->ipv6DNSBytesNb = 0; 
     1072  theMIB->ipv6DNSPcktsNb = 0; 
     1073  theMIB->ipv6DNSFlowNb = 0; 
     1074  theMIB->ipv6OthersApBytesNb = 0; 
     1075  theMIB->ipv6OthersApPcktsNb = 0; 
     1076  theMIB->ipv6OthersApFlowNb = 0; 
     1077  return 1; 
     1078}