- Timestamp:
- 02/08/07 22:44:36 (16 years ago)
- Location:
- trunk/src
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dataFlowSet.c
r23 r25 624 624 res = bsearch(&prefixKey, V4PTab, nbPV4, 625 625 sizeof(struct PrefixV4), prefCmp); 626 if (res!=NULL){ /* OUT ("traffic from the prefix") */ 626 if (res!=NULL){ 627 /* OUT ("traffic from the prefix/subnet") */ 627 628 res->bytesNbOUT += agCache.bytes; 628 629 res->pktsNbOUT += agCache.pkts; -
trunk/src/prefix_mgmt.c
r17 r25 23 23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 24 24 */ 25 #include <stdio.h>26 25 27 26 #include "prefix_mgmt.h" … … 38 37 ); 39 38 } 39 40 41 /* 42 * prefGlobalCmp() 43 */ 44 int 45 prefGlobalCmp(const void *elem1, const void *elem2){ 46 struct PrefixV4 *el1 = (struct PrefixV4 *) elem1; 47 struct PrefixV4 *el2 = (struct PrefixV4 *) elem2; 48 if ( el1->beginning >= el2->beginning && el1->beginning <= el2->end ) { 49 return 0; 50 } else if (el1->beginning < el2->beginning) { 51 return -1; 52 } else if (el1->beginning > el2->end) { 53 return 1; 54 } else { 55 syslog(LOG_ERR,"You have won !!! This case doesn't exist !!!!"); 56 exit(1); 57 return 0; 58 } 59 } 60 -
trunk/src/prefix_mgmt.h
r16 r25 26 26 #define PREFIX_MGMT_H 27 27 28 #include <unistd.h> 29 #include <stdio.h> 30 #include <string.h> 31 #include <stdlib.h> 32 #include <syslog.h> 33 #include <errno.h> 34 28 35 #include "get_conf.h" 29 36 30 int prefCmp(const void *, const void *); 37 int prefCmp(const void *, const void *); /* quickly cmp, used in headers_mgmt.c */ 38 int prefGlobalCmp(const void *, const void *); /* bigger cmp, used in dataflowset.c */ 31 39 32 40 #endif /* PREFIX_MGMT_H */ -
trunk/src/renetcol.c
r24 r25 151 151 fprintf(stderr, "renetcol: reading the IPv4 prefix...\n"); 152 152 if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 153 fprintf(stderr, "renetcol: 153 fprintf(stderr, "renetcol: Error \n"); 154 154 exit(1); 155 155 } else { 156 fprintf(stderr, "renetcol: 156 fprintf(stderr, "renetcol: OK \n"); 157 157 } 158 158 if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ … … 160 160 exit(1); 161 161 } else { 162 fprintf(stderr, "renetcol: 162 fprintf(stderr, "renetcol: OK \n"); 163 163 } 164 164 myPtrs.rulesListPtr = NULL; 165 165 fprintf(stderr, "renetcol: reading the rules...\n"); 166 166 myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 167 fprintf(stderr, "renetcol 167 fprintf(stderr, "renetcol: OK \n"); 168 168 tmp = myPtrs.rulesListPtr; 169 169 for ( ; tmp->next; tmp=tmp->next) { -
trunk/src/renetcolAgg.c
r24 r25 69 69 now = time((time_t *)NULL); 70 70 for (i=0; i<shmForAgg->v4PrefixNb; i++){ 71 72 71 /* HERE Put in RRD FILE */ 73 74 name[0] = '\0'; 72 name[0] = '\0'; 75 73 createstr[0] = '\0'; 76 74 ipStr[0] = '\0'; 77 75 buf[0] = '\0'; 78 /* strcat(name, RRD_LOCATION); */ 76 strcat(name, RRD_LOCATION); 79 77 sprintf(ipStr, "%lu", shmForAgg->prefixV4Tab[index][i].beginning); 80 78 strcat(name, ipStr); 81 /* strcat(name, SAMPLING_HERE); */79 /* strcat(name, SAMPLING_HERE); */ 82 80 strcat(name, RRD_EXTENSION); 83 81 fprintf(stderr, "%s\n", name); … … 87 85 fprintf(stderr, "%s\n", createstr); 88 86 res_rrd = wrap_rrd_create(createstr); 89 /* printf("%d\n", res_rrd); */90 87 }else{ 91 88 fclose(fp); 92 89 } 93 90 94 snprintf(buf, 1024, "%s%s %lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu",95 /* RRD_LOCATION, */ 91 snprintf(buf, 2048, "%s%s%s %lu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu:%llu", 92 RRD_LOCATION, 96 93 ipStr, 97 94 RRD_EXTENSION, 98 now, /* or ctime(&now) with %s */95 now, /* or ctime(&now) with %s FIXME -300 */ 99 96 shmForAgg->prefixV4Tab[index][i].flowNbIN, /* 1 */ 100 97 shmForAgg->prefixV4Tab[index][i].flowNbOUT, … … 129 126 ); 130 127 printf("\n%s\n", buf); 131 res_rrd = wrap_rrd_update(buf); 132 printf("resultat wrap_rrd_update : %d\n", res_rrd); 133 134 /* fprintf(stderr, "%lu \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n %llu flows,\t %llu bytes,\t %llu pkts\n Pkts (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Bytes (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n Flows (udp tcp icmp others): %llu \t %llu \t %llu \t %llu\n \n", */ 135 /* shmForAgg->prefixV4Tab[index][i].beginning, */ 136 /* shmForAgg->prefixV4Tab[index][i].flowNbIN, */ 137 /* shmForAgg->prefixV4Tab[index][i].bytesNbIN, */ 138 /* shmForAgg->prefixV4Tab[index][i].pktsNbIN, */ 139 /* shmForAgg->prefixV4Tab[index][i].udpPktsNbIN, */ 140 /* shmForAgg->prefixV4Tab[index][i].tcpPktsNbIN, */ 141 /* shmForAgg->prefixV4Tab[index][i].icmpPktsNbIN, */ 142 /* shmForAgg->prefixV4Tab[index][i].othersPktsNbIN, */ 143 /* shmForAgg->prefixV4Tab[index][i].udpBytesNbIN, */ 144 /* shmForAgg->prefixV4Tab[index][i].tcpBytesNbIN, */ 145 /* shmForAgg->prefixV4Tab[index][i].icmpBytesNbIN, */ 146 /* shmForAgg->prefixV4Tab[index][i].othersBytesNbIN, */ 147 /* shmForAgg->prefixV4Tab[index][i].udpFlowNbIN, */ 148 /* shmForAgg->prefixV4Tab[index][i].tcpFlowNbIN, */ 149 /* shmForAgg->prefixV4Tab[index][i].icmpFlowNbIN, */ 150 /* shmForAgg->prefixV4Tab[index][i].othersFlowNbIN, */ 151 /* shmForAgg->prefixV4Tab[index][i].flowNbOUT, */ 152 /* shmForAgg->prefixV4Tab[index][i].bytesNbOUT, */ 153 /* shmForAgg->prefixV4Tab[index][i].pktsNbOUT, */ 154 /* shmForAgg->prefixV4Tab[index][i].udpPktsNbOUT, */ 155 /* shmForAgg->prefixV4Tab[index][i].tcpPktsNbOUT, */ 156 /* shmForAgg->prefixV4Tab[index][i].icmpPktsNbOUT, */ 157 /* shmForAgg->prefixV4Tab[index][i].othersPktsNbOUT, */ 158 /* shmForAgg->prefixV4Tab[index][i].udpBytesNbOUT, */ 159 /* shmForAgg->prefixV4Tab[index][i].tcpBytesNbOUT, */ 160 /* shmForAgg->prefixV4Tab[index][i].icmpBytesNbOUT, */ 161 /* shmForAgg->prefixV4Tab[index][i].othersBytesNbOUT, */ 162 /* shmForAgg->prefixV4Tab[index][i].udpFlowNbOUT, */ 163 /* shmForAgg->prefixV4Tab[index][i].tcpFlowNbOUT, */ 164 /* shmForAgg->prefixV4Tab[index][i].icmpFlowNbOUT, */ 165 /* shmForAgg->prefixV4Tab[index][i].othersFlowNbOUT */ 166 /* ); */ 128 if ( 0 == (res_rrd = wrap_rrd_update(buf) )) { 129 syslog(LOG_ERR, "wrap_rrd_update return : %d, param were : %s", res_rrd, buf); 130 } 131 /* Reinit the shared table */ 167 132 shmForAgg->prefixV4Tab[index][i].flowNbIN = 0; 168 133 shmForAgg->prefixV4Tab[index][i].bytesNbIN = 0; -
trunk/src/renetcolAgg.h
r24 r25 39 39 40 40 #include "rrdwrap.h" 41 #include "dataFlowSet.h" 41 42 42 #define RRD_LOCATION " /tmp/"43 #define RRD_LOCATION "" 43 44 #define RRD_EXTENSION ".rrd" 44 45 #define END_RRD_CREATE " --start 1106560200 DS:inFlows:GAUGE:600:U:U DS:outFlows:GAUGE:600:U:U DS:inBytes:GAUGE:600:U:U DS:outBytes:GAUGE:600:U:U DS:inPkts:GAUGE:600:U:U DS:outPkts:GAUGE:600:U:U DS:inUdpPkts:GAUGE:600:U:U DS:outUdpPkts:GAUGE:600:U:U DS:inTcpPkts:GAUGE:600:U:U DS:outTcpPkts:GAUGE:600:U:U DS:inIcmpPkts:GAUGE:600:U:U DS:outIcmpPkts:GAUGE:600:U:U DS:inOthersPkts:GAUGE:600:U:U DS:outOthersPkts:GAUGE:600:U:U DS:inUdpBytes:GAUGE:600:U:U DS:outUdpBytes:GAUGE:600:U:U DS:inTcpBytes:GAUGE:600:U:U DS:outTcpBytes:GAUGE:600:U:U DS:inIcmpBytes:GAUGE:600:U:U DS:outIcmpBytes:GAUGE:600:U:U DS:inOthersBytes:GAUGE:600:U:U DS:outOthersBytes:GAUGE:600:U:U DS:inUdpFlows:GAUGE:600:U:U DS:outUdpFlows:GAUGE:600:U:U DS:inTcpFlows:GAUGE:600:U:U DS:outTcpFlows:GAUGE:600:U:U DS:inIcmpFlows:GAUGE:600:U:U DS:outIcmpFlows:GAUGE:600:U:U DS:inOthersFlows:GAUGE:600:U:U DS:outOthersFlows:GAUGE:600:U:U RRA:AVERAGE:0.5:1:2100 RRA:AVERAGE:0.5:24:1550 RRA:AVERAGE:0.5:288:1594 RRA:AVERAGE:0.5:2016:1040 RRA:MAX:0.5:1:2100 RRA:MAX:0.5:24:1550 RRA:MAX:0.5:288:1594 RRA:MAX:0.5:2016:1040" 45 46 #include "dataFlowSet.h"47 48 46 #define SHMSIZE 3000000 49 47