root/trunk/src/dataFlowSet.c @ 36

Revision 36, 33.7 KB (checked in by andreu, 16 years ago)

ticket #1 #2 #7 closed - release 0.0.9beta

  • Property svn:eol-style set to native
RevLine 
[2]1/*
2 * File: dataFlowSet.c
3 *
[15]4 * Authors: ANDREU Francois-Xavier
[2]5 *
[28]6 * Copyright (C) 2005 2006 2007 GIP RENATER
[2]7 */
8
9/*  This file is part of renetcol.
10 *
11 *  renetcol is free software; you can redistribute it and/or modify
12 *  it under the terms of the GNU General Public License as published by
13 *  the Free Software Foundation; either version 2 of the License, or
14 *  (at your option) any later version.
15 *
16 *  renetcol is distributed in the hope that it will be useful,
17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 *  GNU General Public License for more details.
20 *
21 *  You should have received a copy of the GNU General Public License
22 *  along with renetcol; if not, write to the Free Software
23 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 */
25
26#include "dataFlowSet.h"
27
28/*
[22]29 * Check Data FlowSet
[2]30 *
31 */
[27]32short 
33checkDataFlowSet(short shift,
[23]34                 struct MyPtrs *myPtrs,
35                 int myQueue,
36                 struct PrefixV4 *V4PTab,
37                 size_t nbPV4
38                 )
[2]39{
[30]40  TplFlowSetPtr tmp = NULL;
41  TplOptionPtr tmpOpt = NULL;
42  FieldPtr pftmp = NULL;
43  FieldPtr secondPftmp = NULL;
[2]44  unsigned short data_length = 0;
45  unsigned short flow_size = 0;
[23]46  unsigned short oldOffset = *myPtrs->offsetV9Ptr;
[2]47  unsigned short secondOffset = 0;
48  unsigned short secondOldOffset = 0;
[14]49  int moreIsNecessary = 1;
[2]50  int field_size = 0;
51  int cpt = 0;
52  int secondCpt = 0;
53  int overflow = 0;
54  int noEnd = 1;
[16]55  int i = 0;
56  int j = 0;
[2]57  int pos = 0;
58  unsigned char buffer1; 
59  unsigned char buffer2[2];
60  unsigned char buffer4[4];
[23]61  RulesPtr tmpRuleList = myPtrs->rulesListPtr;
[36]62  RulesPtr tmpRL = myPtrs->rulesListPtr;
[2]63  msgType myMsg;
64  char *msgTextIndex;
[36]65  char *msgToSend;
[2]66  unsigned short tplMsgType = 11;
[36]67  struct PrefixV4 prefixKey, *res, *res2; /* for bsearch */
[16]68  struct AggCache agCache;
[22]69  int bool = 0; /* in IPV4 Agg mode enabled, we need to now if it's an IPv4 */
70                /* flow, we test on the field and then put bool at 1 */
[27]71  int isMplsFlow = 0;
72  int paddingCounter = 0;
73  int crazyCounter = 0;
74
[20]75#ifdef CRIHAN
[22]76  struct IPFLowCache ipFirstCache;
77  struct MPLSFlowCache mplsFirstCache;
78  unsigned long firstTime = 0;
79  unsigned long lastTime = 0;
[2]80
[18]81  ipFirstCache.ipProt = 0;
82  ipFirstCache.bytes = 0;
83  ipFirstCache.pkts = 0;
84  ipFirstCache.inSnmp = 0;
85  ipFirstCache.outSnmp = 0;
86  ipFirstCache.v4AdS = 0;
87  ipFirstCache.v4AdD = 0;
88  ipFirstCache.tProt = 0;
89  ipFirstCache.sPort = 0;
90  ipFirstCache.dPort = 0;
91  ipFirstCache.maskD = 0;
92  ipFirstCache.maskS = 0;
93  ipFirstCache.routerAd = 0;
94  ipFirstCache.liveTime = 0;
95  mplsFirstCache.ipProt = 0;
96  mplsFirstCache.v4AdS = 0;
97  mplsFirstCache.v4AdD = 0;
98  mplsFirstCache.routerAd = 0;
99  mplsFirstCache.mplsLabel1 = 0;
[20]100#endif /* CRIHAN */
[19]101
[23]102  buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++;
103  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++;
104  (*myPtrs->currentFlowsetIdPtr) = *((unsigned short*)&buffer2);
105  buffer2[1] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++;
106  buffer2[0] = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++;
[2]107  data_length = *((unsigned short*)&buffer2);
[30]108
[29]109  if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,
110                      (*myPtrs->currentFlowsetIdPtr)))!=NULL ) {
111#ifdef DEBUG
[30]112    fprintf(stderr,"{d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length);
[34]113    if ( (*myPtrs->currentFlowsetIdPtr) > TRESHOLD_TEMPLATE_ID ) {
[30]114/*      fprintf(stderr,"Bad TID from router: %lu.%lu.%lu.%lu\n", */
115/*              (*myPtrs->currentFlowsetIdPtr), */
116/*              (myPtrs->pcktPtr->ipH->srcAdd>>24), */
117/*              (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */
118/*              (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */
119/*              (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)); */
120/*      fprintf(stderr," Bytes : \n"); */
121/*      while ( ( myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr) ) > (myPtrs->ptr_buffer+1416) ){ */
122/*        buffer1= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr));(*myPtrs->offsetV9Ptr)++; */
123/*        tmp = *((unsigned char*)&buffer1); */
124/*        fprintf (stderr, " %s ", tmp); */
125/*      } */
126/*      exit(-1); */
127      return (data_length+shift);
128    }
[29]129#endif
[2]130    pftmp = tmp->lastField;
131    for (; pftmp; pftmp = pftmp->prev) {
132      flow_size += pftmp->fieldLength;
133    }
134    if ( data_length%flow_size >= 9 ) {
[23]135      (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count;
[2]136      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",
[23]137             (*myPtrs->currentFlowsetIdPtr),
138             (myPtrs->pcktPtr->ipH->srcAdd>>24),
139             (myPtrs->pcktPtr->ipH->srcAdd<<8>>24),
140             (myPtrs->pcktPtr->ipH->srcAdd<<16>>24),
141             (myPtrs->pcktPtr->ipH->srcAdd<<24>>24));
[2]142      return (data_length+shift);
143    }
[27]144    if ( data_length >= 1452 ) {
145      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",
146             (*myPtrs->currentFlowsetIdPtr),
147             (myPtrs->pcktPtr->ipH->srcAdd>>24),
148             (myPtrs->pcktPtr->ipH->srcAdd<<8>>24),
149             (myPtrs->pcktPtr->ipH->srcAdd<<16>>24),
150             (myPtrs->pcktPtr->ipH->srcAdd<<24>>24));
151      return (-1);
152    }
[22]153#ifdef IPV4AGG
[23]154    agCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;
[22]155#endif
[18]156
[20]157#ifdef CRIHAN
[23]158    ipFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;
159    mplsFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd;
[20]160#endif /* CRIHAN */
[18]161
[2]162    pftmp = tmp->lastField;
163    secondPftmp = tmp->lastField;   
[23]164    secondOffset = *myPtrs->offsetV9Ptr;
[2]165    secondOldOffset = secondOffset;
[23]166    while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) {
[2]167      /*
[29]168       * progression in a data flow Set
[2]169       * notes:
170       *   48=header ip + header netf
171       *   shift = shift if there is a template declaration
172       */
173      cpt++;
[27]174      j = 0;
[2]175      pos = (pftmp->fieldType)*10+j;
176      field_size = (int) pftmp->fieldLength;
[27]177     
178      /* special case: check yes on all flows from one router (phantom field nb 0) */
179      while ( ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j))) != NULL ) { 
180        if  ( (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j)))->value->stor.lvalue)
181              == myPtrs->pcktPtr->ipH->srcAdd )
182          {
183            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+j)))->check = 1;
184          }     
185        j++;
186      }   
187      j = 0;
188     
[2]189      /*
190       * Comparaison between the field value and the rules
191       * ... if one rule exist
[27]192       * FIXME : warning, if no rules, no accounting ?
[2]193       */
[23]194      if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL) {
195        oldOffset = *myPtrs->offsetV9Ptr;
196        while (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL){
[2]197          /*
198           * while on one cache table line
199           */
[23]200          *myPtrs->offsetV9Ptr = oldOffset;
[2]201          switch ((int)
[23]202                  (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)){
[2]203          case 2:
[27]204            /* operator: "=" */ 
[2]205            switch (field_size) {
206            case 1:
[23]207              buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[17]208              /* rule check */
[23]209              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.cvalue
[2]210                  == *((unsigned char*)&buffer1)) {
[23]211                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[16]212              }
[17]213              /* end rule check */
[22]214#ifdef IPV4AGG
215              if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){
216                agCache.maskS = *((unsigned char*)&buffer1);
217              }
218              if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){
219                agCache.maskD = *((unsigned char*)&buffer1);
220              }
221              if (pftmp->fieldType==60){
222                agCache.ipProt = *((unsigned char*)&buffer1);
223              }
224              if (pftmp->fieldType==4){
225                agCache.tProt = *((unsigned char*)&buffer1);
226              }
227              if (pftmp->fieldType==61){
228                agCache.sens = *((unsigned char*)&buffer1);
229              }
230              if (pftmp->fieldType==5){
231                agCache.dscp = *((unsigned char*)&buffer1);
232              }
233#endif       
[20]234#ifdef CRIHAN
[17]235              if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){
[18]236                ipFirstCache.maskS = *((unsigned char*)&buffer1);
[17]237              }
238              if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){
[18]239                ipFirstCache.maskD = *((unsigned char*)&buffer1);
[17]240              }
[18]241              if (pftmp->fieldType==60){
242                ipFirstCache.ipProt = *((unsigned char*)&buffer1);
243                mplsFirstCache.ipProt = *((unsigned char*)&buffer1);
244              }
245              if (pftmp->fieldType==4){
246                ipFirstCache.tProt = *((unsigned char*)&buffer1);
247              }
[22]248#endif
[2]249              break;
250            case 2:
[23]251              buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
252              buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
253              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.svalue
[2]254                  == *((unsigned short*)&buffer2))
[23]255                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[22]256#ifdef IPV4AGG
257              if (pftmp->fieldType==10){
258                agCache.idSnmp = *((unsigned short*)&buffer2);
259              }
260#endif
[20]261#ifdef CRIHAN
[17]262              if (pftmp->fieldType==10){
[18]263                ipFirstCache.inSnmp = *((unsigned short*)&buffer2);
[17]264              }
[18]265              if (pftmp->fieldType==14){
266                ipFirstCache.outSnmp = *((unsigned short*)&buffer2);
267              }
268              if (pftmp->fieldType==7){
269                ipFirstCache.sPort = *((unsigned short*)&buffer2);
270              }
271              if (pftmp->fieldType==11){
272                ipFirstCache.dPort = *((unsigned short*)&buffer2);
273              }
[22]274#endif
[2]275              break;
[17]276            case 3:
277              buffer4[3]= 0;
[23]278              buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
279              buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
280              buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
281              if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue
[17]282                  == *((unsigned long*)&buffer4))
[23]283                ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[17]284              /* aggregation */
285              /* end aggregation */
[27]286              if (pftmp->fieldType==70){
287                isMplsFlow = 1;
288              }
[20]289#ifdef CRIHAN
[18]290              if (pftmp->fieldType==70){
291                mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4;
292              }
[22]293#endif
[17]294              break;
[2]295            case 4:
[23]296              buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
297              buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
298              buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
299              buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[15]300              /* FIXME : here , add a check on the field type */
[16]301              if ((pftmp->fieldType==8)||(pftmp->fieldType==12)){
[23]302                if ((((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.lvalue)
303                    == (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) )
[16]304                  {
[23]305                    ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[16]306                  }
[29]307              }
[22]308#ifdef IPV4AGG
309              if ((pftmp->fieldType==8)){
[27]310                bool = 1; /* very important, test if we have an IPv4 flow for Agg */
[22]311                agCache.v4AdS = *((unsigned long*)&buffer4);
312              }
313              if ((pftmp->fieldType==12)){
314                agCache.v4AdD = *((unsigned long*)&buffer4);
315              }
316              if (pftmp->fieldType==1){
317                agCache.bytes = *((unsigned long*)&buffer4);
318              }
319              if (pftmp->fieldType==2){
320                agCache.pkts = *((unsigned long*)&buffer4);
321              }
322#endif
[20]323#ifdef CRIHAN
[18]324              if (pftmp->fieldType==8){
325                ipFirstCache.v4AdS = *((unsigned long*)&buffer4);
[19]326                mplsFirstCache.v4AdS = *((unsigned long*)&buffer4);
[17]327              }
[18]328              if (pftmp->fieldType==12){
329                ipFirstCache.v4AdD = *((unsigned long*)&buffer4);
[19]330                mplsFirstCache.v4AdD = *((unsigned long*)&buffer4);
[17]331              }
332              if (pftmp->fieldType==1){
[18]333                ipFirstCache.bytes = *((unsigned long*)&buffer4);
[17]334              }
335              if (pftmp->fieldType==2){
[18]336                ipFirstCache.pkts = *((unsigned long*)&buffer4);
[17]337              }
[18]338              if (pftmp->fieldType==22){
339                firstTime = *((unsigned long*)&buffer4);
340              }
341              if (pftmp->fieldType==21){
342                lastTime = *((unsigned long*)&buffer4);
343              }
[22]344#endif
[2]345              break;
346            case 16:
347              for (i=0; i<4; i++) {
[23]348                buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
349                buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
350                buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
351                buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[14]352                if (1==moreIsNecessary){
353                  switch(i){
354                  case 0:
[23]355                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 32){
356                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]357                          ==
[23]358                          (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)
[14]359                          )
360                        {
[23]361                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[14]362                          moreIsNecessary = 0;
363                        } else {
[23]364                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]365                          moreIsNecessary = 0;
366                        }
[2]367                    } else {
[23]368                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]369                          ==
370                          (*((unsigned long*)&buffer4))
371                          )
372                        {
[23]373                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1;
[14]374                        } else {
[23]375                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]376                          moreIsNecessary = 0;
377                        }
[2]378                    }
[14]379                    break;
380                  case 1:
[23]381                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 64){
382                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]383                          ==
[23]384                          (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)
[14]385                          )
386                        {
[23]387                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
388                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]389                          moreIsNecessary = 0;
390                        } else {
[23]391                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]392                          moreIsNecessary = 0;
393                        }
394                    } else {
[23]395                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]396                          ==
397                          (*((unsigned long*)&buffer4))
398                          )
399                        {
[23]400                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
401                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]402                        } else {
[23]403                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]404                          moreIsNecessary = 0;
405                        }
406                    }
407                    break;
408                  case 2:
[23]409                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 96){
410                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]411                          ==
[23]412                          (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)
[14]413                          )
414                        {
[23]415                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
416                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]417                          moreIsNecessary = 0;
418                        } else {
[23]419                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]420                          moreIsNecessary = 0;
421                        }
422                    } else {
[23]423                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]424                          ==
425                          (*((unsigned long*)&buffer4))
426                          )
427                        {
[23]428                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
429                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]430                        } else {
[23]431                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]432                          moreIsNecessary = 0;
433                        }
434                    }
435                    break;
436                  case 3:
[23]437                    if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 128){
438                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]439                          ==
[23]440                          (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)
[14]441                          )
442                        {
[23]443                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
444                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]445                        } else {
[23]446                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]447                          moreIsNecessary = 0;
448                        }
449                    } else {
[23]450                      if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i])
[14]451                          ==
452                          (*((unsigned long*)&buffer4))
453                          )
454                        {
[23]455                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check =
456                            ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1;
[14]457                        } else {
[23]458                          ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0;
[14]459                          moreIsNecessary = 0;
460                        }
461                    }
462                    break;
463                  default:
464                    break;
465                  } /* end of switch(i) */
466                } /* end of if moreIsNecessary */
[2]467              }
[14]468              moreIsNecessary = 1;
[22]469              /* aggregation for IPv6 flows */
[16]470             
471              /* end aggregation */
[2]472              break;
473            default:
474              syslog(LOG_INFO, "Field size not known: %d\n", field_size);
475              for (i=0; i<field_size; i++){
[23]476                (*myPtrs->offsetV9Ptr)++;
[2]477              }
478              break;
479            }
480            break;
481          default:
482            syslog(LOG_INFO, "Operator not known: %d\n",
[23]483                   (int)(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator));
[2]484            break;
485          }
486          j++;
487          pos = (pftmp->fieldType)*10+j;
[23]488        } /* end while myPtrs->rulesAddressPtr */
[2]489      } else {
490        /*
[22]491         * no rule within this field type, but we must read the value
[2]492         */
493        switch (field_size) {
494        case 1:
[23]495          buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[22]496#ifdef IPV4AGG
497          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){
498            agCache.maskS = *((unsigned char*)&buffer1);
499          }
500          if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){
501            agCache.maskD = *((unsigned char*)&buffer1);
502          }
503          if (pftmp->fieldType==60){
504            agCache.ipProt = *((unsigned char*)&buffer1);
505          }
506          if (pftmp->fieldType==4){
507            agCache.tProt = *((unsigned char*)&buffer1);
508          }
509          if (pftmp->fieldType==61){
510            agCache.sens = *((unsigned char*)&buffer1);
511          }
512          if (pftmp->fieldType==5){
513            agCache.dscp = *((unsigned char*)&buffer1);
514          }       
515#endif
[20]516#ifdef CRIHAN
[17]517          if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){
[18]518            ipFirstCache.maskS = *((unsigned char*)&buffer1);
[17]519          }
520          if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){
[18]521            ipFirstCache.maskD = *((unsigned char*)&buffer1);
[17]522          }
[18]523          if (pftmp->fieldType==60){
524            ipFirstCache.ipProt = *((unsigned char*)&buffer1);
525            mplsFirstCache.ipProt = *((unsigned char*)&buffer1);
[17]526          }
[18]527          if (pftmp->fieldType==4){
528            ipFirstCache.tProt = *((unsigned char*)&buffer1);
[17]529          }
[22]530#endif
[2]531          break;
532        case 2:
[23]533          buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
534          buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[22]535#ifdef IPV4AGG
[17]536          if (pftmp->fieldType==10){
537            agCache.idSnmp = *((unsigned short*)&buffer2);
538          }       
[22]539#endif
[20]540#ifdef CRIHAN
[18]541          if (pftmp->fieldType==10){
542            ipFirstCache.inSnmp = *((unsigned short*)&buffer2);
543          }
544          if (pftmp->fieldType==14){
545            ipFirstCache.outSnmp = *((unsigned short*)&buffer2);
546          }
547          if (pftmp->fieldType==7){
548            ipFirstCache.sPort = *((unsigned short*)&buffer2);
549          }
550          if (pftmp->fieldType==11){
551            ipFirstCache.dPort = *((unsigned short*)&buffer2);
552          }
[22]553#endif
[2]554          break;
[17]555        case 3:
556          buffer4[3]= 0;
[23]557          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
558          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
559          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[17]560          /* aggregation */
561          /* end aggregation */
[27]562          if (pftmp->fieldType==70){
563            isMplsFlow = 1;
564          }
[20]565#ifdef CRIHAN
[18]566          if (pftmp->fieldType==70){
567            mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4;
568          }
[22]569#endif
[17]570          break;
[2]571        case 4:
[23]572          buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
573          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
574          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
575          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[22]576#ifdef IPV4AGG
577          if ((pftmp->fieldType==8)){
578            bool = 1;
579            agCache.v4AdS = *((unsigned long*)&buffer4);
580          } else if ((pftmp->fieldType==12)){
581            agCache.v4AdD = *((unsigned long*)&buffer4);
582          } else if (pftmp->fieldType==1){
583            agCache.bytes = *((unsigned long*)&buffer4);
584          } else if (pftmp->fieldType==2){
585            agCache.pkts = *((unsigned long*)&buffer4);
586          }
587#endif
[20]588#ifdef CRIHAN
[18]589          if (pftmp->fieldType==8){
590            ipFirstCache.v4AdS = *((unsigned long*)&buffer4);
[19]591            mplsFirstCache.v4AdS = *((unsigned long*)&buffer4);
[17]592          }
[18]593          if (pftmp->fieldType==12){
594            ipFirstCache.v4AdD = *((unsigned long*)&buffer4);
[19]595            mplsFirstCache.v4AdD = *((unsigned long*)&buffer4);
[18]596          }
597          if (pftmp->fieldType==1){
598            ipFirstCache.bytes = *((unsigned long*)&buffer4);
599          }
600          if (pftmp->fieldType==2){
601            ipFirstCache.pkts = *((unsigned long*)&buffer4);
602          }
603          if (pftmp->fieldType==22){
604            firstTime = *((unsigned long*)&buffer4);
605          }
606          if (pftmp->fieldType==21){
607            lastTime = *((unsigned long*)&buffer4);
608          }
[22]609#endif
[2]610          break;
611        case 16:
612          for (i=0; i<4; i++) {
[23]613            buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
614            buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
615            buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
616            buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
[2]617          }
[22]618          /* aggregation IPv6 */         
[16]619          /* end aggregation */
[2]620          break;
621        default:
622          syslog(LOG_INFO,"UNKNOWN FIELDS LENGTH: %d ", field_size);
623          for (i=0; i<field_size; i++){
[23]624            (*myPtrs->offsetV9Ptr)++;
[2]625          }
626        }
627      } /* end if one cache table line existence */
628      if (cpt==tmp->fieldCount) {
629        /*
630         * end of one flow (not the flowset)
631         */
[20]632#ifdef CRIHAN
[18]633        if ( mplsFirstCache.mplsLabel1 == 0 ) {
[23]634          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->ipProt = ipFirstCache.ipProt;
[18]635          ipFirstCache.ipProt = 0;
[23]636          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->bytes = ipFirstCache.bytes;
[18]637          ipFirstCache.bytes = 0;
[23]638          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->pkts = ipFirstCache.pkts;
[18]639          ipFirstCache.pkts = 0;
[23]640          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->inSnmp = ipFirstCache.inSnmp;
[18]641          ipFirstCache.inSnmp = 0;
[23]642          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->outSnmp = ipFirstCache.outSnmp;
[18]643          ipFirstCache.outSnmp = 0;
[23]644          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdS = ipFirstCache.v4AdS;
[18]645          ipFirstCache.outSnmp = 0;
[23]646          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdD = ipFirstCache.v4AdD;
[18]647          ipFirstCache.v4AdD = 0;
[23]648          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->tProt = ipFirstCache.tProt;
[18]649          ipFirstCache.tProt = 0;
[23]650          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->sPort = ipFirstCache.sPort;
[18]651          ipFirstCache.sPort = 0;
[23]652          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->dPort = ipFirstCache.dPort;
[18]653          ipFirstCache.dPort = 0;
[23]654          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskD = ipFirstCache.maskD;
[18]655          ipFirstCache.maskD = 0;
[23]656          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskS = ipFirstCache.maskS;
[18]657          ipFirstCache.maskS = 0;
[23]658          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->routerAd = ipFirstCache.routerAd;
659          (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->liveTime = lastTime - firstTime;
[18]660          firstTime = 0; lastTime = 0;
[23]661          (*myPtrs->ipNbPtr)++;
[18]662        } else {
[23]663          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->ipProt = mplsFirstCache.ipProt;
[18]664          mplsFirstCache.ipProt = 0;
[23]665          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdS =  mplsFirstCache.v4AdS;
[18]666          mplsFirstCache.v4AdS = 0;
[23]667          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdD =  mplsFirstCache.v4AdD;
[18]668          mplsFirstCache.v4AdD = 0;
[23]669          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->routerAd =  mplsFirstCache.routerAd;
670          (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->mplsLabel1 =  mplsFirstCache.mplsLabel1;
[18]671          mplsFirstCache.mplsLabel1 = 0;
[23]672          (*myPtrs->mplsNbPtr)++;
[18]673        }
[22]674#endif 
675        /* put aggregation cache information to IPv4 Prefixes table */
[23]676        /* Aggregation mode must be enable in ./configure options   */
677        /* first we must know if the address belong to our prefix   */
[36]678        myPtrs->nbFluxTT++;
[22]679#ifdef IPV4AGG
[27]680        if ( (bool == 1) && (isMplsFlow == 0) ){
[22]681          prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS);
682          res = bsearch(&prefixKey, V4PTab, nbPV4,
[27]683                        sizeof(struct PrefixV4), prefGlobalCmp);
684          if (res!=NULL){
685            if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) {
[36]686              myPtrs->nbFluxSR4++;
[27]687              /* OUT ("traffic from the prefix/subnet")  */
688              res->bytesNbOUT += agCache.bytes;
689              res->pktsNbOUT += agCache.pkts;
690              (res->flowNbOUT)++;
[36]691              /* inter-pop matrix Accounting */
692              prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD);
693              res2 = bsearch(&prefixKey, V4PTab, nbPV4,
694                            sizeof(struct PrefixV4), prefGlobalCmp);
695              if (res2!=NULL){
696                myPtrs->nbFluxIR4++;
697                ((struct POP *)((myPtrs->matrixPOP)
698                                +((res->routerNb)*ROUTER_INDEX_MAX)
699                                +((res2->routerNb))))->pktsNb += agCache.pkts;
700                ((struct POP *)((myPtrs->matrixPOP)
701                                +((res->routerNb)*ROUTER_INDEX_MAX)
702                                +((res2->routerNb))))->bytesNb += agCache.bytes;
703                ((struct POP *)((myPtrs->matrixPOP)
704                                +((res->routerNb)*ROUTER_INDEX_MAX)
705                                +((res2->routerNb))))->flowNb++;
706              } else {
707                myPtrs->nbFluxSE++;
708                (
709                 ((struct POP *)(myPtrs->matrixPOP)
710                 +((res->routerNb)*ROUTER_INDEX_MAX)
711                 +((ROUTER_INDEX_MAX-1))))->pktsNb += agCache.pkts;
712                (
713                 ((struct POP *)(myPtrs->matrixPOP)
714                 +((res->routerNb)*ROUTER_INDEX_MAX)
715                 +((ROUTER_INDEX_MAX-1))))->bytesNb += agCache.bytes;
716                (
717                 ((struct POP *)(myPtrs->matrixPOP)
718                 +((res->routerNb)*ROUTER_INDEX_MAX)
719                 +((ROUTER_INDEX_MAX-1))))->flowNb++;
720              }
721              /* end interpop matrix accounting */
[27]722            } else {
723              /* doublon or bad reference in prefix list */
[22]724            }
[23]725          } else {
726            prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD);
727            res = bsearch(&prefixKey, V4PTab, nbPV4,
[27]728                          sizeof(struct PrefixV4), prefGlobalCmp);
729            if (res!=NULL){
730              if ( myPtrs->routersID[res->routerNb] == agCache.routerAd  ) {
731                /* IN ("traffic to the prefix")  */
732                res->bytesNbIN += agCache.bytes;
733                res->pktsNbIN += agCache.pkts;
734                (res->flowNbIN)++;
735              } else {
736                /* doublon or bad reference in prefix list */
737               
738/*              fprintf(stderr, "IN NC: %lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu R:%lu.%lu.%lu.%lu \n", */
739/*                      (agCache.v4AdS>>24), */
740/*                      (agCache.v4AdS<<8>>24),  */
741/*                      (agCache.v4AdS<<16>>24),  */
742/*                      (agCache.v4AdS<<24>>24),  */
743/*                      (agCache.maskS),  */
744/*                      (agCache.v4AdD>>24),  */
745/*                      (agCache.v4AdD<<8>>24),  */
746/*                      (agCache.v4AdD<<16>>24),  */
747/*                      (agCache.v4AdD<<24>>24),  */
748/*                      (agCache.maskD),  */
749/*                      (myPtrs->pcktPtr->ipH->srcAdd>>24),  */
750/*                      (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), */
751/*                      (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), */
752/*                      (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) */
753/*                      ); */
[23]754              }
755            } else {
756              /* HERE : we are in the cases of the address/mask don't      */
757              /*        belong to a prefix listed in the IPv4 prefix file  */
758              /* possibilities :                                           */
759              /*     -  prefix not referenced but allowed to be routed     */
760              /*     -  prefix not referenced but not allowed to be routed */
761              /*     -  spoofing                                           */
[36]762              myPtrs->nbFluxUK++;
[32]763#ifdef PRINTUNKNOWNSUBNET 
764              fprintf(stderr, "%lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu (R:%lu.%lu.%lu.%lu) \n",
765                      (agCache.v4AdS>>24),
766                      (agCache.v4AdS<<8>>24),
767                      (agCache.v4AdS<<16>>24),
768                      (agCache.v4AdS<<24>>24),
769                      (agCache.maskS),
770                      (agCache.v4AdD>>24),
771                      (agCache.v4AdD<<8>>24),
772                      (agCache.v4AdD<<16>>24),
773                      (agCache.v4AdD<<24>>24),
774                      (agCache.maskD),
775                      (myPtrs->pcktPtr->ipH->srcAdd>>24),
776                      (myPtrs->pcktPtr->ipH->srcAdd<<8>>24),
777                      (myPtrs->pcktPtr->ipH->srcAdd<<16>>24),
778                      (myPtrs->pcktPtr->ipH->srcAdd<<24>>24)
779                      );
780#endif
[23]781            }
782          }
[22]783        }
784        bool = 0;
[27]785        isMplsFlow = 0;
[22]786#endif
[2]787        /*
788         * Redirection if needed
789         * switch the rules definition (check & fieldToRecord),
[27]790         * we send the flow or a part of the flow to a remote host or a file.
791         * In a first time (until release 0.0.7, the information was sent via
792         * the process renetcolSender with an IPC message queue. But, the perf
793         * of IPC Msg was very bad with a system compilation by default.
794         * So now, we send information directly from here.
[2]795         */
[23]796        tmpRuleList = myPtrs->rulesListPtr;
[36]797        tmpRL = myPtrs->rulesListPtr;
[2]798        while (tmpRuleList){
[27]799          RuleDefPtr tmpRuleDefList = tmpRuleList->def;
[2]800          unsigned short check = 1;
[36]801          int s=0;
[2]802          secondOffset = secondOldOffset;
803          while (tmpRuleDefList){
804            check = check && tmpRuleDefList->check;
805            tmpRuleDefList->check = 0;
806            tmpRuleDefList = tmpRuleDefList->next;
807          }
808          if ( (tmpRuleList->def != NULL) && (check == 1)) {
809            /* msg building */
810            secondPftmp = tmp->lastField;
[36]811            msgTextIndex = mempcpy(mempcpy(mempcpy(myMsg.text,   
[2]812                                                   &tplMsgType,
813                                                   sizeof(unsigned short)
814                                                   ),
815                                           &tmpRuleList->id,
816                                           sizeof(tmpRuleList->id)
817                                           ),
[23]818                                   &myPtrs->currentRouterPtr->IpAddress,
[2]819                                   sizeof(unsigned long)
820                                   );
821            msgTextIndex = mempcpy(mempcpy(mempcpy(msgTextIndex,
822                                                   &tmp->sourceId,
823                                                   sizeof(unsigned long)
824                                                   ),
825                                           &tmp->templateFlowSetId,
826                                           sizeof(tmp->templateFlowSetId)
827                                           ),
[23]828                                   myPtrs->ptr_buffer+secondOffset,
[2]829                                   flow_size
830                                   );
831            myMsg.type = 1;
[27]832            /* OLD transfert type */
[36]833/*          msgSend( myQueue, myMsg); */
[27]834            /* NEW transfert type */
[36]835            for ( ; tmpRL; tmpRL=tmpRL->next){
836              if (tmpRL->id == tmpRuleList->id){
837                s = sendMessage(tmpRL->host->sockId, myMsg.text, sizeof(myMsg.text),
838                                tmpRL->host->hostAddressPtr);
839              }
840            }
[27]841            /* FIXME : perhaps check "s" */
[2]842            noEnd = 1;
843            secondCpt=0;
844          } /* end if check */
845          tmpRuleList = tmpRuleList->next;
846          secondPftmp = tmp->lastField;
847        } /* end while tmpRuleList */
848        /*
849         * end redirection
850         */
[23]851        secondOffset = *myPtrs->offsetV9Ptr;
[2]852        secondOldOffset = secondOffset;
853        pftmp = tmp->lastField;
854        cpt=0;
[23]855        (*myPtrs->currentFlowsetNumberPtr)++; /* pointer on the flows number */
856        if (((*myPtrs->offsetV9Ptr)-48-shift+flow_size) > data_length){
[2]857          overflow = 1; /* buffer index not correct */
858        }
859      } else {
860        /* not the flow end, progress in field list */
861        pftmp = pftmp->prev;
862      }
[29]863    } /* end of the while on one flow record */
[32]864   
[30]865    while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) {
866      (*myPtrs->offsetV9Ptr)++; /* if padding */
867      paddingCounter++;
868      if ( paddingCounter > 8 ) {
[29]869#ifdef DEBUG
[30]870        fprintf(stderr," padding too high: %d ", paddingCounter);
871#endif
872        syslog(LOG_INFO,"padding too high: %d ", paddingCounter);
873        return (-1);
874      }
875    }
876    while ( (*myPtrs->offsetV9Ptr)-48-shift > data_length ) {
877      (*myPtrs->offsetV9Ptr)--; /* crazy loop (when bug appears in template def) */
878      crazyCounter++;
879    }
880#ifdef DEBUG
881    if (crazyCounter != 0){ fprintf(stderr," crazyCounter: %d ", crazyCounter); }
882#endif
883    if (crazyCounter!=0) { syslog(LOG_INFO,"crazyCounter: %d ", crazyCounter);}
884   
885#ifdef DEBUG
[29]886    fprintf(stderr,"}");
887#endif
[30]888
889    return (data_length+shift);
890    /* end new place */
891   
[2]892  }else{
[30]893    /*
894     *
895     *
896     *       Optional template
897     *
898     *
899     */
[29]900    if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId,
901                              (*myPtrs->currentFlowsetIdPtr)))!=NULL) {       
[30]902#ifdef DEBUG
903      fprintf(stderr,"<d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length);
904#endif     
[29]905      for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){
906        /* FIXME : today we skip the scope fields, it's bad :( */ 
[30]907        if ((pftmp=tmpOpt->lastField)!=NULL) {
[29]908          for (j=0; j<pftmp->fieldLength; j++) {
909            (*myPtrs->offsetV9Ptr)++;
910          }
911          pftmp = pftmp->prev;
912        }
913      }
914      while (pftmp != NULL) {
915        if (pftmp->fieldLength==1){
916          buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
917        }
918        if (pftmp->fieldLength==2){
919          buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
920          buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
921        }
922        if (pftmp->fieldLength==4){
923          buffer4[3]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
924          buffer4[2]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
925          buffer4[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
926          buffer4[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++;
927          if (pftmp->fieldType==34){
[34]928            if ((*((unsigned long*)&buffer4)==1)
929                || (*((unsigned long*)&buffer4)==10)
930                || (*((unsigned long*)&buffer4)==1000)) {
931              if (myPtrs->currentRouterPtr->sampled != *((unsigned long*)&buffer4) ) {
[30]932#ifdef DEBUGAGG
[34]933                fprintf(stderr,"\n SV (p) %lu != %lu (r)", *((unsigned long*)&buffer4),
934                        myPtrs->currentRouterPtr->sampled);
[30]935#endif                     
[34]936                myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4);
937                for (i=0; i<nbPV4; i++) {
938                  /* we update the PrefixV4 structure with the sampled information */
939                  if ( myPtrs->currentRouterPtr->IpAddress == myPtrs->routersID[V4PTab[i].routerNb]) {
940                    V4PTab[i].sampling = *((unsigned long*)&buffer4);
941                    myPtrs->secondV4Tab[i].sampling = *((unsigned long*)&buffer4);
942                  }
[29]943                }
944              }
945            }
946          }
947        }       
948        pftmp = pftmp->prev;
949      }
950      if ( pftmp == NULL ) {
951        while ((*myPtrs->offsetV9Ptr)%4 != 0) {
952          (*myPtrs->offsetV9Ptr)++;
[30]953#ifdef DEBUG
954          fprintf(stderr," p ");
955#endif
[29]956        }
957      } else {
958        fprintf(stderr,"PB ");
959      }
960#ifdef DEBUG
961      fprintf(stderr,">");
962#endif
[30]963      return (data_length+shift);
[29]964    } else {
965      /*
966       * template unknown, we skip this all the data
967       */
968      (*myPtrs->offsetV9Ptr)+=(data_length-4);
969      (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count;
970#ifdef DEBUG
971      fprintf(stderr, " U, r: %lu.%lu.%lu.%lu, sourceId: %lu, TID: %hu",
972              (myPtrs->pcktPtr->ipH->srcAdd>>24),
973              (myPtrs->pcktPtr->ipH->srcAdd<<8>>24),
974              (myPtrs->pcktPtr->ipH->srcAdd<<16>>24),
975              (myPtrs->pcktPtr->ipH->srcAdd<<24>>24),
976              myPtrs->currentHeaderV9Ptr->sourceId,
977              (*myPtrs->currentFlowsetIdPtr)
978              );
979#endif
[30]980      return (data_length+shift);
[29]981    }
[2]982  }
983}
Note: See TracBrowser for help on using the browser.