- Files:
-
- 93 added
- 35 modified
Legend:
- Unmodified
- Added
- Removed
-
/trunk/configure.in
r20 r29 3 3 4 4 AC_PREREQ(2.59) 5 AC_INIT(RENETCOL, 0.0. 5, andreu@renater.fr)5 AC_INIT(RENETCOL, 0.0.8, andreu@renater.fr) 6 6 AC_CONFIG_SRCDIR(src/) 7 7 AC_PROG_MAKE_SET 8 8 AM_CONFIG_HEADER(config.h) 9 9 AM_INIT_AUTOMAKE 10 CFLAGS="-I/usr/local/include -g -ansi -Wall -D _SVID_SOURCE \ 11 -DSIGSETJMP_IS_BROKEN \ 12 -D _XOPEN_SOURCE \ 13 -pedantic \ 14 -pg" 10 CFLAGS="-I/usr/local/include -g -ansi -Wno-long-long -Wall -D _SVID_SOURCE -DSIGSETJMP_IS_BROKEN -D _XOPEN_SOURCE -pedantic -pg" 15 11 12 CFLAGS_OPTIMIZE="-O2" 16 13 CFLAGS_CRIHAN="-DCRIHAN" 14 CFLAGS_IPV4AGG="-DIPV4AGG" 15 CFLAGS_DEBUG="-DDEBUG" 16 CFLAGS_DEBUGAGG="-DDEBUGAGG" 17 17 18 18 # Checks for programs. … … 29 29 AC_TYPE_SIZE_T 30 30 31 AC_ARG_ENABLE(optimize,[ --enable-optimize gcc O2 option compilation default=no], 32 optimize=$enableval,optimize=no) 33 if test $optimize = yes ; then 34 CFLAGS="$CFLAGS $CFLAGS_OPTIMIZE" 35 fi 36 31 37 AC_ARG_ENABLE(crihan,[ --enable-crihan allow files outputs for CRIHAN tools default=no], 32 38 crihan=$enableval,crihan=no) 33 39 if test $crihan = yes ; then 34 40 CFLAGS="$CFLAGS $CFLAGS_CRIHAN" 41 fi 42 43 AC_ARG_ENABLE(ipv4agg,[ --enable-ipv4agg aggregation for IPv4 prefix=yes], 44 ipv4agg=$enableval,ipv4agg=yes) 45 if test $ipv4agg = yes ; then 46 CFLAGS="$CFLAGS $CFLAGS_IPV4AGG" 47 fi 48 49 AC_ARG_ENABLE(debug,[ --enable-debug Debug mode definition=no], 50 debug=$enableval,debug=no) 51 if test $debug = yes ; then 52 CFLAGS="$CFLAGS $CFLAGS_DEBUG" 53 fi 54 55 AC_ARG_ENABLE(debugagg,[ --enable-debugagg Debug Agg mode definition=no], 56 debugagg=$enableval,debugagg=no) 57 if test $debugagg = yes ; then 58 CFLAGS="$CFLAGS $CFLAGS_DEBUGAGG" 35 59 fi 36 60 -
/trunk/src/V9Header_mgmt.h
r2 r28 2 2 * File: V9Header_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/renetcol.c
r20 r30 2 2 * File: renetcol.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier5 * 6 * Copyright (C) 2005 GIP RENATER4 * Authors: ANDREU Francois-Xavier 5 * 6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 26 26 #include "renetcol.h" 27 27 28 #ifdef CRIHAN 29 struct IPFLowCache tabIP[MAX_IP_FLOW], *tabIPPtr = tabIP; 30 struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW], *tabMPLSPtr = tabMPLS; 31 unsigned long ipNb = 0; 32 unsigned long mplsNb = 0; 33 unsigned long *ipNbPtr = &ipNb; 34 unsigned long *mplsNbPtr = &mplsNb; 35 unsigned short currentIPOutputFile = 0; 36 unsigned short currentMPLSOutputFile = 0; 28 struct MyPtrs myPtrs; /* defined in dataflowset.h */ 29 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 37 unsigned short currentIPOutputFile = 0; /* index on the current IP file */ 38 unsigned short currentMPLSOutputFile = 0; /* index on the current MPLS file */ 37 39 char outputName[256]; 38 char cof_str[20]; 39 FILE *fIP; 40 FILE *fMPLS; 41 #endif /* CRIHAN */ 42 43 char *rulesFileName; 44 char *configFileName; 45 char *prefixV4FileName; 46 struct sigaction myAction; 47 sigjmp_buf contextSigalrm; 48 /* struct sigaction myAction; for timer */ 40 char cof_str[20]; /* current ouput file name */ 41 FILE *fIP; /* pointer on the IP output file */ 42 FILE *fMPLS; /* pointer on the MPLS output file */ 43 44 char *rulesFileName; /* file name of the rules (like acl) */ 45 char *configFileName; /* file name where routers list is */ 46 char *prefixV4FileName; /* IPv4 prefix list */ 47 48 struct sigaction myAction; /* handler for renetcolSender communication */ 49 sigjmp_buf contextSigalrm; /* '' */ 49 50 volatile sig_atomic_t sigusr1Up = 0; 50 /* V9 */ 51 unsigned short offsetV9 = 0; 52 unsigned short *offsetV9Ptr = &offsetV9; 51 /* struct sigaction myAction; for timer not used in this version */ 52 53 unsigned short currentIntervalle = 0; /* based on 5 min intervalles */ 54 55 unsigned short offsetV9 = 0; /* index in a neflow v9 packet */ 56 53 57 unsigned char buffer1; 54 58 unsigned char buffer2[2]; 55 59 unsigned char buffer4[4]; 56 60 unsigned char buffer6[6]; 61 57 62 short currentFlowsetNumber; 58 short *currentFlowsetNumberPtr = ¤tFlowsetNumber;59 63 short currentFlowsetId; 60 short *currentFlowsetIdPtr = ¤tFlowsetId; 61 TplFlowSetPtr curTplFlSetPtr; 64 TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */ 62 65 TplOptionPtr curTplOptionPtr; 63 RouterPtr routersListPtr; 64 RouterPtr currentRouterPtr; 65 DatagramPtr pcktPtr; 66 RouterPtr routersListPtr; 67 66 68 unsigned long sortedRouterList[ROUTER_INDEX_MAX]; 67 69 unsigned long indexedRouterList[ROUTER_INDEX_MAX]; 68 int routerNb = 0; 69 unsigned short v4PrefixNb = 0; 70 struct PrefixV4 prefixV4Tab[PREFIX_V4_MAX]; 71 RulesPtr rulesListPtr; 72 NetFlowV9HeaderPtr currentHeaderV9Ptr; 73 key_t myKey = 0; 74 int myQueue = 0; 75 RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD]; 76 RuleDefPtr *rulesAddressPtr; 70 int routerNb = 0; /* routers number */ 71 /* unsigned short v4PrefixNb = 0; IPv4 prefix number */ 72 /* struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX]; IPv4 prefix structure */ 73 74 75 key_t myKey = 0; /* FIXME to delete in futur */ 76 int myQueue = 0; /* FIXME to delete in futur */ 77 78 /* Next structure used as cache in rules reading */ 79 RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD]; 80 77 81 int reInitConf = 0; 78 /* ENDV9 */ 79 static unsigned long datagramNumber; 80 static time_t now; 81 static unsigned long myHost; /* FIXME to erase */ 82 83 static time_t lastRock; 82 84 static struct tm *tmPtr; 85 83 86 extern int errno; 84 87 static int inputSock; … … 90 93 /* static unsigned short flowNumber; */ 91 94 static unsigned short receptPort = RECEPTION_PORT; 92 static unsigned char *ptr_buffer; 95 /* static unsigned char *ptr_buffer; */ 93 96 static char *receptAddress = RECEPTION_ADDRESS; 94 97 static struct sockaddr_in name; … … 104 107 { 105 108 RulesPtr tmp = NULL; 106 109 int shmid; 110 key_t key; 111 107 112 if ( argc != 4) { 108 113 fprintf (stderr, … … 112 117 } 113 118 119 #ifdef CRIHAN 120 fprintf(stderr, "renetcol compilation with CRIHAN feature enable\n"); 121 #endif 122 #ifdef IPV4AGG 123 fprintf(stderr, "renetcol compilation and execution with IPv4 Aggregation feature enable\n"); 124 #endif 125 114 126 openlog(argv[0], LOG_PID, LOG_USER); 115 127 116 128 configFileName = (char *) malloc((strlen(argv[1])+1) * sizeof(char)); 117 129 strcpy (configFileName, argv[1]); … … 122 134 123 135 initCache(); 124 fprintf(stderr, "reading the routers list\n");125 136 routerNb = getRegisteredRouters(configFileName, &sortedRouterList[0], 126 137 &indexedRouterList[0]); 127 fprintf(stderr, "reading the IPv4 prefix\n"); 128 if ( (v4PrefixNb = getPrefixV4(prefixV4FileName, &prefixV4Tab[0])) < 1){ 129 fprintf(stderr, "Error during prefix v4 reading\n"); 130 exit(1); 131 } 132 rulesListPtr = NULL; 133 fprintf(stderr, "reading the rules\n"); 134 rulesListPtr = getLightRules(rulesListPtr, rulesFileName); 135 tmp = rulesListPtr; 138 key = 8765; 139 if ((shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666)) < 0) { 140 perror("shmget"); 141 exit(1); 142 } 143 if ((shmForAgg = (struct SHMForAgg *)shmat(shmid, (void *)0, 0)) == (void *) -1) { 144 perror("shmat"); 145 exit(1); 146 } 147 148 if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[0][0]))) < 1){ 149 fprintf(stderr, "renetcol: Error \n"); 150 exit(1); 151 } 152 if ( (shmForAgg->v4PrefixNb = getPrefixV4(prefixV4FileName, &(shmForAgg->prefixV4Tab[1][0]))) < 1){ 153 fprintf(stderr, "renetcol: Error \n"); 154 exit(1); 155 } 156 157 shmForAgg->currentTable = 0; 158 shmForAgg->secondTable = 1; 159 160 myPtrs.rulesListPtr = NULL; 161 myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 162 tmp = myPtrs.rulesListPtr; 136 163 for ( ; tmp->next; tmp=tmp->next) { 137 164 if (tmp->type != 2) { 138 rulesListPtr = delRule(tmp,rulesListPtr);165 myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 139 166 } 140 167 } … … 142 169 /* exit(1); */ 143 170 144 fprintf(stderr, " I become a deamon, next messages via syslogd.\n");171 fprintf(stderr, "renetcol: I become a deamon, next messages via syslogd. By.\n"); 145 172 if (fork () != 0) 146 173 exit (0); … … 156 183 sigaction (SIGUSR1, &myAction, NULL); 157 184 158 setCache(rulesListPtr); 159 rulesAddressPtr = (RuleDefPtr *)rulesAddress; 185 /* Pointer on rules Table */ 186 setCache(myPtrs.rulesListPtr); 187 myPtrs.rulesAddressPtr = (RuleDefPtr *)rulesAddress; 160 188 161 189 /* init IPC messages queue */ … … 165 193 166 194 /* INIT THE CURRENTS VARIABLES*/ 167 currentRouterPtr = routersListPtr;168 currentHeaderV9Ptr = (NetFlowV9HeaderPtr)195 myPtrs.currentRouterPtr = routersListPtr; 196 myPtrs.currentHeaderV9Ptr = (NetFlowV9HeaderPtr) 169 197 malloc(sizeof(struct NetFlowV9Header)); 170 pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 171 if (pcktPtr==NULL) { 198 myPtrs.offsetV9Ptr = &offsetV9; 199 myPtrs.currentFlowsetIdPtr = ¤tFlowsetId; 200 myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram)); 201 myPtrs.currentFlowsetNumberPtr = ¤tFlowsetNumber; 202 myPtrs.ipNbPtr = &ipNb; 203 myPtrs.mplsNbPtr = &mplsNb; 204 myPtrs.routersID = &indexedRouterList; 205 myPtrs.currentV4Tab = shmForAgg->prefixV4Tab[shmForAgg->currentTable]; 206 myPtrs.secondV4Tab = shmForAgg->prefixV4Tab[shmForAgg->secondTable]; 207 208 if (myPtrs.pcktPtr==NULL) { 172 209 fprintf(stderr, "ERROR in struct Datagram allocation\n"); 173 210 exit(1); 174 211 } else { 175 pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader));176 pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader));177 } 178 179 if (! ( ptr_buffer = malloc(sockBufSize)))212 myPtrs.pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader)); 213 myPtrs.pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader)); 214 } 215 216 if (! (myPtrs.ptr_buffer = malloc(sockBufSize))) 180 217 { 181 218 printf("ERROR during socket buffer allocation\n"); … … 186 223 initStream(); 187 224 188 datagramNumber =0; /* FIXME : ???? */189 190 now = time((time_t *)NULL);191 tmPtr = localtime(&now);192 225 socketLoop(); /* all work on datagram is made here */ 226 193 227 closelog(); 228 194 229 fprintf(stderr, "END\n"); 230 195 231 return (0); 196 232 } 197 233 198 234 /* 199 * 200 */ 201 void sendMyPid(int queueID) 235 * send his PID to another program via IPC message queue 236 * 237 * @param queueID the IPC queue ident 238 * 239 */ 240 void 241 sendMyPid(int queueID) 202 242 { 203 243 msgType myMsg; … … 219 259 220 260 /* 261 * Send the "read rules list" message to another program 262 * 263 * @param queueID the IPC queue ident 221 264 * 222 265 */ … … 236 279 237 280 /* 238 * 239 */ 240 void sigusr1Mgmt(int num) 281 * 282 */ 283 void 284 sigusr1Mgmt(int num) 241 285 { 242 286 sigusr1Up = 1; … … 244 288 245 289 /* 246 * 290 * init the rule structure 247 291 */ 248 292 void … … 251 295 RulesPtr tmp = NULL; 252 296 initCache(); 253 tmp = rulesListPtr;297 tmp = myPtrs.rulesListPtr; 254 298 for ( ; tmp; tmp=tmp->next) { 255 rulesListPtr = delRule(tmp,rulesListPtr);256 } 257 rulesListPtr = NULL;258 rulesListPtr = getLightRules(rulesListPtr, rulesFileName);259 tmp = rulesListPtr;299 myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 300 } 301 myPtrs.rulesListPtr = NULL; 302 myPtrs.rulesListPtr = getLightRules(myPtrs.rulesListPtr, rulesFileName); 303 tmp = myPtrs.rulesListPtr; 260 304 for ( ; tmp; tmp=tmp->next) { 261 305 if (tmp->type != 2) { 262 rulesListPtr = delRule(tmp,rulesListPtr);306 myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr); 263 307 } 264 308 } 265 309 tmp = NULL; 266 310 initCache(); 267 setCache( rulesListPtr);311 setCache(myPtrs.rulesListPtr); 268 312 sendReadRulesSignal(myQueue); 269 313 } 270 314 271 315 /* 272 * 316 * init cache table 273 317 */ 274 318 void … … 314 358 { 315 359 static unsigned short n0, n1, n2, n3; 316 360 317 361 initSocket(); 318 362 if (sscanf(receptAddress,"%hu.%hu.%hu.%hu",&n0,&n1,&n2,&n3)==0) { … … 323 367 buffer4[2] = (unsigned char)n1; 324 368 buffer4[3] = (unsigned char)n0; 325 myHost = *((unsigned long*)&buffer4[0]);326 369 } 327 370 … … 332 375 socketLoop() 333 376 { 334 unsignedshort shift;377 short shift; 335 378 short version = 0; 336 379 int regRouter = 0; 337 /* CRI */338 380 time_t now = time((time_t *)NULL); 339 int iIP, iMPLS; 381 int iIP, iMPLS, i; 382 int loopNb = 0; 383 int gardeFou = 0; 340 384 time_t lastIPOutput, lastMPLSOutput; 341 385 time_t receptionTime; 342 /* end */343 386 344 387 now = time((time_t *)NULL); 388 tmPtr = localtime(&now); 389 currentIntervalle = tmPtr->tm_min; 345 390 lastMPLSOutput = now; 346 391 lastIPOutput = now; 347 392 do { 393 #ifdef DEBUG 394 fprintf (stderr, "["); 395 #endif 396 if ( ((tmPtr->tm_min)%STEP == 0) && (currentIntervalle != tmPtr->tm_min)){ 397 currentIntervalle = tmPtr->tm_min; 398 if (shmForAgg->currentTable == 0) { 399 shmForAgg->currentTable = 1; 400 shmForAgg->secondTable = 0; 401 }else{ 402 shmForAgg->currentTable = 0; 403 shmForAgg->secondTable = 1; 404 } 405 shmForAgg->readed = 1; 406 } 348 407 if (sigusr1Up == 1){ 349 408 sigusr1Up = 0; … … 351 410 } 352 411 socketReading(); 353 getIpHeader(pcktPtr, ptr_buffer); 354 regRouter = checkIpHeader(pcktPtr, &sortedRouterList[0], routerNb); 355 getUdpHeader(pcktPtr, ptr_buffer); 356 checkUdpHeader(pcktPtr, regRouter, receptPort); 412 getIpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 413 regRouter = checkIpHeader(myPtrs.pcktPtr, &sortedRouterList[0], routerNb); 414 getUdpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer); 415 if ( checkUdpHeader(myPtrs.pcktPtr, regRouter, receptPort) == 1 ){ 416 continue; 417 } 357 418 358 419 switch( version = 359 getNetFlowHeader( pcktPtr,ptr_buffer,360 currentHeaderV9Ptr,offsetV9Ptr)){420 getNetFlowHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer, 421 myPtrs.currentHeaderV9Ptr, myPtrs.offsetV9Ptr)){ 361 422 case 9: 362 if (( currentRouterPtr=notExistRouter(routersListPtr,363 423 if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr, 424 myPtrs.pcktPtr->ipH->srcAdd))==NULL) { 364 425 routersListPtr = addRouter(routersListPtr, 365 pcktPtr->ipH->srcAdd,426 myPtrs.pcktPtr->ipH->srcAdd, 366 427 (unsigned long) 0); 367 currentRouterPtr = routersListPtr;428 myPtrs.currentRouterPtr = routersListPtr; 368 429 } 369 430 currentFlowsetNumber = 0; 370 431 shift = 0; 371 while ((currentFlowsetNumber < currentHeaderV9Ptr->count)) { 432 gardeFou=0; 433 while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)) { 434 gardeFou++; 372 435 curTplFlSetPtr = NULL; 373 436 currentFlowsetId=getFlowsetId(currentFlowsetNumber, 374 offsetV9Ptr,ptr_buffer);437 myPtrs.offsetV9Ptr, myPtrs.ptr_buffer); 375 438 if ( currentFlowsetId == 0 ) { 376 shift = checkTemplateFlowSet(currentRouterPtr, offsetV9Ptr, 377 ptr_buffer, currentHeaderV9Ptr, 378 curTplFlSetPtr, 379 currentFlowsetNumberPtr, 380 myQueue); 381 /* showAllTplFlSet(); */ 439 if ( (shift = checkTemplateFlowSet(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 440 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 441 curTplFlSetPtr, 442 myPtrs.currentFlowsetNumberPtr, 443 myQueue)) < 0 ) { 444 #ifdef DEBUG 445 fprintf (stderr, "w>\n"); 446 #endif 447 currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 448 }; 449 writeAllTplFlSet(); 382 450 } else if (currentFlowsetId == 1) { 383 shift = checkTemplateOption(currentRouterPtr,offsetV9Ptr,384 ptr_buffer,currentHeaderV9Ptr,451 if ( (shift = checkTemplateOption(myPtrs.currentRouterPtr, myPtrs.offsetV9Ptr, 452 myPtrs.ptr_buffer, myPtrs.currentHeaderV9Ptr, 385 453 curTplOptionPtr, 386 currentFlowsetNumberPtr); 454 myPtrs.currentFlowsetNumberPtr) ) < 0 ) { 455 #ifdef DEBUG 456 fprintf (stderr, "wo>\n"); 457 #endif 458 currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 459 } 460 } else if (currentFlowsetId > 255) { 461 if ( (shift = checkDataFlowSet(shift, 462 &myPtrs, 463 myQueue, 464 shmForAgg->prefixV4Tab[shmForAgg->currentTable], 465 (size_t) shmForAgg->v4PrefixNb 466 ) ) < 0 ) { 467 #ifdef DEBUG 468 fprintf (stderr, "wd>\n"); 469 #endif 470 currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 471 } 387 472 } else { 388 shift = checkDataFlowSet(shift, currentRouterPtr, 389 currentHeaderV9Ptr, offsetV9Ptr, 390 ptr_buffer, currentFlowsetNumberPtr, 391 currentFlowsetIdPtr, pcktPtr, 392 rulesAddressPtr, rulesListPtr, 393 myQueue, prefixV4Tab, 394 (size_t) v4PrefixNb, 395 tabIPPtr, 396 tabMPLSPtr, 397 ipNbPtr, mplsNbPtr); 473 #ifdef DEBUG 474 fprintf (stderr, "1<<255\n"); 475 #endif 476 currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1; 398 477 } 399 } 478 if ( gardeFou > 200) { exit(-1); } 479 } /* end while flowset exist */ 400 480 break; 401 481 default: 402 /* syslog(LOG_INFO, */ 403 /* "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", */ 404 /* (unsigned short) version, */ 405 /* (pcktPtr->ipH->srcAdd>>24), */ 406 /* (pcktPtr->ipH->srcAdd<<8>>24), */ 407 /* (pcktPtr->ipH->srcAdd<<16>>24), */ 408 /* (pcktPtr->ipH->srcAdd<<24>>24)); */ 482 syslog(LOG_INFO, 483 "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", 484 (unsigned short) version, 485 (myPtrs.pcktPtr->ipH->srcAdd>>24), 486 (myPtrs.pcktPtr->ipH->srcAdd<<8>>24), 487 (myPtrs.pcktPtr->ipH->srcAdd<<16>>24), 488 (myPtrs.pcktPtr->ipH->srcAdd<<24>>24)); 409 489 break; 410 490 } 491 if (loopNb > 1000 ){ 492 /* FIXME perhaps call this function via the compilation options */ 493 writeAllTplFlSet(); 494 #ifdef DEBUG 495 fprintf(stderr, "W"); 496 #endif 497 loopNb = 0; 498 } 499 loopNb++; 411 500 412 501 #ifdef CRIHAN … … 493 582 } 494 583 #endif /* CRIHAN */ 584 now = time((time_t *)NULL); 585 tmPtr = localtime(&now); 586 #ifdef DEBUG 587 fprintf (stderr, "]\n"); 588 #endif 495 589 } while (1); 496 590 } … … 529 623 } 530 624 /* Here socket DGRAM creation, only to not have a unreachable service */ 625 /* message in return */ 531 626 inputSock2 = socket(AF_INET, SOCK_DGRAM, 0); 532 627 if (inputSock2 < 0) … … 568 663 569 664 sockNameFromlg = sizeof(fromName); 570 rcv = recvfrom(inputSock, ptr_buffer, sockBufSize, 0,665 rcv = recvfrom(inputSock, myPtrs.ptr_buffer, sockBufSize, 0, 571 666 (struct sockaddr *)(&fromName), 572 667 (socklen_t *)&sockNameFromlg); … … 584 679 585 680 /* 586 * check up flow datagramme 681 * check up flow datagramme 587 682 */ 588 683 short 589 684 checkFlow(short flowNumber) 590 685 { 591 return(0); 686 return(0); /* FIXME : why this function ??? */ 592 687 } 593 688 … … 595 690 * showAllTplFlSet 596 691 * 692 * to use only in debug mode 597 693 */ 598 694 void … … 602 698 TplFlowSetPtr tmpFS; 603 699 TplOptionPtr tmpOP; 604 fprintf(stderr," All template definitions: (field, size) :\n");700 fprintf(stderr,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n"); 605 701 for (; tmp; tmp=tmp->next) { 606 fprintf(stderr," router %lu.%lu.%lu.%lu :\n",702 fprintf(stderr,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n", 607 703 (tmp->IpAddress>>24), 608 704 (tmp->IpAddress<<8>>24), … … 611 707 tmpFS = tmp->tplList; 612 708 for (; tmpFS; tmpFS=tmpFS->next) { 613 fprintf(stderr,"ID %hu: ", tmpFS->templateFlowSetId); 614 printFieldSet(tmpFS->fieldSet); 709 fprintf(stderr,"TId %hu (sourceId: %lu):\n", 710 tmpFS->templateFlowSetId, 711 tmpFS->sourceId); 712 printFieldSet(stderr, tmpFS->fieldSet); 615 713 fprintf(stderr,"\n"); 616 714 } 617 715 if ((tmpOP = tmp->tplOptList) != NULL){ 618 fprintf(stderr,"template option: \n");619 716 for (; tmpOP; tmpOP=tmpOP->next) { 620 fprintf(stderr,"ID %hu: ", tmpOP->templateOptionId); 621 printFieldSet(tmpOP->fieldSet); 717 fprintf(stderr,"OpTId %hu (sourceId: %lu) >\n", 718 tmpOP->templateOptionId, 719 tmpOP->sourceId); 720 printFieldSet(stderr, tmpOP->fieldSet); 622 721 fprintf(stderr,"\n"); 623 722 } … … 626 725 } 627 726 } 727 728 729 /* 730 * writeAllTplFlSet 731 * 732 */ 733 void 734 writeAllTplFlSet() 735 { 736 737 RouterPtr tmp = routersListPtr; 738 TplFlowSetPtr tmpFS; 739 TplOptionPtr tmpOP; 740 FILE *TPLFILE; 741 if (!(TPLFILE = fopen("/tmp/TemplateDef.txt", "w"))) { 742 syslog (LOG_ERR, "error during %s opening", "/tmp/TemplateDef.txt"); 743 } 744 fprintf(TPLFILE,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n"); 745 for (; tmp; tmp=tmp->next) { 746 fprintf(TPLFILE,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n", 747 (tmp->IpAddress>>24), 748 (tmp->IpAddress<<8>>24), 749 (tmp->IpAddress<<16>>24), 750 (tmp->IpAddress<<24>>24)); 751 tmpFS = tmp->tplList; 752 for (; tmpFS; tmpFS=tmpFS->next) { 753 fprintf(TPLFILE,"TId %hu (sourceId: %lu):\n", 754 tmpFS->templateFlowSetId, 755 tmpFS->sourceId); 756 printFieldSet(TPLFILE, tmpFS->fieldSet); 757 fprintf(TPLFILE,"\n"); 758 } 759 if ((tmpOP = tmp->tplOptList) != NULL){ 760 for (; tmpOP; tmpOP=tmpOP->next) { 761 fprintf(TPLFILE,"OpTId %hu (sourceId: %lu) last %d brackets are Scope >\n lg: %hu, opScopeLg: %hu, opLg: %hu\n", 762 tmpOP->templateOptionId, 763 tmpOP->sourceId, 764 tmpOP->optionScopeLg/4, 765 tmpOP->length, 766 tmpOP->optionScopeLg, 767 tmpOP->optionLg); 768 printFieldSet(TPLFILE, tmpOP->fieldSet); 769 fprintf(TPLFILE,"\n"); 770 } 771 fprintf(TPLFILE,"\n"); 772 } 773 } 774 fclose(TPLFILE); 775 } -
/trunk/src/remote_output.c
r8 r28 2 2 * File: remote_output.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/template.c
r16 r30 2 2 * File: template.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier5 * 6 * Copyright (C) 2005 GIP RENATER4 * Authors: ANDREU Francois-Xavier 5 * 6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 53 53 * it can exist many templates definitions in a template flowset 54 54 */ 55 unsignedshort55 short 56 56 checkTemplateFlowSet(RouterPtr cr, unsigned short *offV9, 57 57 unsigned char *buf, … … 67 67 unsigned char buffer2[2]; 68 68 unsigned short tmp = 0; 69 unsigned short getFlowsetId = 0;69 unsigned short flowsetId = 0; 70 70 unsigned short length = 0; 71 TplFlowSetPtr ptpltmp ;71 TplFlowSetPtr ptpltmp = NULL; 72 72 /* for msg sending: */ 73 73 msgType myMsg; … … 75 75 char *msgTextIndex; 76 76 unsigned short tplMsgType = 1; 77 unsigned short badFieldNumber = 0; 78 unsigned short badFieldLength = 0; 79 unsigned short badFieldCount = 0; 77 80 78 81 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 79 82 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 80 getFlowsetId = *((unsigned short*)&buffer2);83 flowsetId = *((unsigned short*)&buffer2); 81 84 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 82 85 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 83 86 length = *((unsigned short*)&buffer2); 84 87 do { 88 #ifdef DEBUG 89 fprintf (stderr, "{"); 90 #endif 91 badFieldNumber = 0; 92 badFieldLength = 0; 93 badFieldCount = 0; 85 94 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 86 95 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; … … 96 105 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 97 106 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 98 cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 107 if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 108 badFieldCount = 1; 109 ptpltmp = cTFSPtr; 110 if (ptpltmp->prev == NULL) { 111 cr->tplList = ptpltmp->next; 112 if (cr->tplList) { 113 cr->tplList->prev = NULL; 114 } 115 } else { 116 ptpltmp->prev->next = ptpltmp->next; 117 if (ptpltmp->next) { 118 ptpltmp->next->prev = ptpltmp->prev; 119 } 120 } 121 deleteTplFlSet(ptpltmp); 122 cTFSPtr = NULL; 123 return (-1); 124 } 99 125 cpt_fields = 0; 100 126 for ( i=0; i<cTFSPtr->fieldCount; i++) { … … 102 128 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 103 129 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 104 fldPtr->fieldType = *((unsigned short*)&buffer2); 105 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 106 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 107 fldPtr->fieldLength = *((unsigned short*)&buffer2); 130 if ( (fldPtr->fieldType = *((unsigned short*)&buffer2) ) > 89) { 131 badFieldNumber = 1; 132 } 133 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 134 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 135 if ( (fldPtr->fieldLength = *((unsigned short*)&buffer2) ) > 16) { 136 badFieldLength = 1; 137 } 108 138 fldPtr->next = cTFSPtr->fieldSet; 109 139 fldPtr->prev = NULL; … … 114 144 } 115 145 cpt_fields++; 116 if ( cpt_fields > 40 ) { /* FIXME : declarer une constante pour cela */ 117 fprintf(stderr,"IP: %lu \n",cr->IpAddress); 118 fprintf (stderr, "cTFSPtr->templateFlowSetId: %hu\n", 146 if ( (cTFSPtr->templateFlowSetId < 256 ) 147 || (cpt_fields > 40) 148 || (badFieldNumber == 1) 149 || badFieldLength == 1 150 || (badFieldCount == 1)) { 151 fprintf(stderr,"\n IP: %lu.%lu.%lu.%lu, %d,%d\n", 152 cr->IpAddress>>24, 153 cr->IpAddress<<8>>24, 154 cr->IpAddress<<16>>24, 155 cr->IpAddress<<24>>24, 156 badFieldNumber, 157 badFieldLength 158 ); 159 fprintf (stderr, "\n cTFSPtr->templateFlowSetId: %hu\n", 119 160 cTFSPtr->templateFlowSetId); 120 161 while ( ((*offV9))> (index)){ … … 125 166 } 126 167 syslog (LOG_INFO, 127 "fields nb too large, bug collector or wrong template def"); 128 exit(1); 168 "in new template: field nb gt 89, field lg gt 16 or too many fields, bad template definition possibility"); 169 fprintf(stderr, 170 "\n in new template function: too many fields, bug collector or wrong template def \n"); 171 ptpltmp = cTFSPtr; 172 if (ptpltmp->prev == NULL) { 173 cr->tplList = ptpltmp->next; 174 if (cr->tplList) { 175 cr->tplList->prev = NULL; 176 } 177 } else { 178 ptpltmp->prev->next = ptpltmp->next; 179 if (ptpltmp->next) { 180 ptpltmp->next->prev = ptpltmp->prev; 181 } 182 } 183 deleteTplFlSet(ptpltmp); 184 cTFSPtr = NULL; 185 return (-1); 129 186 } 130 187 } … … 143 200 } 144 201 deleteTplFlSet(ptpltmp); 202 ptpltmp = NULL; 145 203 cTFSPtr = NULL; 146 204 cTFSPtr = newRouterTplList(); … … 152 210 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 153 211 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 154 cTFSPtr->fieldCount = *((unsigned short*)&buffer2); 212 if ( (cTFSPtr->fieldCount = *((unsigned short*)&buffer2) ) == 0 ) { 213 badFieldCount = 1; 214 ptpltmp = cTFSPtr; 215 if (ptpltmp->prev == NULL) { 216 cr->tplList = ptpltmp->next; 217 if (cr->tplList) { 218 cr->tplList->prev = NULL; 219 } 220 } else { 221 ptpltmp->prev->next = ptpltmp->next; 222 if (ptpltmp->next) { 223 ptpltmp->next->prev = ptpltmp->prev; 224 } 225 } 226 deleteTplFlSet(ptpltmp); 227 cTFSPtr = NULL; 228 return (-1); 229 } 155 230 cpt_fields = 0; 156 231 for ( i=0; i<cTFSPtr->fieldCount; i++) { … … 158 233 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 159 234 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 160 fldPtr->fieldType = *((unsigned short*)&buffer2); 161 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 162 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 163 fldPtr->fieldLength = *((unsigned short*)&buffer2); 235 if ( (fldPtr->fieldType = *((unsigned short*)&buffer2) ) > 89) { 236 badFieldNumber = 1; 237 } 238 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 239 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 240 if ( (fldPtr->fieldLength = *((unsigned short*)&buffer2) ) > 16) { 241 badFieldLength = 1; 242 } 164 243 fldPtr->next = cTFSPtr->fieldSet; 165 244 fldPtr->prev = NULL; … … 172 251 } 173 252 cpt_fields++; 174 if ( cpt_fields > 40 ) { /* FIXME : declarer une constante pour cela */ 253 if ( (cTFSPtr->templateFlowSetId < 256 ) 254 || (cpt_fields > 40) 255 || (badFieldNumber == 1) 256 || badFieldLength == 1 257 || (badFieldCount == 1)) { 175 258 while ( ((*offV9))> (index)){ 176 259 buffer2[1]= *(buf+index); index++; … … 180 263 } 181 264 syslog (LOG_INFO, 182 "fields nb too large, bug collector or wrong template def"); 183 exit(1); 265 "in update template function: too many fields, bug collector or wrong template def in template update"); 266 fprintf(stderr, 267 "\nin update template function: too many fields, bug collector or wrong template def in template update\n"); 268 ptpltmp = cTFSPtr; 269 if (ptpltmp->prev == NULL) { 270 cr->tplList = ptpltmp->next; 271 if (cr->tplList) { 272 cr->tplList->prev = NULL; 273 } 274 } else { 275 ptpltmp->prev->next = ptpltmp->next; 276 if (ptpltmp->next) { 277 ptpltmp->next->prev = ptpltmp->prev; 278 } 279 } 280 deleteTplFlSet(ptpltmp); 281 cTFSPtr = NULL; 282 return (-1); 184 283 } 185 284 } … … 194 293 /* ( cr->IpAddress)<<24>>24); */ 195 294 /* fprintf(stderr,"%lu %d\n", cTFSPtr->sourceId, sizeof(cTFSPtr->sourceId)); */ 295 /* FIXME HERE don't send an wrong def if error detected */ 196 296 msgTextIndex = mempcpy(mempcpy(mempcpy(mempcpy(mempcpy(myMsg.text, 197 297 &tplMsgType, … … 224 324 (*cFNPtr)++; 225 325 } while ( (cpt) < (length-2) ); /*length-2*/ 326 #ifdef DEBUG 327 fprintf (stderr, "}"); 328 #endif 226 329 return length; 227 330 } … … 231 334 * 232 335 */ 233 unsignedshort336 short 234 337 checkTemplateOption(RouterPtr cr, unsigned short *offV9, 235 338 unsigned char *buf, NetFlowV9HeaderPtr v9Ptr, … … 238 341 { 239 342 int i; 240 staticint cpt = 0;241 staticunsigned short getFlowsetId = 0;242 staticunsigned short length = 0;343 int cpt = 0; 344 unsigned short getFlowsetId = 0; 345 unsigned short length = 0; 243 346 unsigned char buffer2[2]; 244 347 TplOptionPtr ptplotmp; 348 unsigned short badFieldNumber = 0; 349 unsigned short badFieldLength = 0; 350 int cpt_fields = 0; 245 351 246 352 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; … … 251 357 length = *((unsigned short*)&buffer2); 252 358 do { 359 #ifdef DEBUG 360 fprintf (stderr, "<"); 361 #endif 362 badFieldNumber = 0; 363 badFieldLength = 0; 253 364 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 254 365 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; … … 268 379 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 269 380 cTOPtr->optionLg = *((unsigned short*)&buffer2); 381 cpt_fields = 0; 270 382 for ( i=0; i<(((cTOPtr->optionScopeLg)+(cTOPtr->optionLg))/4); i++) { 271 383 FieldPtr tmp = (FieldPtr) malloc(sizeof(struct Field)); 272 384 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 273 385 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 274 tmp->fieldType = *((unsigned short*)&buffer2); 275 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 276 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 277 tmp->fieldLength = *((unsigned short*)&buffer2); 386 if ( (tmp->fieldType = *((unsigned short*)&buffer2) ) > 89) { 387 badFieldNumber = 1; 388 } 389 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 390 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 391 if ( (tmp->fieldLength = *((unsigned short*)&buffer2) ) > 16) { 392 badFieldLength = 1; 393 } 278 394 tmp->next = cTOPtr->fieldSet; 279 395 tmp->prev = NULL; … … 282 398 if (i==0) { 283 399 cTOPtr->lastField = tmp; 400 } 401 cpt_fields++; 402 if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 403 syslog (LOG_INFO, 404 "in option template function: too many fields, bug collector or wrong template def in template update"); 405 #ifdef DEBUG 406 fprintf(stderr, 407 "\nin option template function: too many fields, bug collector or wrong template def in template update\n"); 408 #endif 409 ptplotmp = cTOPtr; 410 if (ptplotmp->prev == NULL) { 411 cr->tplOptList = ptplotmp->next; 412 if (cr->tplOptList) { 413 cr->tplOptList->prev = NULL; 414 } 415 } else { 416 ptplotmp->prev->next = ptplotmp->next; 417 if (ptplotmp->next) { 418 ptplotmp->next->prev = ptplotmp->prev; 419 } 420 } 421 deleteTplOption(ptplotmp); 422 cTOPtr = NULL; 423 return (-1); 284 424 } 285 425 } … … 314 454 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 315 455 cTOPtr->optionLg = *((unsigned short*)&buffer2); 456 cpt_fields = 0; 316 457 for ( i=0; i<(((cTOPtr->optionScopeLg)+(cTOPtr->optionLg))/4); i++) { 317 458 FieldPtr tmp = (FieldPtr) malloc(sizeof(struct Field)); 318 459 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 319 460 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 320 tmp->fieldType = *((unsigned short*)&buffer2); 321 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 322 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 323 tmp->fieldLength = *((unsigned short*)&buffer2); 461 if ( (tmp->fieldType = *((unsigned short*)&buffer2) ) > 89) { 462 badFieldNumber = 1; 463 } 464 buffer2[1]= *(buf+(*offV9)); (*offV9)++; cpt++; 465 buffer2[0]= *(buf+(*offV9)); (*offV9)++; cpt++; 466 if ( (tmp->fieldLength = *((unsigned short*)&buffer2) ) > 16) { 467 badFieldLength = 1; 468 } 324 469 tmp->next = cTOPtr->fieldSet; 325 470 tmp->prev = NULL; … … 328 473 if (i==0) { 329 474 cTOPtr->lastField = tmp; 475 } 476 cpt_fields++; 477 if ( (cTOPtr->templateOptionId < 256) || (cpt_fields > 40) || (badFieldNumber == 1) || badFieldLength == 1) { 478 syslog (LOG_INFO, 479 "in update option tpl function: too many fields, bug collector or wrong template def in template update"); 480 #ifdef DEBUG 481 fprintf(stderr, 482 "\nin update option tpl function: too many fields, bug collector or wrong template def in template update\n"); 483 #endif 484 ptplotmp = cTOPtr; 485 if (ptplotmp->prev == NULL) { 486 cr->tplOptList = ptplotmp->next; 487 if (cr->tplOptList) { 488 cr->tplOptList->prev = NULL; 489 } 490 } else { 491 ptplotmp->prev->next = ptplotmp->next; 492 if (ptplotmp->next) { 493 ptplotmp->next->prev = ptplotmp->prev; 494 } 495 } 496 deleteTplOption(ptplotmp); 497 cTOPtr = NULL; 498 return (-1); 330 499 } 331 500 } … … 337 506 } while ((cpt) < (length-2)); 338 507 /* show_all_tplFlSet(); */ 508 #ifdef DEBUG 509 fprintf (stderr, ">"); 510 #endif 339 511 return length; 340 512 } -
/trunk/src/renetcol.h
r20 r29 2 2 * File: renetcol.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 70 70 71 71 #define ROUTER_INDEX_MAX 70 72 #define PREFIX_V4_MAX 400073 72 #define FIELD_TYPE_NUMBER 89 74 73 #define MAX_RULES_PER_FIELD 10 … … 80 79 #define MAX_IP_OUTPUT_FILES 3 81 80 #define MAX_MPLS_OUTPUT_FILES 3 82 #define MAX_IP_FLOW 1000083 #define MAX_MPLS_FLOW 20084 81 #define IP_TIME_THRESHOLD 60 /* in sec */ 85 82 #define MPLS_TIME_THRESHOLD 60 /* in sec */ 86 83 #endif /* CRIHAN */ 84 85 #define MAX_IP_FLOW 10000 86 #define MAX_MPLS_FLOW 200 87 88 #define SHMSIZE 33554432 89 90 #define STEP 5 /* in min */ 91 92 struct SHMForAgg { 93 unsigned short currentTable; 94 unsigned short secondTable; 95 unsigned short readed; 96 unsigned short v4PrefixNb; 97 struct PrefixV4 prefixV4Tab[2][MAX_IPV4_PREFIX]; 98 /* struct PrefixV6 ; */ 99 }; 100 87 101 88 102 void setCache(RulesPtr); … … 101 115 short checkFlow(short); 102 116 void showAllTplFlSet(); 117 void writeAllTplFlSet(); 103 118 -
/trunk/src/remote_output.h
r8 r28 2 2 * File: remote_output.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/template.h
r2 r28 2 2 * File: template.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 34 34 35 35 short getFlowsetId(short, unsigned short *, unsigned char *); 36 unsignedshort checkTemplateFlowSet(RouterPtr, unsigned short *,36 short checkTemplateFlowSet(RouterPtr, unsigned short *, 37 37 unsigned char *, 38 38 NetFlowV9HeaderPtr, 39 39 TplFlowSetPtr, short *, int); 40 unsignedshort checkTemplateOption(RouterPtr, unsigned short *,40 short checkTemplateOption(RouterPtr, unsigned short *, 41 41 unsigned char *, 42 42 NetFlowV9HeaderPtr, -
/trunk/src/rrdwrap.c
r17 r27 2 2 3 3 /* Contributed by Antony Clothier */ 4 5 /* Ligne 152 commented FXA*/ 4 6 5 7 #include "rrdwrap.h" … … 148 150 opterr=0; /* no error messages */ 149 151 150 i = rrd_graph(argc, argv, prdata, &xsize, &ysize); 152 /* i = rrd_graph(argc, argv, prdata, &xsize, &ysize); */ 151 153 152 154 /* free up the memory*/ -
/trunk/src/get_conf.c
r17 r29 2 2 * File: get_conf.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 141 141 unsigned char buffer4[4]; 142 142 int i = 0; 143 char prefixStrTab[ 10000][50];143 char prefixStrTab[MAX_IPV4_PREFIX][50]; 144 144 145 145 if (!(prefixFile = fopen(filename, "r"))) { … … 151 151 strcpy(prefixStrTab[counter], line); 152 152 counter++; 153 if (counter == 10000) {153 if (counter == MAX_IPV4_PREFIX) { 154 154 fprintf(stderr, "bufferoverflow in getPrefixV4 function (get_conf.c)\ 155 change the value of prefixStrTabdeclaration and recompile \n");155 change the value of MAX_IPV4_PREFIX declaration and recompile \n"); 156 156 exit(1); 157 157 } … … 171 171 *((unsigned long*)&buffer4[0]) +~(~0<<(32-n4)); 172 172 pV4TabPtr[i].mask = n4; 173 pV4TabPtr[i].sampling = 0; 173 174 pV4TabPtr[i].routerNb = n5; 175 pV4TabPtr[i].flowNbIN = 0; 176 pV4TabPtr[i].bytesNbIN = 0; 177 pV4TabPtr[i].pktsNbIN = 0; 178 pV4TabPtr[i].flowNbOUT = 0; 179 pV4TabPtr[i].bytesNbOUT = 0; 180 pV4TabPtr[i].pktsNbOUT = 0; 181 pV4TabPtr[i].firstCoSIN = 0; 182 pV4TabPtr[i].secondCoSIN = 0; 183 pV4TabPtr[i].thirdCoSIN = 0; 184 pV4TabPtr[i].fourthCoSIN = 0; 185 pV4TabPtr[i].firstCoSOUT = 0; 186 pV4TabPtr[i].secondCoSOUT = 0; 187 pV4TabPtr[i].thirdCoSOUT = 0; 188 pV4TabPtr[i].fourthCoSOUT = 0; 174 189 } 175 190 if( fclose(prefixFile) == 0) { -
/trunk/src/renetcolMsgCtl.c
r2 r28 2 2 * File: renetcolMsgCtl.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/routers_mgmt.c
r2 r30 2 2 * File: routers_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 29 29 { 30 30 RouterPtr tmp = rL; 31 int i = 0; 31 32 for ( ; tmp; tmp=tmp->next) { 33 i++; 32 34 if ( tmp->IpAddress == address ){ 35 /* fprintf (stderr, "ExistRouter %d parcours %lu.%lu.%lu.%lu\ \n", */ 36 /* i, */ 37 /* address>>24, */ 38 /* address<<8>>24, */ 39 /* address<<16>>24, */ 40 /* address<<24>>24 */ 41 /* ); */ 33 42 return tmp; 34 43 } 35 44 } 45 /* fprintf (stderr, "notExistRouter %lu.%lu.%lu.%lu\n", */ 46 /* address>>24, */ 47 /* address<<8>>24, */ 48 /* address<<16>>24, */ 49 /* address<<24>>24); */ 36 50 return NULL; 37 51 } … … 42 56 RouterPtr tmp = (RouterPtr) malloc(sizeof(struct Router)); 43 57 if (tmp==NULL) { 58 /* FIXME : syslog here */ 44 59 fprintf(stderr, "ERROR in malloc in add_routers function\n"); 45 60 exit(1); … … 60 75 TplFlowSetPtr tmp = (TplFlowSetPtr) malloc(sizeof(struct TemplateFlowSet)); 61 76 tmp->sourceId = 0; 62 tmp->templateFlowSetId = 0;77 tmp->templateFlowSetId = 99; 63 78 tmp->fieldCount = 0; 64 79 tmp->fieldSet = NULL; … … 88 103 ptpl = NULL; 89 104 } 90 return NULL; /* FIXME I don't known */105 return NULL; 91 106 } 92 107 … … 95 110 TplOptionPtr tmp = (TplOptionPtr) malloc(sizeof(struct TemplateOption)); 96 111 tmp->sourceId = 0; 97 tmp->templateOptionId = 0;112 tmp->templateOptionId = 66; 98 113 tmp->length = 0; 99 114 tmp->optionScopeLg = 0; -
/trunk/src/get_conf.h
r17 r29 2 2 * File: get_conf.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 26 26 #define GET_CONF_H 27 27 28 #define MAX_IPV4_PREFIX 10000 29 28 30 struct PrefixV4{ 29 unsigned long beginning; 31 unsigned long beginning; /* FIXME to transform in start */ 30 32 unsigned long end; 31 unsigned short mask; 32 unsigned short routerNb; 33 unsigned short mask; /* prefix mask */ 34 unsigned short routerNb; /* router ID */ 35 unsigned long sampling; /* Sampling value */ 36 unsigned long long flowNbIN; /* WARNING !!! */ 37 unsigned long long bytesNbIN; /* Here, IN means "to the prefix" */ 38 unsigned long long pktsNbIN; 39 unsigned long long flowNbOUT; /* WARNING !!! */ 40 unsigned long long bytesNbOUT; /* Here, OUT means "from the prefix" */ 41 unsigned long long pktsNbOUT; 42 unsigned long long firstCoSIN; /* only the bytes for CoS */ 43 unsigned long long secondCoSIN; 44 unsigned long long thirdCoSIN; 45 unsigned long long fourthCoSIN; 46 unsigned long long firstCoSOUT; 47 unsigned long long secondCoSOUT; 48 unsigned long long thirdCoSOUT; 49 unsigned long long fourthCoSOUT; 33 50 }; 34 51 -
/trunk/src/fields_mgmt.c
r2 r28 2 2 * File: fields_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2004 GIP RENATER6 * Copyright (C) 2004 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 31 31 * print_fields_set 32 32 */ 33 void printFieldSet(F ieldPtr pf)33 void printFieldSet(FILE *file, FieldPtr pf) 34 34 { 35 35 FieldPtr tmp = pf; 36 fprintf(stderr, "template definition: (field, size)\n");37 36 for (; tmp; tmp=tmp->next) { 38 fprintf( stderr, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength);37 fprintf(file, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength); 39 38 } 40 fprintf( stderr,"\n");39 fprintf(file,"\n"); 41 40 } 42 41 … … 44 43 * invPrintFieldSet 45 44 */ 46 void invPrintFieldSet(F ieldPtr pf)45 void invPrintFieldSet(FILE *file, FieldPtr pf) 47 46 { 48 47 FieldPtr tmp = pf; 49 fprintf(stderr, "fields set (inv): \n");50 48 for (; tmp; tmp=tmp->prev) { 51 fprintf( stderr, " %hu %hu \n", tmp->fieldType, tmp->fieldLength);49 fprintf(file, "(%hu,%hu) ", tmp->fieldType, tmp->fieldLength); 52 50 } 51 fprintf(file,"\n"); 53 52 } 54 53 -
/trunk/src/routers_mgmt.h
r2 r28 2 2 * File: routers_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/headers_mgmt.c
r8 r28 2 2 * File: headers_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/fields_mgmt.h
r2 r28 2 2 * File: fields_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 26 26 #define FIELDS_MGMT_H 27 27 28 #include <stdio.h> 29 28 30 typedef struct Field * FieldPtr; 29 31 typedef struct Field { … … 36 38 FieldPtr addField (FieldPtr, unsigned short, unsigned short); 37 39 int delField(unsigned short, unsigned short); 38 void printFieldSet(F ieldPtr);39 void invPrintFieldSet(F ieldPtr);40 void printFieldSet(FILE *, FieldPtr); 41 void invPrintFieldSet(FILE *, FieldPtr); 40 42 void freeField(FieldPtr); 41 43 /*p_routers search_fields(unsigned short);*/ -
/trunk/src/output_file.c
r18 r28 2 2 * File: output_file.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/headers_mgmt.h
r8 r28 2 2 * File: headers_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/output_file.h
r18 r28 4 4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/msg_mgmt.c
r8 r28 2 2 * File: msg_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/renetcolSender.c
r20 r30 2 2 * File: renetcolSender.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier5 * 6 * Copyright (C) 2005 GIP RENATER4 * Authors: ANDREU Francois-Xavier 5 * 6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 299 299 } 300 300 if (sscanf (argv[2], "%ld", &type) != 1){ 301 fprintf(stderr, " Invalid type\n");301 fprintf(stderr, "renetcolSender: Error, Invalid message type in command\n"); 302 302 exit(1); 303 303 } … … 329 329 330 330 /* chdir ("/"); */ 331 fprintf(stderr, " I become a deamon, next messages via syslogd.\n");331 fprintf(stderr, "renetcolSender: I become a deamon, next messages via syslogd. By.\n"); 332 332 if (fork () != 0) 333 333 exit (0); -
/trunk/src/dataFlowSet.c
r20 r30 4 4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 27 27 28 28 /* 29 * checkDataFlowSet29 * Check Data FlowSet 30 30 * 31 31 */ 32 unsigned short 33 checkDataFlowSet(unsigned short shift, RouterPtr cr, NetFlowV9HeaderPtr v9Ptr, 34 unsigned short *offV9, unsigned char *buf, short *cFNPtr, 35 short *cFId, DatagramPtr pcktPtr, RuleDefPtr *rulesCache, 36 RulesPtr rlPtr, int myQueue, struct PrefixV4 *V4PTab, 37 size_t nbPV4, 38 struct IPFLowCache *ipCache, struct MPLSFlowCache *mplsCache, 39 unsigned long *ipCounter, unsigned long *mplsCounter) 32 short 33 checkDataFlowSet(short shift, 34 struct MyPtrs *myPtrs, 35 int myQueue, 36 struct PrefixV4 *V4PTab, 37 size_t nbPV4 38 ) 40 39 { 41 TplFlowSetPtr tmp; 42 FieldPtr pftmp; 43 FieldPtr secondPftmp; 40 TplFlowSetPtr tmp = NULL; 41 TplOptionPtr tmpOpt = NULL; 42 FieldPtr pftmp = NULL; 43 FieldPtr secondPftmp = NULL; 44 44 unsigned short data_length = 0; 45 45 unsigned short flow_size = 0; 46 unsigned short oldOffset = * offV9;46 unsigned short oldOffset = *myPtrs->offsetV9Ptr; 47 47 unsigned short secondOffset = 0; 48 48 unsigned short secondOldOffset = 0; … … 59 59 unsigned char buffer2[2]; 60 60 unsigned char buffer4[4]; 61 RulesPtr tmpRuleList = rlPtr;61 RulesPtr tmpRuleList = myPtrs->rulesListPtr; 62 62 msgType myMsg; 63 63 char *msgTextIndex; … … 65 65 struct PrefixV4 prefixKey, *res; /* for bsearch */ 66 66 struct AggCache agCache; 67 #ifdef CRIHAN 68 struct IPFLowCache ipFirstCache; /* CRI */ 69 struct MPLSFlowCache mplsFirstCache; /* CRI */ 70 unsigned long firstTime = 0; /* CRI */ 71 unsigned long lastTime = 0; /* CRI */ 72 #endif /* CRIHAN */ 73 int bool = 0; 74 75 #ifdef CRIHAN 67 int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */ 68 /* flow, we test on the field and then put bool at 1 */ 69 int isMplsFlow = 0; 70 int paddingCounter = 0; 71 int crazyCounter = 0; 72 73 #ifdef CRIHAN 74 struct IPFLowCache ipFirstCache; 75 struct MPLSFlowCache mplsFirstCache; 76 unsigned long firstTime = 0; 77 unsigned long lastTime = 0; 78 76 79 ipFirstCache.ipProt = 0; 77 80 ipFirstCache.bytes = 0; … … 95 98 #endif /* CRIHAN */ 96 99 97 buffer2[1] = *( buf+(*offV9));(*offV9)++;98 buffer2[0] = *( buf+(*offV9));(*offV9)++;99 (* cFId) = *((unsigned short*)&buffer2);100 buffer2[1] = *( buf+(*offV9));(*offV9)++;101 buffer2[0] = *( buf+(*offV9));(*offV9)++;100 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 101 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 102 (*myPtrs->currentFlowsetIdPtr) = *((unsigned short*)&buffer2); 103 buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 104 buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; 102 105 data_length = *((unsigned short*)&buffer2); 103 if ((tmp=existTplId(cr, v9Ptr->sourceId, 104 (*cFId)))!=NULL) { 106 107 if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId, 108 (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { 109 #ifdef DEBUG 110 fprintf(stderr,"{d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 111 if ( (*myPtrs->currentFlowsetIdPtr) > 270 ) { 112 /* fprintf(stderr,"Bad TID from router: %lu.%lu.%lu.%lu\n", */ 113 /* (*myPtrs->currentFlowsetIdPtr), */ 114 /* (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 115 /* (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 116 /* (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 117 /* (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); */ 118 /* fprintf(stderr," Bytes : \n"); */ 119 /* while ( ( myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr) ) > (myPtrs->ptr_buffer+1416) ){ */ 120 /* buffer1= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; */ 121 /* tmp = *((unsigned char*)&buffer1); */ 122 /* fprintf (stderr, " %s ", tmp); */ 123 /* } */ 124 /* exit(-1); */ 125 return (data_length+shift); 126 } 127 #endif 105 128 pftmp = tmp->lastField; 106 129 for (; pftmp; pftmp = pftmp->prev) { … … 108 131 } 109 132 if ( data_length%flow_size >= 9 ) { 110 (* cFNPtr) = v9Ptr->count;133 (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 111 134 syslog(LOG_INFO, "data flowset length not match with length from template definition, wrong template definition suspected; all next informations of this data flowset are not considered! flowset ID: %hu, from router: %lu.%lu.%lu.%lu", 112 (* cFId),113 ( pcktPtr->ipH->srcAdd>>24),114 ( pcktPtr->ipH->srcAdd<<8>>24),115 ( pcktPtr->ipH->srcAdd<<16>>24),116 ( pcktPtr->ipH->srcAdd<<24>>24));135 (*myPtrs->currentFlowsetIdPtr), 136 (myPtrs->pcktPtr->ipH->srcAdd>>24), 137 (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 138 (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 139 (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 117 140 return (data_length+shift); 118 141 } 119 /* aggreg */ 120 /* agCache.routerAd = pcktPtr->ipH->srcAdd; */ 121 /* end aggreg */ 122 123 #ifdef CRIHAN 124 ipFirstCache.routerAd = pcktPtr->ipH->srcAdd; 125 mplsFirstCache.routerAd = pcktPtr->ipH->srcAdd; 142 if ( data_length >= 1452 ) { 143 syslog(LOG_INFO, "data flowset length too raised; all next informations of this data flowset are not considered! flowset ID: %hu, from router: %lu.%lu.%lu.%lu", 144 (*myPtrs->currentFlowsetIdPtr), 145 (myPtrs->pcktPtr->ipH->srcAdd>>24), 146 (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 147 (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 148 (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); 149 return (-1); 150 } 151 #ifdef IPV4AGG 152 agCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; 153 #endif 154 155 #ifdef CRIHAN 156 ipFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; 157 mplsFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; 126 158 #endif /* CRIHAN */ 127 159 128 160 pftmp = tmp->lastField; 129 161 secondPftmp = tmp->lastField; 130 secondOffset = * offV9;162 secondOffset = *myPtrs->offsetV9Ptr; 131 163 secondOldOffset = secondOffset; 132 while ( (((* offV9)-48-shift) <= data_length) && (overflow!=1) ) {164 while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) { 133 165 /* 134 * progression in a flow Set166 * progression in a data flow Set 135 167 * notes: 136 168 * 48=header ip + header netf … … 138 170 */ 139 171 cpt++; 140 j =0;172 j = 0; 141 173 pos = (pftmp->fieldType)*10+j; 142 174 field_size = (int) pftmp->fieldLength; 175 176 /* special case: check yes on all flows from one router (phantom field nb 0) */ 177 while ( ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j))) != NULL ) { 178 if ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j)))->value->stor.lvalue) 179 == myPtrs->pcktPtr->ipH->srcAdd ) 180 { 181 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j)))->check = 1; 182 } 183 j++; 184 } 185 j = 0; 186 143 187 /* 144 188 * Comparaison between the field value and the rules 145 189 * ... if one rule exist 190 * FIXME : warning, if no rules, no accounting ? 146 191 */ 147 if (((RuleDefPtr)(*( rulesCache+pos))) != NULL) {148 oldOffset = * offV9;149 while (((RuleDefPtr)(*( rulesCache+pos))) != NULL){192 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL) { 193 oldOffset = *myPtrs->offsetV9Ptr; 194 while (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL){ 150 195 /* 151 196 * while on one cache table line 152 197 */ 153 * offV9= oldOffset;198 *myPtrs->offsetV9Ptr = oldOffset; 154 199 switch ((int) 155 (((RuleDefPtr)(*( rulesCache+pos)))->operator)){200 (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)){ 156 201 case 2: 202 /* operator: "=" */ 157 203 switch (field_size) { 158 204 case 1: 159 buffer1 = *( buf+(*offV9)); (*offV9)++;205 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 160 206 /* rule check */ 161 if (((RuleDefPtr)(*( rulesCache+pos)))->value->stor.cvalue207 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.cvalue 162 208 == *((unsigned char*)&buffer1)) { 163 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;209 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 164 210 } 165 211 /* end rule check */ 166 /* aggregation */ 167 /* if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 168 /* agCache.maskS = *((unsigned char*)&buffer1); */ 169 /* } */ 170 /* if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 171 /* agCache.maskD = *((unsigned char*)&buffer1); */ 172 /* } */ 173 /* if (pftmp->fieldType==60){ */ 174 /* agCache.ipProt = *((unsigned char*)&buffer1); */ 175 /* } */ 176 /* if (pftmp->fieldType==4){ */ 177 /* agCache.tProt = *((unsigned char*)&buffer1); */ 178 /* } */ 179 /* if (pftmp->fieldType==61){ */ 180 /* agCache.sens = *((unsigned char*)&buffer1); */ 181 /* } */ 182 /* if (pftmp->fieldType==5){ */ 183 /* agCache.dscp = *((unsigned char*)&buffer1); */ 184 /* } */ 185 /* end aggregation */ 212 #ifdef IPV4AGG 213 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 214 agCache.maskS = *((unsigned char*)&buffer1); 215 } 216 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 217 agCache.maskD = *((unsigned char*)&buffer1); 218 } 219 if (pftmp->fieldType==60){ 220 agCache.ipProt = *((unsigned char*)&buffer1); 221 } 222 if (pftmp->fieldType==4){ 223 agCache.tProt = *((unsigned char*)&buffer1); 224 } 225 if (pftmp->fieldType==61){ 226 agCache.sens = *((unsigned char*)&buffer1); 227 } 228 if (pftmp->fieldType==5){ 229 agCache.dscp = *((unsigned char*)&buffer1); 230 } 231 #endif 186 232 #ifdef CRIHAN 187 233 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ … … 198 244 ipFirstCache.tProt = *((unsigned char*)&buffer1); 199 245 } 200 #endif /* CRIHAN */246 #endif 201 247 break; 202 248 case 2: 203 buffer2[1]= *( buf+(*offV9)); (*offV9)++;204 buffer2[0]= *( buf+(*offV9)); (*offV9)++;205 if (((RuleDefPtr)(*( rulesCache+pos)))->value->stor.svalue249 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 250 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 251 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue 206 252 == *((unsigned short*)&buffer2)) 207 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;208 /* aggregation */ 209 /* if (pftmp->fieldType==10){ */ 210 /* agCache.idSnmp = *((unsigned short*)&buffer2); */ 211 /* } */ 212 /* end aggregation */ 253 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 254 #ifdef IPV4AGG 255 if (pftmp->fieldType==10){ 256 agCache.idSnmp = *((unsigned short*)&buffer2); 257 } 258 #endif 213 259 #ifdef CRIHAN 214 260 if (pftmp->fieldType==10){ … … 224 270 ipFirstCache.dPort = *((unsigned short*)&buffer2); 225 271 } 226 #endif /* CRIHAN */272 #endif 227 273 break; 228 274 case 3: 229 275 buffer4[3]= 0; 230 buffer4[2]= *( buf+(*offV9)); (*offV9)++;231 buffer4[1]= *( buf+(*offV9)); (*offV9)++;232 buffer4[0]= *( buf+(*offV9)); (*offV9)++;233 if (((RuleDefPtr)(*( rulesCache+pos)))->value->stor.lvalue276 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 277 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 278 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 279 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue 234 280 == *((unsigned long*)&buffer4)) 235 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;281 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 236 282 /* aggregation */ 237 283 /* end aggregation */ 284 if (pftmp->fieldType==70){ 285 isMplsFlow = 1; 286 } 238 287 #ifdef CRIHAN 239 288 if (pftmp->fieldType==70){ 240 289 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 241 290 } 242 #endif /* CRIHAN */291 #endif 243 292 break; 244 293 case 4: 245 buffer4[3]= *( buf+(*offV9)); (*offV9)++;246 buffer4[2]= *( buf+(*offV9)); (*offV9)++;247 buffer4[1]= *( buf+(*offV9)); (*offV9)++;248 buffer4[0]= *( buf+(*offV9)); (*offV9)++;294 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 295 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 296 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 297 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 249 298 /* FIXME : here , add a check on the field type */ 250 299 if ((pftmp->fieldType==8)||(pftmp->fieldType==12)){ 251 if ((((RuleDefPtr)(*( rulesCache+pos)))->value->stor.lvalue)252 == (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*( rulesCache+pos)))->value->mask)<<(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask) )300 if ((((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue) 301 == (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) ) 253 302 { 254 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;303 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 255 304 } 256 } 257 /* aggregation */ 258 /* if ((pftmp->fieldType==8)){ */ 259 /* agCache.v4AdS = *((unsigned long*)&buffer4); */ 260 /* } */ 261 /* if ((pftmp->fieldType==12)){ */ 262 /* agCache.v4AdD = *((unsigned long*)&buffer4); */ 263 /* } */ 264 /* if (pftmp->fieldType==1){ */ 265 /* agCache.bytes = *((unsigned long*)&buffer4); */ 266 /* } */ 267 /* if (pftmp->fieldType==2){ */ 268 /* agCache.pkts = *((unsigned long*)&buffer4); */ 269 /* } */ 270 /* end aggregation */ 305 } 306 #ifdef IPV4AGG 307 if ((pftmp->fieldType==8)){ 308 bool = 1; /* very important, test if we have an IPv4 flow for Agg */ 309 agCache.v4AdS = *((unsigned long*)&buffer4); 310 } 311 if ((pftmp->fieldType==12)){ 312 agCache.v4AdD = *((unsigned long*)&buffer4); 313 } 314 if (pftmp->fieldType==1){ 315 agCache.bytes = *((unsigned long*)&buffer4); 316 } 317 if (pftmp->fieldType==2){ 318 agCache.pkts = *((unsigned long*)&buffer4); 319 } 320 #endif 271 321 #ifdef CRIHAN 272 322 if (pftmp->fieldType==8){ … … 290 340 lastTime = *((unsigned long*)&buffer4); 291 341 } 292 #endif /* CRIHAN */342 #endif 293 343 break; 294 344 case 16: 295 345 for (i=0; i<4; i++) { 296 buffer4[3]= *( buf+(*offV9)); (*offV9)++;297 buffer4[2]= *( buf+(*offV9)); (*offV9)++;298 buffer4[1]= *( buf+(*offV9)); (*offV9)++;299 buffer4[0]= *( buf+(*offV9)); (*offV9)++;346 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 347 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 348 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 349 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 300 350 if (1==moreIsNecessary){ 301 351 switch(i){ 302 352 case 0: 303 if (((RuleDefPtr)(*( rulesCache+pos)))->value->mask <= 32){304 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])353 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 32){ 354 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 305 355 == 306 (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*( rulesCache+pos)))->value->mask)<<(32-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)356 (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 307 357 ) 308 358 { 309 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;359 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 310 360 moreIsNecessary = 0; 311 361 } else { 312 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;362 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 313 363 moreIsNecessary = 0; 314 364 } 315 365 } else { 316 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])366 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 317 367 == 318 368 (*((unsigned long*)&buffer4)) 319 369 ) 320 370 { 321 ((RuleDefPtr)(*( rulesCache+pos)))->check = 1;371 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; 322 372 } else { 323 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;373 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 324 374 moreIsNecessary = 0; 325 375 } … … 327 377 break; 328 378 case 1: 329 if (((RuleDefPtr)(*( rulesCache+pos)))->value->mask <= 64){330 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])379 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 64){ 380 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 331 381 == 332 (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*( rulesCache+pos)))->value->mask)<<(64-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)382 (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 333 383 ) 334 384 { 335 ((RuleDefPtr)(*( rulesCache+pos)))->check =336 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;385 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 386 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 337 387 moreIsNecessary = 0; 338 388 } else { 339 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;389 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 340 390 moreIsNecessary = 0; 341 391 } 342 392 } else { 343 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])393 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 344 394 == 345 395 (*((unsigned long*)&buffer4)) 346 396 ) 347 397 { 348 ((RuleDefPtr)(*( rulesCache+pos)))->check =349 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;398 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 399 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 350 400 } else { 351 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;401 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 352 402 moreIsNecessary = 0; 353 403 } … … 355 405 break; 356 406 case 2: 357 if (((RuleDefPtr)(*( rulesCache+pos)))->value->mask <= 96){358 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])407 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 96){ 408 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 359 409 == 360 (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*( rulesCache+pos)))->value->mask)<<(96-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)410 (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 361 411 ) 362 412 { 363 ((RuleDefPtr)(*( rulesCache+pos)))->check =364 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;413 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 414 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 365 415 moreIsNecessary = 0; 366 416 } else { 367 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;417 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 368 418 moreIsNecessary = 0; 369 419 } 370 420 } else { 371 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])421 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 372 422 == 373 423 (*((unsigned long*)&buffer4)) 374 424 ) 375 425 { 376 ((RuleDefPtr)(*( rulesCache+pos)))->check =377 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;426 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 427 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 378 428 } else { 379 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;429 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 380 430 moreIsNecessary = 0; 381 431 } … … 383 433 break; 384 434 case 3: 385 if (((RuleDefPtr)(*( rulesCache+pos)))->value->mask <= 128){386 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])435 if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 128){ 436 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 387 437 == 388 (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*( rulesCache+pos)))->value->mask)<<(128-((RuleDefPtr)(*(rulesCache+pos)))->value->mask)438 (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) 389 439 ) 390 440 { 391 ((RuleDefPtr)(*( rulesCache+pos)))->check =392 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;441 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 442 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 393 443 } else { 394 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;444 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 395 445 moreIsNecessary = 0; 396 446 } 397 447 } else { 398 if (ntohl(((RuleDefPtr)(*( rulesCache+pos)))->value->stor.tabAdd6[i])448 if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) 399 449 == 400 450 (*((unsigned long*)&buffer4)) 401 451 ) 402 452 { 403 ((RuleDefPtr)(*( rulesCache+pos)))->check =404 ((RuleDefPtr)(*( rulesCache+pos)))->check && 1;453 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 454 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; 405 455 } else { 406 ((RuleDefPtr)(*( rulesCache+pos)))->check = 0;456 ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; 407 457 moreIsNecessary = 0; 408 458 } … … 415 465 } 416 466 moreIsNecessary = 1; 417 /* aggregation */467 /* aggregation for IPv6 flows */ 418 468 419 469 /* end aggregation */ … … 422 472 syslog(LOG_INFO, "Field size not known: %d\n", field_size); 423 473 for (i=0; i<field_size; i++){ 424 (* offV9)++;474 (*myPtrs->offsetV9Ptr)++; 425 475 } 426 476 break; … … 429 479 default: 430 480 syslog(LOG_INFO, "Operator not known: %d\n", 431 (int)(((RuleDefPtr)(*( rulesCache+pos)))->operator));481 (int)(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)); 432 482 break; 433 483 } 434 484 j++; 435 485 pos = (pftmp->fieldType)*10+j; 436 } /* end while rulesCache*/486 } /* end while myPtrs->rulesAddressPtr */ 437 487 } else { 438 488 /* 439 * no rule within this field type, but we must read ingthe value489 * no rule within this field type, but we must read the value 440 490 */ 441 491 switch (field_size) { 442 492 case 1: 443 buffer1 = *( buf+(*offV9)); (*offV9)++;444 /* aggregation */ 445 /* if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 446 /* agCache.maskS = *((unsigned char*)&buffer1); */ 447 /* } */ 448 /* if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 449 /* agCache.maskD = *((unsigned char*)&buffer1); */ 450 /* } */ 451 /* if (pftmp->fieldType==60){ */ 452 /* agCache.ipProt = *((unsigned char*)&buffer1); */ 453 /* } */ 454 /* if (pftmp->fieldType==4){ */ 455 /* agCache.tProt = *((unsigned char*)&buffer1); */ 456 /* } */ 457 /* if (pftmp->fieldType==61){ */ 458 /* agCache.sens = *((unsigned char*)&buffer1); */ 459 /* } */ 460 /* if (pftmp->fieldType==5){ */ 461 /* agCache.dscp = *((unsigned char*)&buffer1); */ 462 /* } */ 463 /* end aggregation */ 493 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 494 #ifdef IPV4AGG 495 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 496 agCache.maskS = *((unsigned char*)&buffer1); 497 } 498 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 499 agCache.maskD = *((unsigned char*)&buffer1); 500 } 501 if (pftmp->fieldType==60){ 502 agCache.ipProt = *((unsigned char*)&buffer1); 503 } 504 if (pftmp->fieldType==4){ 505 agCache.tProt = *((unsigned char*)&buffer1); 506 } 507 if (pftmp->fieldType==61){ 508 agCache.sens = *((unsigned char*)&buffer1); 509 } 510 if (pftmp->fieldType==5){ 511 agCache.dscp = *((unsigned char*)&buffer1); 512 } 513 #endif 464 514 #ifdef CRIHAN 465 515 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ … … 476 526 ipFirstCache.tProt = *((unsigned char*)&buffer1); 477 527 } 478 #endif /* CRIHAN */528 #endif 479 529 break; 480 530 case 2: 481 buffer2[1]= *( buf+(*offV9)); (*offV9)++;482 buffer2[0]= *( buf+(*offV9)); (*offV9)++;483 /* aggregation */ 531 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 532 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 533 #ifdef IPV4AGG 484 534 if (pftmp->fieldType==10){ 485 535 agCache.idSnmp = *((unsigned short*)&buffer2); 486 536 } 487 /* end aggregation */ 537 #endif 488 538 #ifdef CRIHAN 489 539 if (pftmp->fieldType==10){ … … 499 549 ipFirstCache.dPort = *((unsigned short*)&buffer2); 500 550 } 501 #endif /* CRIHAN */551 #endif 502 552 break; 503 553 case 3: 504 554 buffer4[3]= 0; 505 buffer4[2]= *( buf+(*offV9)); (*offV9)++;506 buffer4[1]= *( buf+(*offV9)); (*offV9)++;507 buffer4[0]= *( buf+(*offV9)); (*offV9)++;555 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 556 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 557 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 508 558 /* aggregation */ 509 559 /* end aggregation */ 560 if (pftmp->fieldType==70){ 561 isMplsFlow = 1; 562 } 510 563 #ifdef CRIHAN 511 564 if (pftmp->fieldType==70){ 512 565 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 513 566 } 514 #endif /* CRIHAN */567 #endif 515 568 break; 516 569 case 4: 517 buffer4[3]= *( buf+(*offV9)); (*offV9)++;518 buffer4[2]= *( buf+(*offV9)); (*offV9)++;519 buffer4[1]= *( buf+(*offV9)); (*offV9)++;520 buffer4[0]= *( buf+(*offV9)); (*offV9)++;521 /* aggregation */ 522 /* if ((pftmp->fieldType==8)){ */ 523 /* bool = 1; */ 524 /* agCache.v4AdS = *((unsigned long*)&buffer4); */ 525 /* } else if ((pftmp->fieldType==12)){ */ 526 /* agCache.v4AdD = *((unsigned long*)&buffer4); */ 527 /* } else if (pftmp->fieldType==1){ */ 528 /* agCache.bytes = *((unsigned long*)&buffer4); */ 529 /* } else if (pftmp->fieldType==2){ */ 530 /* agCache.pkts = *((unsigned long*)&buffer4); */ 531 /* } */ 532 /* end aggregation */ 570 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 571 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 572 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 573 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 574 #ifdef IPV4AGG 575 if ((pftmp->fieldType==8)){ 576 bool = 1; 577 agCache.v4AdS = *((unsigned long*)&buffer4); 578 } else if ((pftmp->fieldType==12)){ 579 agCache.v4AdD = *((unsigned long*)&buffer4); 580 } else if (pftmp->fieldType==1){ 581 agCache.bytes = *((unsigned long*)&buffer4); 582 } else if (pftmp->fieldType==2){ 583 agCache.pkts = *((unsigned long*)&buffer4); 584 } 585 #endif 533 586 #ifdef CRIHAN 534 587 if (pftmp->fieldType==8){ … … 552 605 lastTime = *((unsigned long*)&buffer4); 553 606 } 554 #endif /* CRIHAN */607 #endif 555 608 break; 556 609 case 16: 557 610 for (i=0; i<4; i++) { 558 buffer2[1]= *( buf+(*offV9)); (*offV9)++;559 buffer2[0]= *( buf+(*offV9)); (*offV9)++;560 buffer2[1]= *( buf+(*offV9)); (*offV9)++;561 buffer2[0]= *( buf+(*offV9)); (*offV9)++;562 } 563 /* aggregation */611 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 612 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 613 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 614 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 615 } 616 /* aggregation IPv6 */ 564 617 /* end aggregation */ 565 618 break; … … 567 620 syslog(LOG_INFO,"UNKNOWN FIELDS LENGTH: %d ", field_size); 568 621 for (i=0; i<field_size; i++){ 569 (* offV9)++;622 (*myPtrs->offsetV9Ptr)++; 570 623 } 571 624 } … … 577 630 #ifdef CRIHAN 578 631 if ( mplsFirstCache.mplsLabel1 == 0 ) { 579 ( ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt;632 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->ipProt = ipFirstCache.ipProt; 580 633 ipFirstCache.ipProt = 0; 581 ( ipCache+(*ipCounter))->bytes = ipFirstCache.bytes;634 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->bytes = ipFirstCache.bytes; 582 635 ipFirstCache.bytes = 0; 583 ( ipCache+(*ipCounter))->pkts = ipFirstCache.pkts;636 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->pkts = ipFirstCache.pkts; 584 637 ipFirstCache.pkts = 0; 585 ( ipCache+(*ipCounter))->inSnmp = ipFirstCache.inSnmp;638 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->inSnmp = ipFirstCache.inSnmp; 586 639 ipFirstCache.inSnmp = 0; 587 ( ipCache+(*ipCounter))->outSnmp = ipFirstCache.outSnmp;640 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->outSnmp = ipFirstCache.outSnmp; 588 641 ipFirstCache.outSnmp = 0; 589 ( ipCache+(*ipCounter))->v4AdS = ipFirstCache.v4AdS;642 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdS = ipFirstCache.v4AdS; 590 643 ipFirstCache.outSnmp = 0; 591 ( ipCache+(*ipCounter))->v4AdD = ipFirstCache.v4AdD;644 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdD = ipFirstCache.v4AdD; 592 645 ipFirstCache.v4AdD = 0; 593 ( ipCache+(*ipCounter))->tProt = ipFirstCache.tProt;646 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->tProt = ipFirstCache.tProt; 594 647 ipFirstCache.tProt = 0; 595 ( ipCache+(*ipCounter))->sPort = ipFirstCache.sPort;648 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->sPort = ipFirstCache.sPort; 596 649 ipFirstCache.sPort = 0; 597 ( ipCache+(*ipCounter))->dPort = ipFirstCache.dPort;650 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->dPort = ipFirstCache.dPort; 598 651 ipFirstCache.dPort = 0; 599 ( ipCache+(*ipCounter))->maskD = ipFirstCache.maskD;652 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskD = ipFirstCache.maskD; 600 653 ipFirstCache.maskD = 0; 601 ( ipCache+(*ipCounter))->maskS = ipFirstCache.maskS;654 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskS = ipFirstCache.maskS; 602 655 ipFirstCache.maskS = 0; 603 ( ipCache+(*ipCounter))->routerAd = ipFirstCache.routerAd;604 ( ipCache+(*ipCounter))->liveTime = lastTime - firstTime;656 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->routerAd = ipFirstCache.routerAd; 657 (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->liveTime = lastTime - firstTime; 605 658 firstTime = 0; lastTime = 0; 606 (* ipCounter)++;659 (*myPtrs->ipNbPtr)++; 607 660 } else { 608 (m plsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt;661 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->ipProt = mplsFirstCache.ipProt; 609 662 mplsFirstCache.ipProt = 0; 610 (m plsCache+(*mplsCounter))->v4AdS = mplsFirstCache.v4AdS;663 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdS = mplsFirstCache.v4AdS; 611 664 mplsFirstCache.v4AdS = 0; 612 (m plsCache+(*mplsCounter))->v4AdD = mplsFirstCache.v4AdD;665 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdD = mplsFirstCache.v4AdD; 613 666 mplsFirstCache.v4AdD = 0; 614 (m plsCache+(*mplsCounter))->routerAd = mplsFirstCache.routerAd;615 (m plsCache+(*mplsCounter))->mplsLabel1 = mplsFirstCache.mplsLabel1;667 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->routerAd = mplsFirstCache.routerAd; 668 (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->mplsLabel1 = mplsFirstCache.mplsLabel1; 616 669 mplsFirstCache.mplsLabel1 = 0; 617 (*m plsCounter)++;670 (*myPtrs->mplsNbPtr)++; 618 671 } 619 #endif /* CRIHAN */ 620 /* put aggregation cache information to tables */ 621 /* if (bool == 1){ */ 622 /* prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); */ 623 /* res = bsearch(&prefixKey, V4PTab, nbPV4, */ 624 /* sizeof(struct PrefixV4), prefCmp); */ 625 /* } */ 626 bool = 0; 627 /* end put */ 672 #endif 673 /* put aggregation cache information to IPv4 Prefixes table */ 674 /* Aggregation mode must be enable in ./configure options */ 675 /* first we must know if the address belong to our prefix */ 676 #ifdef IPV4AGG 677 if ( (bool == 1) && (isMplsFlow == 0) ){ 678 prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); 679 res = bsearch(&prefixKey, V4PTab, nbPV4, 680 sizeof(struct PrefixV4), prefGlobalCmp); 681 if (res!=NULL){ 682 if ( myPtrs->routersID[res->routerNb] == agCache.routerAd ) { 683 /* OUT ("traffic from the prefix/subnet") */ 684 res->bytesNbOUT += agCache.bytes; 685 res->pktsNbOUT += agCache.pkts; 686 (res->flowNbOUT)++; 687 } else { 688 /* doublon or bad reference in prefix list */ 689 } 690 } else { 691 prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); 692 res = bsearch(&prefixKey, V4PTab, nbPV4, 693 sizeof(struct PrefixV4), prefGlobalCmp); 694 if (res!=NULL){ 695 if ( myPtrs->routersID[res->routerNb] == agCache.routerAd ) { 696 /* IN ("traffic to the prefix") */ 697 res->bytesNbIN += agCache.bytes; 698 res->pktsNbIN += agCache.pkts; 699 (res->flowNbIN)++; 700 } else { 701 /* doublon or bad reference in prefix list */ 702 703 /* fprintf(stderr, "IN NC: %lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */ 704 /* (agCache.v4AdS>>24), */ 705 /* (agCache.v4AdS<<8>>24), */ 706 /* (agCache.v4AdS<<16>>24), */ 707 /* (agCache.v4AdS<<24>>24), */ 708 /* (agCache.maskS), */ 709 /* (agCache.v4AdD>>24), */ 710 /* (agCache.v4AdD<<8>>24), */ 711 /* (agCache.v4AdD<<16>>24), */ 712 /* (agCache.v4AdD<<24>>24), */ 713 /* (agCache.maskD), */ 714 /* (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 715 /* (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 716 /* (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 717 /* (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */ 718 /* ); */ 719 } 720 } else { 721 /* HERE : we are in the cases of the address/mask don't */ 722 /* belong to a prefix listed in the IPv4 prefix file */ 723 /* possibilities : */ 724 /* - prefix not referenced but allowed to be routed */ 725 /* - prefix not referenced but not allowed to be routed */ 726 /* - spoofing */ 727 /* fprintf(stderr, "%lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */ 728 /* (agCache.v4AdS>>24), */ 729 /* (agCache.v4AdS<<8>>24), */ 730 /* (agCache.v4AdS<<16>>24), */ 731 /* (agCache.v4AdS<<24>>24), */ 732 /* (agCache.maskS), */ 733 /* (agCache.v4AdD>>24), */ 734 /* (agCache.v4AdD<<8>>24), */ 735 /* (agCache.v4AdD<<16>>24), */ 736 /* (agCache.v4AdD<<24>>24), */ 737 /* (agCache.maskD), */ 738 /* (myPtrs->pcktPtr->ipH->srcAdd>>24), */ 739 /* (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */ 740 /* (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */ 741 /* (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */ 742 /* ); */ 743 } 744 } 745 } 746 bool = 0; 747 isMplsFlow = 0; 748 #endif 628 749 /* 629 750 * Redirection if needed 630 751 * switch the rules definition (check & fieldToRecord), 631 * we send the flow or a part of the flow to a remote host or a file 752 * we send the flow or a part of the flow to a remote host or a file. 753 * In a first time (until release 0.0.7, the information was sent via 754 * the process renetcolSender with an IPC message queue. But, the perf 755 * of IPC Msg was very bad with a system compilation by default. 756 * So now, we send information directly from here. 632 757 */ 633 tmpRuleList = rlPtr;758 tmpRuleList = myPtrs->rulesListPtr; 634 759 while (tmpRuleList){ 760 /* RulesPtr tmpRuleList_for_to = myPtrs->rulesListPtr; */ 761 RuleDefPtr tmpRuleDefList = tmpRuleList->def; 635 762 unsigned short check = 1; 636 RuleDefPtr tmpRuleDefList = tmpRuleList->def; 763 /* int s=0; */ 637 764 secondOffset = secondOldOffset; 638 765 while (tmpRuleDefList){ … … 644 771 /* msg building */ 645 772 secondPftmp = tmp->lastField; 646 /* memcpy(myMsg.text, (char*)(buf+secondOffset),flow_size); */647 773 msgTextIndex = mempcpy(mempcpy(mempcpy(myMsg.text, 648 774 &tplMsgType, … … 652 778 sizeof(tmpRuleList->id) 653 779 ), 654 & cr->IpAddress,780 &myPtrs->currentRouterPtr->IpAddress, 655 781 sizeof(unsigned long) 656 782 ); … … 662 788 sizeof(tmp->templateFlowSetId) 663 789 ), 664 buf+secondOffset,790 myPtrs->ptr_buffer+secondOffset, 665 791 flow_size 666 792 ); 667 793 myMsg.type = 1; 794 /* OLD transfert type */ 668 795 msgSend( myQueue, myMsg); 796 /* NEW transfert type */ 797 /* for ( ; tmpRuleList_for_to; tmpRuleList_for_to=tmpRuleList_for_to->next){ */ 798 /* fprintf(stderr, "?\n"); */ 799 /* if (tmpRuleList_for_to->id == tmpRuleList->id){ */ 800 /* fprintf(stderr, "y\n"); */ 801 /* s = sendMessage(tmpRuleList_for_to->host->sockId, &(myMsg.text), sizeof(myMsg.text), */ 802 /* tmpRuleList_for_to->host->hostAddressPtr); */ 803 /* fprintf(stderr, "o\n"); */ 804 /* } */ 805 /* } */ 806 /* FIXME : perhaps check "s" */ 669 807 noEnd = 1; 670 808 secondCpt=0; … … 676 814 * end redirection 677 815 */ 678 secondOffset = * offV9;816 secondOffset = *myPtrs->offsetV9Ptr; 679 817 secondOldOffset = secondOffset; 680 818 pftmp = tmp->lastField; 681 819 cpt=0; 682 (* cFNPtr)++; /* pointer on the flows number */683 if (((* offV9)-48-shift+flow_size) > data_length){820 (*myPtrs->currentFlowsetNumberPtr)++; /* pointer on the flows number */ 821 if (((*myPtrs->offsetV9Ptr)-48-shift+flow_size) > data_length){ 684 822 overflow = 1; /* buffer index not correct */ 685 823 } … … 688 826 pftmp = pftmp->prev; 689 827 } 690 } /* end of the while on one flow record */ 828 } /* end of the while on one flow record */ 829 830 /* new place */ 831 832 while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { 833 (*myPtrs->offsetV9Ptr)++; /* if padding */ 834 paddingCounter++; 835 if ( paddingCounter > 8 ) { 836 #ifdef DEBUG 837 fprintf(stderr," padding too high: %d ", paddingCounter); 838 #endif 839 syslog(LOG_INFO,"padding too high: %d ", paddingCounter); 840 return (-1); 841 } 842 } 843 while ( (*myPtrs->offsetV9Ptr)-48-shift > data_length ) { 844 (*myPtrs->offsetV9Ptr)--; /* crazy loop (when bug appears in template def) */ 845 crazyCounter++; 846 } 847 #ifdef DEBUG 848 if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); } 849 #endif 850 if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);} 851 852 #ifdef DEBUG 853 fprintf(stderr,"}"); 854 #endif 855 856 return (data_length+shift); 857 /* end new place */ 858 691 859 }else{ 692 /* 693 * template unknown, we skip this all the data 860 /* 861 * 862 * 863 * Optional template 864 * 865 * 694 866 */ 695 (*offV9)+=(data_length-4); 696 (*cFNPtr) = v9Ptr->count; 867 if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId, 868 (*myPtrs->currentFlowsetIdPtr)))!=NULL) { 869 #ifdef DEBUG 870 fprintf(stderr,"<d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); 871 #endif 872 for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ 873 /* FIXME : today we skip the scope fields, it's bad :( */ 874 if ((pftmp=tmpOpt->lastField)!=NULL) { 875 for (j=0; j<pftmp->fieldLength; j++) { 876 (*myPtrs->offsetV9Ptr)++; 877 } 878 pftmp = pftmp->prev; 879 } 880 } 881 while (pftmp != NULL) { 882 if (pftmp->fieldLength==1){ 883 buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 884 } 885 if (pftmp->fieldLength==2){ 886 buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 887 buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 888 } 889 if (pftmp->fieldLength==4){ 890 buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 891 buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 892 buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 893 buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; 894 if (pftmp->fieldType==34){ 895 if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) { 896 #ifdef DEBUGAGG 897 fprintf(stderr,"SV (p) %lu != %lu (r)\n", *((unsigned long*)&buffer4), 898 myPtrs->currentRouterPtr->sampled); 899 #endif 900 myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); 901 for (i=0; i<nbPV4; i++) { 902 /* we update the PrefixV4 structure with the sampled information */ 903 if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) { 904 V4PTab[i].sampling = *((unsigned long*)&buffer4); 905 myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4); 906 } 907 } 908 } 909 } 910 } 911 pftmp = pftmp->prev; 912 } 913 if ( pftmp == NULL ) { 914 while ((*myPtrs->offsetV9Ptr)%4 != 0) { 915 (*myPtrs->offsetV9Ptr)++; 916 #ifdef DEBUG 917 fprintf(stderr," p "); 918 #endif 919 } 920 } else { 921 fprintf(stderr,"PB "); 922 } 923 #ifdef DEBUG 924 fprintf(stderr,">"); 925 #endif 926 return (data_length+shift); 927 } else { 928 /* 929 * template unknown, we skip this all the data 930 */ 931 (*myPtrs->offsetV9Ptr)+=(data_length-4); 932 (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; 933 #ifdef DEBUG 934 fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu", 935 (myPtrs->pcktPtr->ipH->srcAdd>>24), 936 (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), 937 (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), 938 (myPtrs->pcktPtr->ipH->srcAdd<<24>>24), 939 myPtrs->currentHeaderV9Ptr->sourceId, 940 (*myPtrs->currentFlowsetIdPtr) 941 ); 942 #endif 943 return (data_length+shift); 944 } 697 945 } 698 while ( ((*offV9)-48-shift) < data_length ) { 699 (*offV9)++; /* if padding */ 700 } 701 while ( (*offV9)-48-shift > data_length ) { 702 (*offV9)--; /* crazy loop (when bug appears in template def) */ 703 } 704 return (data_length+shift); 946 /* old place */ 947 705 948 } -
/trunk/src/rules_mgmt.c
r17 r28 2 2 * File: rules_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 82 82 printHostDef(rPtr->host); 83 83 } 84 invPrintFieldSet(rPtr->fieldToRecord); 84 /* invPrintFieldSet(rPtr->fieldToRecord); */ 85 85 printRule(rPtr->next); 86 86 } … … 174 174 int cptLine; 175 175 176 if ( !(ruleFile = fopen(filename, "r"))) {176 if ((ruleFile = fopen(filename, "r")) == NULL) { 177 177 syslog(LOG_ERR, "error during %s opening\n", filename); 178 178 exit(1); … … 469 469 if ((ft==1) || (ft==25)){ 470 470 tmp->value = addValue(tmp->value, operatorToNumber, value); 471 } else if ( (ft== 8) || (ft==12) || (ft==15) || (ft==18) ){471 } else if ( (ft==0) || (ft==8) || (ft==12) || (ft==15) || (ft==18) ){ 472 472 tmp->value = addAddress(tmp->value, operatorToNumber, value); 473 473 } else if ( (ft==27) || (ft==28) || (ft==62) || (ft==63) ){ -
/trunk/src/msg_mgmt.h
r2 r28 2 2 * File: msg_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 28 28 typedef struct { 29 29 long type; 30 char text [512];30 unsigned char text [512]; 31 31 } msgType; 32 32 -
/trunk/src/prefix_mgmt.c
r17 r28 4 4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 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/renetcolSender.h
r8 r28 2 2 * File: renetcolSender.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/tplflset_mgmt.c
r2 r28 2 2 * File: tplflset_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/dataFlowSet.h
r20 r29 4 4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 73 73 unsigned char tProt; 74 74 unsigned char ipProt; 75 unsigned char sens; /* In/out */75 unsigned char sens; /* In/out field 61 */ 76 76 unsigned short idSnmp; 77 77 unsigned long bytes; … … 86 86 }; 87 87 88 unsigned short 89 checkDataFlowSet(unsigned short, RouterPtr, NetFlowV9HeaderPtr, 90 unsigned short *, unsigned char *, short *, 91 short *, DatagramPtr, RuleDefPtr *, RulesPtr, int, 92 struct PrefixV4 *, size_t, 93 struct IPFLowCache *, struct MPLSFlowCache *, 94 unsigned long *, unsigned long *); 88 struct MyPtrs { 89 RouterPtr currentRouterPtr; 90 NetFlowV9HeaderPtr currentHeaderV9Ptr; 91 unsigned short *offsetV9Ptr; 92 unsigned char *ptr_buffer; 93 short *currentFlowsetNumberPtr; 94 short *currentFlowsetIdPtr; 95 DatagramPtr pcktPtr; 96 RuleDefPtr *rulesAddressPtr; 97 RulesPtr rulesListPtr; /* Rules list */ 98 struct IPFLowCache *tabIPPtr; 99 struct MPLSFlowCache *tabMPLSPtr; 100 unsigned long *ipNbPtr; 101 unsigned long *mplsNbPtr; 102 unsigned long *routersID; 103 struct PrefixV4 *currentV4Tab; 104 struct PrefixV4 *secondV4Tab; 105 }; 106 107 short 108 checkDataFlowSet(short, 109 struct MyPtrs *, 110 int, 111 struct PrefixV4 *, size_t 112 ); 95 113 96 114 #endif /* DATAFLOWSET_H */ -
/trunk/src/rules_mgmt.h
r10 r28 2 2 * File: rules_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/prefix_mgmt.h
r16 r28 4 4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 … … 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/tplflset_mgmt.h
r2 r28 2 2 * File: tplflset_mgmt.h 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/src/Makefile.am
r20 r24 1 bin_PROGRAMS = renetcol renetcolSender renetcolMsgCtl 2 renetcol_SOURCES = renetcol.c template.c V9Header_mgmt.c msg_mgmt.c fields_mgmt.c\3 routers_mgmt.c tplflset_mgmt.c headers_mgmt.c renetcol.h template.h\4 V9Header_mgmt.h msg_mgmt.h fields_mgmt.h routers_mgmt.h \5 tplflset_mgmt.h headers_mgmt.h dataFlowSet.c dataFlowSet.h\6 7 remote_output.h remote_output.c8 renetcolSender_SOURCES = renetcolSender.c renetcolSender.h msg_mgmt.h msg_mgmt.c\9 rules_mgmt.c rules_mgmt.h remote_output.h remote_output.c\10 1 bin_PROGRAMS = renetcol renetcolSender renetcolMsgCtl renetcolAgg 2 renetcol_SOURCES = renetcol.c template.c V9Header_mgmt.c msg_mgmt.c \ 3 fields_mgmt.c routers_mgmt.c tplflset_mgmt.c headers_mgmt.c \ 4 renetcol.h template.h V9Header_mgmt.h msg_mgmt.h fields_mgmt.h \ 5 routers_mgmt.h tplflset_mgmt.h headers_mgmt.h dataFlowSet.c \ 6 dataFlowSet.h get_conf.c get_conf.h rules_mgmt.c rules_mgmt.h \ 7 remote_output.h remote_output.c prefix_mgmt.h prefix_mgmt.c 8 renetcolSender_SOURCES = renetcolSender.c renetcolSender.h msg_mgmt.h \ 9 msg_mgmt.c rules_mgmt.c rules_mgmt.h remote_output.h \ 10 remote_output.c fields_mgmt.h fields_mgmt.c 11 11 renetcolMsgCtl_SOURCES = renetcolMsgCtl.c 12 BUILT_SOURCES = renetcol.o renetcolSender.o 12 renetcolAgg_SOURCES = renetcolAgg.c renetcolAgg.h rrdwrap.h rrdwrap.c 13 BUILT_SOURCES = renetcol.o renetcolSender.o renetcolAgg.o 13 14 renetcol_LDADD = -ldl -lc_p 14 15 renetcolSender_LDADD = -ldl -lc_p 16 renetcolAgg_LDADD = -ldl -lrrd 15 17 $(PACKAGE)-$(VERSION).tar.gz: dist 16 18 .PHONY: clean 17 19 clean: 18 rm -f renetcol renetcolSender renetcolMsgCtl *.o20 rm -f renetcol renetcolSender renetcolMsgCtl renetcolAgg *.o -
/trunk/src/V9Header_mgmt.c
r8 r28 2 2 * File: V9Header_mgmt.c 3 3 * 4 * Authors: ANDREU Fran çois-Xavier4 * Authors: ANDREU Francois-Xavier 5 5 * 6 * Copyright (C) 2005 GIP RENATER6 * Copyright (C) 2005 2006 2007 GIP RENATER 7 7 */ 8 8 -
/trunk/tool/renetcolGUI_0_0_3.py
r18 r27 589 589 coll_hbox.set_border_width(5) 590 590 coll_frame.add(coll_hbox) 591 button = gtk.CheckButton(" router ")591 ## button = gtk.CheckButton(" router ") 592 592 button.connect("toggled", callback_check_rule, None) 593 593 coll_hbox.pack_start(button, False, False, 0) 594 mainTT.set_tip(button, "Check it to capture all flows from one router and enter the IPv4 address of this router. NOT SUPPORTED IN THIS RELEASE")595 button.show()594 mainTT.set_tip(button, "Check it to capture all flows from one router and enter the IPv4 address of this router. IN TEST") 595 ## button.show() 596 596 coll_pbbox = gtk.HButtonBox() 597 597 coll_hbox.pack_start(coll_pbbox, False, True, 5) 598 prefix_entry(45, "Required Format : \n <field> <operation> <address>\nlike 8 = 10.0.0.1 \nor 8 = 10.0.1.0/24 \nor 27 = 2001::1 \nor 27 = 2001::/64 (IPv6 address only on Linux system)\nonly '=' operator for the moment\n------------------------------\nIn this version 0.0. 2, you can compare the following fields:\nIPV4_SRC_ADDR: 8\nIPV4_DST_ADDR: 12\nIPV4_NEXT_HOP: 15\nBGP_IPV4_NEXT_HOP: 18\nIPV6_SRC_ADDR: 27\nIPV6_DST_ADDR: 28\nIPV6_NEXT_HOP: 62\nBPG_IPV6_NEXT_HOP: 63\nIP_PROTOCOL_VERSION: 60\n---------------------------", coll_pbbox, "", 0)598 prefix_entry(45, "Required Format : \n <field> <operation> <address>\nlike 8 = 10.0.0.1 \nor 8 = 10.0.1.0/24 \nor 27 = 2001::1 \nor 27 = 2001::/64 (IPv6 address only on Linux system)\nonly '=' operator for the moment\n------------------------------\nIn this version 0.0.7, you can compare the following fields:\nROUTER_SRC_ADDR: 0\nIPV4_SRC_ADDR: 8\nIPV4_DST_ADDR: 12\nIPV4_NEXT_HOP: 15\nBGP_IPV4_NEXT_HOP: 18\nIPV6_SRC_ADDR: 27\nIPV6_DST_ADDR: 28\nIPV6_NEXT_HOP: 62\nBPG_IPV6_NEXT_HOP: 63\nIP_PROTOCOL_VERSION: 60\n---------------------------", coll_pbbox, "", 0) 599 599 coll_frame2 = gtk.Frame("Disable rules") 600 600 coll_vbox.pack_start(coll_frame2, False, False, 5) … … 724 724 operator = rule[1] 725 725 value = rule[2] 726 if (field==' 8' or field=='12' or field=='15' or field=='18' or field=='47'):726 if (field=='0' or field=='8' or field=='12' or field=='15' or field=='18' or field=='47'): 727 727 if (re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$',value)): 728 728 splitter = value.split('/') … … 992 992 993 993 print "---------------------------------------------------------------" 994 print "In this version 0.0. 3, you can apply rules on the collector based on the following fields:"994 print "In this version 0.0.7, you can apply rules on the collector based on the following fields:" 995 995 print "IPV4_SRC_ADDR: 8," 996 996 print "IPV4_DST_ADDR: 12," … … 1002 1002 print "IPV6_NEXT_HOP: 62," 1003 1003 print "BPG_IPV6_NEXT_HOP: 63," 1004 print "IP_PROTOCOL_VERSION: 60" 1004 print "IP_PROTOCOL_VERSION: 60, please note that the IPv4 template don't have this field" 1005 print "ROUTER_SRC_ADDR: 0, here it's not a real number for a field" 1005 1006 print "----------------------------------------------------------------" 1006 1007