[2] | 1 | |
---|
| 2 | |
---|
| 3 | |
---|
[15] | 4 | |
---|
[2] | 5 | |
---|
[28] | 6 | |
---|
[2] | 7 | |
---|
| 8 | |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | #include "dataFlowSet.h" |
---|
| 27 | |
---|
| 28 | |
---|
[22] | 29 | |
---|
[2] | 30 | |
---|
| 31 | |
---|
[27] | 32 | short |
---|
| 33 | checkDataFlowSet(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; |
---|
[2] | 62 | msgType myMsg; |
---|
| 63 | char *msgTextIndex; |
---|
| 64 | unsigned short tplMsgType = 11; |
---|
[16] | 65 | struct PrefixV4 prefixKey, *res; |
---|
| 66 | struct AggCache agCache; |
---|
[22] | 67 | int bool = 0; |
---|
| 68 | |
---|
[27] | 69 | int isMplsFlow = 0; |
---|
| 70 | int paddingCounter = 0; |
---|
| 71 | int crazyCounter = 0; |
---|
| 72 | |
---|
[20] | 73 | #ifdef CRIHAN |
---|
[22] | 74 | struct IPFLowCache ipFirstCache; |
---|
| 75 | struct MPLSFlowCache mplsFirstCache; |
---|
| 76 | unsigned long firstTime = 0; |
---|
| 77 | unsigned long lastTime = 0; |
---|
[2] | 78 | |
---|
[18] | 79 | ipFirstCache.ipProt = 0; |
---|
| 80 | ipFirstCache.bytes = 0; |
---|
| 81 | ipFirstCache.pkts = 0; |
---|
| 82 | ipFirstCache.inSnmp = 0; |
---|
| 83 | ipFirstCache.outSnmp = 0; |
---|
| 84 | ipFirstCache.v4AdS = 0; |
---|
| 85 | ipFirstCache.v4AdD = 0; |
---|
| 86 | ipFirstCache.tProt = 0; |
---|
| 87 | ipFirstCache.sPort = 0; |
---|
| 88 | ipFirstCache.dPort = 0; |
---|
| 89 | ipFirstCache.maskD = 0; |
---|
| 90 | ipFirstCache.maskS = 0; |
---|
| 91 | ipFirstCache.routerAd = 0; |
---|
| 92 | ipFirstCache.liveTime = 0; |
---|
| 93 | mplsFirstCache.ipProt = 0; |
---|
| 94 | mplsFirstCache.v4AdS = 0; |
---|
| 95 | mplsFirstCache.v4AdD = 0; |
---|
| 96 | mplsFirstCache.routerAd = 0; |
---|
| 97 | mplsFirstCache.mplsLabel1 = 0; |
---|
[20] | 98 | #endif |
---|
[19] | 99 | |
---|
[23] | 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)++; |
---|
[2] | 105 | data_length = *((unsigned short*)&buffer2); |
---|
[30] | 106 | |
---|
[29] | 107 | if ( (tmp=existTplId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId, |
---|
| 108 | (*myPtrs->currentFlowsetIdPtr)))!=NULL ) { |
---|
| 109 | #ifdef DEBUG |
---|
[30] | 110 | fprintf(stderr,"{d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); |
---|
| 111 | if ( (*myPtrs->currentFlowsetIdPtr) > 270 ) { |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|
| 124 | |
---|
| 125 | return (data_length+shift); |
---|
| 126 | } |
---|
[29] | 127 | #endif |
---|
[2] | 128 | pftmp = tmp->lastField; |
---|
| 129 | for (; pftmp; pftmp = pftmp->prev) { |
---|
| 130 | flow_size += pftmp->fieldLength; |
---|
| 131 | } |
---|
| 132 | if ( data_length%flow_size >= 9 ) { |
---|
[23] | 133 | (*myPtrs->currentFlowsetNumberPtr) = myPtrs->currentHeaderV9Ptr->count; |
---|
[2] | 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", |
---|
[23] | 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)); |
---|
[2] | 140 | return (data_length+shift); |
---|
| 141 | } |
---|
[27] | 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 | } |
---|
[22] | 151 | #ifdef IPV4AGG |
---|
[23] | 152 | agCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; |
---|
[22] | 153 | #endif |
---|
[18] | 154 | |
---|
[20] | 155 | #ifdef CRIHAN |
---|
[23] | 156 | ipFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; |
---|
| 157 | mplsFirstCache.routerAd = myPtrs->pcktPtr->ipH->srcAdd; |
---|
[20] | 158 | #endif |
---|
[18] | 159 | |
---|
[2] | 160 | pftmp = tmp->lastField; |
---|
| 161 | secondPftmp = tmp->lastField; |
---|
[23] | 162 | secondOffset = *myPtrs->offsetV9Ptr; |
---|
[2] | 163 | secondOldOffset = secondOffset; |
---|
[23] | 164 | while ( (((*myPtrs->offsetV9Ptr)-48-shift) <= data_length) && (overflow!=1) ) { |
---|
[2] | 165 | |
---|
[29] | 166 | |
---|
[2] | 167 | |
---|
| 168 | |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | cpt++; |
---|
[27] | 172 | j = 0; |
---|
[2] | 173 | pos = (pftmp->fieldType)*10+j; |
---|
| 174 | field_size = (int) pftmp->fieldLength; |
---|
[27] | 175 | |
---|
| 176 | |
---|
| 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 | |
---|
[2] | 187 | |
---|
| 188 | |
---|
| 189 | |
---|
[27] | 190 | |
---|
[2] | 191 | |
---|
[23] | 192 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL) { |
---|
| 193 | oldOffset = *myPtrs->offsetV9Ptr; |
---|
| 194 | while (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos))) != NULL){ |
---|
[2] | 195 | |
---|
| 196 | |
---|
| 197 | |
---|
[23] | 198 | *myPtrs->offsetV9Ptr = oldOffset; |
---|
[2] | 199 | switch ((int) |
---|
[23] | 200 | (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)){ |
---|
[2] | 201 | case 2: |
---|
[27] | 202 | |
---|
[2] | 203 | switch (field_size) { |
---|
| 204 | case 1: |
---|
[23] | 205 | buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; |
---|
[17] | 206 | |
---|
[23] | 207 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.cvalue |
---|
[2] | 208 | == *((unsigned char*)&buffer1)) { |
---|
[23] | 209 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[16] | 210 | } |
---|
[17] | 211 | |
---|
[22] | 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 |
---|
[20] | 232 | #ifdef CRIHAN |
---|
[17] | 233 | if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ |
---|
[18] | 234 | ipFirstCache.maskS = *((unsigned char*)&buffer1); |
---|
[17] | 235 | } |
---|
| 236 | if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ |
---|
[18] | 237 | ipFirstCache.maskD = *((unsigned char*)&buffer1); |
---|
[17] | 238 | } |
---|
[18] | 239 | if (pftmp->fieldType==60){ |
---|
| 240 | ipFirstCache.ipProt = *((unsigned char*)&buffer1); |
---|
| 241 | mplsFirstCache.ipProt = *((unsigned char*)&buffer1); |
---|
| 242 | } |
---|
| 243 | if (pftmp->fieldType==4){ |
---|
| 244 | ipFirstCache.tProt = *((unsigned char*)&buffer1); |
---|
| 245 | } |
---|
[22] | 246 | #endif |
---|
[2] | 247 | break; |
---|
| 248 | case 2: |
---|
[23] | 249 | 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 |
---|
[2] | 252 | == *((unsigned short*)&buffer2)) |
---|
[23] | 253 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[22] | 254 | #ifdef IPV4AGG |
---|
| 255 | if (pftmp->fieldType==10){ |
---|
| 256 | agCache.idSnmp = *((unsigned short*)&buffer2); |
---|
| 257 | } |
---|
| 258 | #endif |
---|
[20] | 259 | #ifdef CRIHAN |
---|
[17] | 260 | if (pftmp->fieldType==10){ |
---|
[18] | 261 | ipFirstCache.inSnmp = *((unsigned short*)&buffer2); |
---|
[17] | 262 | } |
---|
[18] | 263 | if (pftmp->fieldType==14){ |
---|
| 264 | ipFirstCache.outSnmp = *((unsigned short*)&buffer2); |
---|
| 265 | } |
---|
| 266 | if (pftmp->fieldType==7){ |
---|
| 267 | ipFirstCache.sPort = *((unsigned short*)&buffer2); |
---|
| 268 | } |
---|
| 269 | if (pftmp->fieldType==11){ |
---|
| 270 | ipFirstCache.dPort = *((unsigned short*)&buffer2); |
---|
| 271 | } |
---|
[22] | 272 | #endif |
---|
[2] | 273 | break; |
---|
[17] | 274 | case 3: |
---|
| 275 | buffer4[3]= 0; |
---|
[23] | 276 | 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 |
---|
[17] | 280 | == *((unsigned long*)&buffer4)) |
---|
[23] | 281 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[17] | 282 | |
---|
| 283 | |
---|
[27] | 284 | if (pftmp->fieldType==70){ |
---|
| 285 | isMplsFlow = 1; |
---|
| 286 | } |
---|
[20] | 287 | #ifdef CRIHAN |
---|
[18] | 288 | if (pftmp->fieldType==70){ |
---|
| 289 | mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; |
---|
| 290 | } |
---|
[22] | 291 | #endif |
---|
[17] | 292 | break; |
---|
[2] | 293 | case 4: |
---|
[23] | 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)++; |
---|
[15] | 298 | |
---|
[16] | 299 | if ((pftmp->fieldType==8)||(pftmp->fieldType==12)){ |
---|
[23] | 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) ) |
---|
[16] | 302 | { |
---|
[23] | 303 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[16] | 304 | } |
---|
[29] | 305 | } |
---|
[22] | 306 | #ifdef IPV4AGG |
---|
| 307 | if ((pftmp->fieldType==8)){ |
---|
[27] | 308 | bool = 1; |
---|
[22] | 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 |
---|
[20] | 321 | #ifdef CRIHAN |
---|
[18] | 322 | if (pftmp->fieldType==8){ |
---|
| 323 | ipFirstCache.v4AdS = *((unsigned long*)&buffer4); |
---|
[19] | 324 | mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); |
---|
[17] | 325 | } |
---|
[18] | 326 | if (pftmp->fieldType==12){ |
---|
| 327 | ipFirstCache.v4AdD = *((unsigned long*)&buffer4); |
---|
[19] | 328 | mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); |
---|
[17] | 329 | } |
---|
| 330 | if (pftmp->fieldType==1){ |
---|
[18] | 331 | ipFirstCache.bytes = *((unsigned long*)&buffer4); |
---|
[17] | 332 | } |
---|
| 333 | if (pftmp->fieldType==2){ |
---|
[18] | 334 | ipFirstCache.pkts = *((unsigned long*)&buffer4); |
---|
[17] | 335 | } |
---|
[18] | 336 | if (pftmp->fieldType==22){ |
---|
| 337 | firstTime = *((unsigned long*)&buffer4); |
---|
| 338 | } |
---|
| 339 | if (pftmp->fieldType==21){ |
---|
| 340 | lastTime = *((unsigned long*)&buffer4); |
---|
| 341 | } |
---|
[22] | 342 | #endif |
---|
[2] | 343 | break; |
---|
| 344 | case 16: |
---|
| 345 | for (i=0; i<4; i++) { |
---|
[23] | 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)++; |
---|
[14] | 350 | if (1==moreIsNecessary){ |
---|
| 351 | switch(i){ |
---|
| 352 | case 0: |
---|
[23] | 353 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 32){ |
---|
| 354 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 355 | == |
---|
[23] | 356 | (*((unsigned long*)&buffer4))>>(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(32-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) |
---|
[14] | 357 | ) |
---|
| 358 | { |
---|
[23] | 359 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[14] | 360 | moreIsNecessary = 0; |
---|
| 361 | } else { |
---|
[23] | 362 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 363 | moreIsNecessary = 0; |
---|
| 364 | } |
---|
[2] | 365 | } else { |
---|
[23] | 366 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 367 | == |
---|
| 368 | (*((unsigned long*)&buffer4)) |
---|
| 369 | ) |
---|
| 370 | { |
---|
[23] | 371 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 1; |
---|
[14] | 372 | } else { |
---|
[23] | 373 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 374 | moreIsNecessary = 0; |
---|
| 375 | } |
---|
[2] | 376 | } |
---|
[14] | 377 | break; |
---|
| 378 | case 1: |
---|
[23] | 379 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 64){ |
---|
| 380 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 381 | == |
---|
[23] | 382 | (*((unsigned long*)&buffer4))>>(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(64-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) |
---|
[14] | 383 | ) |
---|
| 384 | { |
---|
[23] | 385 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 386 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 387 | moreIsNecessary = 0; |
---|
| 388 | } else { |
---|
[23] | 389 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 390 | moreIsNecessary = 0; |
---|
| 391 | } |
---|
| 392 | } else { |
---|
[23] | 393 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 394 | == |
---|
| 395 | (*((unsigned long*)&buffer4)) |
---|
| 396 | ) |
---|
| 397 | { |
---|
[23] | 398 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 399 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 400 | } else { |
---|
[23] | 401 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 402 | moreIsNecessary = 0; |
---|
| 403 | } |
---|
| 404 | } |
---|
| 405 | break; |
---|
| 406 | case 2: |
---|
[23] | 407 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 96){ |
---|
| 408 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 409 | == |
---|
[23] | 410 | (*((unsigned long*)&buffer4))>>(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(96-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) |
---|
[14] | 411 | ) |
---|
| 412 | { |
---|
[23] | 413 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 414 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 415 | moreIsNecessary = 0; |
---|
| 416 | } else { |
---|
[23] | 417 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 418 | moreIsNecessary = 0; |
---|
| 419 | } |
---|
| 420 | } else { |
---|
[23] | 421 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 422 | == |
---|
| 423 | (*((unsigned long*)&buffer4)) |
---|
| 424 | ) |
---|
| 425 | { |
---|
[23] | 426 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 427 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 428 | } else { |
---|
[23] | 429 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 430 | moreIsNecessary = 0; |
---|
| 431 | } |
---|
| 432 | } |
---|
| 433 | break; |
---|
| 434 | case 3: |
---|
[23] | 435 | if (((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask <= 128){ |
---|
| 436 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 437 | == |
---|
[23] | 438 | (*((unsigned long*)&buffer4))>>(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask)<<(128-((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->mask) |
---|
[14] | 439 | ) |
---|
| 440 | { |
---|
[23] | 441 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 442 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 443 | } else { |
---|
[23] | 444 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 445 | moreIsNecessary = 0; |
---|
| 446 | } |
---|
| 447 | } else { |
---|
[23] | 448 | if (ntohl(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->value->stor.tabAdd6[i]) |
---|
[14] | 449 | == |
---|
| 450 | (*((unsigned long*)&buffer4)) |
---|
| 451 | ) |
---|
| 452 | { |
---|
[23] | 453 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = |
---|
| 454 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check && 1; |
---|
[14] | 455 | } else { |
---|
[23] | 456 | ((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->check = 0; |
---|
[14] | 457 | moreIsNecessary = 0; |
---|
| 458 | } |
---|
| 459 | } |
---|
| 460 | break; |
---|
| 461 | default: |
---|
| 462 | break; |
---|
| 463 | } |
---|
| 464 | } |
---|
[2] | 465 | } |
---|
[14] | 466 | moreIsNecessary = 1; |
---|
[22] | 467 | |
---|
[16] | 468 | |
---|
| 469 | |
---|
[2] | 470 | break; |
---|
| 471 | default: |
---|
| 472 | syslog(LOG_INFO, "Field size not known: %d\n", field_size); |
---|
| 473 | for (i=0; i<field_size; i++){ |
---|
[23] | 474 | (*myPtrs->offsetV9Ptr)++; |
---|
[2] | 475 | } |
---|
| 476 | break; |
---|
| 477 | } |
---|
| 478 | break; |
---|
| 479 | default: |
---|
| 480 | syslog(LOG_INFO, "Operator not known: %d\n", |
---|
[23] | 481 | (int)(((RuleDefPtr)(*(myPtrs->rulesAddressPtr+pos)))->operator)); |
---|
[2] | 482 | break; |
---|
| 483 | } |
---|
| 484 | j++; |
---|
| 485 | pos = (pftmp->fieldType)*10+j; |
---|
[23] | 486 | } |
---|
[2] | 487 | } else { |
---|
| 488 | |
---|
[22] | 489 | |
---|
[2] | 490 | |
---|
| 491 | switch (field_size) { |
---|
| 492 | case 1: |
---|
[23] | 493 | buffer1 = *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; |
---|
[22] | 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 |
---|
[20] | 514 | #ifdef CRIHAN |
---|
[17] | 515 | if ((pftmp->fieldType==9)||(pftmp->fieldType==29)){ |
---|
[18] | 516 | ipFirstCache.maskS = *((unsigned char*)&buffer1); |
---|
[17] | 517 | } |
---|
| 518 | if ((pftmp->fieldType==13)||(pftmp->fieldType==30)){ |
---|
[18] | 519 | ipFirstCache.maskD = *((unsigned char*)&buffer1); |
---|
[17] | 520 | } |
---|
[18] | 521 | if (pftmp->fieldType==60){ |
---|
| 522 | ipFirstCache.ipProt = *((unsigned char*)&buffer1); |
---|
| 523 | mplsFirstCache.ipProt = *((unsigned char*)&buffer1); |
---|
[17] | 524 | } |
---|
[18] | 525 | if (pftmp->fieldType==4){ |
---|
| 526 | ipFirstCache.tProt = *((unsigned char*)&buffer1); |
---|
[17] | 527 | } |
---|
[22] | 528 | #endif |
---|
[2] | 529 | break; |
---|
| 530 | case 2: |
---|
[23] | 531 | buffer2[1]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; |
---|
| 532 | buffer2[0]= *(myPtrs->ptr_buffer+(*myPtrs->offsetV9Ptr)); (*myPtrs->offsetV9Ptr)++; |
---|
[22] | 533 | #ifdef IPV4AGG |
---|
[17] | 534 | if (pftmp->fieldType==10){ |
---|
| 535 | agCache.idSnmp = *((unsigned short*)&buffer2); |
---|
| 536 | } |
---|
[22] | 537 | #endif |
---|
[20] | 538 | #ifdef CRIHAN |
---|
[18] | 539 | if (pftmp->fieldType==10){ |
---|
| 540 | ipFirstCache.inSnmp = *((unsigned short*)&buffer2); |
---|
| 541 | } |
---|
| 542 | if (pftmp->fieldType==14){ |
---|
| 543 | ipFirstCache.outSnmp = *((unsigned short*)&buffer2); |
---|
| 544 | } |
---|
| 545 | if (pftmp->fieldType==7){ |
---|
| 546 | ipFirstCache.sPort = *((unsigned short*)&buffer2); |
---|
| 547 | } |
---|
| 548 | if (pftmp->fieldType==11){ |
---|
| 549 | ipFirstCache.dPort = *((unsigned short*)&buffer2); |
---|
| 550 | } |
---|
[22] | 551 | #endif |
---|
[2] | 552 | break; |
---|
[17] | 553 | case 3: |
---|
| 554 | buffer4[3]= 0; |
---|
[23] | 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)++; |
---|
[17] | 558 | |
---|
| 559 | |
---|
[27] | 560 | if (pftmp->fieldType==70){ |
---|
| 561 | isMplsFlow = 1; |
---|
| 562 | } |
---|
[20] | 563 | #ifdef CRIHAN |
---|
[18] | 564 | if (pftmp->fieldType==70){ |
---|
| 565 | mplsFirstCache.mplsLabel1 = (*((unsigned long*)&buffer4))>>4; |
---|
| 566 | } |
---|
[22] | 567 | #endif |
---|
[17] | 568 | break; |
---|
[2] | 569 | case 4: |
---|
[23] | 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)++; |
---|
[22] | 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 |
---|
[20] | 586 | #ifdef CRIHAN |
---|
[18] | 587 | if (pftmp->fieldType==8){ |
---|
| 588 | ipFirstCache.v4AdS = *((unsigned long*)&buffer4); |
---|
[19] | 589 | mplsFirstCache.v4AdS = *((unsigned long*)&buffer4); |
---|
[17] | 590 | } |
---|
[18] | 591 | if (pftmp->fieldType==12){ |
---|
| 592 | ipFirstCache.v4AdD = *((unsigned long*)&buffer4); |
---|
[19] | 593 | mplsFirstCache.v4AdD = *((unsigned long*)&buffer4); |
---|
[18] | 594 | } |
---|
| 595 | if (pftmp->fieldType==1){ |
---|
| 596 | ipFirstCache.bytes = *((unsigned long*)&buffer4); |
---|
| 597 | } |
---|
| 598 | if (pftmp->fieldType==2){ |
---|
| 599 | ipFirstCache.pkts = *((unsigned long*)&buffer4); |
---|
| 600 | } |
---|
| 601 | if (pftmp->fieldType==22){ |
---|
| 602 | firstTime = *((unsigned long*)&buffer4); |
---|
| 603 | } |
---|
| 604 | if (pftmp->fieldType==21){ |
---|
| 605 | lastTime = *((unsigned long*)&buffer4); |
---|
| 606 | } |
---|
[22] | 607 | #endif |
---|
[2] | 608 | break; |
---|
| 609 | case 16: |
---|
| 610 | for (i=0; i<4; i++) { |
---|
[23] | 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)++; |
---|
[2] | 615 | } |
---|
[22] | 616 | |
---|
[16] | 617 | |
---|
[2] | 618 | break; |
---|
| 619 | default: |
---|
| 620 | syslog(LOG_INFO,"UNKNOWN FIELDS LENGTH: %d ", field_size); |
---|
| 621 | for (i=0; i<field_size; i++){ |
---|
[23] | 622 | (*myPtrs->offsetV9Ptr)++; |
---|
[2] | 623 | } |
---|
| 624 | } |
---|
| 625 | } |
---|
| 626 | if (cpt==tmp->fieldCount) { |
---|
| 627 | |
---|
| 628 | |
---|
| 629 | |
---|
[20] | 630 | #ifdef CRIHAN |
---|
[18] | 631 | if ( mplsFirstCache.mplsLabel1 == 0 ) { |
---|
[23] | 632 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->ipProt = ipFirstCache.ipProt; |
---|
[18] | 633 | ipFirstCache.ipProt = 0; |
---|
[23] | 634 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->bytes = ipFirstCache.bytes; |
---|
[18] | 635 | ipFirstCache.bytes = 0; |
---|
[23] | 636 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->pkts = ipFirstCache.pkts; |
---|
[18] | 637 | ipFirstCache.pkts = 0; |
---|
[23] | 638 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->inSnmp = ipFirstCache.inSnmp; |
---|
[18] | 639 | ipFirstCache.inSnmp = 0; |
---|
[23] | 640 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->outSnmp = ipFirstCache.outSnmp; |
---|
[18] | 641 | ipFirstCache.outSnmp = 0; |
---|
[23] | 642 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdS = ipFirstCache.v4AdS; |
---|
[18] | 643 | ipFirstCache.outSnmp = 0; |
---|
[23] | 644 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->v4AdD = ipFirstCache.v4AdD; |
---|
[18] | 645 | ipFirstCache.v4AdD = 0; |
---|
[23] | 646 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->tProt = ipFirstCache.tProt; |
---|
[18] | 647 | ipFirstCache.tProt = 0; |
---|
[23] | 648 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->sPort = ipFirstCache.sPort; |
---|
[18] | 649 | ipFirstCache.sPort = 0; |
---|
[23] | 650 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->dPort = ipFirstCache.dPort; |
---|
[18] | 651 | ipFirstCache.dPort = 0; |
---|
[23] | 652 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskD = ipFirstCache.maskD; |
---|
[18] | 653 | ipFirstCache.maskD = 0; |
---|
[23] | 654 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->maskS = ipFirstCache.maskS; |
---|
[18] | 655 | ipFirstCache.maskS = 0; |
---|
[23] | 656 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->routerAd = ipFirstCache.routerAd; |
---|
| 657 | (myPtrs->tabIPPtr+(*myPtrs->ipNbPtr))->liveTime = lastTime - firstTime; |
---|
[18] | 658 | firstTime = 0; lastTime = 0; |
---|
[23] | 659 | (*myPtrs->ipNbPtr)++; |
---|
[18] | 660 | } else { |
---|
[23] | 661 | (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->ipProt = mplsFirstCache.ipProt; |
---|
[18] | 662 | mplsFirstCache.ipProt = 0; |
---|
[23] | 663 | (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdS = mplsFirstCache.v4AdS; |
---|
[18] | 664 | mplsFirstCache.v4AdS = 0; |
---|
[23] | 665 | (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->v4AdD = mplsFirstCache.v4AdD; |
---|
[18] | 666 | mplsFirstCache.v4AdD = 0; |
---|
[23] | 667 | (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->routerAd = mplsFirstCache.routerAd; |
---|
| 668 | (myPtrs->tabMPLSPtr+(*myPtrs->mplsNbPtr))->mplsLabel1 = mplsFirstCache.mplsLabel1; |
---|
[18] | 669 | mplsFirstCache.mplsLabel1 = 0; |
---|
[23] | 670 | (*myPtrs->mplsNbPtr)++; |
---|
[18] | 671 | } |
---|
[22] | 672 | #endif |
---|
| 673 | |
---|
[23] | 674 | |
---|
| 675 | |
---|
[22] | 676 | #ifdef IPV4AGG |
---|
[27] | 677 | if ( (bool == 1) && (isMplsFlow == 0) ){ |
---|
[22] | 678 | prefixKey.beginning = agCache.v4AdS>>(32-agCache.maskS)<<(32-agCache.maskS); |
---|
| 679 | res = bsearch(&prefixKey, V4PTab, nbPV4, |
---|
[27] | 680 | sizeof(struct PrefixV4), prefGlobalCmp); |
---|
| 681 | if (res!=NULL){ |
---|
| 682 | if ( myPtrs->routersID[res->routerNb] == agCache.routerAd ) { |
---|
| 683 | |
---|
| 684 | res->bytesNbOUT += agCache.bytes; |
---|
| 685 | res->pktsNbOUT += agCache.pkts; |
---|
| 686 | (res->flowNbOUT)++; |
---|
| 687 | } else { |
---|
| 688 | |
---|
[22] | 689 | } |
---|
[23] | 690 | } else { |
---|
| 691 | prefixKey.beginning = agCache.v4AdD>>(32-agCache.maskD)<<(32-agCache.maskD); |
---|
| 692 | res = bsearch(&prefixKey, V4PTab, nbPV4, |
---|
[27] | 693 | sizeof(struct PrefixV4), prefGlobalCmp); |
---|
| 694 | if (res!=NULL){ |
---|
| 695 | if ( myPtrs->routersID[res->routerNb] == agCache.routerAd ) { |
---|
| 696 | |
---|
| 697 | res->bytesNbIN += agCache.bytes; |
---|
| 698 | res->pktsNbIN += agCache.pkts; |
---|
| 699 | (res->flowNbIN)++; |
---|
| 700 | } else { |
---|
| 701 | |
---|
| 702 | |
---|
| 703 | |
---|
| 704 | |
---|
| 705 | |
---|
| 706 | |
---|
| 707 | |
---|
| 708 | |
---|
| 709 | |
---|
| 710 | |
---|
| 711 | |
---|
| 712 | |
---|
| 713 | |
---|
| 714 | |
---|
| 715 | |
---|
| 716 | |
---|
| 717 | |
---|
| 718 | |
---|
[23] | 719 | } |
---|
| 720 | } else { |
---|
| 721 | |
---|
| 722 | |
---|
| 723 | |
---|
| 724 | |
---|
| 725 | |
---|
| 726 | |
---|
[32] | 727 | #ifdef PRINTUNKNOWNSUBNET |
---|
| 728 | fprintf(stderr, "%lu.%lu.%lu.%lu/%hu -> %lu.%lu.%lu.%lu/%hu (R:%lu.%lu.%lu.%lu) \n", |
---|
| 729 | (agCache.v4AdS>>24), |
---|
| 730 | (agCache.v4AdS<<8>>24), |
---|
| 731 | (agCache.v4AdS<<16>>24), |
---|
| 732 | (agCache.v4AdS<<24>>24), |
---|
| 733 | (agCache.maskS), |
---|
| 734 | (agCache.v4AdD>>24), |
---|
| 735 | (agCache.v4AdD<<8>>24), |
---|
| 736 | (agCache.v4AdD<<16>>24), |
---|
| 737 | (agCache.v4AdD<<24>>24), |
---|
| 738 | (agCache.maskD), |
---|
| 739 | (myPtrs->pcktPtr->ipH->srcAdd>>24), |
---|
| 740 | (myPtrs->pcktPtr->ipH->srcAdd<<8>>24), |
---|
| 741 | (myPtrs->pcktPtr->ipH->srcAdd<<16>>24), |
---|
| 742 | (myPtrs->pcktPtr->ipH->srcAdd<<24>>24) |
---|
| 743 | ); |
---|
| 744 | #endif |
---|
[23] | 745 | } |
---|
| 746 | } |
---|
[22] | 747 | } |
---|
| 748 | bool = 0; |
---|
[27] | 749 | isMplsFlow = 0; |
---|
[22] | 750 | #endif |
---|
[2] | 751 | |
---|
| 752 | |
---|
| 753 | |
---|
[27] | 754 | |
---|
| 755 | |
---|
| 756 | |
---|
| 757 | |
---|
| 758 | |
---|
[2] | 759 | |
---|
[23] | 760 | tmpRuleList = myPtrs->rulesListPtr; |
---|
[2] | 761 | while (tmpRuleList){ |
---|
[30] | 762 | |
---|
[27] | 763 | RuleDefPtr tmpRuleDefList = tmpRuleList->def; |
---|
[2] | 764 | unsigned short check = 1; |
---|
[30] | 765 | |
---|
[2] | 766 | secondOffset = secondOldOffset; |
---|
| 767 | while (tmpRuleDefList){ |
---|
| 768 | check = check && tmpRuleDefList->check; |
---|
| 769 | tmpRuleDefList->check = 0; |
---|
| 770 | tmpRuleDefList = tmpRuleDefList->next; |
---|
| 771 | } |
---|
| 772 | if ( (tmpRuleList->def != NULL) && (check == 1)) { |
---|
| 773 | |
---|
| 774 | secondPftmp = tmp->lastField; |
---|
| 775 | msgTextIndex = mempcpy(mempcpy(mempcpy(myMsg.text, |
---|
| 776 | &tplMsgType, |
---|
| 777 | sizeof(unsigned short) |
---|
| 778 | ), |
---|
| 779 | &tmpRuleList->id, |
---|
| 780 | sizeof(tmpRuleList->id) |
---|
| 781 | ), |
---|
[23] | 782 | &myPtrs->currentRouterPtr->IpAddress, |
---|
[2] | 783 | sizeof(unsigned long) |
---|
| 784 | ); |
---|
| 785 | msgTextIndex = mempcpy(mempcpy(mempcpy(msgTextIndex, |
---|
| 786 | &tmp->sourceId, |
---|
| 787 | sizeof(unsigned long) |
---|
| 788 | ), |
---|
| 789 | &tmp->templateFlowSetId, |
---|
| 790 | sizeof(tmp->templateFlowSetId) |
---|
| 791 | ), |
---|
[23] | 792 | myPtrs->ptr_buffer+secondOffset, |
---|
[2] | 793 | flow_size |
---|
| 794 | ); |
---|
| 795 | myMsg.type = 1; |
---|
[27] | 796 | |
---|
[2] | 797 | msgSend( myQueue, myMsg); |
---|
[27] | 798 | |
---|
| 799 | |
---|
| 800 | |
---|
| 801 | |
---|
| 802 | |
---|
| 803 | |
---|
| 804 | |
---|
| 805 | |
---|
| 806 | |
---|
| 807 | |
---|
| 808 | |
---|
[2] | 809 | noEnd = 1; |
---|
| 810 | secondCpt=0; |
---|
| 811 | } |
---|
| 812 | tmpRuleList = tmpRuleList->next; |
---|
| 813 | secondPftmp = tmp->lastField; |
---|
| 814 | } |
---|
| 815 | |
---|
| 816 | |
---|
| 817 | |
---|
[23] | 818 | secondOffset = *myPtrs->offsetV9Ptr; |
---|
[2] | 819 | secondOldOffset = secondOffset; |
---|
| 820 | pftmp = tmp->lastField; |
---|
| 821 | cpt=0; |
---|
[23] | 822 | (*myPtrs->currentFlowsetNumberPtr)++; |
---|
| 823 | if (((*myPtrs->offsetV9Ptr)-48-shift+flow_size) > data_length){ |
---|
[2] | 824 | overflow = 1; |
---|
| 825 | } |
---|
| 826 | } else { |
---|
| 827 | |
---|
| 828 | pftmp = pftmp->prev; |
---|
| 829 | } |
---|
[29] | 830 | } |
---|
[32] | 831 | |
---|
[30] | 832 | while ( ((*myPtrs->offsetV9Ptr)-48-shift) < data_length ) { |
---|
| 833 | (*myPtrs->offsetV9Ptr)++; |
---|
| 834 | paddingCounter++; |
---|
| 835 | if ( paddingCounter > 8 ) { |
---|
[29] | 836 | #ifdef DEBUG |
---|
[30] | 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)--; |
---|
| 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 |
---|
[29] | 853 | fprintf(stderr,"}"); |
---|
| 854 | #endif |
---|
[30] | 855 | |
---|
| 856 | return (data_length+shift); |
---|
| 857 | |
---|
| 858 | |
---|
[2] | 859 | }else{ |
---|
[30] | 860 | |
---|
| 861 | |
---|
| 862 | |
---|
| 863 | |
---|
| 864 | |
---|
| 865 | |
---|
| 866 | |
---|
[29] | 867 | if ((tmpOpt=existTplOptId(myPtrs->currentRouterPtr, myPtrs->currentHeaderV9Ptr->sourceId, |
---|
| 868 | (*myPtrs->currentFlowsetIdPtr)))!=NULL) { |
---|
[30] | 869 | #ifdef DEBUG |
---|
| 870 | fprintf(stderr,"<d id: %hu, lg %hu", (*myPtrs->currentFlowsetIdPtr), data_length); |
---|
| 871 | #endif |
---|
[29] | 872 | for ( i=0; i<(tmpOpt->optionScopeLg/4); i++){ |
---|
| 873 | |
---|
[30] | 874 | if ((pftmp=tmpOpt->lastField)!=NULL) { |
---|
[29] | 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) ) { |
---|
[30] | 896 | #ifdef DEBUGAGG |
---|
| 897 | fprintf(stderr,"SV (p) %lu != %lu (r)\n", *((unsigned long*)&buffer4), |
---|
| 898 | myPtrs->currentRouterPtr->sampled); |
---|
| 899 | #endif |
---|
[29] | 900 | myPtrs->currentRouterPtr->sampled = *((unsigned long*)&buffer4); |
---|
| 901 | for (i=0; i<nbPV4; i++) { |
---|
| 902 | |
---|
| 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)++; |
---|
[30] | 916 | #ifdef DEBUG |
---|
| 917 | fprintf(stderr," p "); |
---|
| 918 | #endif |
---|
[29] | 919 | } |
---|
| 920 | } else { |
---|
| 921 | fprintf(stderr,"PB "); |
---|
| 922 | } |
---|
| 923 | #ifdef DEBUG |
---|
| 924 | fprintf(stderr,">"); |
---|
| 925 | #endif |
---|
[30] | 926 | return (data_length+shift); |
---|
[29] | 927 | } else { |
---|
| 928 | |
---|
| 929 | |
---|
| 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 |
---|
[30] | 943 | return (data_length+shift); |
---|
[29] | 944 | } |
---|
[2] | 945 | } |
---|
| 946 | } |
---|