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

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

RECORDFLOW option

Line 
1/*
2 * File: renetcolSMP3.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 "renetcolSMP3.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[SMP3_ROUTER_INDEX_MAX];
71unsigned long indexedRouterList[SMP3_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 = SMP3_RECEPTION_PORT;
93/* static unsigned char *ptr_buffer; */
94static char *receptAddress = SMP3_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, SMP3_RECORD_FILE_1,sizeof(SMP3_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, "renetcolSMP3 compilation and execution with IPv4 Prefixes Aggregation feature enable based on routers ID in %s file.\n", SMP3_ROUTERS_LIST);
154#endif
155
156#if defined(IPV4AGGIDSNMP)
157  fprintf(stderr, "renetcolSMP3 compilation and execution with IPv4 Prefixes Aggregation feature enable based on SNMP ID in %s file.\n", SMP3_INTERFACES_TYPE_LIST);
158#endif
159#if defined(IPV6AGGIDSNMP)
160  fprintf(stderr, "renetcolSMP3 compilation and execution with IPv6 Prefixes Aggregation feature enable based on SNMP ID in %s file.\n", SMP3_INTERFACES_TYPE_LIST);
161#endif
162#if defined(IPV6LINKAGG)
163  fprintf(stderr, "renetcolSMP3 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(SMP3_ROUTERS_LIST,
172                                        &sortedRouterList[0],
173                                        &indexedRouterList[0])) == -1) {
174    fprintf(stderr,
175            "ERROR in getRegisteredRouters from file %s\n",
176            SMP3_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 = 8767;
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, "renetcolSMP3: 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, "renetcolSMP3: 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, "renetcolSMP3: 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, "renetcolSMP3: 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, "renetcolSMP3: 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, "renetcolSMP3: Error in %s\n", AS_LIST);
276    exit(1);
277  }
278#endif
279
280  /* the fork */
281  fprintf(stderr, "renetcolSMP3: 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(SMP3_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<SMP3_ROUTER_INDEX_MAX; i++){
346    for (j=0; j<SMP3_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<SMP3_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 * send his PID to another program via IPC message queue
429 *
430 * @param queueID the IPC queue ident
431 *
432 */
433void
434sendMyPid(int queueID)
435{
436  msgType myMsg;
437  char *msgTextIndex;
438  unsigned short tplMsgType = 15;
439  pid_t myPID;
440
441  myPID = getpid();
442  msgTextIndex = mempcpy(mempcpy(myMsg.text,
443                                 &tplMsgType,
444                                 sizeof (unsigned short)
445                                 ),
446                         &myPID,
447                         sizeof(pid_t)
448                         );
449  myMsg.type = 1;
450  msgSend(queueID, myMsg);
451}
452
453/*
454 * Send the "read rules list" message to another program
455 *
456 * @param queueID the IPC queue ident
457 *
458 */
459void sendReadRulesSignal(int queueID)
460{
461  msgType myMsg;
462  char *msgTextIndex;
463  unsigned short tplMsgType = 13;
464
465  msgTextIndex = mempcpy(myMsg.text,
466                         &tplMsgType,
467                         sizeof (unsigned short)
468                         );
469  myMsg.type = 1;
470  msgSend(queueID, myMsg);
471}
472
473/*
474 *
475 */
476void
477sigusr1Mgmt(int num)
478{
479  sigusr1Up = 1;
480}
481
482/*
483 * init the rule structure
484 */
485void
486initRule()
487{
488  RulesPtr tmp = NULL;
489  initCache();
490  tmp = myPtrs.rulesListPtr;
491  for ( ; tmp; tmp=tmp->next) {
492    myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr);
493  }
494  myPtrs.rulesListPtr = NULL;
495  myPtrs.rulesListPtr = getRules(myPtrs.rulesListPtr, RULES_FILE);
496  tmp = myPtrs.rulesListPtr;
497  for ( ; tmp; tmp=tmp->next) {
498    if (tmp->type != 2) {
499      myPtrs.rulesListPtr = delRule(tmp, myPtrs.rulesListPtr);
500    }
501  }
502  tmp = NULL;
503  initCache();
504  setCache(myPtrs.rulesListPtr);
505  sendReadRulesSignal(myQueue);
506#ifdef DEBUG
507  printRule(myPtrs.rulesListPtr);
508#endif
509}
510
511/*
512 * init cache table
513 */
514void
515initCache()
516{
517  int i,j;
518  for (i=0; i<FIELD_TYPE_NUMBER+1; i++){
519    for (j=0; j<MAX_RULES_PER_FIELD; j++){
520      rulesAddress[i][j] = NULL;
521    }
522  }
523}
524
525/*
526 * setCache()
527 */
528void
529setCache(RulesPtr rPtr)
530{
531  int i=0;
532  RulesPtr tmp = rPtr;
533  RuleDefPtr def = NULL;
534
535#ifdef DEBUG
536  fprintf(stderr,"Cache for Rules: \n");
537#endif
538  while (tmp) {
539    def = tmp->def;
540    while (def) {
541      i = 0;
542      while (rulesAddress[def->fieldType][i] != NULL){
543        i++;
544      }
545      rulesAddress[def->fieldType][i] = def;
546#ifdef DEBUG
547      fprintf(stderr,"%d: %d \n", def->fieldType, i);
548#endif
549      def = def->next;
550    }
551#ifdef DEBUG
552    fprintf(stderr,"\n");
553#endif
554    tmp = tmp->next;
555  }
556#ifdef DEBUG
557  fprintf(stderr,"Cache for Rules: OK");
558#endif
559}
560
561/*
562 * initStream()
563 *
564 * Stream can be a file (pcap format) or a socket
565 */
566void
567initStream()
568{
569  static unsigned short n0, n1, n2, n3;
570
571#ifdef READFROMFILE
572  initFile();
573#else
574  initSocket();
575  if (sscanf(receptAddress,"%hu.%hu.%hu.%hu",&n0,&n1,&n2,&n3)==0) {
576    perror("sscanf");
577  }
578  buffer4[0] = (unsigned char)n3;
579  buffer4[1] = (unsigned char)n2;
580  buffer4[2] = (unsigned char)n1;
581  buffer4[3] = (unsigned char)n0;
582#endif
583}
584
585/*
586 * socketLoop()
587 */
588int
589socketLoop()
590{
591  short shift;
592  short version = 0;
593  int regRouter = 0;
594  time_t now = time((time_t *)NULL);
595  int loopNb = 0;
596  int gardeFou = 0;
597  time_t lastIPOutput, lastMPLSOutput;
598  RouterPtr tmp = routersListPtr;
599  int dd = 0;
600  FILE *TPLFILE;
601#if defined(RECORDFLOW)
602  FILE *currentRECORDFLOWFILE;
603#endif
604  now = time((time_t *)NULL);
605  tmPtr = localtime(&now);
606  currentIntervalle = tmPtr->tm_min;
607  lastMPLSOutput = now;
608  lastIPOutput = now;
609#if defined(RECORDFLOW
610currentRECORDFLOWFILE = fRECORDF1;
611#endif
612  do {
613#ifdef DEBUG
614    fprintf (stderr, "[");
615#endif
616    if ( ((tmPtr->tm_min)%STEP == 0) && (currentIntervalle != tmPtr->tm_min)){
617      currentIntervalle = tmPtr->tm_min;
618      if (shmForAgg->currentTable == 0) {
619        shmForAgg->currentTable = 1;
620        shmForAgg->secondTable = 0;
621#if defined(RECORDFLOW)
622        /*free(bufRF1);*/
623        fflush(fRECORDF1);
624        if (fclose(fRECORDF1) == NULL){
625          fprintf(stderr,"error fclose : %s",strerror(errno));
626        }
627        strncpy(pathRF, RECORD_FILE_PATH,sizeof(RECORD_FILE_PATH));
628        strncpy(nameRF, SMP3_RECORD_FILE_2,sizeof(SMP3_RECORD_FILE_2));
629        errno = 0;
630        prepend_timestamp ( nameRF, sizeof nameRF );
631        if ( errno != ERANGE )
632          printf ( "Timestamped: %s\n", nameRF );
633        else {
634          /* Handle the error */
635        }
636        strncat(pathRF, nameRF, sizeof(nameRF));
637
638        if ((fRECORDF2 = fopen(pathRF, "w")) == NULL) {
639          syslog(LOG_ERR,"Error in %s opening : %s", pathRF, strerror(errno));
640        } else {
641          bufRF2 = (char *)malloc (262144);
642          setvbuf (fRECORDF2, bufRF2, _IOFBF, 262144);
643        }
644        currentRECORDFLOWFILE = fRECORDF2;
645#endif
646      }else{
647        shmForAgg->currentTable = 0;
648        shmForAgg->secondTable = 1;
649#if defined(RECORDFLOW)
650        /*free(bufRF2);*/
651        fflush(fRECORDF2);
652        fclose(fRECORDF2);
653        strncpy(pathRF, RECORD_FILE_PATH,sizeof(RECORD_FILE_PATH));
654        strncpy(nameRF, SMP3_RECORD_FILE_1,sizeof(SMP3_RECORD_FILE_1));
655        errno = 0;
656        prepend_timestamp ( nameRF, sizeof nameRF );
657        if ( errno != ERANGE )
658          printf ( "Timestamped: %s\n", nameRF );
659        else {
660          /* Handle the error */
661        }
662        strncat(pathRF, nameRF, sizeof(nameRF));
663        if ((fRECORDF1 = fopen(pathRF, "w")) == NULL) {
664          syslog(LOG_ERR,"Error in %s opening : %s", pathRF, strerror(errno));
665        } else {
666          bufRF1 = (char *)malloc (262144);
667          setvbuf (fRECORDF1, bufRF1, _IOFBF, 262144);
668        }
669        currentRECORDFLOWFILE = fRECORDF1;
670#endif
671      }
672      shmForAgg->readed = 1;
673      myPtrs.currentMIB = shmForAgg->myMIB[shmForAgg->currentTable];
674      myPtrs.secondMIB = shmForAgg->myMIB[shmForAgg->secondTable];
675#ifdef ASACC
676      myPtrs.currentASTab = shmForAgg->ASTab[shmForAgg->currentTable];
677#endif
678#ifdef MATRIX
679      myPtrs.matrixPOP = &(shmForAgg->matrixPOP[shmForAgg->currentTable][0][0]);
680#endif
681#ifdef IPV6LINKAGG
682      myPtrs.currentV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->currentTable][0][0]);
683      myPtrs.secondV6IndexTab = &(shmForAgg->indexV6Tab[shmForAgg->secondTable][0][0]);
684      /* FIXME : to delete : */
685      if (!(TPLFILE = fopen("/tmp/IPV6LINKAGGSMP3.txt", "w"))) {
686        syslog (LOG_ERR, "error during %s opening", "/tmp/IPV6LINKAGGSMP3.txt");
687      }
688      tmp = routersListPtr;
689      for (; tmp; tmp=tmp->next) {
690        for (dd=0;dd<MAX_INDEX_BY_ROUTER;dd++) {
691          if ( tmp->snmpIndexType[dd] != 2) {
692            fprintf(TPLFILE,
693                    "router: %lu.%lu.%lu.%lu dd: %hu , indexSNMP : %hu , type : %hu ,total bytes IN : %llu, OUT : %llu\n",
694                    (tmp->IpAddress>>24),
695                    (tmp->IpAddress<<8>>24),
696                    (tmp->IpAddress<<16>>24),
697                    (tmp->IpAddress<<24>>24),
698                    dd,
699                    tmp->snmpIndexID[dd],
700                    tmp->snmpIndexType[dd],
701                    ((struct IndexV6 *)((myPtrs.secondV6IndexTab)
702                                        +((tmp->ID)*MAX_INDEX_BY_ROUTER)
703                                        +(tmp->snmpIndexID[dd])))->bytesNbIN,
704                    ((struct IndexV6 *)((myPtrs.secondV6IndexTab)
705                                        +((tmp->ID)*MAX_INDEX_BY_ROUTER)
706                                        +(tmp->snmpIndexID[dd])))->bytesNbOUT
707                    );
708          }
709        }
710      }
711      fclose(TPLFILE); /* <-- */
712#endif
713    }
714    if (sigusr1Up == 1){
715      sigusr1Up = 0;
716      initRule();
717    }
718#ifdef READFROMFILE
719    fileReading();
720#else
721    socketReading();
722#endif
723    getIpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer);
724    regRouter = checkIpHeader(myPtrs.pcktPtr, &sortedRouterList[0], routerNb);
725    myPtrs.currentMIB->ipPacketNb += 1;
726    getUdpHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer);
727    if ( checkUdpHeader(myPtrs.pcktPtr, regRouter, receptPort) == 1 ){
728      continue;
729    }
730    myPtrs.currentMIB->udpPacketNb += 1;
731    switch( version =
732            getNetFlowHeader(myPtrs.pcktPtr, myPtrs.ptr_buffer,
733                             myPtrs.currentHeaderV9Ptr, myPtrs.offsetV9Ptr)){
734    case 9:
735#ifdef DEBUG
736      fprintf (stderr, ", %d %hu %lu ,",
737               myPtrs.currentHeaderV9Ptr->version,
738               myPtrs.currentHeaderV9Ptr->count,
739               myPtrs.currentHeaderV9Ptr->package_sequence);
740#endif
741      myPtrs.currentMIB->v9PacketNb += 1;
742      myPtrs.currentMIB->flowNb += myPtrs.currentHeaderV9Ptr->count;
743      if ((myPtrs.currentRouterPtr=notExistRouter(routersListPtr,
744                                                  myPtrs.pcktPtr->ipH->srcAdd))==NULL) {
745        myPtrs.currentRouterPtr = routersListPtr;
746      }
747      if ((enginePtrTmp = existEngId(myPtrs.currentRouterPtr,myPtrs.currentHeaderV9Ptr->sourceId))==NULL) {
748        /* add new engineID */
749        enginePtrTmp = newRouterEngineList();
750        enginePtrTmp->next = myPtrs.currentRouterPtr->engineList;
751        if (myPtrs.currentRouterPtr->engineList!=NULL) {
752          myPtrs.currentRouterPtr->engineList->prev=enginePtrTmp;}
753        myPtrs.currentRouterPtr->engineList = enginePtrTmp;
754        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId;
755        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence;
756      } else {
757        enginePtrTmp->engineId = myPtrs.currentHeaderV9Ptr->sourceId;
758        if (enginePtrTmp->package_sequence != (myPtrs.currentHeaderV9Ptr->package_sequence-1)) {
759          myPtrs.currentMIB->v9UnSeqNb += 1;
760        }
761        enginePtrTmp->package_sequence = myPtrs.currentHeaderV9Ptr->package_sequence;
762      }
763      currentFlowsetNumber = 0;
764      shift = 0;
765      gardeFou=0;
766      while ((currentFlowsetNumber < myPtrs.currentHeaderV9Ptr->count)
767             && (shift+48 < myPtrs.pcktPtr->udp_header->length)) {
768        gardeFou++;
769        curTplFlSetPtr = NULL;
770        currentFlowsetId=getFlowsetId(currentFlowsetNumber,
771                                      myPtrs.offsetV9Ptr, myPtrs.ptr_buffer);
772        myPtrs.currentMIB->flowSetNb += 1;
773        if ( currentFlowsetId == 0 ) {
774          if ( (shift = checkTemplateFlowSet(shift, myPtrs.currentRouterPtr,
775                                             myPtrs.currentMIB,
776                                             myPtrs.offsetV9Ptr,
777                                             myPtrs.ptr_buffer,
778                                             myPtrs.currentHeaderV9Ptr,
779                                             curTplFlSetPtr,
780                                             myPtrs.currentFlowsetNumberPtr,
781                                             myQueue)) < 0 ) {
782#ifdef DEBUG
783            fprintf (stderr, "w> ");
784#endif
785            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
786          }
787          /* writeAllTplFlSet(); */
788        } else if (currentFlowsetId == 1) {
789          if ( (shift = checkTemplateOption(shift, myPtrs.currentRouterPtr,
790                                            myPtrs.currentMIB,
791                                            myPtrs.offsetV9Ptr,
792                                            myPtrs.ptr_buffer,
793                                            myPtrs.currentHeaderV9Ptr,
794                                            curTplOptionPtr,
795                                            myPtrs.currentFlowsetNumberPtr) ) < 0 ) {
796#ifdef DEBUG
797            fprintf (stderr, "wo> ");
798#endif
799            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
800          }
801        } else if (currentFlowsetId > 255) {
802#if defined(RECORDFLOW)
803          if ( (shift = checkDataFlowSet(shift,
804                                         &myPtrs,
805                                         myQueue,
806                                         shmForAgg->prefixV4Tab[shmForAgg->currentTable],
807                                         (size_t) shmForAgg->v4PrefixNb,
808                                         shmForAgg->prefixV4SubnetTab[shmForAgg->currentTable],
809                                         (size_t) shmForAgg->v4SubnetNb,
810           currentRECORDFLOWFILE) ) < 0 ) {
811#else
812          if ( (shift = checkDataFlowSet(shift,
813                                         &myPtrs,
814                                         myQueue,
815                                         shmForAgg->prefixV4Tab[shmForAgg->currentTable],
816                                         (size_t) shmForAgg->v4PrefixNb,
817                                         shmForAgg->prefixV4SubnetTab[shmForAgg->currentTable],
818                                         (size_t) shmForAgg->v4SubnetNb) ) < 0 ) {
819#endif
820#ifdef DEBUG
821            fprintf (stderr, "wd> ");
822#endif
823            currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
824          }
825        } else {
826#ifdef DEBUG
827          fprintf (stderr, " 1<<255 ");
828#endif
829          currentFlowsetNumber = myPtrs.currentHeaderV9Ptr->count + 1;
830        }
831        if ( gardeFou > 200) { exit(-1); }
832      } /* end while flowset exist */
833#ifdef DEBUG
834      if (shift > 1456) {
835        fprintf(stderr," SHIT SHIFT > 1456 : %d \n", shift);
836      }
837#endif
838      break;
839    default:
840      syslog(LOG_INFO,
841             "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu",
842             (unsigned short) version,
843             (myPtrs.pcktPtr->ipH->srcAdd>>24),
844             (myPtrs.pcktPtr->ipH->srcAdd<<8>>24),
845             (myPtrs.pcktPtr->ipH->srcAdd<<16>>24),
846             (myPtrs.pcktPtr->ipH->srcAdd<<24>>24));
847      break;
848    }
849    if (loopNb  > 140000 ){
850      /* FIXME perhaps call this function via the compilation options */
851      writeAllTplFlSet();
852#ifdef DEBUG
853      fprintf(stderr, "W");
854#endif
855      loopNb = 0;
856    }
857    loopNb++;
858
859    now = time((time_t *)NULL);
860    tmPtr = localtime(&now);
861#ifdef DEBUG
862    fprintf (stderr, "]\n");
863    fprintf (stderr, "IP: %llu , UDP: %llu, NDEv9: %llu, drops: %llu, FS: %llu, Flows: %llu, realFl: %llu Diff:%llu\n",
864             myPtrs.currentMIB->ipPacketNb,
865             myPtrs.currentMIB->udpPacketNb,
866             myPtrs.currentMIB->v9PacketNb,
867             myPtrs.currentMIB->v9UnSeqNb,
868             myPtrs.currentMIB->flowSetNb,
869             myPtrs.currentMIB->flowNb,
870             myPtrs.currentMIB->realFlowNb,
871             myPtrs.currentMIB->flowNb - myPtrs.currentMIB->realFlowNb
872             );
873#endif
874  } while (1);
875}
876
877/*
878 * initSocket()
879 */
880short
881initSocket()
882{
883  inputSock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
884  if (inputSock < 0)
885    {
886      syslog(LOG_ERR,"socket : %s", strerror(errno));
887      exit(1);
888    }
889  memset((void*)&name, 0, sizeof(name));
890  name.sin_family = AF_INET;
891  /*name.sin_addr.s_addr = htonl(INADDR_ANY);*/
892  name.sin_addr.s_addr = inet_addr(SMP3_RECEPTION_ADDRESS);
893  if (name.sin_addr.s_addr == INADDR_NONE){
894    syslog(LOG_ERR, " INADDR_NONE ");
895    exit(1);
896  }
897  name.sin_port = htons(receptPort);
898  if (bind(inputSock,(struct sockaddr *)(&name), sizeof(name)) < 0)
899    {
900      syslog(LOG_ERR, "bind : %s", strerror(errno));
901      exit(1);
902    }
903  sockNamelg = sizeof(name);
904  if (getsockname(inputSock, (struct sockaddr *) (&name),
905                  (socklen_t *)&sockNamelg) < 0)
906    {
907      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
908      exit(1);
909    }
910  /* Here socket DGRAM creation, only to not have a unreachable service */
911  /* message in return */
912  inputSock2 = socket(AF_INET, SOCK_DGRAM, 0);
913  if (inputSock2 < 0)
914    {
915      syslog(LOG_ERR,"socket : %s", strerror(errno));
916      exit(1);
917    }
918  memset((void*)&name, 0, sizeof(name));
919  name2.sin_family = AF_INET;
920  /*name2.sin_addr.s_addr = htonl(INADDR_ANY);*/
921  name2.sin_addr.s_addr = inet_addr(SMP3_RECEPTION_ADDRESS);
922  if (name2.sin_addr.s_addr == INADDR_NONE){
923    syslog(LOG_ERR, " INADDR_NONE ");
924    exit(1);
925  }
926  name2.sin_port = htons(receptPort);
927  if (bind(inputSock2,(struct sockaddr *)(&name2), sizeof(name2)) < 0)
928    {
929      syslog(LOG_ERR, "bind : %s", strerror(errno));
930      exit(1);
931    }
932  sockNamelg = sizeof(name2);
933  if (getsockname(inputSock2, (struct sockaddr *) (&name2),
934                  (socklen_t *)&sockNamelg) < 0)
935    {
936      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
937      exit(1);
938    }
939  return(0);
940}
941
942/*
943 * initFile
944 */
945short initFile()
946{
947
948}
949
950/*
951 * socketReading
952 */
953short
954socketReading()
955{
956  signed short sockLg;
957
958  sockNameFromlg = sizeof(fromName);
959  rcv = recvfrom(inputSock, myPtrs.ptr_buffer, sockBufSize, 0,
960                 (struct sockaddr *)(&fromName),
961                 (socklen_t *)&sockNameFromlg);
962  sockLg = rcv;
963  if (sockLg < 0) {
964    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
965    exit(1);
966  }
967  if (sockLg == 0) {
968    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
969    exit(1);
970  }
971  return(0);
972}
973
974/*
975 * fileReading
976 */
977short fileReading()
978{
979#ifdef READFROMFILE
980  struct pcap_pkthdr myPcapHeader;
981  const u_char *ethernetPacket;
982
983  if ((ethernetPacket = pcap_next(myPcapHandle, &myPcapHeader)) == NULL) {
984    fprintf (stderr, "IP: %llu , UDP: %llu, NDEv9: %llu, drops: %llu, FS: %llu, Flows: %llu, realFl: %llu Diff:%llu\n",
985             myPtrs.currentMIB->ipPacketNb,
986             myPtrs.currentMIB->udpPacketNb,
987             myPtrs.currentMIB->v9PacketNb,
988             myPtrs.currentMIB->v9UnSeqNb,
989             myPtrs.currentMIB->flowSetNb,
990             myPtrs.currentMIB->flowNb,
991             myPtrs.currentMIB->realFlowNb,
992             myPtrs.currentMIB->flowNb - myPtrs.currentMIB->realFlowNb
993             );
994    pcap_close(myPcapHandle);
995    exit(0);
996  }
997  myPtrs.ptr_buffer = (DatagramPtr) (ethernetPacket + 14);
998#ifdef DEBUG
999  fprintf(stderr,"P");
1000#endif
1001#endif
1002}
1003
1004/*
1005 * check up flow datagramme
1006 */
1007short
1008checkFlow(short flowNumber)
1009{
1010  return(0); /* FIXME : why this function ??? */
1011}
1012
1013/*
1014 * showAllTplFlSet
1015 *
1016 * to use only in debug mode
1017 */
1018void
1019showAllTplFlSet()
1020{
1021  RouterPtr tmp = routersListPtr;
1022  TplFlowSetPtr tmpFS;
1023  TplOptionPtr tmpOP;
1024  fprintf(stderr,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n");
1025  for (; tmp; tmp=tmp->next) {
1026    fprintf(stderr,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n",
1027            (tmp->IpAddress>>24),
1028            (tmp->IpAddress<<8>>24),
1029            (tmp->IpAddress<<16>>24),
1030            (tmp->IpAddress<<24>>24));
1031    tmpFS =  tmp->tplList;
1032    for (; tmpFS; tmpFS=tmpFS->next) {
1033      fprintf(stderr,"TId %hu (sourceId: %lu):\n",
1034              tmpFS->templateFlowSetId,
1035              tmpFS->sourceId);
1036      printFieldSet(stderr, tmpFS->fieldSet);
1037      fprintf(stderr,"\n");
1038    }
1039    if ((tmpOP = tmp->tplOptList) != NULL){
1040      for (; tmpOP; tmpOP=tmpOP->next) {
1041        fprintf(stderr,"OpTId %hu (sourceId: %lu) >\n",
1042                tmpOP->templateOptionId,
1043                tmpOP->sourceId);
1044        printFieldSet(stderr, tmpOP->fieldSet);
1045        fprintf(stderr,"\n");
1046      }
1047      fprintf(stderr,"\n");
1048    }
1049  }
1050}
1051
1052
1053/*
1054 * writeAllTplFlSet
1055 *
1056 */
1057void
1058writeAllTplFlSet()
1059{
1060
1061  RouterPtr tmp = routersListPtr;
1062  TplFlowSetPtr tmpFS;
1063  TplOptionPtr tmpOP;
1064  FILE *TPLFILE;
1065  if (!(TPLFILE = fopen("/tmp/TemplateDefSMP3.txt", "w"))) {
1066    syslog (LOG_ERR, "error during %s opening", "/tmp/TemplateDefSMP3.txt");
1067  }
1068  for (; tmp; tmp=tmp->next) {
1069    tmpFS =  tmp->tplList;
1070    for (; tmpFS; tmpFS=tmpFS->next) {
1071      fprintf(TPLFILE,"%lu.%lu.%lu.%lu TId %hu %lu ",
1072              (tmp->IpAddress>>24),
1073              (tmp->IpAddress<<8>>24),
1074              (tmp->IpAddress<<16>>24),
1075              (tmp->IpAddress<<24>>24),
1076              tmpFS->templateFlowSetId,
1077              tmpFS->sourceId);
1078      printFieldSet(TPLFILE, tmpFS->fieldSet);
1079      fprintf(TPLFILE,"\n");
1080    }
1081    if ((tmpOP = tmp->tplOptList) != NULL){
1082      for (; tmpOP; tmpOP=tmpOP->next) {
1083        fprintf(TPLFILE,"%lu.%lu.%lu.%lu OpTId %hu %lu %d %hu %hu %hu ",
1084                (tmp->IpAddress>>24),
1085                (tmp->IpAddress<<8>>24),
1086                (tmp->IpAddress<<16>>24),
1087                (tmp->IpAddress<<24>>24),
1088                tmpOP->templateOptionId,
1089                tmpOP->sourceId,
1090                tmpOP->optionScopeLg/4, /* last x brackets are scope */
1091                tmpOP->length,
1092                tmpOP->optionScopeLg,
1093                tmpOP->optionLg);
1094        printFieldSet(TPLFILE, tmpOP->fieldSet);
1095        fprintf(TPLFILE,"\n");
1096      }
1097      /*      fprintf(TPLFILE,"\n");*/
1098    }
1099  }
1100  fclose(TPLFILE);
1101}
1102
1103/*
1104 * initMIB
1105 */
1106int initMIB(struct RenetcolMIB *theMIB)
1107{
1108  theMIB->ipPacketNb = 0;
1109  theMIB->udpPacketNb = 0;
1110  theMIB->v9PacketNb = 0;
1111  theMIB->v9UnSeqNb = 0;
1112  theMIB->flowSetNb = 0;
1113  theMIB->dataFlowSetNb = 0;
1114  theMIB->defFlowSetNb = 0;
1115  theMIB->optDataFlowSetNb = 0;
1116  theMIB->optDefFlowSetNb = 0;
1117  theMIB->flowNb = 0;
1118  theMIB->realFlowNb = 0;
1119  theMIB->ipv4Bytes = 0;
1120  theMIB->ipv4Pckts = 0;
1121  theMIB->ipv4Flow = 0;
1122  theMIB->ipv4IcmpFlowNb = 0;
1123  theMIB->ipv4IcmpBytesNb = 0;
1124  theMIB->ipv4IcmpPktsNb = 0;
1125  theMIB->ipv4UDPFlowNb = 0;
1126  theMIB->ipv4UDPBytesNb = 0;
1127  theMIB->ipv4UDPPktsNb = 0;
1128  theMIB->ipv4TCPFlowNb = 0;
1129  theMIB->ipv4TCPBytesNb = 0;
1130  theMIB->ipv4TCPPktsNb = 0;
1131  theMIB->ipv4OthersFlowNb = 0;
1132  theMIB->ipv4OthersBytesNb = 0;
1133  theMIB->ipv4OthersPktsNb = 0;
1134  theMIB->ipv4FlowSizePcktsE1 = 0;
1135  theMIB->ipv4FlowSizePcktsLT10 = 0;
1136  theMIB->ipv4FlowSizePcktsLT100 = 0;
1137  theMIB->ipv4FlowSizePcktsLT1k = 0;
1138  theMIB->ipv4FlowSizePcktsLT10k = 0;
1139  theMIB->ipv4FlowSizePcktsMT10k = 0;
1140  theMIB->ipv4FlowSizeBytesLT50 = 0;
1141  theMIB->ipv4FlowSizeBytesLT100 = 0;
1142  theMIB->ipv4FlowSizeBytesLT1k = 0;
1143  theMIB->ipv4FlowSizeBytesLT10k = 0;
1144  theMIB->ipv4FlowSizeBytesLT100k = 0;
1145  theMIB->ipv4FlowSizeBytesLT1M = 0;
1146  theMIB->ipv4FlowSizeBytesLT10M = 0;
1147  theMIB->ipv4FlowSizeBytesLT100M = 0;
1148  theMIB->ipv4FlowSizeBytesMT100M = 0;
1149  theMIB->ipv4WebBytesNb = 0;
1150  theMIB->ipv4WebPcktsNb = 0;
1151  theMIB->ipv4WebFlowNb = 0;
1152  theMIB->ipv4DNSBytesNb = 0;
1153  theMIB->ipv4DNSPcktsNb = 0;
1154  theMIB->ipv4DNSFlowNb = 0;
1155  theMIB->ipv4OthersApBytesNb = 0;
1156  theMIB->ipv4OthersApPcktsNb = 0;
1157  theMIB->ipv4OthersApFlowNb = 0;
1158  theMIB->ipv6Bytes = 0;
1159  theMIB->ipv6Pckts = 0;
1160  theMIB->ipv6Flow = 0;
1161  theMIB->ipv6IcmpFlowNb = 0;
1162  theMIB->ipv6IcmpBytesNb = 0;
1163  theMIB->ipv6IcmpPktsNb = 0;
1164  theMIB->ipv6UDPFlowNb = 0;
1165  theMIB->ipv6UDPBytesNb = 0;
1166  theMIB->ipv6UDPPktsNb = 0;
1167  theMIB->ipv6TCPFlowNb = 0;
1168  theMIB->ipv6TCPBytesNb = 0;
1169  theMIB->ipv6TCPPktsNb = 0;
1170  theMIB->ipv6OthersFlowNb = 0;
1171  theMIB->ipv6OthersBytesNb = 0;
1172  theMIB->ipv6OthersPktsNb = 0;
1173  theMIB->ipv6FlowSizePcktsE1 = 0;
1174  theMIB->ipv6FlowSizePcktsLT10 = 0;
1175  theMIB->ipv6FlowSizePcktsLT100 = 0;
1176  theMIB->ipv6FlowSizePcktsLT1k = 0;
1177  theMIB->ipv6FlowSizePcktsLT10k = 0;
1178  theMIB->ipv6FlowSizePcktsMT10k = 0;
1179  theMIB->ipv6FlowSizeBytesLT50 = 0;
1180  theMIB->ipv6FlowSizeBytesLT100 = 0;
1181  theMIB->ipv6FlowSizeBytesLT1k = 0;
1182  theMIB->ipv6FlowSizeBytesLT10k = 0;
1183  theMIB->ipv6FlowSizeBytesLT100k = 0;
1184  theMIB->ipv6FlowSizeBytesLT1M = 0;
1185  theMIB->ipv6FlowSizeBytesLT10M = 0;
1186  theMIB->ipv6FlowSizeBytesLT100M = 0;
1187  theMIB->ipv6FlowSizeBytesMT100M = 0;
1188  theMIB->ipv6WebBytesNb = 0;
1189  theMIB->ipv6WebPcktsNb = 0;
1190  theMIB->ipv6WebFlowNb = 0;
1191  theMIB->ipv6DNSBytesNb = 0;
1192  theMIB->ipv6DNSPcktsNb = 0;
1193  theMIB->ipv6DNSFlowNb = 0;
1194  theMIB->ipv6OthersApBytesNb = 0;
1195  theMIB->ipv6OthersApPcktsNb = 0;
1196  theMIB->ipv6OthersApFlowNb = 0;
1197  return 1;
1198}
Note: See TracBrowser for help on using the browser.