| 31 | * @param shift Shift |
| 32 | * @param cr Current router pointer |
| 33 | * @param v9Ptr Pointer in the datagram ?? |
| 34 | * @param offv9 index in the datagram |
| 35 | * @param buf Pointer to the buffer |
| 36 | * @param cFNPtr Pointer on the current flowset number |
| 37 | * @param cFId Pointer on the current flowset ID |
| 38 | * @param pcktPtr Pointer on the datagram buffer |
| 39 | * @param rulesCache Pointer on the rules table (cache for the next param) |
| 40 | * @param rlPtr Pointer on the rules list |
| 41 | * @param myQueue FIXME : to erase/delete/suppress |
| 42 | * @param V4PTab Pointer on the IPv4 Prefix Table |
| 43 | * @param nbPV4 Previous table size |
| 44 | * @param ipCache Cache for all IP flow (for CRIHAN compilation option) |
| 45 | * @param mplsCache Cache for all MPLS flow (for CRIHAN compilation option) |
| 46 | * @param ipCounter Param to defined IP Cache size |
| 47 | * @param mplsCounter Param to defined MPLS Cache size |
| 48 | * @return shift (index in the datagram) FIXME |
| 49 | * |
| 50 | * FIXME to tune : just a param like a table ? |
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; |
| 87 | int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */ |
| 88 | /* flow, we test on the field and then put bool at 1 */ |
| 89 | #ifdef CRIHAN |
| 90 | struct IPFLowCache ipFirstCache; |
| 91 | struct MPLSFlowCache mplsFirstCache; |
| 92 | unsigned long firstTime = 0; |
| 93 | unsigned long lastTime = 0; |
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 */ |
| 185 | #ifdef IPV4AGG |
| 186 | if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ |
| 187 | agCache.maskS = *((unsigned char*)&buffer1); |
| 188 | } |
| 189 | if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ |
| 190 | agCache.maskD = *((unsigned char*)&buffer1); |
| 191 | } |
| 192 | if (pftmp->fieldType==60){ |
| 193 | agCache.ipProt = *((unsigned char*)&buffer1); |
| 194 | } |
| 195 | if (pftmp->fieldType==4){ |
| 196 | agCache.tProt = *((unsigned char*)&buffer1); |
| 197 | } |
| 198 | if (pftmp->fieldType==61){ |
| 199 | agCache.sens = *((unsigned char*)&buffer1); |
| 200 | } |
| 201 | if (pftmp->fieldType==5){ |
| 202 | agCache.dscp = *((unsigned char*)&buffer1); |
| 203 | } |
| 204 | #endif |
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 */ |
| 276 | #ifdef IPV4AGG |
| 277 | if ((pftmp->fieldType==8)){ |
| 278 | agCache.v4AdS = *((unsigned long*)&buffer4); |
| 279 | } |
| 280 | if ((pftmp->fieldType==12)){ |
| 281 | agCache.v4AdD = *((unsigned long*)&buffer4); |
| 282 | } |
| 283 | if (pftmp->fieldType==1){ |
| 284 | agCache.bytes = *((unsigned long*)&buffer4); |
| 285 | } |
| 286 | if (pftmp->fieldType==2){ |
| 287 | agCache.pkts = *((unsigned long*)&buffer4); |
| 288 | } |
| 289 | #endif |
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 */ |
| 463 | #ifdef IPV4AGG |
| 464 | if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ |
| 465 | agCache.maskS = *((unsigned char*)&buffer1); |
| 466 | } |
| 467 | if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ |
| 468 | agCache.maskD = *((unsigned char*)&buffer1); |
| 469 | } |
| 470 | if (pftmp->fieldType==60){ |
| 471 | agCache.ipProt = *((unsigned char*)&buffer1); |
| 472 | } |
| 473 | if (pftmp->fieldType==4){ |
| 474 | agCache.tProt = *((unsigned char*)&buffer1); |
| 475 | } |
| 476 | if (pftmp->fieldType==61){ |
| 477 | agCache.sens = *((unsigned char*)&buffer1); |
| 478 | } |
| 479 | if (pftmp->fieldType==5){ |
| 480 | agCache.dscp = *((unsigned char*)&buffer1); |
| 481 | } |
| 482 | #endif |
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 */ |
| 540 | #ifdef IPV4AGG |
| 541 | if ((pftmp->fieldType==8)){ |
| 542 | bool = 1; |
| 543 | agCache.v4AdS = *((unsigned long*)&buffer4); |
| 544 | } else if ((pftmp->fieldType==12)){ |
| 545 | agCache.v4AdD = *((unsigned long*)&buffer4); |
| 546 | } else if (pftmp->fieldType==1){ |
| 547 | agCache.bytes = *((unsigned long*)&buffer4); |
| 548 | } else if (pftmp->fieldType==2){ |
| 549 | agCache.pkts = *((unsigned long*)&buffer4); |
| 550 | } |
| 551 | #endif |
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 */ |
| 638 | #endif |
| 639 | /* put aggregation cache information to IPv4 Prefixes table */ |
| 640 | #ifdef IPV4AGG |
| 641 | if (bool == 1){ |
| 642 | prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); |
| 643 | res = bsearch(&prefixKey, V4PTab, nbPV4, |
| 644 | sizeof(struct PrefixV4), prefCmp); |
| 645 | if (res!=NULL){ |
| 646 | res->bytesNb += agCache.bytes; |
| 647 | res->pktsNb += agCache.pkts; |
| 648 | res->flowNb += 1; |
| 649 | switch (agCache.ipProt) { |
| 650 | case 1: |
| 651 | res->icmpBytesNb += agCache.bytes; |
| 652 | res->icmpPktsNb += agCache.pkts; |
| 653 | res->icmpFlowNb += 1; |
| 654 | break; |
| 655 | case 6: |
| 656 | res->tcpBytesNb += agCache.bytes; |
| 657 | res->tcpPktsNb += agCache.pkts; |
| 658 | res->tcpFlowNb += 1; |
| 659 | break; |
| 660 | case 17: |
| 661 | res->udpBytesNb += agCache.bytes; |
| 662 | res->udpPktsNb += agCache.pkts; |
| 663 | res->udpFlowNb += 1; |
| 664 | break; |
| 665 | default: |
| 666 | res->othersBytesNb += agCache.bytes; |
| 667 | res->othersPktsNb += agCache.pkts; |
| 668 | res->othersFlowNb += 1; |
| 669 | } |
| 670 | } |
| 671 | /* if (res==NULL){ */ |
| 672 | /* fprintf(stderr, "IPv4_spoofing? "); */ |
| 673 | /* } */ |
| 674 | } |
| 675 | bool = 0; |
| 676 | #endif |