root/branches/renetcolSMP/src/renetcolSMP4.c

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

RECORDFLOW option

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