root/trunk/src/renetcol.c @ 22

Revision 22, 17.7 KB (checked in by andreu, 16 years ago)

aggregation et timer

  • Property svn:eol-style set to native
Line 
1/*
2 * File: renetcol.c
3 *
4 * Authors: ANDREU François-Xavier
5 *
6 * Copyright (C) 2005 GIP RENATER
7 */
8
9/*  This file is part of renetcol.
10 *
11 *  renetcol is free software; you can redistribute it and/or modify
12 *  it under the terms of the GNU General Public License as published by
13 *  the Free Software Foundation; either version 2 of the License, or
14 *  (at your option) any later version.
15 *
16 *  renetcol is distributed in the hope that it will be useful,
17 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 *  GNU General Public License for more details.
20 *
21 *  You should have received a copy of the GNU General Public License
22 *  along with renetcol; if not, write to the Free Software
23 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 */
25
26#include "renetcol.h"
27
28/* #ifdef CRIHAN */
29struct IPFLowCache tabIP[MAX_IP_FLOW], *tabIPPtr = tabIP;
30struct MPLSFlowCache tabMPLS[MAX_MPLS_FLOW], *tabMPLSPtr = tabMPLS;
31unsigned long ipNb = 0; /* counter of IP flows number */
32unsigned long mplsNb = 0; /* counter of MPLS flow number */
33unsigned long *ipNbPtr = &ipNb;
34unsigned long *mplsNbPtr = &mplsNb;
35unsigned short currentIPOutputFile = 0; /* index on the current IP file */
36unsigned short currentMPLSOutputFile = 0; /* index on the current MPLS file */
37char outputName[256];
38char cof_str[20]; /* current ouput file name */
39FILE *fIP; /* pointer on the IP output file */
40FILE *fMPLS; /* pointer on the MPLS output file */
41/* #endif */
42
43char *rulesFileName; /* file name of the rules (like acl) */
44char *configFileName;  /* file name where routers list is */
45char *prefixV4FileName;  /* IPv4 prefix list */
46
47struct sigaction myAction; /* handler for renetcolSender communication */
48sigjmp_buf contextSigalrm; /* '' */
49volatile sig_atomic_t sigusr1Up = 0;
50/* struct sigaction myAction;  for timer not used in this version */
51
52unsigned short currentIntervalle = 0; /* based on 5 min intervalles */ 
53
54unsigned short offsetV9 = 0; /* index in a neflow v9 packet */
55unsigned short *offsetV9Ptr = &offsetV9;
56
57unsigned char buffer1;
58unsigned char buffer2[2];
59unsigned char buffer4[4];
60unsigned char buffer6[6];
61
62short currentFlowsetNumber;
63short *currentFlowsetNumberPtr = &currentFlowsetNumber;
64short currentFlowsetId;
65short *currentFlowsetIdPtr = &currentFlowsetId;
66TplFlowSetPtr curTplFlSetPtr; /* current template flowset pointer */
67TplOptionPtr curTplOptionPtr;
68RouterPtr routersListPtr;
69RouterPtr currentRouterPtr;
70DatagramPtr pcktPtr;
71unsigned long sortedRouterList[ROUTER_INDEX_MAX];
72unsigned long indexedRouterList[ROUTER_INDEX_MAX];
73int routerNb = 0; /* routers number */
74unsigned short v4PrefixNb = 0; /* IPv4 prefix number */
75struct PrefixV4 prefixV4Tab[MAX_IPV4_PREFIX]; /* IPv4 prefix structure */
76RulesPtr rulesListPtr; /* Rules list */
77NetFlowV9HeaderPtr currentHeaderV9Ptr;
78key_t myKey = 0; /* FIXME to delete in futur */
79int myQueue = 0; /* FIXME to delete in futur */
80
81/* Next structure used as cache in rules reading */
82RuleDefPtr rulesAddress[FIELD_TYPE_NUMBER+1][MAX_RULES_PER_FIELD];
83RuleDefPtr *rulesAddressPtr;
84
85int reInitConf = 0;
86
87static unsigned long datagramNumber;
88
89static time_t lastRock;
90static struct tm *tmPtr;
91
92static unsigned long myHost; /* FIXME to erase */
93extern int errno;
94static int inputSock;
95static int sockNamelg;
96static int inputSock2;
97static int sockNameFromlg;
98static int rcv;
99static int sockBufSize = SOCKET_BUFFER_SIZE;           
100/* static unsigned short flowNumber; */
101static unsigned short receptPort = RECEPTION_PORT;
102static unsigned char *ptr_buffer;
103static char *receptAddress = RECEPTION_ADDRESS;
104static struct sockaddr_in name;
105static struct sockaddr_in name2;
106static struct sockaddr_in fromName;
107
108/*
109 * Main
110 * ----
111 */
112int 
113main (int argc, char *argv[])
114{
115  RulesPtr tmp = NULL;
116
117  if ( argc != 4) {
118    fprintf (stderr,
119             "%s: Usage: %s <routers file> <prefix IPv4 file> <rules file>\n exp: %s routers.txt IPv4_prefix.txt rules.txt\n",
120             argv[0], argv[0], argv[0]);
121    exit(1);
122  }
123
124#ifdef CRIHAN
125  fprintf(stderr, "renetcol compilation with CRIHAN feature enable\n");
126#endif
127#ifdef IPV4AGG
128  fprintf(stderr, "renetcol compilation and execution with IPv4 Aggregation feature enable\n");
129#endif
130 
131  openlog(argv[0], LOG_PID, LOG_USER);
132 
133  configFileName = (char *) malloc((strlen(argv[1])+1) * sizeof(char));
134  strcpy (configFileName, argv[1]);
135  prefixV4FileName = (char *) malloc((strlen(argv[2])+1) * sizeof(char));
136  strcpy (prefixV4FileName, argv[2]);
137  rulesFileName = (char *) malloc((strlen(argv[3])+1) * sizeof(char));
138  strcpy (rulesFileName, argv[3]);
139
140  initCache();
141  fprintf(stderr, "reading the routers list\n");
142  routerNb = getRegisteredRouters(configFileName, &sortedRouterList[0],
143                                  &indexedRouterList[0]);
144  fprintf(stderr, "reading the IPv4 prefix\n");
145  if ( (v4PrefixNb = getPrefixV4(prefixV4FileName, &prefixV4Tab[0])) < 1){
146    fprintf(stderr, "Error during prefix v4 reading\n");
147    exit(1);
148  }
149  rulesListPtr = NULL;
150  fprintf(stderr, "reading the rules\n");
151  rulesListPtr = getLightRules(rulesListPtr, rulesFileName);
152  tmp = rulesListPtr;
153  for ( ; tmp->next; tmp=tmp->next) {
154    if (tmp->type != 2) {
155      rulesListPtr = delRule(tmp, rulesListPtr);
156    }
157  }
158/*   printRule(rulesListPtr); */
159/*   exit(1); */
160
161  fprintf(stderr, "I become a deamon, next messages via syslogd.\n");
162  if (fork () != 0)
163    exit (0);
164  if (setsid() == -1){
165    exit(4);
166  }
167
168  /* handler, SIGUSR1 from renetcolSender */
169  myAction.sa_handler = sigusr1Mgmt;
170  myAction.sa_flags = SA_RESTART;
171  sigemptyset (&(myAction.sa_mask));
172  sigaddset (&(myAction.sa_mask), SIGALRM);
173  sigaction (SIGUSR1, &myAction, NULL);
174
175  /* Pointer on rules Table */
176  setCache(rulesListPtr);
177  rulesAddressPtr = (RuleDefPtr *)rulesAddress;
178
179  /* init IPC messages queue */
180  myKey = createKey(argv[0]);
181  myQueue = createQueue(myKey);
182  sendMyPid(myQueue);
183
184  /* INIT THE CURRENTS VARIABLES*/
185  currentRouterPtr = routersListPtr;
186  currentHeaderV9Ptr = (NetFlowV9HeaderPtr)
187    malloc(sizeof(struct NetFlowV9Header));
188  pcktPtr = (DatagramPtr) malloc(sizeof(struct Datagram));
189  if (pcktPtr==NULL) {
190    fprintf(stderr, "ERROR in struct Datagram allocation\n");
191    exit(1);
192  } else {
193    pcktPtr->ipH = (IpHeaderPtr) malloc(sizeof(struct IpHeader));
194    pcktPtr->udp_header = (UdpHeaderPtr) malloc(sizeof(struct UdpHeader));
195  }
196
197  if (! (ptr_buffer = malloc(sockBufSize))) 
198    {
199      printf("ERROR during socket buffer allocation\n");
200      exit(2);
201    }
202
203  /* INIT INPUT STREAM*/
204  initStream();
205
206  datagramNumber =0; /* FIXME : ???? */
207
208  socketLoop(); /* all work on datagram is made here */
209  closelog();
210  fprintf(stderr, "END\n");
211  return (0);
212}
213
214/*
215 *
216 */
217void sendMyPid(int queueID)
218{
219  msgType myMsg;
220  char *msgTextIndex;
221  unsigned short tplMsgType = 12;
222  pid_t myPID;
223 
224  myPID = getpid();
225  msgTextIndex = mempcpy(mempcpy(myMsg.text,
226                                 &tplMsgType,
227                                 sizeof (unsigned short)
228                                 ),
229                         &myPID,
230                         sizeof(pid_t)
231                         );
232  myMsg.type = 1;
233  msgSend(queueID, myMsg);
234}
235
236/*
237 *
238 */
239void sendReadRulesSignal(int queueID)
240{
241  msgType myMsg;
242  char *msgTextIndex;
243  unsigned short tplMsgType = 13;
244 
245  msgTextIndex = mempcpy(myMsg.text,
246                         &tplMsgType,
247                         sizeof (unsigned short)
248                         );
249  myMsg.type = 1;
250  msgSend(queueID, myMsg);
251}
252
253/*
254 *
255 */
256void sigusr1Mgmt(int num)
257{
258  sigusr1Up = 1;
259}
260
261/*
262 *
263 */
264void 
265initRule()
266{
267  RulesPtr tmp = NULL;
268  initCache();
269  tmp = rulesListPtr;
270  for ( ; tmp; tmp=tmp->next) {
271    rulesListPtr = delRule(tmp, rulesListPtr);
272  }
273  rulesListPtr = NULL;
274  rulesListPtr = getLightRules(rulesListPtr, rulesFileName);
275  tmp = rulesListPtr;
276  for ( ; tmp; tmp=tmp->next) {
277    if (tmp->type != 2) {
278      rulesListPtr = delRule(tmp, rulesListPtr);
279    }
280  }
281  tmp = NULL;
282  initCache();
283  setCache(rulesListPtr);
284  sendReadRulesSignal(myQueue);
285}
286
287/*
288 *
289 */
290void
291initCache()
292{
293  int i,j;
294  for (i=0; i<FIELD_TYPE_NUMBER+1; i++){
295    for (j=0; j<MAX_RULES_PER_FIELD; j++){
296      rulesAddress[i][j] = NULL;
297    }
298  }
299}
300
301/*
302 * setCache()
303 */
304void
305setCache(RulesPtr rPtr)
306{
307  int i=0;
308  RulesPtr tmp = rPtr;
309  RuleDefPtr def = NULL;
310
311  while (tmp) {
312    def = tmp->def;
313    while (def) {
314      i = 0;
315      while (rulesAddress[def->fieldType][i] != NULL){
316        i++;
317      }
318      rulesAddress[def->fieldType][i] = def;
319      def = def->next;
320    }
321    tmp = tmp->next;
322  }
323}
324
325/*
326 * initStream()
327 */
328void 
329initStream()
330{
331  static unsigned short n0, n1, n2, n3;
332
333  initSocket();
334  if (sscanf(receptAddress,"%hu.%hu.%hu.%hu",&n0,&n1,&n2,&n3)==0) {
335    perror("sscanf");
336  }             
337  buffer4[0] = (unsigned char)n3;
338  buffer4[1] = (unsigned char)n2;
339  buffer4[2] = (unsigned char)n1;
340  buffer4[3] = (unsigned char)n0;
341  myHost = *((unsigned long*)&buffer4[0]);
342}
343
344/*
345 * socketLoop()
346 */
347int 
348socketLoop()
349{
350  unsigned short shift;
351  short version = 0;
352  int regRouter = 0;
353  time_t now = time((time_t *)NULL);
354  int iIP, iMPLS, i;
355  time_t lastIPOutput, lastMPLSOutput;
356  time_t receptionTime;
357
358  now = time((time_t *)NULL);
359  tmPtr = localtime(&now);
360  currentIntervalle = tmPtr->tm_min;
361  lastMPLSOutput = now;
362  lastIPOutput = now;
363  do {
364    if ( ((tmPtr->tm_min)%2 == 0) && (currentIntervalle != tmPtr->tm_min)){
365      printf("We change the table, min : %d\n", tmPtr->tm_min);
366      currentIntervalle = tmPtr->tm_min;
367    }
368    if (sigusr1Up == 1){
369      sigusr1Up = 0;
370      initRule();
371    }
372    socketReading();
373    getIpHeader(pcktPtr, ptr_buffer);
374    regRouter = checkIpHeader(pcktPtr, &sortedRouterList[0], routerNb);
375    getUdpHeader(pcktPtr, ptr_buffer);
376    checkUdpHeader(pcktPtr, regRouter, receptPort);
377   
378    switch( version =
379            getNetFlowHeader(pcktPtr, ptr_buffer,
380                             currentHeaderV9Ptr, offsetV9Ptr)){
381    case 9:
382      if ((currentRouterPtr=notExistRouter(routersListPtr,
383                                           pcktPtr->ipH->srcAdd))==NULL) {
384        routersListPtr = addRouter(routersListPtr,
385                                   pcktPtr->ipH->srcAdd,
386                                   (unsigned long) 0);
387        currentRouterPtr = routersListPtr;
388      }
389      currentFlowsetNumber = 0;
390      shift = 0;
391      while ((currentFlowsetNumber < currentHeaderV9Ptr->count)) {
392        curTplFlSetPtr = NULL;
393        currentFlowsetId=getFlowsetId(currentFlowsetNumber,
394                                      offsetV9Ptr, ptr_buffer);
395        if ( currentFlowsetId == 0 ) {
396          shift = checkTemplateFlowSet(currentRouterPtr, offsetV9Ptr,
397                                       ptr_buffer, currentHeaderV9Ptr,
398                                       curTplFlSetPtr,
399                                       currentFlowsetNumberPtr,
400                                       myQueue);
401          /* FIXME : TplFlSet Def in a file before next release */
402          /* showAllTplFlSet(); */
403        } else if (currentFlowsetId == 1) {
404          shift = checkTemplateOption(currentRouterPtr, offsetV9Ptr,
405                                      ptr_buffer, currentHeaderV9Ptr,
406                                      curTplOptionPtr,
407                                      currentFlowsetNumberPtr);
408        } else {
409          shift = checkDataFlowSet(shift, currentRouterPtr,
410                                   currentHeaderV9Ptr, offsetV9Ptr,
411                                   ptr_buffer, currentFlowsetNumberPtr,
412                                   currentFlowsetIdPtr, pcktPtr,
413                                   rulesAddressPtr, rulesListPtr,
414                                   myQueue, prefixV4Tab,
415                                   (size_t) v4PrefixNb,
416                                   tabIPPtr,
417                                   tabMPLSPtr,
418                                   ipNbPtr, mplsNbPtr);
419        }
420      }
421      break;
422    default:
423      /* FIXME : Uncomment before next release */
424/*        syslog(LOG_INFO,  */
425/*           "NetFlow exp. version unknown: %hu, from router: %lu.%lu.%lu.%lu", */
426/*           (unsigned short) version, */
427/*           (pcktPtr->ipH->srcAdd>>24), */
428/*           (pcktPtr->ipH->srcAdd<<8>>24), */
429/*           (pcktPtr->ipH->srcAdd<<16>>24), */
430/*           (pcktPtr->ipH->srcAdd<<24>>24));  */
431      break;
432    }
433/*     for (i=0; i<v4PrefixNb; i++){ */
434/*       fprintf(stderr, "%lu %llu flows\n", */
435/*            prefixV4Tab[i].beginning, */
436/*            prefixV4Tab[i].flowNb); */
437/*     } */
438
439#ifdef CRIHAN
440    now = time((time_t *)NULL);
441    receptionTime = now;
442    if ( (ipNb > (MAX_IP_FLOW - 50)) ||
443         ( (now-lastIPOutput) > IP_TIME_THRESHOLD) ) {
444      outputName[0] = '\0';
445      sprintf(cof_str, "%d", currentIPOutputFile);
446      strcat(outputName, OUTPUT_IP);
447      strcat(outputName, cof_str);
448      strcat(outputName, EXTENSION);
449      if (fopen(outputName, "x") == NULL) {
450        currentIPOutputFile = (currentIPOutputFile + 1)%MAX_IP_OUTPUT_FILES;
451        outputName[0] = '\0';
452        sprintf(cof_str, "%d", currentIPOutputFile);
453        strcat(outputName, OUTPUT_IP);
454        strcat(outputName, cof_str);
455        strcat(outputName, EXTENSION);
456      }
457      if ((fIP = fopen(outputName, "w")) == NULL) {
458        syslog(LOG_ERR,"Error in OUTPUT_IP opening : %s", strerror(errno));
459      } else {
460        for ( iIP = 0; iIP < ipNb; iIP++){
461          if ( tabIP[iIP].ipProt == 0 ) {
462            fprintf(fIP, "%lu;%lu;%hu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu;%d;%hu;%hu;%d;%d;%lu.%lu.%lu.%lu;%lu;%d\n",
463                    tabIP[iIP].bytes, tabIP[iIP].pkts,
464                    tabIP[iIP].inSnmp,  tabIP[iIP].outSnmp,
465                    tabIP[iIP].v4AdS>>24, tabIP[iIP].v4AdS<<8>>24,
466                    tabIP[iIP].v4AdS<<16>>24, tabIP[iIP].v4AdS<<24>>24,
467                    tabIP[iIP].v4AdD>>24, tabIP[iIP].v4AdD<<8>>24,
468                    tabIP[iIP].v4AdD<<16>>24, tabIP[iIP].v4AdD<<24>>24,
469                    tabIP[iIP].tProt, tabIP[iIP].sPort,
470                    tabIP[iIP].dPort, tabIP[iIP].maskD,
471                    tabIP[iIP].maskS, tabIP[iIP].routerAd>>24,
472                    tabIP[iIP].routerAd<<8>>24, tabIP[iIP].routerAd<<16>>24,
473                    tabIP[iIP].routerAd<<24>>24, tabIP[iIP].liveTime,
474                    receptionTime
475                    );
476          }
477        }
478        fclose(fIP);
479      }
480      ipNb = 0;
481      lastIPOutput = now;
482    }
483    now = time((time_t *)NULL);
484    if ( mplsNb > (MAX_MPLS_FLOW - 50) ||
485         ( (now-lastMPLSOutput) > MPLS_TIME_THRESHOLD) ) {
486      outputName[0] = '\0';
487      sprintf(cof_str, "%d", currentMPLSOutputFile);
488      strcat(outputName, OUTPUT_MPLS);
489      strcat(outputName, cof_str);
490      strcat(outputName, EXTENSION);
491      if (fopen(outputName, "x") == NULL) {
492        currentMPLSOutputFile = (currentMPLSOutputFile + 1)%MAX_MPLS_OUTPUT_FILES;
493        outputName[0] = '\0';
494        sprintf(cof_str, "%d", currentMPLSOutputFile);
495        strcat(outputName, OUTPUT_MPLS);
496        strcat(outputName, cof_str);
497        strcat(outputName, EXTENSION);
498      }
499      if ((fMPLS = fopen(outputName, "w")) == NULL) {
500        syslog(LOG_ERR,"Error in OUTPUT_MPLS opening : %s", strerror(errno));
501      } else {
502        for ( iMPLS = 0; iMPLS < mplsNb; iMPLS++){
503          if ( tabMPLS[iMPLS].ipProt == 0 ) {
504            fprintf(fMPLS, "%lu.%lu.%lu.%lu;%hu;%lu.%lu.%lu.%lu;%lu.%lu.%lu.%lu\n",
505                    tabMPLS[iMPLS].routerAd>>24,tabMPLS[iMPLS].routerAd<<8>>24,
506                    tabMPLS[iMPLS].routerAd<<16>>24,
507                    tabMPLS[iMPLS].routerAd<<24>>24,
508                    tabMPLS[iMPLS].mplsLabel1,tabMPLS[iMPLS].v4AdS>>24,
509                    tabMPLS[iMPLS].v4AdS<<8>>24,tabMPLS[iMPLS].v4AdS<<16>>24,
510                    tabMPLS[iMPLS].v4AdS<<24>>24,tabMPLS[iMPLS].v4AdD>>24,
511                    tabMPLS[iMPLS].v4AdD<<8>>24,tabMPLS[iMPLS].v4AdD<<16>>24,
512                    tabMPLS[iMPLS].v4AdD<<24>>24
513                    );
514          }
515        }
516        fclose(fMPLS);
517      }
518      mplsNb = 0;
519      lastMPLSOutput = now;
520    }
521#endif /* CRIHAN */
522    now = time((time_t *)NULL);
523    tmPtr = localtime(&now);
524  } while (1);
525}
526
527/*
528 * initSocket()
529 */
530short 
531initSocket()
532{
533  inputSock = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
534  if (inputSock < 0)
535    {
536      syslog(LOG_ERR,"socket : %s", strerror(errno));
537      exit(1);
538    }
539  memset((void*)&name, 0, sizeof(name));
540  name.sin_family = AF_INET;
541  name.sin_addr.s_addr = htonl(INADDR_ANY);
542  if (name.sin_addr.s_addr == INADDR_NONE){
543    syslog(LOG_ERR, " INADDR_NONE ");
544    exit(1);
545  }
546  name.sin_port = htons(receptPort);
547  if (bind(inputSock,(struct sockaddr *)(&name), sizeof(name)) < 0)
548    {
549      syslog(LOG_ERR, "bind : %s", strerror(errno));
550      exit(1);
551    }                                                           
552  sockNamelg = sizeof(name);
553  if (getsockname(inputSock, (struct sockaddr *) (&name),
554                  (socklen_t *)&sockNamelg) < 0)
555    {
556      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
557      exit(1);
558    }
559  /* Here socket DGRAM creation, only to not have a unreachable service */
560  inputSock2 = socket(AF_INET, SOCK_DGRAM, 0);
561  if (inputSock2 < 0)
562    {
563      syslog(LOG_ERR,"socket : %s", strerror(errno));
564      exit(1);
565    }
566  memset((void*)&name, 0, sizeof(name));
567  name2.sin_family = AF_INET;
568  name2.sin_addr.s_addr = htonl(INADDR_ANY);
569  if (name2.sin_addr.s_addr == INADDR_NONE){
570    syslog(LOG_ERR, " INADDR_NONE ");
571    exit(1);
572  }
573  name2.sin_port = htons(receptPort);
574  if (bind(inputSock2,(struct sockaddr *)(&name2), sizeof(name2)) < 0)
575    {
576      syslog(LOG_ERR, "bind : %s", strerror(errno));
577      exit(1);
578    }                                                           
579  sockNamelg = sizeof(name2);
580  if (getsockname(inputSock2, (struct sockaddr *) (&name2),
581                  (socklen_t *)&sockNamelg) < 0)
582    {
583      syslog(LOG_ERR, "getsockname: %s", strerror(errno));
584      exit(1);
585    }
586  return(0);
587}
588
589
590/*
591 * init socket
592 */
593short 
594socketReading()
595{
596  signed short sockLg;
597
598  sockNameFromlg = sizeof(fromName);
599  rcv = recvfrom(inputSock, ptr_buffer, sockBufSize, 0,
600                 (struct sockaddr *)(&fromName),
601                 (socklen_t *)&sockNameFromlg);   
602  sockLg = rcv;
603  if (sockLg < 0) {
604    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
605    exit(1);
606  }
607  if (sockLg == 0) {
608    syslog(LOG_ERR,"recvfrom : %s", strerror(errno));
609    exit(1);
610  }
611  return(0);
612}
613 
614/*
615 * check up flow datagramme
616 */
617short 
618checkFlow(short flowNumber)
619{
620  return(0);
621}
622
623/*
624 * showAllTplFlSet
625 *
626 */
627void 
628showAllTplFlSet()
629{
630  RouterPtr tmp = routersListPtr;
631  TplFlowSetPtr tmpFS;
632  TplOptionPtr tmpOP;
633  fprintf(stderr,"\n*********************************************\n* All template definitions: (field, size) : *\n*********************************************\n");
634  for (; tmp; tmp=tmp->next) {
635    fprintf(stderr,"----------------------\nrouter %lu.%lu.%lu.%lu : \n----------------------\n",
636            (tmp->IpAddress>>24),
637            (tmp->IpAddress<<8>>24),
638            (tmp->IpAddress<<16>>24),
639            (tmp->IpAddress<<24>>24));
640    tmpFS =  tmp->tplList;
641    for (; tmpFS; tmpFS=tmpFS->next) {
642      fprintf(stderr,"TId %hu (sourceId: %lu):\n",
643              tmpFS->templateFlowSetId,
644              tmpFS->sourceId);
645      printFieldSet(tmpFS->fieldSet);
646      fprintf(stderr,"\n");
647    }
648    if ((tmpOP = tmp->tplOptList) != NULL){
649      for (; tmpOP; tmpOP=tmpOP->next) {
650        fprintf(stderr,"OpTId %hu (sourceId: %lu) >\n",
651                tmpOP->templateOptionId,
652                tmpOP->sourceId);
653        printFieldSet(tmpOP->fieldSet);
654        fprintf(stderr,"\n");
655      }
656      fprintf(stderr,"\n");
657    }
658  }
659}
Note: See TracBrowser for help on using the browser.