root/branches/renetcolSMP/src/renetcolSMP2.c @ 166

Revision 166, 33.7 KB (checked in by andreu, 8 years ago)

RECORDFLOW option

Line 
1/*
2 * File: renetcolSMP2.c
3 *
4 * Authors: ANDREU Francois-Xavier
5 *
6 * Copyright (C) 2005-2011 GIP RENATER
7 * Copyright (C) 2012 ANDREU Francois-Xavier
8 */
9
10/*  This file is part of renetcol.
11 *
12 *  renetcol is free software; you can redistribute it and/or modify
13 *  it under the terms of the GNU General Public License as published by
14 *  the Free Software Foundation; either version 2 of the License, or
15 *  (at your option) any later version.
16 *
17 *  renetcol is distributed in the hope that it will be useful,
18 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 *  GNU General Public License for more details.
21 *
22 *  You should have received a copy of the GNU General Public License
23 *  along with renetcol; if not, write to the Free Software
24 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 */
26
27#include "renetcolSMP2.h"
28
29struct MyPtrs myPtrs; /* defined in routers_mgmt.h */
30
31struct SHMForAgg *shmForAgg;
32
33unsigned short currentIPOutputFile = 0;    /* index on the current IP file */
34unsigned short currentMPLSOutputFile = 0;  /* index on the current MPLS file */
35char outputName[256];
36char cof_str[20];                          /* current ouput file name */
37FILE *fIP;                                 /* pointer on the IP output file */
38FILE *fMPLS;                              /* pointer on the MPLS output file */
39
40#if defined(RECORDFLOW)
41FILE *fRECORDF1;
42FILE *fRECORDF2;
43char    *bufRF1 = NULL;
44char    *bufRF2 = NULL;
45char *nameRF[128];
46char *pathRF[256];
47#endif
48
49struct sigaction myAction; /* handler for renetcolSender communication */
50sigjmp_buf contextSigalrm; /* '' */
51volatile sig_atomic_t sigusr1Up = 0;
52/* struct sigaction myAction;  for timer not used in this version */
53
54unsigned short currentIntervalle = 0;        /* based on 5 min intervalles */
55
56unsigned short offsetV9 = 0;                 /* index in a neflow v9 packet */
57
58unsigned char buffer1;
59unsigned char buffer2[2];
60unsigned char buffer4[4];
61unsigned char buffer6[6];
62
63short currentFlowsetNumber;
64short currentFlowsetId;
65TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */
66TplOptionPtr curTplOptionPtr;
67RouterPtr routersListPtr;
68NDEEnginePtr enginePtrTmp;
69
70unsigned long sortedRouterList[SMP2_ROUTER_INDEX_MAX];
71unsigned long indexedRouterList[SMP2_ROUTER_INDEX_MAX];
72int routerNb = 0;                                  /* routers number */
73
74key_t myKey = 0;
75int myQueue = 0;
76
77/* Next structure used as cache in rules reading */
78RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD];
79
80int reInitConf = 0;
81
82static struct tm *tmPtr;
83
84extern int errno;
85static int inputSock;
86static int sockNamelg;
87static int inputSock2;
88static int sockNameFromlg;
89static int rcv;
90static int sockBufSize = SOCKET_BUFFER_SIZE;
91/* static unsigned short flowNumber; */
92static unsigned short receptPort = SMP2_RECEPTION_PORT;
93/* static unsigned char *ptr_buffer; */
94static char *receptAddress = SMP2_RECEPTION_ADDRESS;
95static struct sockaddr_in name;
96static struct sockaddr_in name2;
97static struct sockaddr_in fromName;
98char *log = "renetcol";
99#ifdef READFROMFILE
100  char *myPcapFileName, errBuffer[PCAP_ERRBUF_SIZE];
101  pcap_t *myPcapHandle;
102#endif
103
104/*
105 * Main
106 * ----
107 */
108int
109main (int argc, char *argv[])
110{
111  RulesPtr tmp = NULL;
112  int shmid;
113  key_t key;
114  int i,j;
115  int k;
116  unsigned short routerIndex = 0;
117
118#if defined(READFROMFILE)
119  if ( argc != 2) {
120    fprintf (stderr,
121             "%s: Usage: %s <pcap file>\n exp: %s /tmp/my_pcap_file.pcap\n",
122             argv[0], argv[0], argv[0]);
123    exit(1);
124  }
125  myPcapFileName = argv[1];
126  if ((myPcapHandle = pcap_open_offline(myPcapFileName, errBuffer)) == NULL) {
127    fprintf(stderr, "Couldn't open PCAP file %s: %s\n", myPcapFileName, errBuffer);
128    exit(1);
129  }
130#endif
131
132#if defined(RECORDFLOW)
133  strncpy(pathRF, RECORD_FILE_PATH,sizeof(RECORD_FILE_PATH));
134  strncpy(nameRF, SMP2_RECORD_FILE_1,sizeof(SMP2_RECORD_FILE_1));
135  errno = 0;
136  prepend_timestamp ( nameRF, sizeof nameRF );
137  if ( errno != ERANGE )
138    printf ( "Timestamped: %s\n", nameRF );
139  else {
140      /* Handle the error */
141  }
142  strncat(pathRF,nameRF, sizeof(nameRF));
143  if ((fRECORDF1 = fopen(pathRF, "w")) == NULL) {
144    syslog(LOG_ERR,"Error in %s opening : %s", pathRF, strerror(errno));
145  } else {
146    fprintf(stderr,"fRECORDF1 %d",fRECORDF1);
147    bufRF1 = (char *)malloc (262144);
148    setvbuf (fRECORDF1, bufRF1, _IOFBF, 262144);
149  }
150#endif
151
152#if defined(IPV4AGGIDR)
153  fprintf(stderr, "renetcolSMP2 compilation and execution with IPv4 Prefixes Aggregation feature enable based on routers ID in %s file.\n", SMP2_ROUTERS_LIST);
154#endif
155
156#if defined(IPV4AGGIDSNMP)
157  fprintf(stderr, "renetcolSMP2 compilation and execution with IPv4 Prefixes Aggregation feature enable based on SNMP ID in %s file.\n", SMP2_INTERFACES_TYPE_LIST);
158#endif
159#if defined(IPV6AGGIDSNMP)
160  fprintf(stderr, "renetcolSMP2 compilation and execution with IPv6 Prefixes Aggregation feature enable based on SNMP ID in %s file.\n", SMP2_INTERFACES_TYPE_LIST);
161#endif
162#if defined(IPV6LINKAGG)
163  fprintf(stderr, "renetcolSMP2 compilation and execution with IPv6 Links Aggregation.\n");
164#endif
165
166  /*   openlog(argv[0], LOG_PID, LOG_USER);*/
167  openlog(log, NULL, LOG_LOCAL7);
168
169  initCache();
170  /* GET the list of routers who are available to send NDE to the collector */
171  if ( (routerNb = getRegisteredRouters(SMP2_ROUTERS_LIST,
172                                        &sortedRouterList[0],
173                                        &indexedRouterList[0])) == -1) {
174    fprintf(stderr,
175            "ERROR in getRegisteredRouters from file %s\n",
176            SMP2_ROUTERS_LIST);
177    exit(-1);
178  }
179  /* Create the list of routers */
180  for (routerIndex=0; routerIndex<routerNb; routerIndex++){
181    routersListPtr = addRouter(routersListPtr, sortedRouterList[routerIndex],routerIndex);
182  }
183
184  /* Shared memory */
185  key = 8766;
186  if ((shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666)) < 0) {
187    perror("shmget");
188    exit(1);
189  }
190  if ((shmForAgg = (struct SHMForAgg *)shmat(shmid, (void *)0, 0)) == (void *) -1) {
191    perror("shmat");
192    exit(1);
193  }
194
195  if ( (shmForAgg->v4PrefixNb =
196        getPrefixV4(SUBNETS_LIST,
197                    &(shmForAgg->prefixV4Tab[0][0]),
198                    &(shmForAgg->prefixV4SubnetTab[0][0]),
199                    &(shmForAgg->v4SubnetNb)
200                    )) < 1){
201    fprintf(stderr, "renetcolSMP2: Error in %s\n", SUBNETS_LIST);
202  } else {
203    fprintf(stderr, "We have found %hu supernets from %s\n",
204            shmForAgg->v4PrefixNb,
205            SUBNETS_LIST);
206    fprintf(stderr, "and %hu subnets\n",
207            shmForAgg->v4SubnetNb);
208  }
209  if ( (shmForAgg->v4PrefixNb =
210        getPrefixV4(SUBNETS_LIST,
211                    &(shmForAgg->prefixV4Tab[1][0]),
212                    &(shmForAgg->prefixV4SubnetTab[1][0]),
213                    &(shmForAgg->v4SubnetNb)
214                    )) < 1){
215    fprintf(stderr, "renetcolSMP2: Error in %s\n", SUBNETS_LIST);
216    exit(1);
217  }
218#if defined(IPV6AGGIDSNMP)
219  if ( (shmForAgg->v6PrefixNb =
220        getPrefixV6(SUBNETS_V6_LIST,
221                    &(shmForAgg->prefixV6Tab[0][0])
222                    )) < 1){
223    fprintf(stderr, "renetcolSMP2: Error in %s\n", SUBNETS_V6_LIST);
224  } else {
225    fprintf(stderr, "We have found %hu IPv6 prefixes from %s\n",
226            shmForAgg->v6PrefixNb,
227            SUBNETS_V6_LIST);
228  }
229  if ( (shmForAgg->v6PrefixNb =
230        getPrefixV6(SUBNETS_V6_LIST,
231                    &(shmForAgg->prefixV6Tab[1][0])
232                    )) < 1){
233    fprintf(stderr, "renetcolSMP2: Error in %s\n", SUBNETS_V6_LIST);
234    exit(1);
235  }
236#endif
237
238/*   for (i=0; i<shmForAgg->v4PrefixNb; i++){ */
239/*    fprintf(stderr, "SUPERNET : %lu, %hu\n",shmForAgg->prefixV4Tab[0][i].beginning, shmForAgg->prefixV4Tab[0][i].hasSubnet); */
240/*   } */
241/*   for (i=0; i<shmForAgg->v4SubnetNb; i++){ */
242/*    fprintf(stderr, "SUBNET : %lu, %hu\n",shmForAgg->prefixV4SubnetTab[0][i].beginning, shmForAgg->prefixV4SubnetTab[0][i].hasSubnet); */
243/*   } */
244
245  shmForAgg->currentTable = 0;
246  shmForAgg->secondTable = 1;
247  shmForAgg->readed = 0;
248  /* get the rules */
249  myPtrs.rulesListPtr = NULL;
250  myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, RULES_FILE);
251  tmp = myPtrs.rulesListPtr;
252 if (tmp!=NULL){
253   for ( ; tmp->next; tmp=tmp->next) {
254     if (tmp->type != 2) {
255       myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr);
256     }
257   }
258 }
259  tmp = NULL;
260#ifdef DEBUG
261  printRule(myPtrs.rulesListPtr);
262#endif
263
264#ifdef ASACC
265  /* get the AS list */
266  if ( (shmForAgg->ASNb = getAS(AS_LIST, &(shmForAgg->ASTab[0][0]))) < 1){
267    fprintf(stderr, "renetcolSMP2: Error in %s\n", AS_LIST);
268    exit(1);
269  } else {
270    fprintf(stderr, "%hu AS are readed from %s\n",
271            shmForAgg->ASNb,
272            AS_LIST);
273  }
274  if ( (shmForAgg->ASNb = getAS(AS_LIST, &(shmForAgg->ASTab[1][0]))) < 1){
275    fprintf(stderr, "renetcolSMP2: Error in %s\n", AS_LIST);
276    exit(1);
277  }
278#endif
279
280  /* the fork */
281  fprintf(stderr, "renetcolSMP2: I become a deamon, next messages via syslogd. Bye.\n");
282  if (fork () != 0)
283    exit (0);
284  if (setsid() == -1){
285    exit(4);
286  }
287  /* handler, SIGUSR1 from renetcolSender */
288  myAction.sa_handler = sigusr1Mgmt;
289  myAction.sa_flags = SA_RESTART;
290  sigemptyset (&(myAction.sa_mask));
291  sigaddset (&(myAction.sa_mask), SIGALRM);
292  sigaction (SIGUSR1, &myAction, NULL);
293
294  /* Cache for fast rules access */
295  setCache(myPtrs.rulesListPtr);
296  myPtrs.rulesAddressPtr = (RuleDefPtr *)rulesAddress;
297  /* IPC messages queue init */
298  myKey = createKey(argv[0]);
299  myQueue = createQueue(myKey);
300  sendMyPid(myQueue);
301  /* get SNMP index information */
302#ifdef IPV4AGGIDSNMP
303  k = getSNMPIndexList(SMP2_INTERFACES_TYPE_LIST, routersListPtr);
304#endif
305  /* INIT THE CURRENTS VARIABLES*/
306  myPtrs.currentRouterPtr = routersListPtr;
307  myPtrs.currentHeaderV9Ptr = (NetFlowV9HeaderPtr)
308    malloc(sizeof(struct NetFlowV9Header));
309  myPtrs.offsetV9Ptr = &offsetV9;
310  myPtrs.currentFlowsetIdPtr = &currentFlowsetId;
311  myPtrs.pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram));
312  myPtrs.currentFlowsetNumberPtr = &currentFlowsetNumber;
313  myPtrs.currentMIB = shmForAgg->myMIB[shmForAgg->currentTable];
314  myPtrs.secondMIB = shmForAgg->myMIB[shmForAgg->secondTable];
315  if (initMIB(myPtrs.currentMIB)!=1) {
316    fprintf(stderr, "ERROR in MIB initialisation\n");
317    exit(1);}
318  if (initMIB(myPtrs.secondMIB)!=1) {
319    fprintf(stderr, "ERROR in second MIB initialisation\n");
320    exit(1);}
321#ifdef IPV4AGGIDR
322  myPtrs.routersID = &indexedRouterList;
323#endif
324  myPtrs.currentV4Tab = shmForAgg->prefixV4Tab[shmForAgg->currentTable];
325  myPtrs.secondV4Tab = shmForAgg->prefixV4Tab[shmForAgg->secondTable];
326#ifdef IPV6AGGIDSNMP
327  myPtrs.currentV6Tab = shmForAgg->prefixV6Tab[shmForAgg->currentTable];
328  myPtrs.secondV6Tab = shmForAgg->prefixV6Tab[shmForAgg->secondTable];
329#endif
330#ifdef IPV6LINKAGG
331  myPtrs.currentV6IndexTab = shmForAgg->indexV6Tab[shmForAgg->currentTable];
332  myPtrs.secondV6IndexTab = shmForAgg->indexV6Tab[shmForAgg->secondTable];
333#endif
334#ifdef ASACC
335  myPtrs.asNb = shmForAgg->ASNb;
336  myPtrs.currentASTab = shmForAgg->ASTab[shmForAgg->currentTable];
337  myPtrs.secondASTab = shmForAgg->ASTab[shmForAgg->secondTable];
338#endif
339#ifdef MATRIX
340  myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]);
341#endif
342
343  /* INIT MATRIX TABLES */
344#ifdef MATRIX
345  for (i=0; i<SMP2_ROUTER_INDEX_MAX; i++){
346    for (j=0; j<SMP2_ROUTER_INDEX_MAX; j++) {
347      shmForAgg->matrixPOP[0][i][j].bytesNb = 0;
348      shmForAgg->matrixPOP[0][i][j].pktsNb = 0;
349      shmForAgg->matrixPOP[0][i][j].flowNb = 0;
350      shmForAgg->matrixPOP[1][i][j].bytesNb = 0;
351      shmForAgg->matrixPOP[1][i][j].pktsNb = 0;
352      shmForAgg->matrixPOP[1][i][j].flowNb = 0;
353    }
354  }
355#endif
356  /* INIT IPV6 index TABLES */
357#ifdef IPV6LINKAGG
358  for (i=0; i<SMP2_ROUTER_INDEX_MAX; i++){
359    for (j=0; j<MAX_INDEX_BY_ROUTER; j++) {
360      shmForAgg->indexV6Tab[0][i][j].routerIPAddress = 0;
361      shmForAgg->indexV6Tab[0][i][j].indexSNMP = 0;
362      shmForAgg->indexV6Tab[0][i][j].hasStats = 0;
363      shmForAgg->indexV6Tab[0][i][j].sampling = 0;
364      shmForAgg->indexV6Tab[0][i][j].bytesNbIN = 0;
365      shmForAgg->indexV6Tab[0][i][j].pktsNbIN = 0;
366      shmForAgg->indexV6Tab[0][i][j].flowNbIN = 0;
367      shmForAgg->indexV6Tab[0][i][j].bytesNbOUT = 0;
368      shmForAgg->indexV6Tab[0][i][j].pktsNbOUT = 0;
369      shmForAgg->indexV6Tab[0][i][j].flowNbOUT = 0;
370      shmForAgg->indexV6Tab[1][i][j].routerIPAddress = 0;
371      shmForAgg->indexV6Tab[1][i][j].indexSNMP = 0;
372      shmForAgg->indexV6Tab[1][i][j].hasStats = 0;
373      shmForAgg->indexV6Tab[1][i][j].sampling = 0;
374      shmForAgg->indexV6Tab[1][i][j].bytesNbIN = 0;
375      shmForAgg->indexV6Tab[1][i][j].pktsNbIN = 0;
376      shmForAgg->indexV6Tab[1][i][j].flowNbIN = 0;
377      shmForAgg->indexV6Tab[1][i][j].bytesNbOUT = 0;
378      shmForAgg->indexV6Tab[1][i][j].pktsNbOUT = 0;
379      shmForAgg->indexV6Tab[1][i][j].flowNbOUT = 0;
380    }
381  }
382#endif
383
384  /* Checkup */
385  if (myPtrs.pcktPtr==NULL) {
386    fprintf(stderr, "ERROR in struct Datagram allocation\n");
387    exit(1);
388  } else {
389    myPtrs.pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader));
390    myPtrs.pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader));
391  }
392  if (! (myPtrs.ptr_buffer = malloc(sockBufSize)))
393    {
394      printf("ERROR during socket buffer allocation\n");
395      exit(2);
396    }
397
398  /* INIT INPUT STREAM*/
399  initStream();
400
401  socketLoop(); /* all work on datagram is made here */
402
403  closelog();
404
405  fprintf(stderr, "END\n");
406
407  return (0);
408}
409
410char *prepend_timestamp ( char s[], size_t capacity )
411{
412    const char fmt[] = "%y-%m-%d_%H-%M";
413    size_t n = sizeof ( fmt );
414    size_t len = strlen ( s );
415    if ( len + n < capacity ) {
416        time_t init = time ( NULL );
417        memmove ( s + n, s, len + 1 );
418        strftime ( s, n, fmt, localtime ( &init ) );
419        s[n - 1] = '_';
420    }
421    else
422        errno = ERANGE;
423
424    return s;
425}
426
427
428/*
429 * send his PID to another program via IPC message queue
430 *
431 * @param queueID the IPC queue ident
432 *
433 */
434void
435sendMyPid(int queueID)
436{
437  msgType myMsg;
438  char *msgTextIndex;
439  unsigned short tplMsgType = 14;
440  pid_t myPID;
441
442  myPID = getpid();
443  msgTextIndex = mempcpy(mempcpy(myMsg.text,
444                                 &tplMsgType,
445                                 sizeof (unsigned short)
446                                 ),
447                         &myPID,
448                         sizeof(pid_t)
449                         );
450  myMsg.type = 1;
451  msgSend(queueID, myMsg);
452}
453
454/*
455 * Send the "read rules list" message to another program
456 *
457 * @param queueID the IPC queue ident
458 *
459 */
460void sendReadRulesSignal(int queueID)
461{
462  msgType myMsg;
463  char *msgTextIndex;
464  unsigned short tplMsgType = 13;
465
466  msgTextIndex = mempcpy(myMsg.text,
467                         &tplMsgType,
468                         sizeof (unsigned short)
469                         );
470  myMsg.type = 1;
471  msgSend(queueID, myMsg);
472}
473
474/*
475 *
476 */
477void
478sigusr1Mgmt(int num)
479{
480  sigusr1Up = 1;
481}
482
483/*
484 * init the rule structure
485 */
486void
487initRule()
488{
489  RulesPtr tmp = NULL;
490  initCache();
491  tmp = myPtrs.rulesListPtr;
492  for ( ; tmp; tmp=tmp->next) {
493    myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr);
494  }
495  myPtrs.rulesListPtr = NULL;
496  myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, RULES_FILE);
497  tmp = myPtrs.rulesListPtr;
498  for ( ; tmp; tmp=tmp->next) {
499    if (tmp->type != 2) {
500      myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr);
501    }
502  }
503  tmp = NULL;
504  initCache();
505  setCache(myPtrs.rulesListPtr);
506  sendReadRulesSignal(myQueue);
507#ifdef DEBUG
508  printRule(myPtrs.rulesListPtr);
509#endif
510}
511
512/*
513 * init cache table
514 */
515void
516initCache()
517{
518  int i,j;
519  for (i=0; i<FIELD_TYPE_NUMBER+1; i++){
520    for (j=0; j<MAX_RULES_PER_FIELD; j++){
521      rulesAddress[i][j] = NULL;
522    }
523  }
524}
525
526/*
527 * setCache()
528 */
529void
530setCache(RulesPtr rPtr)
531{
532  int i=0;
533  RulesPtr tmp = rPtr;
534  RuleDefPtr def = NULL;
535
536#ifdef DEBUG
537  fprintf(stderr,"Cache for Rules: \n");
538#endif
539  while (tmp) {
540    def = tmp->def;
541    while (def) {
542      i = 0;
543      while (rulesAddress[def->fieldType][i] != NULL){
544        i++;
545      }
546      rulesAddress[def->fieldType][i] = def;
547#ifdef DEBUG
548      fprintf(stderr,"%d: %d \n", def->fieldType, i);
549#endif
550      def = def->next;
551    }
552#ifdef DEBUG
553    fprintf(stderr,"\n");
554#endif
555    tmp = tmp->next;
556  }
557#ifdef DEBUG
558  fprintf(stderr,"Cache for Rules: OK");
559#endif
560}
561
562/*
563 * initStream()
564 *
565 * Stream can be a file (pcap format) or a socket
566 */
567void
568initStream()
569{
570  static unsigned short n0, n1, n2, n3;
571
572#ifdef READFROMFILE
573  initFile();
574#else
575  initSocket();
576  if (sscanf(receptAddress,"%hu.%hu.%hu.%hu",&n0,&n1,&n2,&n3)==0) {
577    perror("sscanf");
578  }
579  buffer4[0] = (unsigned char)n3;
580  buffer4[1] = (unsigned char)n2;
581  buffer4[2] = (unsigned char)n1;
582  buffer4[3] = (unsigned char)n0;
583#endif
584}
585
586/*
587 * socketLoop()
588 */
589int
590socketLoop()
591{
592  short shift;
593  short version = 0;
594  int regRouter = 0;
595  time_t now = time((time_t *)NULL);
596  int loopNb = 0;
597  int gardeFou = 0;
598  time_t lastIPOutput, lastMPLSOutput;
599  RouterPtr tmp = routersListPtr;
600  int dd = 0;
601  FILE *TPLFILE;
602#if defined(RECORDFLOW)
603  FILE *currentRECORDFLOWFILE;
604#endif
605  now = time((time_t *)NULL);
606  tmPtr = localtime(&now);
607  currentIntervalle = tmPtr->tm_min;
608  lastMPLSOutput = now;
609  lastIPOutput = now;
610#if defined(RECORDFLOW
611currentRECORDFLOWFILE = fRECORDF1;
612#endif
613  do {
614#ifdef DEBUG
615    fprintf (stderr, "[");
616#endif
617    if ( ((tmPtr->tm_min)%STEP == 0) && (currentIntervalle != tmPtr->tm_min)){
618      currentIntervalle = tmPtr->tm_min;
619      if (shmForAgg->currentTable == 0) {
620        shmForAgg->currentTable = 1;
621        shmForAgg->secondTable = 0;
622#if defined(RECORDFLOW)
623        /*free(bufRF1);*/
624        fflush(fRECORDF1);
625        if (fclose(fRECORDF1) == NULL){
626          fprintf(stderr,"error fclose : %s",strerror(errno));
627        }
628        strncpy(pathRF, RECORD_FILE_PATH,sizeof(RECORD_FILE_PATH));
629        strncpy(nameRF, SMP2_RECORD_FILE_2,sizeof(SMP2_RECORD_FILE_2));
630        errno = 0;
631        prepend_timestamp ( nameRF, sizeof nameRF );
632        if ( errno != ERANGE )
633          printf ( "Timestamped: %s\n", nameRF );
634        else {
635          /* Handle the error */
636        }
637        strncat(pathRF, nameRF, sizeof(nameRF));
638
639        if ((fRECORDF2 = fopen(pathRF, "w")) == NULL) {
640          syslog(LOG_ERR,"Error in %s opening : %s", pathRF, strerror(errno));
641        } else {
642          bufRF2 = (char *)malloc (262144);
643          setvbuf (fRECORDF2, bufRF2, _IOFBF, 262144);
644        }
645        currentRECORDFLOWFILE = fRECORDF2;
646#endif
647      }else{
648        shmForAgg->currentTable = 0;
649        shmForAgg->secondTable = 1;
650#if defined(RECORDFLOW)
651        /*free(bufRF2);*/
652        fflush(fRECORDF2);
653        fclose(fRECORDF2);
654        strncpy(pathRF, RECORD_FILE_PATH,sizeof(RECORD_FILE_PATH));
655        strncpy(nameRF, SMP2_RECORD_FILE_1,sizeof(SMP2_RECORD_FILE_1));
656        errno = 0;
657        prepend_timestamp ( nameRF, sizeof nameRF );
658        if ( errno != ERANGE )
659          printf ( "Timestamped: %s\n", nameRF );
660        else {
661          /* Handle the error */
662        }
663        strncat(pathRF, nameRF, sizeof(nameRF));
664        if ((fRECORDF1 = fopen(pathRF, "w")) == NULL) {
665          syslog(LOG_ERR,"Error in %s opening : %s", pathRF, strerror(errno));
666        } else {
667          bufRF1 = (char *)malloc (262144);
668          setvbuf (fRECORDF1, bufRF1, _IOFBF, 262144);
669        }
670        currentRECORDFLOWFILE = fRECORDF1;
671#endif
672      }
673      shmForAgg->readed = 1;
674      myPtrs.currentMIB = shmForAgg->myMIB[shmForAgg->currentTable];
675      myPtrs.secondMIB = shmForAgg->myMIB[shmForAgg->secondTable];
676#ifdef ASACC
677      myPtrs.currentASTab = shmForAgg->ASTab[shmForAgg->currentTable];
678#endif
679#ifdef MATRIX
680      myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]);
681#endif
682#ifdef IPV6LINKAGG
683      myPtrs.currentV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->currentTable][0][0]);
684      myPtrs.secondV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->secondTable][0][0]);
685      /* FIXME : to delete : */
686      if (!(TPLFILE = fopen("/tmp/IPV6LINKAGGSMP2.txt", "w"))) {
687        syslog (LOG_ERR, "error during %s opening", "/tmp/IPV6LINKAGGSMP2.txt");
688      }
689      tmp = routersListPtr;
690      for (; tmp; tmp=tmp->next) {
691        for (dd=0;dd<MAX_INDEX_BY_ROUTER;dd++) {
692          if ( tmp->snmpIndexType[dd] != 2) {
693            fprintf(TPLFILE,
694                    "router: %lu.%lu.%lu.%lu dd: %hu , indexSNMP : %hu , type : %hu ,total bytes IN : %llu, OUT : %llu\n",
695                    (tmp->IpAddress>>24),
696                    (tmp->IpAddress<<8>>24),
697                    (tmp->IpAddress<<16>>24),
698                    (tmp->IpAddress<<24>>24),
699                    dd,
700                    tmp->snmpIndexID[dd],
701                    tmp->snmpIndexType[dd],
702                    ((struct IndexV6 *)((myPtrs.secondV6IndexTab)
703                                        +((tmp->ID)*MAX_INDEX_BY_ROUTER)
704                                        +(tmp->snmpIndexID[dd])))->bytesNbIN,
705                    ((struct IndexV6 *)((myPtrs.secondV6IndexTab)
706                                        +((tmp->ID)*MAX_INDEX_BY_ROUTER)
707                                        +(tmp->snmpIndexID[dd])))->bytesNbOUT
708                    );
709          }
710        }
711      }
712      fclose(TPLFILE); /* <-- */
713#endif
714    }
715    if (sigusr1Up == 1){
716      sigusr1Up = 0;
717      initRule();
718    }
719#ifdef READFROMFILE
720    fileReading();
721#else
722    socketReading();
723#endif
724    getIpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer);
725    regRouter = checkIpHeader(myPtrs.pcktPtr, &sortedRouterList[0], routerNb);
726    myPtrs.currentMIB->ipPacketNb += 1;
727    getUdpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer);
728    if ( checkUdpHeader(myPtrs.pcktPtr, regRouter, receptPort) == 1 ){
729      continue;
730    }
731    myPtrs.currentMIB->udpPacketNb += 1;
732    switch( version =
733            getNetFlowHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer,
734                             myPtrs.currentHeaderV9Ptr, myPtrs.offsetV9Ptr)){
735    case 9:
736#ifdef DEBUG
737      fprintf (stderr, ", %d %hu %lu ,",
738               myPtrs.currentHeaderV9Ptr->version,
739               myPtrs.currentHeaderV9Ptr->count,
740               myPtrs.currentHeaderV9Ptr->package_sequence);
741#endif
742      myPtrs.currentMIB->v9PacketNb += 1;
743      myPtrs.currentMIB->flowNb += myPtrs.currentHeaderV9Ptr->count;
744      if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr,
745                                                  myPtrs.pcktPtr->ipH->srcAdd))==NULL) {
746        myPtrs.currentRouterPtr = routersListPtr;
747      }
748      if ((enginePtrTmp = existEngId(myPtrs.currentRouterPtr,myPtrs.currentHeaderV9Ptr->sourceId))==NULL) {
749        /* add new engineID */
750        enginePtrTmp = newRouterEngineList();
751        enginePtrTmp->next = myPtrs.currentRouterPtr->engineList;
752        if (myPtrs.currentRouterPtr->engineList!=NULL) {
753          myPtrs.currentRouterPtr->engineList->prev=enginePtrTmp;}
754        myPtrs.currentRouterPtr->engineList = enginePtrTmp;
755        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId;
756        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence;
757      } else {
758        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId;
759        if (enginePtrTmp->package_sequence != (myPtrs.currentHeaderV9Ptr->package_sequence-1)) {
760          myPtrs.currentMIB->v9UnSeqNb += 1;
761        }
762        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence;
763      }
764      currentFlowsetNumber = 0;
765      shift = 0;
766      gardeFou=0;
767      while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)
768             && (shift+48 < myPtrs.pcktPtr->udp_header->length)) {
769        gardeFou++;
770        curTplFlSetPtr = NULL;
771        currentFlowsetId=getFlowsetId(currentFlowsetNumber,
772                                      myPtrs.offsetV9Ptr, myPtrs.ptr_buffer);
773        myPtrs.currentMIB->flowSetNb += 1;
774        if ( currentFlowsetId == 0 ) {
775          if ( (shift = checkTemplateFlowSet(shift, myPtrs.currentRouterPtr,
776                                             myPtrs.currentMIB,
777                                             myPtrs.offsetV9Ptr,
778                                             myPtrs.ptr_buffer,
779                                             myPtrs.currentHeaderV9Ptr,
780                                             curTplFlSetPtr,
781                                             myPtrs.currentFlowsetNumberPtr,
782                                             myQueue)) < 0 ) {
783#ifdef DEBUG
784            fprintf (stderr, "w> ");
785#endif
786            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
787          }
788          /* writeAllTplFlSet(); */
789        } else if (currentFlowsetId == 1) {
790          if ( (shift = checkTemplateOption(shift, myPtrs.currentRouterPtr,
791                                            myPtrs.currentMIB,
792                                            myPtrs.offsetV9Ptr,
793                                            myPtrs.ptr_buffer,
794                                            myPtrs.currentHeaderV9Ptr,
795                                            curTplOptionPtr,
796                                            myPtrs.currentFlowsetNumberPtr) ) < 0 ) {
797#ifdef DEBUG
798            fprintf (stderr, "wo> ");
799#endif
800            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
801          }
802        } else if (currentFlowsetId > 255) {
803#if defined(RECORDFLOW)
804          if ( (shift = checkDataFlowSet(shift,
805                                         &myPtrs,
806                                         myQueue,
807                                         shmForAgg->prefixV4Tab[shmForAgg->currentTable],
808                                         (size_t) shmForAgg->v4PrefixNb,
809                                         shmForAgg->prefixV4SubnetTab[shmForAgg->currentTable],
810                                         (size_t) shmForAgg->v4SubnetNb,
811           currentRECORDFLOWFILE )) < 0 ) {
812#else
813          if ( (shift = checkDataFlowSet(shift,
814                                         &myPtrs,
815                                         myQueue,
816                                         shmForAgg->prefixV4Tab[shmForAgg->currentTable],
817                                         (size_t) shmForAgg->v4PrefixNb,
818                                         shmForAgg->prefixV4SubnetTab[shmForAgg->currentTable],
819                                         (size_t) shmForAgg->v4SubnetNb) ) < 0 ) {
820#endif
821#ifdef DEBUG
822            fprintf (stderr, "wd> ");
823#endif
824            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
825          }
826        } else {
827#ifdef DEBUG
828          fprintf (stderr, " 1<<255 ");
829#endif
830          currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
831        }
832        if ( gardeFou > 200) { exit(-1); }
833      } /* end while flowset exist */
834#ifdef DEBUG
835      if (shift > 1456) {
836        fprintf(stderr," SHIT SHIFT > 1456 : %d \n", shift);
837      }
838#endif
839      break;
840    default:
841      syslog(LOG_INFO,
842             "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu",
843             (unsigned short) version,
844             (myPtrs.pcktPtr->ipH->srcAdd>>24),
845             (myPtrs.pcktPtr->ipH->srcAdd<<8>>24),
846             (myPtrs.pcktPtr->ipH->srcAdd<<16>>24),
847             (myPtrs.pcktPtr->ipH->srcAdd<<24>>24));
848      break;
849    }
850    if (loopNb  > 140000 ){
851      /* FIXME perhaps call this function via the compilation options */
852      writeAllTplFlSet();
853#ifdef DEBUG
854      fprintf(stderr, "W");
855#endif
856      loopNb = 0;
857    }
858    loopNb++;
859
860    now = time((time_t *)NULL);
861    tmPtr = localtime(&now);
862#ifdef DEBUG
863    fprintf (stderr, "]\n");
864    fprintf (stderr, "IP: %llu , UDP: %llu, NDEv9: %llu, drops: %llu, FS: %llu, Flows: %llu, realFl: %llu Diff:%llu\n",
865             myPtrs.currentMIB->ipPacketNb,
866             myPtrs.currentMIB->udpPacketNb,
867             myPtrs.currentMIB->v9PacketNb,
868             myPtrs.currentMIB->v9UnSeqNb,
869             myPtrs.currentMIB->flowSetNb,
870             myPtrs.currentMIB->flowNb,
871             myPtrs.currentMIB->realFlowNb,
872             myPtrs.currentMIB->flowNb - myPtrs.currentMIB->realFlowNb
873             );
874#endif
875  } while (1);
876}
877
878/*
879 * initSocket()
880 */
881short
882initSocket()
883{
884  inputSock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
885  if (inputSock < 0)
886    {
887      syslog(LOG_ERR,"socket : %s", strerror(errno));
888      exit(1);
889    }
890  memset((void*)&name, 0, sizeof(name));
891  name.sin_family = AF_INET;
892  /*name.sin_addr.s_addr = htonl(INADDR_ANY);*/
893  name.sin_addr.s_addr = inet_addr(SMP2_RECEPTION_ADDRESS);
894  if (name.sin_addr.s_addr == INADDR_NONE){
895    syslog(LOG_ERR, " INADDR_NONE ");
896    exit(1);
897  }
898  name.sin_port = htons(receptPort);
899  if (bind(inputSock,(struct sockaddr *)(&name), sizeof(name)) < 0)
900    {
901      syslog(LOG_ERR, "bind : %s", strerror(errno));
902      exit(1);
903    }
904  sockNamelg = sizeof(name);
905  if (getsockname(inputSock, (struct sockaddr *) (&name),
906                  (socklen_t *)&sockNamelg) < 0)
907    {
908      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
909      exit(1);
910    }
911  /* Here socket DGRAM creation, only to not have a unreachable service */
912  /* message in return */
913  inputSock2 = socket(AF_INET, SOCK_DGRAM, 0);
914  if (inputSock2 < 0)
915    {
916      syslog(LOG_ERR,"socket : %s", strerror(errno));
917      exit(1);
918    }
919  memset((void*)&name, 0, sizeof(name));
920  name2.sin_family = AF_INET;
921  /*name2.sin_addr.s_addr = htonl(INADDR_ANY);*/
922  name2.sin_addr.s_addr = inet_addr(SMP2_RECEPTION_ADDRESS);
923  if (name2.sin_addr.s_addr == INADDR_NONE){
924    syslog(LOG_ERR, " INADDR_NONE ");
925    exit(1);
926  }
927  name2.sin_port = htons(receptPort);
928  if (bind(inputSock2,(struct sockaddr *)(&name2), sizeof(name2)) < 0)
929    {
930      syslog(LOG_ERR, "bind : %s", strerror(errno));
931      exit(1);
932    }
933  sockNamelg = sizeof(name2);
934  if (getsockname(inputSock2, (struct sockaddr *) (&name2),
935                  (socklen_t *)&sockNamelg) < 0)
936    {
937      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
938      exit(1);
939    }
940  return(0);
941}
942
943/*
944 * initFile
945 */
946short initFile()
947{
948
949}
950
951/*
952 * socketReading
953 */
954short
955socketReading()
956{
957  signed short sockLg;
958
959  sockNameFromlg = sizeof(fromName);
960  rcv = recvfrom(inputSock, myPtrs.ptr_buffer, sockBufSize, 0,
961                 (struct sockaddr *)(&fromName),
962                 (socklen_t *)&sockNameFromlg);
963  sockLg = rcv;
964  if (sockLg < 0) {
965    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
966    exit(1);
967  }
968  if (sockLg == 0) {
969    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
970    exit(1);
971  }
972  return(0);
973}
974
975/*
976 * fileReading
977 */
978short fileReading()
979{
980#ifdef READFROMFILE
981  struct pcap_pkthdr myPcapHeader;
982  const u_char *ethernetPacket;
983
984  if ((ethernetPacket = pcap_next(myPcapHandle, &myPcapHeader)) == NULL) {
985    fprintf (stderr, "IP: %llu , UDP: %llu, NDEv9: %llu, drops: %llu, FS: %llu, Flows: %llu, realFl: %llu Diff:%llu\n",
986             myPtrs.currentMIB->ipPacketNb,
987             myPtrs.currentMIB->udpPacketNb,
988             myPtrs.currentMIB->v9PacketNb,
989             myPtrs.currentMIB->v9UnSeqNb,
990             myPtrs.currentMIB->flowSetNb,
991             myPtrs.currentMIB->flowNb,
992             myPtrs.currentMIB->realFlowNb,
993             myPtrs.currentMIB->flowNb - myPtrs.currentMIB->realFlowNb
994             );
995    pcap_close(myPcapHandle);
996    exit(0);
997  }
998  myPtrs.ptr_buffer = (DatagramPtr) (ethernetPacket + 14);
999#ifdef DEBUG
1000  fprintf(stderr,"P");
1001#endif
1002#endif
1003}
1004
1005/*
1006 * check up flow datagramme
1007 */
1008short
1009checkFlow(short flowNumber)
1010{
1011  return(0); /* FIXME : why this function ??? */
1012}
1013
1014/*
1015 * showAllTplFlSet
1016 *
1017 * to use only in debug mode
1018 */
1019void
1020showAllTplFlSet()
1021{
1022  RouterPtr tmp = routersListPtr;
1023  TplFlowSetPtr tmpFS;
1024  TplOptionPtr tmpOP;
1025  fprintf(stderr,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n");
1026  for (; tmp; tmp=tmp->next) {
1027    fprintf(stderr,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n",
1028            (tmp->IpAddress>>24),
1029            (tmp->IpAddress<<8>>24),
1030            (tmp->IpAddress<<16>>24),
1031            (tmp->IpAddress<<24>>24));
1032    tmpFS =  tmp->tplList;
1033    for (; tmpFS; tmpFS=tmpFS->next) {
1034      fprintf(stderr,"TId %hu (sourceId: %lu):\n",
1035              tmpFS->templateFlowSetId,
1036              tmpFS->sourceId);
1037      printFieldSet(stderr, tmpFS->fieldSet);
1038      fprintf(stderr,"\n");
1039    }
1040    if ((tmpOP = tmp->tplOptList) != NULL){
1041      for (; tmpOP; tmpOP=tmpOP->next) {
1042        fprintf(stderr,"OpTId %hu (sourceId: %lu) >\n",
1043                tmpOP->templateOptionId,
1044                tmpOP->sourceId);
1045        printFieldSet(stderr, tmpOP->fieldSet);
1046        fprintf(stderr,"\n");
1047      }
1048      fprintf(stderr,"\n");
1049    }
1050  }
1051}
1052
1053
1054/*
1055 * writeAllTplFlSet
1056 *
1057 */
1058void
1059writeAllTplFlSet()
1060{
1061
1062  RouterPtr tmp = routersListPtr;
1063  TplFlowSetPtr tmpFS;
1064  TplOptionPtr tmpOP;
1065  FILE *TPLFILE;
1066  if (!(TPLFILE = fopen("/tmp/TemplateDefSMP2.txt", "w"))) {
1067    syslog (LOG_ERR, "error during %s opening", "/tmp/TemplateDefSMP2.txt");
1068  }
1069  for (; tmp; tmp=tmp->next) {
1070    tmpFS =  tmp->tplList;
1071    for (; tmpFS; tmpFS=tmpFS->next) {
1072      fprintf(TPLFILE,"%lu.%lu.%lu.%lu TId %hu %lu ",
1073              (tmp->IpAddress>>24),
1074              (tmp->IpAddress<<8>>24),
1075              (tmp->IpAddress<<16>>24),
1076              (tmp->IpAddress<<24>>24),
1077              tmpFS->templateFlowSetId,
1078              tmpFS->sourceId);
1079      printFieldSet(TPLFILE, tmpFS->fieldSet);
1080      fprintf(TPLFILE,"\n");
1081    }
1082    if ((tmpOP = tmp->tplOptList) != NULL){
1083      for (; tmpOP; tmpOP=tmpOP->next) {
1084        fprintf(TPLFILE,"%lu.%lu.%lu.%lu OpTId %hu %lu %d %hu %hu %hu ",
1085                (tmp->IpAddress>>24),
1086                (tmp->IpAddress<<8>>24),
1087                (tmp->IpAddress<<16>>24),
1088                (tmp->IpAddress<<24>>24),
1089                tmpOP->templateOptionId,
1090                tmpOP->sourceId,
1091                tmpOP->optionScopeLg/4, /* last x brackets are scope */
1092                tmpOP->length,
1093                tmpOP->optionScopeLg,
1094                tmpOP->optionLg);
1095        printFieldSet(TPLFILE, tmpOP->fieldSet);
1096        fprintf(TPLFILE,"\n");
1097      }
1098      /*      fprintf(TPLFILE,"\n");*/
1099    }
1100  }
1101  fclose(TPLFILE);
1102}
1103
1104/*
1105 * initMIB
1106 */
1107int initMIB(struct RenetcolMIB *theMIB)
1108{
1109  theMIB->ipPacketNb = 0;
1110  theMIB->udpPacketNb = 0;
1111  theMIB->v9PacketNb = 0;
1112  theMIB->v9UnSeqNb = 0;
1113  theMIB->flowSetNb = 0;
1114  theMIB->dataFlowSetNb = 0;
1115  theMIB->defFlowSetNb = 0;
1116  theMIB->optDataFlowSetNb = 0;
1117  theMIB->optDefFlowSetNb = 0;
1118  theMIB->flowNb = 0;
1119  theMIB->realFlowNb = 0;
1120  theMIB->ipv4Bytes = 0;
1121  theMIB->ipv4Pckts = 0;
1122  theMIB->ipv4Flow = 0;
1123  theMIB->ipv4IcmpFlowNb = 0;
1124  theMIB->ipv4IcmpBytesNb = 0;
1125  theMIB->ipv4IcmpPktsNb = 0;
1126  theMIB->ipv4UDPFlowNb = 0;
1127  theMIB->ipv4UDPBytesNb = 0;
1128  theMIB->ipv4UDPPktsNb = 0;
1129  theMIB->ipv4TCPFlowNb = 0;
1130  theMIB->ipv4TCPBytesNb = 0;
1131  theMIB->ipv4TCPPktsNb = 0;
1132  theMIB->ipv4OthersFlowNb = 0;
1133  theMIB->ipv4OthersBytesNb = 0;
1134  theMIB->ipv4OthersPktsNb = 0;
1135  theMIB->ipv4FlowSizePcktsE1 = 0;
1136  theMIB->ipv4FlowSizePcktsLT10 = 0;
1137  theMIB->ipv4FlowSizePcktsLT100 = 0;
1138  theMIB->ipv4FlowSizePcktsLT1k = 0;
1139  theMIB->ipv4FlowSizePcktsLT10k = 0;
1140  theMIB->ipv4FlowSizePcktsMT10k = 0;
1141  theMIB->ipv4FlowSizeBytesLT50 = 0;
1142  theMIB->ipv4FlowSizeBytesLT100 = 0;
1143  theMIB->ipv4FlowSizeBytesLT1k = 0;
1144  theMIB->ipv4FlowSizeBytesLT10k = 0;
1145  theMIB->ipv4FlowSizeBytesLT100k = 0;
1146  theMIB->ipv4FlowSizeBytesLT1M = 0;
1147  theMIB->ipv4FlowSizeBytesLT10M = 0;
1148  theMIB->ipv4FlowSizeBytesLT100M = 0;
1149  theMIB->ipv4FlowSizeBytesMT100M = 0;
1150  theMIB->ipv4WebBytesNb = 0;
1151  theMIB->ipv4WebPcktsNb = 0;
1152  theMIB->ipv4WebFlowNb = 0;
1153  theMIB->ipv4DNSBytesNb = 0;
1154  theMIB->ipv4DNSPcktsNb = 0;
1155  theMIB->ipv4DNSFlowNb = 0;
1156  theMIB->ipv4OthersApBytesNb = 0;
1157  theMIB->ipv4OthersApPcktsNb = 0;
1158  theMIB->ipv4OthersApFlowNb = 0;
1159  theMIB->ipv6Bytes = 0;
1160  theMIB->ipv6Pckts = 0;
1161  theMIB->ipv6Flow = 0;
1162  theMIB->ipv6IcmpFlowNb = 0;
1163  theMIB->ipv6IcmpBytesNb = 0;
1164  theMIB->ipv6IcmpPktsNb = 0;
1165  theMIB->ipv6UDPFlowNb = 0;
1166  theMIB->ipv6UDPBytesNb = 0;
1167  theMIB->ipv6UDPPktsNb = 0;
1168  theMIB->ipv6TCPFlowNb = 0;
1169  theMIB->ipv6TCPBytesNb = 0;
1170  theMIB->ipv6TCPPktsNb = 0;
1171  theMIB->ipv6OthersFlowNb = 0;
1172  theMIB->ipv6OthersBytesNb = 0;
1173  theMIB->ipv6OthersPktsNb = 0;
1174  theMIB->ipv6FlowSizePcktsE1 = 0;
1175  theMIB->ipv6FlowSizePcktsLT10 = 0;
1176  theMIB->ipv6FlowSizePcktsLT100 = 0;
1177  theMIB->ipv6FlowSizePcktsLT1k = 0;
1178  theMIB->ipv6FlowSizePcktsLT10k = 0;
1179  theMIB->ipv6FlowSizePcktsMT10k = 0;
1180  theMIB->ipv6FlowSizeBytesLT50 = 0;
1181  theMIB->ipv6FlowSizeBytesLT100 = 0;
1182  theMIB->ipv6FlowSizeBytesLT1k = 0;
1183  theMIB->ipv6FlowSizeBytesLT10k = 0;
1184  theMIB->ipv6FlowSizeBytesLT100k = 0;
1185  theMIB->ipv6FlowSizeBytesLT1M = 0;
1186  theMIB->ipv6FlowSizeBytesLT10M = 0;
1187  theMIB->ipv6FlowSizeBytesLT100M = 0;
1188  theMIB->ipv6FlowSizeBytesMT100M = 0;
1189  theMIB->ipv6WebBytesNb = 0;
1190  theMIB->ipv6WebPcktsNb = 0;
1191  theMIB->ipv6WebFlowNb = 0;
1192  theMIB->ipv6DNSBytesNb = 0;
1193  theMIB->ipv6DNSPcktsNb = 0;
1194  theMIB->ipv6DNSFlowNb = 0;
1195  theMIB->ipv6OthersApBytesNb = 0;
1196  theMIB->ipv6OthersApPcktsNb = 0;
1197  theMIB->ipv6OthersApFlowNb = 0;
1198  return 1;
1199}
Note: See TracBrowser for help on using the browser.