Changeset 18
- Timestamp:
- 06/09/06 18:18:15 (17 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dataFlowSet.c
r17 r18 35 35 short *cFId, DatagramPtr pcktPtr, RuleDefPtr *rulesCache, 36 36 RulesPtr rlPtr, int myQueue, struct PrefixV4 *V4PTab, 37 size_t nbPV4) 37 size_t nbPV4, 38 struct IPFLowCache *ipCache, struct MPLSFlowCache *mplsCache, 39 unsigned long *ipCounter, unsigned long *mplsCounter) 38 40 { 39 41 TplFlowSetPtr tmp; … … 63 65 struct PrefixV4 prefixKey, *res; /* for bsearch */ 64 66 struct AggCache agCache; 67 struct IPFLowCache ipFirstCache; /* CRI */ 68 struct MPLSFlowCache mplsFirstCache; /* CRI */ 69 unsigned long firstTime = 0; /* CRI */ 70 unsigned long lastTime = 0; /* CRI */ 65 71 int bool = 0; 72 73 /* CRI */ 74 ipFirstCache.ipProt = 0; 75 ipFirstCache.bytes = 0; 76 ipFirstCache.pkts = 0; 77 ipFirstCache.inSnmp = 0; 78 ipFirstCache.outSnmp = 0; 79 ipFirstCache.v4AdS = 0; 80 ipFirstCache.v4AdD = 0; 81 ipFirstCache.tProt = 0; 82 ipFirstCache.sPort = 0; 83 ipFirstCache.dPort = 0; 84 ipFirstCache.maskD = 0; 85 ipFirstCache.maskS = 0; 86 ipFirstCache.routerAd = 0; 87 ipFirstCache.liveTime = 0; 88 mplsFirstCache.ipProt = 0; 89 mplsFirstCache.v4AdS = 0; 90 mplsFirstCache.v4AdD = 0; 91 mplsFirstCache.routerAd = 0; 92 mplsFirstCache.mplsLabel1 = 0; 93 /* CRI */ 66 94 67 95 buffer2[1] = *(buf+(*offV9));(*offV9)++; … … 88 116 } 89 117 /* aggreg */ 90 agCache.routerAd = pcktPtr->ipH->srcAdd; 118 /* agCache.routerAd = pcktPtr->ipH->srcAdd; */ 91 119 /* end aggreg */ 120 121 /* CRI */ 122 ipFirstCache.routerAd = pcktPtr->ipH->srcAdd; 123 mplsFirstCache.routerAd = pcktPtr->ipH->srcAdd; 124 /* end CRI */ 125 92 126 pftmp = tmp->lastField; 93 127 secondPftmp = tmp->lastField; … … 129 163 /* end rule check */ 130 164 /* aggregation */ 165 /* if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 166 /* agCache.maskS = *((unsigned char*)&buffer1); */ 167 /* } */ 168 /* if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 169 /* agCache.maskD = *((unsigned char*)&buffer1); */ 170 /* } */ 171 /* if (pftmp->fieldType==60){ */ 172 /* agCache.ipProt = *((unsigned char*)&buffer1); */ 173 /* } */ 174 /* if (pftmp->fieldType==4){ */ 175 /* agCache.tProt = *((unsigned char*)&buffer1); */ 176 /* } */ 177 /* if (pftmp->fieldType==61){ */ 178 /* agCache.sens = *((unsigned char*)&buffer1); */ 179 /* } */ 180 /* if (pftmp->fieldType==5){ */ 181 /* agCache.dscp = *((unsigned char*)&buffer1); */ 182 /* } */ 183 /* end aggregation */ 184 /* CRI */ 131 185 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 132 agCache.maskS = *((unsigned char*)&buffer1);186 ipFirstCache.maskS = *((unsigned char*)&buffer1); 133 187 } 134 188 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 135 agCache.maskD = *((unsigned char*)&buffer1); 136 } 137 if (pftmp->fieldType==60){ 138 agCache.ipProt = *((unsigned char*)&buffer1); 139 } 140 if (pftmp->fieldType==4){ 141 agCache.tProt = *((unsigned char*)&buffer1); 142 } 143 if (pftmp->fieldType==61){ 144 agCache.sens = *((unsigned char*)&buffer1); 145 } 146 if (pftmp->fieldType==5){ 147 agCache.dscp = *((unsigned char*)&buffer1); 148 } 149 /* end aggregation */ 189 ipFirstCache.maskD = *((unsigned char*)&buffer1); 190 } 191 if (pftmp->fieldType==60){ 192 ipFirstCache.ipProt = *((unsigned char*)&buffer1); 193 mplsFirstCache.ipProt = *((unsigned char*)&buffer1); 194 } 195 if (pftmp->fieldType==4){ 196 ipFirstCache.tProt = *((unsigned char*)&buffer1); 197 } 198 /* end CRI */ 150 199 break; 151 200 case 2: … … 156 205 ((RuleDefPtr)(*(rulesCache+pos)))->check = 1; 157 206 /* aggregation */ 207 /* if (pftmp->fieldType==10){ */ 208 /* agCache.idSnmp = *((unsigned short*)&buffer2); */ 209 /* } */ 210 /* end aggregation */ 211 /* CRI */ 158 212 if (pftmp->fieldType==10){ 159 agCache.idSnmp = *((unsigned short*)&buffer2); 160 } 161 /* end aggregation */ 213 ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 214 } 215 if (pftmp->fieldType==14){ 216 ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 217 } 218 if (pftmp->fieldType==7){ 219 ipFirstCache.sPort = *((unsigned short*)&buffer2); 220 } 221 if (pftmp->fieldType==11){ 222 ipFirstCache.dPort = *((unsigned short*)&buffer2); 223 } 224 /* end CRI */ 162 225 break; 163 226 case 3: … … 171 234 /* aggregation */ 172 235 /* end aggregation */ 236 /* CRI */ 237 if (pftmp->fieldType==70){ 238 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 239 } 240 /* end CRI */ 173 241 break; 174 242 case 4: … … 186 254 } 187 255 /* aggregation */ 188 if ((pftmp->fieldType==8)){ 189 agCache.v4AdS = *((unsigned long*)&buffer4); 190 } 191 if ((pftmp->fieldType==12)){ 192 agCache.v4AdD = *((unsigned long*)&buffer4); 256 /* if ((pftmp->fieldType==8)){ */ 257 /* agCache.v4AdS = *((unsigned long*)&buffer4); */ 258 /* } */ 259 /* if ((pftmp->fieldType==12)){ */ 260 /* agCache.v4AdD = *((unsigned long*)&buffer4); */ 261 /* } */ 262 /* if (pftmp->fieldType==1){ */ 263 /* agCache.bytes = *((unsigned long*)&buffer4); */ 264 /* } */ 265 /* if (pftmp->fieldType==2){ */ 266 /* agCache.pkts = *((unsigned long*)&buffer4); */ 267 /* } */ 268 /* end aggregation */ 269 /* CRI */ 270 if (pftmp->fieldType==8){ 271 ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 272 } 273 if (pftmp->fieldType==12){ 274 ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 193 275 } 194 276 if (pftmp->fieldType==1){ 195 agCache.bytes = *((unsigned long*)&buffer4);277 ipFirstCache.bytes = *((unsigned long*)&buffer4); 196 278 } 197 279 if (pftmp->fieldType==2){ 198 agCache.pkts = *((unsigned long*)&buffer4); 199 } 200 /* end aggregation */ 280 ipFirstCache.pkts = *((unsigned long*)&buffer4); 281 } 282 if (pftmp->fieldType==22){ 283 firstTime = *((unsigned long*)&buffer4); 284 } 285 if (pftmp->fieldType==21){ 286 lastTime = *((unsigned long*)&buffer4); 287 } 288 /* end CRI */ 201 289 break; 202 290 case 16: … … 351 439 buffer1 = *(buf+(*offV9)); (*offV9)++; 352 440 /* aggregation */ 441 /* if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ */ 442 /* agCache.maskS = *((unsigned char*)&buffer1); */ 443 /* } */ 444 /* if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ */ 445 /* agCache.maskD = *((unsigned char*)&buffer1); */ 446 /* } */ 447 /* if (pftmp->fieldType==60){ */ 448 /* agCache.ipProt = *((unsigned char*)&buffer1); */ 449 /* } */ 450 /* if (pftmp->fieldType==4){ */ 451 /* agCache.tProt = *((unsigned char*)&buffer1); */ 452 /* } */ 453 /* if (pftmp->fieldType==61){ */ 454 /* agCache.sens = *((unsigned char*)&buffer1); */ 455 /* } */ 456 /* if (pftmp->fieldType==5){ */ 457 /* agCache.dscp = *((unsigned char*)&buffer1); */ 458 /* } */ 459 /* end aggregation */ 460 /* CRI */ 353 461 if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ 354 agCache.maskS = *((unsigned char*)&buffer1);462 ipFirstCache.maskS = *((unsigned char*)&buffer1); 355 463 } 356 464 if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ 357 agCache.maskD = *((unsigned char*)&buffer1); 358 } 359 if (pftmp->fieldType==60){ 360 agCache.ipProt = *((unsigned char*)&buffer1); 361 } 362 if (pftmp->fieldType==4){ 363 agCache.tProt = *((unsigned char*)&buffer1); 364 } 365 if (pftmp->fieldType==61){ 366 agCache.sens = *((unsigned char*)&buffer1); 367 } 368 if (pftmp->fieldType==5){ 369 agCache.dscp = *((unsigned char*)&buffer1); 370 } 371 /* end aggregation */ 465 ipFirstCache.maskD = *((unsigned char*)&buffer1); 466 } 467 if (pftmp->fieldType==60){ 468 ipFirstCache.ipProt = *((unsigned char*)&buffer1); 469 mplsFirstCache.ipProt = *((unsigned char*)&buffer1); 470 } 471 if (pftmp->fieldType==4){ 472 ipFirstCache.tProt = *((unsigned char*)&buffer1); 473 } 372 474 break; 373 475 case 2: … … 379 481 } 380 482 /* end aggregation */ 483 /* CRI */ 484 if (pftmp->fieldType==10){ 485 ipFirstCache.inSnmp = *((unsigned short*)&buffer2); 486 } 487 if (pftmp->fieldType==14){ 488 ipFirstCache.outSnmp = *((unsigned short*)&buffer2); 489 } 490 if (pftmp->fieldType==7){ 491 ipFirstCache.sPort = *((unsigned short*)&buffer2); 492 } 493 if (pftmp->fieldType==11){ 494 ipFirstCache.dPort = *((unsigned short*)&buffer2); 495 } 496 /* end CRI */ 381 497 break; 382 498 case 3: … … 385 501 buffer4[1]= *(buf+(*offV9)); (*offV9)++; 386 502 buffer4[0]= *(buf+(*offV9)); (*offV9)++; 387 /* fprintf(stderr,"L: %lu\n",(*((unsigned long*)&buffer4))); */388 /* fprintf(stderr,"L>>4: %lu\n",(*((unsigned long*)&buffer4))>>4); */389 /* fprintf(stderr,"L>>1<<29>>29: %lu\n",(*((unsigned long*)&buffer4))>>1<<29>>29); */390 /* fprintf(stderr,"L<<31>>31: %lu\n",(*((unsigned long*)&buffer4))<<31>>31); */391 503 /* aggregation */ 392 504 /* end aggregation */ 505 /* CRI */ 506 if (pftmp->fieldType==70){ 507 mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; 508 } 509 /* end CRI */ 393 510 break; 394 511 case 4: … … 398 515 buffer4[0]= *(buf+(*offV9)); (*offV9)++; 399 516 /* aggregation */ 400 if ((pftmp->fieldType==8)){ 401 bool = 1; 402 agCache.v4AdS = *((unsigned long*)&buffer4); 403 } else if ((pftmp->fieldType==12)){ 404 agCache.v4AdD = *((unsigned long*)&buffer4); 405 } else if (pftmp->fieldType==1){ 406 agCache.bytes = *((unsigned long*)&buffer4); 407 } else if (pftmp->fieldType==2){ 408 agCache.pkts = *((unsigned long*)&buffer4); 409 } 517 /* if ((pftmp->fieldType==8)){ */ 518 /* bool = 1; */ 519 /* agCache.v4AdS = *((unsigned long*)&buffer4); */ 520 /* } else if ((pftmp->fieldType==12)){ */ 521 /* agCache.v4AdD = *((unsigned long*)&buffer4); */ 522 /* } else if (pftmp->fieldType==1){ */ 523 /* agCache.bytes = *((unsigned long*)&buffer4); */ 524 /* } else if (pftmp->fieldType==2){ */ 525 /* agCache.pkts = *((unsigned long*)&buffer4); */ 526 /* } */ 410 527 /* end aggregation */ 528 /* CRI */ 529 if (pftmp->fieldType==8){ 530 ipFirstCache.v4AdS = *((unsigned long*)&buffer4); 531 } 532 if (pftmp->fieldType==12){ 533 ipFirstCache.v4AdD = *((unsigned long*)&buffer4); 534 } 535 if (pftmp->fieldType==1){ 536 ipFirstCache.bytes = *((unsigned long*)&buffer4); 537 } 538 if (pftmp->fieldType==2){ 539 ipFirstCache.pkts = *((unsigned long*)&buffer4); 540 } 541 if (pftmp->fieldType==22){ 542 firstTime = *((unsigned long*)&buffer4); 543 } 544 if (pftmp->fieldType==21){ 545 lastTime = *((unsigned long*)&buffer4); 546 } 547 /* end CRI */ 411 548 break; 412 549 case 16: … … 417 554 buffer2[0]= *(buf+(*offV9)); (*offV9)++; 418 555 } 419 /* aggregation */ 420 556 /* aggregation */ 421 557 /* end aggregation */ 422 558 break; … … 432 568 * end of one flow (not the flowset) 433 569 */ 570 /* CRI */ 571 printf("!"); 572 if ( mplsFirstCache.mplsLabel1 == 0 ) { 573 (ipCache+(*ipCounter))->ipProt = ipFirstCache.ipProt; 574 ipFirstCache.ipProt = 0; 575 (ipCache+(*ipCounter))->bytes = ipFirstCache.bytes; 576 ipFirstCache.bytes = 0; 577 (ipCache+(*ipCounter))->pkts = ipFirstCache.pkts; 578 ipFirstCache.pkts = 0; 579 (ipCache+(*ipCounter))->inSnmp = ipFirstCache.inSnmp; 580 ipFirstCache.inSnmp = 0; 581 (ipCache+(*ipCounter))->outSnmp = ipFirstCache.outSnmp; 582 ipFirstCache.outSnmp = 0; 583 (ipCache+(*ipCounter))->v4AdS = ipFirstCache.v4AdS; 584 ipFirstCache.outSnmp = 0; 585 (ipCache+(*ipCounter))->v4AdD = ipFirstCache.v4AdD; 586 ipFirstCache.v4AdD = 0; 587 (ipCache+(*ipCounter))->tProt = ipFirstCache.tProt; 588 ipFirstCache.tProt = 0; 589 (ipCache+(*ipCounter))->sPort = ipFirstCache.sPort; 590 ipFirstCache.sPort = 0; 591 (ipCache+(*ipCounter))->dPort = ipFirstCache.dPort; 592 ipFirstCache.dPort = 0; 593 (ipCache+(*ipCounter))->maskD = ipFirstCache.maskD; 594 ipFirstCache.maskD = 0; 595 (ipCache+(*ipCounter))->maskS = ipFirstCache.maskS; 596 ipFirstCache.maskS = 0; 597 (ipCache+(*ipCounter))->routerAd = ipFirstCache.routerAd; 598 (ipCache+(*ipCounter))->liveTime = lastTime - firstTime; 599 firstTime = 0; lastTime = 0; 600 (*ipCounter)++; 601 } else { 602 printf("im\n"); 603 (mplsCache+(*mplsCounter))->ipProt = mplsFirstCache.ipProt; 604 mplsFirstCache.ipProt = 0; 605 (mplsCache+(*mplsCounter))->v4AdS = mplsFirstCache.v4AdS; 606 mplsFirstCache.v4AdS = 0; 607 (mplsCache+(*mplsCounter))->v4AdD = mplsFirstCache.v4AdD; 608 mplsFirstCache.v4AdD = 0; 609 (mplsCache+(*mplsCounter))->routerAd = mplsFirstCache.routerAd; 610 (mplsCache+(*mplsCounter))->mplsLabel1 = mplsFirstCache.mplsLabel1; 611 mplsFirstCache.mplsLabel1 = 0; 612 (*mplsCounter)++; 613 } 614 /* CRI */ 434 615 /* put aggregation cache information to tables */ 435 616 if (bool == 1){ … … 443 624 * Redirection if needed 444 625 * switch the rules definition (check & fieldToRecord), 445 * we send the flow or a part of the flow to the msg queue626 * we send the flow or a part of the flow to a remote host or a file 446 627 */ 447 628 tmpRuleList = rlPtr; -
trunk/src/dataFlowSet.h
r17 r18 37 37 #include "prefix_mgmt.h" 38 38 39 #define MAX_IP_FLOW 1000 40 #define MAX_MPLS_FLOW 1000 41 42 struct IPFLowCache { 43 unsigned char ipProt; /* not write in file, just to know IP version */ 44 unsigned long bytes; 45 unsigned long pkts; 46 unsigned short inSnmp; 47 unsigned short outSnmp; 48 unsigned long v4AdS; 49 unsigned long v4AdD; 50 uint32_t tabAdd6S[4]; 51 uint32_t tabAdd6D[4]; 52 unsigned char tProt; 53 unsigned short sPort; 54 unsigned short dPort; 55 unsigned char maskD; 56 unsigned char maskS; 57 unsigned long routerAd; 58 unsigned long liveTime; 59 }; 60 61 struct MPLSFlowCache { 62 unsigned char ipProt; /* not write in file, just to know IP version */ 63 unsigned long routerAd; 64 unsigned short mplsLabel1; 65 unsigned long v4AdS; 66 unsigned long v4AdD; 67 uint32_t tabAdd6S[4]; 68 uint32_t tabAdd6D[4]; 69 }; 70 39 71 struct AggCache { 40 72 unsigned short mode; … … 61 93 unsigned short *, unsigned char *, short *, 62 94 short *, DatagramPtr, RuleDefPtr *, RulesPtr, int, 63 struct PrefixV4 *, size_t); 95 struct PrefixV4 *, size_t, 96 struct IPFLowCache *, struct MPLSFlowCache *, 97 unsigned long *, unsigned long *); 64 98 65 99 #endif /* DATAFLOWSET_H */ -
trunk/src/renetcol.c
r17 r18 25 25 26 26 #include "renetcol.h" 27 28 /* uptade for CRIHAN -> CRI */ 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 FILE *fIP; 36 FILE *fMPLS; 37 /* end */ 27 38 28 39 char *rulesFileName; … … 269 280 270 281 /* 271 * 282 * setCache() 272 283 */ 273 284 void … … 320 331 short version = 0; 321 332 int regRouter = 0; 333 /* CRI */ 334 int iIP, iMPLS; 335 /* end CRI */ 322 336 323 337 do { … … 368 382 rulesAddressPtr, rulesListPtr, 369 383 myQueue, prefixV4Tab, 370 (size_t) v4PrefixNb); 384 (size_t) v4PrefixNb, 385 tabIPPtr, 386 tabMPLSPtr, 387 ipNbPtr, mplsNbPtr); 371 388 } 372 389 } … … 382 399 break; 383 400 } 401 402 /* CRI */ 403 if ( ipNb > (MAX_IP_FLOW - 50)) { 404 if ((fIP = fopen(OUTPUT_IP, "w")) == NULL) { 405 syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno)); 406 } else { 407 for ( iIP = 0; iIP < ipNb; iIP++){ 408 printf("ipv4\n"); 409 if ( tabIP[iIP].ipProt == 0 ) { 410 printf(".\n"); 411 fprintf(fIP, "%lu;%lu;%hu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%d;%hu;%hu;%d;%d;%lu.%lu.%lu.%lu;%lu\n", 412 tabIP[iIP].bytes, tabIP[iIP].pkts, 413 tabIP[iIP].inSnmp, tabIP[iIP].outSnmp, 414 tabIP[iIP].v4AdS>>24, tabIP[iIP].v4AdS<<8>>24, 415 tabIP[iIP].v4AdS<<16>>24, tabIP[iIP].v4AdS<<24>>24, 416 tabIP[iIP].v4AdD>>24, tabIP[iIP].v4AdD<<8>>24, 417 tabIP[iIP].v4AdD<<16>>24, tabIP[iIP].v4AdD<<24>>24, 418 tabIP[iIP].tProt, tabIP[iIP].sPort, 419 tabIP[iIP].dPort, tabIP[iIP].maskD, 420 tabIP[iIP].maskS, tabIP[iIP].routerAd>>24, 421 tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24, 422 tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime 423 ); 424 } 425 } 426 fclose(fIP); 427 } 428 ipNb = 0; 429 } 430 if ( mplsNb > (MAX_MPLS_FLOW - 50)) { 431 if ((fMPLS = fopen(OUTPUT_MPLS, "w")) == NULL) { 432 syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno)); 433 } else { 434 for ( iMPLS = 0; iMPLS < mplsNb; iMPLS++){ 435 if ( tabMPLS[iMPLS].ipProt == 4 ) { 436 fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu\n", 437 tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24, 438 tabMPLS[iMPLS].routerAd<<16>>24, 439 tabMPLS[iMPLS].routerAd<<24>>24, 440 tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24, 441 tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24, 442 tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24, 443 tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24, 444 tabMPLS[iMPLS].v4AdD<<24>>24 445 ); 446 } 447 } 448 fclose(fMPLS); 449 } 450 mplsNb = 0; 451 } 452 /* end CRI */ 384 453 } while (1); 385 454 } -
trunk/src/renetcol.h
r8 r18 59 59 #include "rules_mgmt.h" 60 60 #include "msg_mgmt.h" 61 61 62 /* #include "mysql_mgmt.h" */ 62 63 … … 66 67 #define RECEPTION_PORT 9999 /* your collector port to recept netflow export */ 67 68 68 #define TIME_OUT 300 /* MAJSCH*/69 #define TIME_OUT 300 /* MAJSCH */ 69 70 70 71 #define ROUTER_INDEX_MAX 70 … … 72 73 #define FIELD_TYPE_NUMBER 89 73 74 #define MAX_RULES_PER_FIELD 10 75 76 #define OUTPUT_IP "/tmp/ipflow.txt" /* CRI */ 77 #define OUTPUT_MPLS "/tmp/mplsflow.txt" /* CRI */ 74 78 75 79 void setCache(RulesPtr); -
trunk/tool/renetcolGUI_0_0_3.py
r14 r18 60 60 1,0,0,0,0,0,0,1,1,0, 61 61 0,0,0,0,0,0,0,0,0,0, 62 0,0,0,0,0,0, 0,0,0,0,63 0,0,0,0,0,0,0,0,0,0, 64 0,0,0,0,0,0,0,0,0,0, 65 0,0,0,0,0,0,0,0,0,0,62 0,0,0,0,0,0,1,1,0,0, 63 0,0,0,0,0,0,0,0,0,0, 64 0,0,0,0,0,0,0,0,0,0, 65 1,1,1,1,1,1,1,1,1,1, 66 66 0,0,0,0,0,0,0,0,0,0 67 67 ] … … 86 86 0,0,0,0,0,0,0,0,0,0 87 87 ] 88 fieldsName = 89 90 91 92 "","","","","","","","","","",93 94 95 "","","","","","","","","","",96 97 88 fieldsName = [ "","IN_BYT","IN_PKTS","","PROT","TOS","TCP_FL","S_PORT","IPv4@S","S_MASK", 89 "InSNMP","D_PORT","IPv4@D","D_MASK","OutSNMP","NextHop","S_AS","D_AS","","", 90 "","Time","","","","","","IPv6@S","IPv6@D","", 91 "","","","","","","","","","", 92 "","","","","","","M_T_L_T","M_T_L_@","","", 93 "","","","","","","","","","", 94 "","","","","","","","","","ROUTER", 95 "M_L_1","M_L_2","M_L_3","M_L_4","M_L_5","M_L_6","M_L_7","M_L_8","M_L_9","M_L_10", 96 "","","","","","","","","","" 97 ] 98 98 flowCpt = 0 99 99 mask = [ 0,0,0 ] … … 154 154 for i in range (0, len(tpl_def[self.flow[0]])): 155 155 f = tpl_def[self.flow[0]][i][0] 156 if ( f==8 or f==12 ) and ( checkUpValues[f]==1 ):156 if ( f==8 or f==12 or f==15 or f==18 or f==47) and ( checkUpValues[f]==1 ): 157 157 res = res & ( ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f])| ((struct.unpack('>L',(socket.inet_aton(self.flow[1][i])))[0] & mask[1-1]) == firstParseValue[f]) ) 158 158 elif ( i==27 or i==28 ): … … 186 186 for k in range (0, 40): 187 187 underscore_line += "-" 188 elif ( f==8 or f==15 or f==12 ):188 elif ( f==8 or f==15 or f==12 or f==18 or f==47 ): 189 189 strField += str(fieldsName[f]) 190 190 l = len(str(fieldsName[f])) … … 231 231 for j in range (0, tabNb): 232 232 strFlow += "\t" 233 elif ( f==8 or f==12 or f==15 ):233 elif ( f==8 or f==12 or f==15 or f==18 or f==47 ): 234 234 strFlow += str(self.flow[1][i]) 235 235 l = len(str(self.flow[1][i])) … … 329 329 value = struct.unpack('>H',flow[14+index:16+index]) 330 330 field_list.insert(i,value[0]) 331 if (tpl_def[mykeystr][i][1]==3): 332 value = struct.unpack('<BBB',flow[14+index:17+index]) 333 valueTmp = struct.pack('<BBBB',value[2],value[1],value[0],0) 334 valueFinal = struct.unpack('<L', valueTmp) 335 valueFinal2 = (valueFinal[0])>>4 336 field_list.insert(i,valueFinal2) 331 337 if (tpl_def[mykeystr][i][1]==4): 332 if (tpl_def[mykeystr][i][0]==8 or tpl_def[mykeystr][i][0]==12 or tpl_def[mykeystr][i][0]==15 ):338 if (tpl_def[mykeystr][i][0]==8 or tpl_def[mykeystr][i][0]==12 or tpl_def[mykeystr][i][0]==15 or tpl_def[mykeystr][i][0]==18 or tpl_def[mykeystr][i][0]==47): 333 339 value = socket.inet_ntoa(flow[14+index:18+index]) 334 340 field_list.insert(i,value) … … 718 724 operator = rule[1] 719 725 value = rule[2] 720 if (field=='8' or field=='12' or field=='15' or field=='18' ):726 if (field=='8' or field=='12' or field=='15' or field=='18' or field=='47'): 721 727 if (re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?$',value)): 722 728 splitter = value.split('/') … … 750 756 is_good = 1 751 757 ##here, check the prefix value? 752 if (field=='60' ):758 if (field=='60' or field=='46'): 753 759 if (int(value) < 256): 754 760 is_good = 1 … … 986 992 987 993 print "---------------------------------------------------------------" 988 print "In this version 0.0. 2, you can apply rules on the collector based on the following fields:"994 print "In this version 0.0.3, you can apply rules on the collector based on the following fields:" 989 995 print "IPV4_SRC_ADDR: 8," 990 996 print "IPV4_DST_ADDR: 12," … … 993 999 print "IPV6_SRC_ADDR: 27," 994 1000 print "IPV6_DST_ADDR: 28," 1001 print "MPLS_TOP_LABEL_TYPE: 46," 995 1002 print "IPV6_NEXT_HOP: 62," 996 1003 print "BPG_IPV6_NEXT_HOP: 63,"