1 /*
2 * Copyright (c) 2002 Mark Fullmer and The Ohio State University
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: ftstat.c,v 1.44 2005/05/10 15:48:12 maf Exp $
27 */
28
29 #include "ftconfig.h"
30 #include "ftlib.h"
31
32 #include <sys/time.h>
33 #include <sys/types.h>
34 #include <sys/wait.h>
35 #include <sys/uio.h>
36 #include <sys/socket.h>
37 #include <sys/resource.h>
38 #include <netinet/in.h>
39 #include <arpa/inet.h>
40 #include <sys/stat.h>
41 #include <ctype.h>
42 #include <stddef.h>
43 #include <syslog.h>
44 #include <dirent.h>
45 #include <limits.h>
46 #include <unistd.h>
47 #include <stdio.h>
48 #include <stdlib.h>
49 #include <time.h>
50 #include <fcntl.h>
51 #include <zlib.h>
52
53 #if HAVE_STRINGS_H
54 #include <strings.h>
55 #endif
56 #if HAVE_STRING_H
57 #include <string.h>
58 #endif
59
60 #if !HAVE_STRSEP
61 char *strsep (char **, const char *);
62 #endif
63
64 #if HAVE_LL_STRTOUL
65 #define strtoull strtoul
66 #endif /* HAVE_LL_STRTOULL */
67
68 #define FMT_SYM_LEN 64
69
70 /*
71 * **** Datastructures and other implementation notes ***
72 *
73 * Each report requires
74 *
75 * struct ftstat_rpt_n which is allocated dynamically at run time.
76 *
77 * ftstat_rpt_n_new() - allocated ftstat_rpt_n
78 * ftstat_rpt_n_accum() - called for each flow
79 * ftstat_rpt_n_calc() - final calculations after all flows
80 * ftstat_rpt_n_dump() - report to file
81 * ftstat_rpt_n_free() - free storage allocated by ftstat_rpt_n_new()
82 * and others during the report run.
83 *
84 * The reports are grouped by a definition. Typically the caller will
85 * invoke all reports in a group by calling ftstat_def_new(),
86 * ftstat_def_accum(), ftstat_def_calc(), ftstat_def_dump(), and
87 * ftstat_def_free().
88 *
89 * The reports in the configuration file are stored in a linked
90 * list of ftstat_rpt with the head in struct ftstat.
91 *
92 * The definitions in the configuration file are stored in a linked
93 * list of ftstat_def with the head in struct ftstat.
94 *
95 * Each definition contains a linked list of ftstat_rpt_item
96 * which points to a report (struct ftstat_rpt).
97 *
98 * Definitions reference reports. Initially the report name is stored
99 * in the definition and then when EOF is reached resolve_reports()
100 * is called to fill in the pointers.
101 *
102 * The config file can reference a filter file and a tag file. These
103 * are loaded when the first tag or filter is specified.
104 *
105 * Each report can have a filter and a definition can have a filter
106 * for all the reports. Configuration of both is allowed.
107 *
108 * Each definition can invoke a tag definition. (add tags)
109 *
110 * Each definition can invoke a mask definition. (replace masks)
111 *
112 * Each report type is defined by the enum ftstat_rpt_type
113 * and then the struct typelookup (tlookup) is used to configure
114 * all the other report specific data items such as its ASCII
115 * name, fields required, function pointers to the report specific
116 * functions, options supported, etc.
117 *
118 * Special note for the *ps (ie min_pps, max_pps, avg_pps, min_bps,
119 * max_bps, avg_bps) calculations. A memory optimization exists that
120 * removes the sizeof struct ftps bytes from the end of all the hash
121 * and bucket allocations (for bucket, they're not allocated). This
122 * means that struct _must_ exist or the subtraction bytes will end
123 * up trashing real data. An example is ftchash_rec_int where the
124 * ftps would never be used, yet it's there so the code that subtracts
125 * it off works properly.
126 *
127 */
128
129 static struct fts3rec_offsets nfo;
130 static uint64_t *sort_i64;
131 static double *sort_idouble;
132
133 #define DUMP_STD_OUT()\
134 if (rpt->out->fields & FT_STAT_FIELD_INDEX) {\
135 len += fmt_uint64(fmt_buf, rpt->idx++, FMT_JUST_LEFT);\
136 comma = 1;\
137 }\
138 if (rpt->out->fields & FT_STAT_FIELD_FIRST) {\
139 if (comma) fmt_buf[len++] = ',';\
140 len += fmt_uint32(fmt_buf+len, rpt->time_start, FMT_JUST_LEFT);\
141 comma = 1;\
142 }\
143 if (rpt->out->fields & FT_STAT_FIELD_LAST) {\
144 if (comma) fmt_buf[len++] = ',';\
145 len += fmt_uint32(fmt_buf+len, rpt->time_end, FMT_JUST_LEFT);\
146 comma = 1;\
147 }\
148
149
150 #define CHASH_DUMP_INIT(A,B)\
151 struct A *B;\
152 struct tally tally;\
153 char fmt_buf1[32], fmt_buf[1024];\
154 int len, fmt, sort_flags, comma;\
155 int sort_offset = 0;\
156 fmt = FMT_JUST_LEFT;\
157 fmt_buf1[0] = fmt_buf[0] = 0;\
158 bzero(&tally, sizeof tally);\
159 tally.t_recs = ftch->entries;\
160 if (rpt->out->options & FT_STAT_OPT_NAMES)\
161 fmt |= FMT_SYM;\
162
163
164 #define CHASH_DUMP_STD_SORT(A) \
165 if (rpt->out->sort_field == FT_STAT_FIELD_FLOWS) {\
166 sort_offset = offsetof(struct A, nflows);\
167 sort_flags |= FT_CHASH_SORT_64;\
168 } else if (rpt->out->sort_field == FT_STAT_FIELD_OCTETS) {\
169 sort_offset = offsetof(struct A, noctets);\
170 sort_flags |= FT_CHASH_SORT_64;\
171 } else if (rpt->out->sort_field == FT_STAT_FIELD_PACKETS) {\
172 sort_offset = offsetof(struct A, npackets);\
173 sort_flags |= FT_CHASH_SORT_64;\
174 } else if (rpt->out->sort_field == FT_STAT_FIELD_DURATION) {\
175 sort_offset = offsetof(struct A, etime);\
176 sort_flags |= FT_CHASH_SORT_64;\
177 } else if (rpt->out->sort_field == FT_STAT_FIELD_AVG_PPS) {\
178 sort_offset = offsetof(struct A, ps.avg_pps);\
179 sort_flags |= FT_CHASH_SORT_DOUBLE;\
180 } else if (rpt->out->sort_field == FT_STAT_FIELD_MIN_PPS) {\
181 sort_offset = offsetof(struct A, ps.min_pps);\
182 sort_flags |= FT_CHASH_SORT_DOUBLE;\
183 } else if (rpt->out->sort_field == FT_STAT_FIELD_MAX_PPS) {\
184 sort_offset = offsetof(struct A, ps.max_pps);\
185 sort_flags |= FT_CHASH_SORT_DOUBLE;\
186 } else if (rpt->out->sort_field == FT_STAT_FIELD_AVG_BPS) {\
187 sort_offset = offsetof(struct A, ps.avg_bps);\
188 sort_flags |= FT_CHASH_SORT_DOUBLE;\
189 } else if (rpt->out->sort_field == FT_STAT_FIELD_MIN_BPS) {\
190 sort_offset = offsetof(struct A, ps.min_bps);\
191 sort_flags |= FT_CHASH_SORT_DOUBLE;\
192 } else if (rpt->out->sort_field == FT_STAT_FIELD_MAX_BPS) {\
193 sort_offset = offsetof(struct A, ps.max_bps);\
194 sort_flags |= FT_CHASH_SORT_DOUBLE;\
195 } else {\
196 fterr_errx(1,"chash_xxx_dump(): internal error");\
197 }
198
199 #define CHASH_STD_OUT(A,B)\
200 if ((rpt->out->options & FT_STAT_OPT_TALLY) && tally.rt_recs &&\
201 (!(tally.rt_recs % rpt->out->tally))) {\
202 if (rpt->all_fields & FT_STAT_FIELD_PS)\
203 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f %%avg-bps=%3.3f %%avg-pps=%3.3f\n",\
204 ((double)tally.rt_recs/(double)tally.t_recs)*100,\
205 ((double)tally.rt_flows/(double)rpt->t_flows)*100,\
206 ((double)tally.rt_octets/(double)rpt->t_octets)*100,\
207 ((double)tally.rt_packets/(double)rpt->t_packets)*100,\
208 (((double)tally.ravg_bps/(double)tally.rt_frecs)/\
209 (double)rpt->avg_bps)*100,\
210 (((double)tally.ravg_pps/(double)tally.rt_frecs)/\
211 (double)rpt->avg_pps)*100);\
212 else\
213 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f\n",\
214 ((double)tally.rt_recs/(double)tally.t_recs)*100,\
215 ((double)tally.rt_flows/(double)rpt->t_flows)*100,\
216 ((double)tally.rt_octets/(double)rpt->t_octets)*100,\
217 ((double)tally.rt_packets/(double)rpt->t_packets)*100);\
218 \
219 } /* tally */\
220 tally.rt_flows += A->nflows;\
221 tally.rt_octets += A->noctets;\
222 tally.rt_packets += A->npackets;\
223 tally.rt_recs ++;\
224 tally.rt_frecs += A->nrecs;\
225 if (rpt->all_fields & FT_STAT_FIELD_PS) {\
226 tally.ravg_bps += A->ps.avg_bps * A->nrecs;\
227 tally.ravg_pps += A->ps.avg_pps * A->nrecs;\
228 }\
229 \
230 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {\
231 if (B) fmt_buf[len++] = ',';\
232 len += fmt_uint64(fmt_buf+len, A->nflows, FMT_JUST_LEFT);\
233 comma = 1;\
234 }\
235 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {\
236 if (comma) fmt_buf[len++] = ',';\
237 len += fmt_uint64(fmt_buf+len, A->noctets, FMT_JUST_LEFT);\
238 comma = 1;\
239 }\
240 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {\
241 if (comma) fmt_buf[len++] = ',';\
242 len += fmt_uint64(fmt_buf+len, A->npackets, FMT_JUST_LEFT);\
243 comma = 1;\
244 }\
245 if (rpt->out->fields & FT_STAT_FIELD_DURATION) {\
246 if (comma) fmt_buf[len++] = ',';\
247 len += fmt_uint64(fmt_buf+len, A->etime, FMT_JUST_LEFT);\
248 comma = 1;\
249 }\
250 if (rpt->out->fields & FT_STAT_FIELD_AVG_BPS) {\
251 if (comma) fmt_buf[len++] = ',';\
252 len += sprintf(fmt_buf+len, "%f", A->ps.avg_bps);\
253 comma = 1;\
254 }\
255 if (rpt->out->fields & FT_STAT_FIELD_MIN_BPS) {\
256 if (comma) fmt_buf[len++] = ',';\
257 len += sprintf(fmt_buf+len, "%f", A->ps.min_bps);\
258 comma = 1;\
259 }\
260 if (rpt->out->fields & FT_STAT_FIELD_MAX_BPS) {\
261 if (comma) fmt_buf[len++] = ',';\
262 len += sprintf(fmt_buf+len, "%f", A->ps.max_bps);\
263 comma = 1;\
264 }\
265 if (rpt->out->fields & FT_STAT_FIELD_AVG_PPS) {\
266 if (comma) fmt_buf[len++] = ',';\
267 len += sprintf(fmt_buf+len, "%f", A->ps.avg_pps);\
268 comma = 1;\
269 }\
270 if (rpt->out->fields & FT_STAT_FIELD_MIN_PPS) {\
271 if (comma) fmt_buf[len++] = ',';\
272 len += sprintf(fmt_buf+len, "%f", A->ps.min_pps);\
273 comma = 1;\
274 }\
275 if (rpt->out->fields & FT_STAT_FIELD_MAX_PPS) {\
276 if (comma) fmt_buf[len++] = ',';\
277 len += sprintf(fmt_buf+len, "%f", A->ps.max_pps);\
278 comma = 1;\
279 }\
280 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {\
281 if (comma) fmt_buf[len++] = ',';\
282 len += fmt_uint64(fmt_buf+len, A->nrecs, FMT_JUST_LEFT);\
283 comma = 1;\
284 }\
285 fmt_buf[len++] = '\n';\
286 fmt_buf[len] = 0;\
287 fputs(fmt_buf, fp);\
288 if (rpt->out->records && (tally.rt_recs == rpt->out->records)) {\
289 fprintf(fp, "# stop, hit record limit.\n");\
290 break;\
291 }
292
293 #define CHASH_STDP_OUT(A,B)\
294 if ((rpt->out->options & FT_STAT_OPT_TALLY) && tally.rt_recs &&\
295 (!(tally.rt_recs % rpt->out->tally))) {\
296 if (rpt->all_fields & FT_STAT_FIELD_PS)\
297 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f %%avg-bps=%3.3f %%avg-pps=%3.3f\n",\
298 ((double)tally.rt_recs/(double)tally.t_recs)*100,\
299 ((double)tally.rt_flows/(double)rpt->t_flows)*100,\
300 ((double)tally.rt_octets/(double)rpt->t_octets)*100,\
301 ((double)tally.rt_packets/(double)rpt->t_packets)*100,\
302 (((double)tally.ravg_bps/(double)tally.rt_frecs)/\
303 (double)rpt->avg_bps)*100,\
304 (((double)tally.ravg_pps/(double)tally.rt_frecs)/\
305 (double)rpt->avg_pps)*100);\
306 else\
307 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f\n",\
308 ((double)tally.rt_recs/(double)tally.t_recs)*100,\
309 ((double)tally.rt_flows/(double)rpt->t_flows)*100,\
310 ((double)tally.rt_octets/(double)rpt->t_octets)*100,\
311 ((double)tally.rt_packets/(double)rpt->t_packets)*100);\
312 \
313 } /* tally */\
314 tally.rt_flows += A->nflows;\
315 tally.rt_octets += A->noctets;\
316 tally.rt_packets += A->npackets;\
317 tally.ravg_bps += A->ps.avg_bps * A->nrecs;\
318 tally.ravg_pps += A->ps.avg_pps * A->nrecs;\
319 tally.rt_recs ++;\
320 tally.rt_frecs += A->nrecs;\
321 \
322 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {\
323 if (B) fmt_buf[len++] = ',';\
324 len += sprintf(fmt_buf+len, "%f",\
325 ((double)A->nflows / (double)rpt->t_flows)*100.0);\
326 comma = 1;\
327 }\
328 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {\
329 if (comma) fmt_buf[len++] = ',';\
330 len += sprintf(fmt_buf+len, "%f",\
331 ((double)A->noctets / (double)rpt->t_octets)*100.0);\
332 comma = 1;\
333 }\
334 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {\
335 if (comma) fmt_buf[len++] = ',';\
336 len += sprintf(fmt_buf+len, "%f",\
337 ((double)A->npackets / (double)rpt->t_packets)*100.0);\
338 comma = 1;\
339 }\
340 if (rpt->out->fields & FT_STAT_FIELD_DURATION) {\
341 if (comma) fmt_buf[len++] = ',';\
342 len += sprintf(fmt_buf+len, "%f",\
343 ((double)A->etime / (double)rpt->t_duration)*100.0);\
344 comma = 1;\
345 }\
346 if (rpt->out->fields & FT_STAT_FIELD_AVG_BPS) {\
347 if (comma) fmt_buf[len++] = ',';\
348 len += sprintf(fmt_buf+len, "%f",\
349 ((double)A->ps.avg_bps / (double)rpt->avg_bps)*100.0);\
350 comma = 1;\
351 }\
352 if (rpt->out->fields & FT_STAT_FIELD_MIN_BPS) {\
353 if (comma) fmt_buf[len++] = ',';\
354 len += sprintf(fmt_buf+len, "%f",\
355 ((double)A->ps.min_bps / (double)rpt->min_bps)*100.0);\
356 comma = 1;\
357 }\
358 if (rpt->out->fields & FT_STAT_FIELD_MAX_BPS) {\
359 if (comma) fmt_buf[len++] = ',';\
360 len += sprintf(fmt_buf+len, "%f",\
361 ((double)A->ps.max_bps / (double)rpt->max_bps)*100.0);\
362 comma = 1;\
363 }\
364 if (rpt->out->fields & FT_STAT_FIELD_AVG_PPS) {\
365 if (comma) fmt_buf[len++] = ',';\
366 len += sprintf(fmt_buf+len, "%f",\
367 ((double)A->ps.avg_pps / (double)rpt->avg_pps)*100.0);\
368 comma = 1;\
369 }\
370 if (rpt->out->fields & FT_STAT_FIELD_MIN_PPS) {\
371 if (comma) fmt_buf[len++] = ',';\
372 len += sprintf(fmt_buf+len, "%f",\
373 ((double)A->ps.min_pps / (double)rpt->min_pps)*100.0);\
374 comma = 1;\
375 }\
376 if (rpt->out->fields & FT_STAT_FIELD_MAX_PPS) {\
377 if (comma) fmt_buf[len++] = ',';\
378 len += sprintf(fmt_buf+len, "%f",\
379 ((double)A->ps.max_pps / (double)rpt->max_pps)*100.0);\
380 comma = 1;\
381 }\
382 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {\
383 if (comma) fmt_buf[len++] = ',';\
384 len += fmt_uint64(fmt_buf+len, A->nrecs, FMT_JUST_LEFT);\
385 comma = 1;\
386 }\
387 fmt_buf[len++] = '\n';\
388 fmt_buf[len] = 0;\
389 fputs(fmt_buf, fp);\
390 if (rpt->out->records && (tally.rt_recs == rpt->out->records)) {\
391 fprintf(fp, "# stop, hit record limit.\n");\
392 break;\
393 }
394
395 #define NEXT_WORD(A,B)\
396 for (;;) {\
397 B = strsep(A, " \t");\
398 if ((B && *B != 0) || (!B))\
399 break;\
400 }\
401
402 /*
403 * A = ftstat_rpt_n (struct to allocate)
404 * B = rptn (local var name for A)
405 * C = hash bits
406 * D = size of hash record (passed to sizeof (struct)
407 * E = size of hash key
408 * F = num hash recs in a chunk
409 *
410 */
411 #define STD_NEW_HASH(A,B,C,D,E,F)\
412 struct A *B;\
413 int slen;\
414 if (!(B = (struct A*)malloc(sizeof (*B)))) {\
415 fterr_warnx("malloc(rpt): failed");\
416 return (struct A*)0L;\
417 }\
418 bzero(B, sizeof *B);\
419 if (rpt->all_fields & FT_STAT_FIELD_PS)\
420 slen = sizeof (struct D);\
421 else\
422 slen = sizeof (struct D) - sizeof (struct ftps);\
423 if (!(B->ftch = ftchash_new(C, slen, E, F))) {\
424 free(B);\
425 fterr_warnx("ftchash_new(): failed");\
426 return (struct A*)0L;\
427 }\
428 return B;\
429
430 /*
431 * A = ftstat_rpt_n (struct to allocate)
432 * B = rptn (local var name for A)
433 * C = bucket size
434 *
435 */
436 #define STD_NEW_BUCKET(A,B,C,D)\
437 struct A *B;\
438 if (!(B = (struct A*)malloc(sizeof (*B)))) {\
439 fterr_warnx("malloc(rpt): failed");\
440 return (struct A*)0L;\
441 }\
442 bzero(B, sizeof *B);\
443 if (bucket_alloc(&B->bucket, (uint32_t)C, D)) {\
444 fterr_warnx("bucket_alloc(): failed");\
445 free(B);\
446 return (struct A*)0L;\
447 }\
448 return B;\
449
450 #define STD_CALC_BUCKET(A,B,C)\
451 struct A *B;\
452 register int i;\
453 if (rpt->t_recs)\
454 rpt->avg_pps /= (double)rpt->t_recs;\
455 if (rpt->t_recs)\
456 rpt->avg_bps /= (double)rpt->t_recs;\
457 B = rpt->data;\
458 for (i = 0; i < C; ++i) {\
459 if ((B->bucket.duration[i]) && (rpt->all_fields & FT_STAT_FIELD_PS)) {\
460 B->bucket.avg_pps[i] /= (double)B->bucket.recs[i];\
461 B->bucket.avg_bps[i] /= (double)B->bucket.recs[i];\
462 }\
463 if (B->bucket.packets[i])\
464 rpt->recs ++;\
465 }\
466 return 0;\
467
468 /*
469 * A = ftstat_rpt_n
470 * B = rptn (local var name for A)
471 * C = ftchash_rec_x
472 * D = ftch_recn (local var name for C)
473 * note rpt_66, 67 have this expanded by hand
474 */
475 #define STD_CALC_HASH(A,B,C,D)\
476 struct C *D;\
477 struct A *B;\
478 B = rpt->data;\
479 if (rpt->t_recs)\
480 rpt->avg_pps /= (double)rpt->t_recs;\
481 if (rpt->t_recs)\
482 rpt->avg_bps /= (double)rpt->t_recs;\
483 rpt->recs = B->ftch->entries;\
484 if (rpt->all_fields & FT_STAT_FIELD_PS) {\
485 ftchash_first(B->ftch);\
486 while ((D = ftchash_foreach(B->ftch))) {\
487 if (D->etime) {\
488 D->ps.avg_pps /= (double)D->nrecs;\
489 D->ps.avg_bps /= (double)D->nrecs;\
490 }\
491 }\
492 }\
493 return 0;
494
495 #define STD_FREE_BUCKET(A)\
496 if (A) {\
497 bucket_free(&A->bucket);\
498 free(A);\
499 }\
500
501 #define STD_FREE_HASH(A)\
502 if (A) {\
503 if (A->ftch)\
504 ftchash_free(A->ftch);\
505 free (A);\
506 }\
507
508 /*
509 * A = ftstat_rpt_n
510 * B = rptn (local var name for A)
511 * D = size of bucket
512 * KEY* = ascii key name
513 */
514 #define STD_DUMP_BUCKET(A,B,C,SYM,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
515 struct A *B;\
516 B = rpt->data;\
517 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4,KEY5,KEY6);\
518 bucket_dump1(fp, rpt, &B->bucket, C, SYM);\
519 return 0;\
520
521 /*
522 * A = ftstat_rpt_n
523 * B = rptn (local var name for A)
524 * C = hash dump function
525 * KEY* = ascii key name
526 */
527 #define STD_DUMP_HASH0(A,B,C,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
528 struct A *B;\
529 B = rpt->data;\
530 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
531 C(fp, rpt, B->ftch);\
532 return 0;
533
534 #define STD_DUMP_HASH0P(A,B,C,D,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
535 struct A *B;\
536 B = rpt->data;\
537 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
538 C(fp, rpt, B->ftch, D);\
539 return 0;
540
541
542 #define STD_DUMP_HASH1(A,B,C,SYM1,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
543 struct A *B;\
544 B = rpt->data;\
545 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
546 C(fp, rpt, B->ftch, SYM1);\
547 return 0;
548
549 #define STD_DUMP_HASH1P(A,B,C,D,SYM1,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
550 struct A *B;\
551 B = rpt->data;\
552 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
553 C(fp, rpt, B->ftch, SYM1, D);\
554 return 0;
555
556 #define STD_DUMP_HASH2(A,B,C,SYM1,SYM2,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
557 struct A *B;\
558 B = rpt->data;\
559 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
560 C(fp, rpt, B->ftch, SYM1, SYM2);\
561 return 0;
562
563 #define STD_DUMP_HASH2P(A,B,C,D,SYM1,SYM2,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
564 struct A *B;\
565 B = rpt->data;\
566 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
567 C(fp, rpt, B->ftch, SYM1, SYM2, D);\
568 return 0;
569
570 #define STD_DUMP_HASH3(A,B,C,SYM1,SYM2,SYM3,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
571 struct A *B;\
572 B = rpt->data;\
573 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
574 C(fp, rpt, B->ftch, SYM1, SYM2, SYM3);\
575 return 0;
576
577 #define STD_DUMP_HASH4(A,B,C,SYM1,SYM2,SYM3,SYM4,KEY,KEY1,KEY2,KEY3,KEY4,KEY5,KEY6)\
578 struct A *B;\
579 B = rpt->data;\
580 recn_dump(fp, rpt->out->fields, KEY, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6);\
581 C(fp, rpt, B->ftch, SYM1, SYM2, SYM3,SYM4);\
582 return 0;
583
584 #define STD_ACCUM\
585 cur.dFlows64 = 1;\
586 FT_RECGET_LAST(cur,rec,*fo);\
587 FT_RECGET_FIRST(cur,rec,*fo);\
588 FT_RECGET64_DPKTS(cur,rec,*fo);\
589 FT_RECGET64_DOCTETS(cur,rec,*fo);\
590 FT_RECGET_UNIX_SECS(cur,rec,*fo);\
591 if (fo->xfields & FT_XFIELD_DFLOWS) {\
592 FT_RECGET64_DFLOWS(cur,rec,*fo);\
593 } else {\
594 cur.dFlows64 = 1;\
595 }\
596 if (rpt->scale) {\
597 cur.dPkts64 *= rpt->scale;\
598 cur.dOctets64 *= rpt->scale;\
599 }\
600 if (!cur.dPkts64) {\
601 rpt->t_ignores ++;\
602 return 0;\
603 }\
604 if (cur.unix_secs > rpt->time_end)\
605 rpt->time_end = cur.unix_secs;\
606 if (cur.unix_secs < rpt->time_start)\
607 rpt->time_start = cur.unix_secs;\
608 {\
609 duration_tmp = (cur.Last - cur.First);\
610 if (duration_tmp) {\
611 rpt->t_recs ++;\
612 rpt->t_duration += duration_tmp;\
613 if (rpt->all_fields & FT_STAT_FIELD_PS) {\
614 pps_tmp = (double)cur.dPkts64/((double)(duration_tmp)/1000.0);\
615 bps_tmp = (double)cur.dOctets64*8/((double)(duration_tmp)/1000.0);\
616 if (pps_tmp > rpt->max_pps)\
617 rpt->max_pps = pps_tmp;\
618 if ((pps_tmp < rpt->min_pps) || (!rpt->min_pps))\
619 rpt->min_pps = pps_tmp;\
620 rpt->avg_pps += pps_tmp;\
621 if (bps_tmp > rpt->max_bps)\
622 rpt->max_bps = bps_tmp;\
623 if ((bps_tmp < rpt->min_bps) || (!rpt->min_bps))\
624 rpt->min_bps = bps_tmp;\
625 rpt->avg_bps += bps_tmp;\
626 }\
627 }\
628 }\
629 rpt->t_flows += cur.dFlows64;\
630 rpt->t_octets += cur.dOctets64;\
631 rpt->t_packets += cur.dPkts64;\
632
633 #define STD_ACCUM_BUCKET1(A,B)\
634 struct fts3rec_all2 cur;\
635 struct A *B;\
636 uint32_t duration_tmp;\
637 double bps_tmp = 0, pps_tmp = 0;\
638 B = rpt->data;\
639 STD_ACCUM;
640
641 #define STD_ACCUM_BUCKET2(A,B)\
642 if (duration_tmp) {\
643 A.duration[B] += duration_tmp;\
644 A.recs[B] ++;\
645 if (rpt->all_fields & FT_STAT_FIELD_PS) {\
646 if (pps_tmp > A.max_pps[B])\
647 A.max_pps[B] = pps_tmp;\
648 if ((pps_tmp < A.min_pps[B]) || (!A.min_pps[B]))\
649 A.min_pps[B] = pps_tmp;\
650 A.avg_pps[B] += pps_tmp;\
651 if (bps_tmp > A.max_bps[B])\
652 A.max_bps[B] = bps_tmp;\
653 if ((bps_tmp < A.min_bps[B]) || (!A.min_bps[B]))\
654 A.min_bps[B] = bps_tmp;\
655 A.avg_bps[B] += bps_tmp;\
656 }\
657 }\
658 A.flows[B] += cur.dFlows64;\
659 A.octets[B] += cur.dOctets64;\
660 A.packets[B] += cur.dPkts64;\
661
662 #define STD_ACCUM_HASH1(A,B,C,D,E)\
663 struct fts3rec_all2 cur;\
664 struct C D, *E;\
665 struct A *B;\
666 uint32_t hash;\
667 uint32_t duration_tmp;\
668 double bps_tmp, pps_tmp;\
669 bzero(&D, sizeof D);\
670 B = rpt->data;\
671 STD_ACCUM;
672
673 #define STD_ACCUM_HASH2(A,B,C)\
674 if (!(C = ftchash_update(A->ftch, &B, hash))) {\
675 fterr_warnx("ftch_update(): failed");\
676 return -1;\
677 }\
678 STD_ACCUM_INCP(C);\
679
680 #define STD_ACCUM_INCP(A)\
681 if (duration_tmp) {\
682 A->etime += (duration_tmp);\
683 A->nrecs ++;\
684 if (rpt->all_fields & FT_STAT_FIELD_PS) {\
685 if (pps_tmp > A->ps.max_pps)\
686 A->ps.max_pps = pps_tmp;\
687 if ((pps_tmp < A->ps.min_pps) || (!A->ps.min_pps))\
688 A->ps.min_pps = pps_tmp;\
689 A->ps.avg_pps += pps_tmp;\
690 if (bps_tmp > A->ps.max_bps)\
691 A->ps.max_bps = bps_tmp;\
692 if ((bps_tmp < A->ps.min_bps) || (!A->ps.min_bps))\
693 A->ps.min_bps = bps_tmp;\
694 A->ps.avg_bps += bps_tmp;\
695 }\
696 }\
697 A->nflows += cur.dFlows64;\
698 A->noctets += cur.dOctets64;\
699 A->npackets += cur.dPkts64;\
700
701 #define STD_CALC\
702 if (rpt->t_recs)\
703 rpt->avg_pps /= (double)rpt->t_recs;\
704 if (rpt->t_recs)\
705 rpt->avg_bps /= (double)rpt->t_recs;
706
707 #define STD_DUMP_TOTALS_HEADER\
708 if (ftsrpt->all_fields & FT_STAT_FIELD_PS)\
709 fprintf(fp, "# rec1: records,ignores,flows,octets,packets,duration,avg_bps,min_bps,max_bps,avg_pps,min_pps,max_pps\n");\
710 else\
711 fprintf(fp, "# rec1: records,ignores,flows,octets,packets,duration\n");\
712
713 #define STD_DUMP_TOTALS_VAL\
714 fmt_uint64(fmt_buf, ftsrpt->recs, FMT_JUST_LEFT);\
715 strcat(fmt_buf, ",");\
716 fmt_uint64(fmt_tmp, ftsrpt->t_ignores, FMT_JUST_LEFT);\
717 strcat(fmt_buf, fmt_tmp);\
718 strcat(fmt_buf, ",");\
719 fmt_uint64(fmt_tmp, ftsrpt->t_flows, FMT_JUST_LEFT);\
720 strcat(fmt_buf, fmt_tmp);\
721 strcat(fmt_buf, ",");\
722 fmt_uint64(fmt_tmp, ftsrpt->t_octets, FMT_JUST_LEFT);\
723 strcat(fmt_buf, fmt_tmp);\
724 strcat(fmt_buf, ",");\
725 fmt_uint64(fmt_tmp, ftsrpt->t_packets, FMT_JUST_LEFT);\
726 strcat(fmt_buf, fmt_tmp);\
727 strcat(fmt_buf, ",");\
728 fmt_uint64(fmt_tmp, ftsrpt->t_duration, FMT_JUST_LEFT);\
729 strcat(fmt_buf, fmt_tmp);\
730 if (ftsrpt->all_fields & FT_STAT_FIELD_PS) {\
731 fprintf(fp, "%s,%f,%f,%f,%f,%f,%f\n", fmt_buf,\
732 ftsrpt->avg_bps, ftsrpt->min_bps, ftsrpt->max_bps,\
733 ftsrpt->avg_pps, ftsrpt->min_pps, ftsrpt->max_pps);\
734 } else {\
735 fprintf(fp, "%s\n", fmt_buf);\
736 }\
737
738
739 enum ftstat_parse_state { PARSE_STATE_UNSET, PARSE_STATE_REPORT,
740 PARSE_STATE_DEFINITION, PARSE_STATE_OUTPUT };
741
742 #define FT_STAT_OPT_PERCENT 0x001
743 #define FT_STAT_OPT_NAMES 0x002
744 #define FT_STAT_OPT_SORT 0x004
745 #define FT_STAT_OPT_HEADER 0x008
746 #define FT_STAT_OPT_XHEADER 0x010
747 #define FT_STAT_OPT_TOTALS 0x020
748 #define FT_STAT_OPT_TALLY 0x080
749 #define FT_STAT_OPT_TAG_MASK 0x100
750 #define FT_STAT_OPT_SRC_PREFIX_LEN 0x200
751 #define FT_STAT_OPT_SRC_PREFIX_MASK 0x400
752 #define FT_STAT_OPT_DST_PREFIX_LEN 0x800
753 #define FT_STAT_OPT_DST_PREFIX_MASK 0x1000
754 #define FT_STAT_OPT_ALL 0x16FF
755 #define FT_STAT_OPT_GENERIC 0x00FF
756 #define FT_STAT_OPT_GENERIC_IP_ADDR 0x07FF
757 #define FT_STAT_OPT_NONE 0x0
758
759 #define FT_STAT_FIELD_INDEX 0x00000001
760 #define FT_STAT_FIELD_FIRST 0x00000002
761 #define FT_STAT_FIELD_LAST 0x00000004
762
763 #define FT_STAT_FIELD_FLOWS 0x00000010
764 #define FT_STAT_FIELD_OCTETS 0x00000020
765 #define FT_STAT_FIELD_PACKETS 0x00000040
766 #define FT_STAT_FIELD_DURATION 0x00000080
767
768 #define FT_STAT_FIELD_AVG_PPS 0x00000100
769 #define FT_STAT_FIELD_AVG_BPS 0x00000200
770 #define FT_STAT_FIELD_MAX_PPS 0x00000400
771 #define FT_STAT_FIELD_MAX_BPS 0x00000800
772
773 #define FT_STAT_FIELD_MIN_PPS 0x00001000
774 #define FT_STAT_FIELD_MIN_BPS 0x00002000
775 #define FT_STAT_FIELD_OTHER 0x00004000
776 #define FT_STAT_FIELD_KEY 0x00008000 /* reports with a single key */
777
778 #define FT_STAT_FIELD_KEY1 0x00010000
779 #define FT_STAT_FIELD_KEY2 0x00020000
780 #define FT_STAT_FIELD_KEY3 0x00040000
781 #define FT_STAT_FIELD_KEY4 0x00080000
782
783 #define FT_STAT_FIELD_KEY5 0x00100000
784 #define FT_STAT_FIELD_KEY6 0x00200000
785
786 #define FT_STAT_FIELD_COUNT 0x01000000 /* reports that do a count */
787 #define FT_STAT_FIELD_FRECS 0x02000000 /* flow records in report line */
788
789 #define FT_STAT_FIELD_PPS 0x00001500 /* any *_PPS */
790 #define FT_STAT_FIELD_BPS 0x00002A00 /* any *_BPS */
791 #define FT_STAT_FIELD_PS (FT_STAT_FIELD_PPS|FT_STAT_FIELD_BPS)
792
793 #define FT_STAT_FIELD_GENERIC 0x0200FFF7 /* most reports */
794 #define FT_STAT_FIELD_GENERIC2 0x02037FF7 /* reports with 2 key fields */
795 #define FT_STAT_FIELD_GENERIC3 0x02077FF7 /* reports with 3 key fields */
796 #define FT_STAT_FIELD_GENERIC4 0x020F7FF7 /* reports with 4 key fields */
797 #define FT_STAT_FIELD_GENERIC5 0x021F7FF7 /* reports with 5 key fields */
798 #define FT_STAT_FIELD_GENERIC6 0x023F7FF7 /* reports with 6 key fields */
799
800 #define FT_STAT_SORT_ASCEND 0x1
801 #define FT_STAT_SORT_DESCEND 0x2
802
803 struct tally {
804 uint64_t rt_flows, rt_octets, rt_packets, rt_recs, t_recs;
805 double ravg_bps, ravg_pps, rt_frecs;
806 };
807
808 struct flow_bucket {
809 uint64_t *recs, *flows, *octets, *packets, *duration;
810 double *avg_pps, *avg_bps;
811 double *min_pps, *min_bps;
812 double *max_pps, *max_bps;
813 uint32_t *index;
814 }; /* flow_bucket */
815
816 struct line_parser {
817 enum ftstat_parse_state state;
818 struct ftstat_rpt *cur_rpt;
819 struct ftstat_def *cur_def;
820 struct ftstat_rpt_out *cur_rpt_out;
821 int lineno;
822 char *buf, *word;
823 const char *fname;
824 };
825
826 struct jump {
827 char *name;
828 enum ftstat_parse_state state;
829 int (*func)(struct line_parser *lp, struct ftstat *ftstat);
830 };
831
832 struct typelookup {
833 char *name;
834 void* (*f_new)();
835 void* (*f_accum)();
836 void* (*f_calc)();
837 void* (*f_dump)();
838 void* (*f_free)();
839 int allowed_fields; /* FT_STAT_FIELD_* */
840 int allowed_options;/* FT_STAT_OPT_* */
841 uint64_t xfields; /* FT_XFIELD_* */
842 };
843
844 struct ftstat_rpt_1 {
845 uint64_t time; /* total time in 1/1000 of flows */
846
847 double aflowtime; /* average time of flow */
848 double aps; /* average packet size */
849 double afs; /* average flow size */
850 double apf; /* average packets per flow */
851 double fps; /* average flows per second */
852 double fps_real; /* average flows per second (realtime) */
853
854 uint64_t start; /* earliest flow time */
855 uint64_t end; /* latest flow time */
856
857 uint32_t time_start; /* earliest flow (realtime) */
858 uint32_t time_end; /* last flow (realtime) */
859
860 uint32_t time_real; /* realtime duration */
861
862 /* average packet sizes */
863 uint64_t psize32; /* bytes/packet 1 <= p <= 32 */
864 uint64_t psize64; /* bytes/packet 32 < p <= 64 */
865 uint64_t psize96; uint64_t psize128; uint64_t psize160; uint64_t psize192;
866 uint64_t psize224; uint64_t psize256; uint64_t psize288; uint64_t psize320;
867 uint64_t psize352; uint64_t psize384; uint64_t psize416; uint64_t psize448;
868 uint64_t psize480; uint64_t psize512; uint64_t psize544; uint64_t psize576;
869 uint64_t psize1024; uint64_t psize1536; uint64_t psize2048; uint64_t psize2560;
870 uint64_t psize3072; uint64_t psize3584; uint64_t psize4096; uint64_t psize4608;
871
872 /* packets per flow */
873 uint64_t fpsize1; /* packets/flow = 1 */
874 uint64_t fpsize2; /* packets/flow = 2 */
875 uint64_t fpsize4; /* packets/flow 2 < p <= 4 */
876 uint64_t fpsize8; /* packets/flow 4 < p <= 8 */
877 uint64_t fpsize12; uint64_t fpsize16; uint64_t fpsize20; uint64_t fpsize24;
878 uint64_t fpsize28; uint64_t fpsize32; uint64_t fpsize36; uint64_t fpsize40;
879 uint64_t fpsize44; uint64_t fpsize48; uint64_t fpsize52; uint64_t fpsize60;
880 uint64_t fpsize100; uint64_t fpsize200; uint64_t fpsize300; uint64_t fpsize400;
881 uint64_t fpsize500; uint64_t fpsize600; uint64_t fpsize700; uint64_t fpsize800;
882 uint64_t fpsize900;
883 uint64_t fpsize_other; /* packets/flow 200 < p */
884
885 /* octets per flow */
886 uint64_t fosize32; /* octets/flow 1 <= p <= 32 */
887 uint64_t fosize64; /* octets/flow 32 < p <= 64 */
888 uint64_t fosize128; /* octets/flow 64 < p <= 128 */
889 uint64_t fosize256; /* octets/flow 128 < p <= 256 */
890 uint64_t fosize512; uint64_t fosize1280; uint64_t fosize2048;
891 uint64_t fosize2816; uint64_t fosize3584; uint64_t fosize4352;
892 uint64_t fosize5120; uint64_t fosize5888; uint64_t fosize6656;
893 uint64_t fosize7424; uint64_t fosize8192; uint64_t fosize8960;
894 uint64_t fosize9728; uint64_t fosize10496; uint64_t fosize11264;
895 uint64_t fosize12032; uint64_t fosize12800; uint64_t fosize13568;
896 uint64_t fosize14336; uint64_t fosize15104; uint64_t fosize15872;
897 uint64_t fosize_other; /* octets/flow 15872 < p */
898
899 /* time per flow */
900 uint64_t ftime10; /* time/flow 1 <= p <= 10 */
901 uint64_t ftime50; /* time/flow 10 < p <= 50 */
902 uint64_t ftime100; uint64_t ftime200; uint64_t ftime500; uint64_t ftime1000;
903 uint64_t ftime2000; uint64_t ftime3000; uint64_t ftime4000; uint64_t ftime5000;
904 uint64_t ftime6000; uint64_t ftime7000; uint64_t ftime8000; uint64_t ftime9000;
905 uint64_t ftime10000; uint64_t ftime12000; uint64_t ftime14000;
906 uint64_t ftime16000; uint64_t ftime18000; uint64_t ftime20000;
907 uint64_t ftime22000; uint64_t ftime24000; uint64_t ftime26000;
908 uint64_t ftime28000; uint64_t ftime30000;
909 uint64_t ftime_other; /* time/flow 2000 < p */
910 };
911
912 struct ftstat_rpt_2 {
913 int foo; /* malloc place holder */
914 };
915
916 struct ftstat_rpt_3 {
917 struct ftchash *ftch;
918 };
919
920 struct ftstat_rpt_4 {
921 struct ftchash *ftch;
922 };
923
924 struct ftstat_rpt_5 {
925 struct ftchash *ftch;
926 };
927
928 struct ftstat_rpt_6 {
929 struct flow_bucket bucket;
930 };
931
932 struct ftstat_rpt_7 {
933 struct flow_bucket bucket;
934 };
935
936 struct ftstat_rpt_8 {
937 struct ftchash *ftch;
938 };
939
940 struct ftstat_rpt_9 {
941 struct ftchash *ftch;
942 };
943
944 struct ftstat_rpt_10 {
945 struct ftchash *ftch;
946 };
947
948 struct ftstat_rpt_11 {
949 struct flow_bucket bucket;
950 };
951
952 struct ftstat_rpt_12 {
953 struct flow_bucket bucket;
954 };
955
956 struct ftstat_rpt_13 {
957 struct flow_bucket bucket;
958 };
959
960 struct ftstat_rpt_14 {
961 struct ftchash *ftch;
962 };
963
964 struct ftstat_rpt_15 {
965 struct ftchash *ftch;
966 };
967
968 struct ftstat_rpt_16 {
969 struct ftchash *ftch;
970 };
971
972 struct ftstat_rpt_17 {
973 struct ftchash *ftch;
974 };
975
976 struct ftstat_rpt_18 {
977 struct ftchash *ftch;
978 };
979
980 struct ftstat_rpt_19 {
981 struct flow_bucket bucket;
982 };
983
984 struct ftstat_rpt_20 {
985 struct flow_bucket bucket;
986 };
987
988 struct ftstat_rpt_21 {
989 struct ftchash *ftch;
990 };
991
992 struct ftstat_rpt_22 {
993 struct flow_bucket bucket;
994 };
995
996 struct ftstat_rpt_23 {
997 struct flow_bucket bucket;
998 };
999
1000 struct ftstat_rpt_24 {
1001 struct ftchash *ftch;
1002 };
1003
1004 struct ftstat_rpt_25 {
1005 struct ftchash *ftch;
1006 };
1007
1008 struct ftstat_rpt_26 {
1009 struct ftchash *ftch;
1010 };
1011
1012 struct ftstat_rpt_27 {
1013 struct ftchash *ftch;
1014 };
1015
1016 struct ftstat_rpt_28 {
1017 struct ftchash *ftch;
1018 };
1019
1020 struct ftstat_rpt_29 {
1021 struct ftchash *ftch;
1022 };
1023
1024 struct ftstat_rpt_30 {
1025 struct ftchash *ftch;
1026 };
1027
1028 struct ftstat_rpt_31 {
1029 struct ftchash *ftch;
1030 };
1031
1032 struct ftstat_rpt_32 {
1033 struct ftchash *ftch;
1034 };
1035
1036 struct ftstat_rpt_33 {
1037 struct ftchash *ftch;
1038 };
1039
1040 struct ftstat_rpt_34 {
1041 struct ftchash *ftch;
1042 };
1043
1044 struct ftstat_rpt_35 {
1045 struct ftchash *ftch;
1046 };
1047
1048 struct ftstat_rpt_36 {
1049 struct ftchash *ftch;
1050 };
1051
1052 struct ftstat_rpt_37 {
1053 struct ftchash *ftch;
1054 };
1055
1056 struct ftstat_rpt_38 {
1057 struct ftchash *ftch;
1058 };
1059
1060 struct ftstat_rpt_39 {
1061 struct ftchash *ftch;
1062 };
1063
1064 struct ftstat_rpt_40 {
1065 struct ftchash *ftch;
1066 };
1067
1068 struct ftstat_rpt_41 {
1069 struct ftchash *ftch;
1070 };
1071
1072 struct ftstat_rpt_42 {
1073 struct ftchash *ftch;
1074 };
1075
1076 struct ftstat_rpt_43 {
1077 struct ftchash *ftch;
1078 };
1079
1080 struct ftstat_rpt_44 {
1081 struct ftchash *ftch;
1082 };
1083
1084 struct ftstat_rpt_45 {
1085 struct ftchash *ftch;
1086 };
1087
1088 struct ftstat_rpt_46 {
1089 struct flow_bucket bucket;
1090 };
1091
1092 struct ftstat_rpt_47 {
1093 struct flow_bucket bucket;
1094 };
1095
1096 struct ftstat_rpt_48 {
1097 struct ftchash *ftch;
1098 };
1099
1100 struct ftstat_rpt_49 {
1101 struct ftchash *ftch;
1102 };
1103
1104 struct ftstat_rpt_50 {
1105 struct ftchash *ftch;
1106 };
1107
1108 struct ftstat_rpt_51 {
1109 struct ftchash *ftch;
1110 };
1111
1112 struct ftstat_rpt_52 {
1113 struct ftchash *ftch;
1114 };
1115
1116 struct ftstat_rpt_53 {
1117 struct ftchash *ftch;
1118 };
1119
1120 struct ftstat_rpt_54 {
1121 struct ftchash *ftch;
1122 };
1123
1124 struct ftstat_rpt_55 {
1125 struct ftchash *ftch;
1126 };
1127
1128 struct ftstat_rpt_56 {
1129 struct ftchash *ftch;
1130 };
1131
1132 struct ftstat_rpt_57 {
1133 struct ftchash *ftch;
1134 };
1135
1136 struct ftstat_rpt_58 {
1137 struct ftchash *ftch;
1138 };
1139
1140 struct ftstat_rpt_59 {
1141 struct ftchash *ftch;
1142 };
1143
1144 struct ftstat_rpt_60 {
1145 struct ftchash *ftch;
1146 };
1147
1148 struct ftstat_rpt_61 {
1149 struct ftchash *ftch;
1150 };
1151
1152 struct ftstat_rpt_62 {
1153 struct ftchash *ftch;
1154 };
1155
1156 struct ftstat_rpt_63 {
1157 struct ftchash *ftch;
1158 };
1159
1160 struct ftstat_rpt_64 {
1161 struct ftchash *ftch;
1162 };
1163
1164 struct ftstat_rpt_65 {
1165 struct flow_bucket bucket;
1166 };
1167
1168 struct ftstat_rpt_66 {
1169 struct ftchash *ftch;
1170 };
1171
1172 struct ftstat_rpt_67 {
1173 struct ftchash *ftch;
1174 };
1175
1176 struct ftstat_rpt_68 {
1177 struct ftchash *ftch;
1178 };
1179
1180 struct ftstat_rpt_69 {
1181 struct ftchash *ftch;
1182 };
1183
1184 struct ftstat_rpt_70 {
1185 struct ftchash *ftch;
1186 };
1187
1188 struct ftstat_rpt_71 {
1189 struct ftchash *ftch;
1190 };
1191
1192 struct ftstat_rpt_72 {
1193 struct ftchash *ftch;
1194 };
1195
1196 struct ftstat_rpt_73 {
1197 struct ftchash *ftch;
1198 };
1199
1200 struct ftstat_rpt_74 {
1201 struct ftchash *ftch;
1202 };
1203
1204 struct ftstat_rpt_75 {
1205 struct ftchash *ftch;
1206 };
1207
1208 struct ftstat_rpt_76 {
1209 struct ftchash *ftch;
1210 };
1211
1212 struct ftstat_rpt_77 {
1213 struct ftchash *ftch;
1214 };
1215
1216 struct ftstat_rpt_78 {
1217 struct ftchash *ftch;
1218 };
1219
1220 int parse_rpt(struct line_parser *lp, struct ftstat *ftstat);
1221 int parse_rpt_type(struct line_parser *lp, struct ftstat *ftstat);
1222 int parse_rpt_filter(struct line_parser *lp, struct ftstat *ftstat);
1223 int parse_rpt_scale(struct line_parser *lp, struct ftstat *ftstat);
1224 int parse_rpt_tag_mask(struct line_parser *lp, struct ftstat *ftstat);
1225 int parse_rpt_ip_src_addr_fmt(struct line_parser *lp, struct ftstat *ftstat);
1226 int parse_rpt_ip_dst_addr_fmt(struct line_parser *lp, struct ftstat *ftstat);
1227 int parse_rpt_output(struct line_parser *lp, struct ftstat *ftstat);
1228 int parse_rpt_out_options(struct line_parser *lp, struct ftstat *ftstat);
1229 int parse_rpt_out_sort(struct line_parser *lp, struct ftstat *ftstat);
1230 int parse_rpt_out_fields(struct line_parser *lp, struct ftstat *ftstat);
1231 int parse_rpt_out_format(struct line_parser *lp, struct ftstat *ftstat);
1232 int parse_rpt_out_path(struct line_parser *lp, struct ftstat *ftstat);
1233 int parse_rpt_out_records(struct line_parser *lp, struct ftstat *ftstat);
1234 int parse_rpt_out_tally(struct line_parser *lp, struct ftstat *ftstat);
1235 int parse_rpt_out_time(struct line_parser *lp, struct ftstat *ftstat);
1236 int parse_def(struct line_parser *lp, struct ftstat *ftstat);
1237 int parse_def_mask(struct line_parser *lp, struct ftstat *ftstat);
1238 int parse_def_tag(struct line_parser *lp, struct ftstat *ftstat);
1239 int parse_def_filter(struct line_parser *lp, struct ftstat *ftstat);
1240 int parse_def_report(struct line_parser *lp, struct ftstat *ftstat);
1241 int parse_def_time_series(struct line_parser *lp, struct ftstat *ftstat);
1242 int parse_include_tag(struct line_parser *lp, struct ftstat *ftstat);
1243 int parse_include_filter(struct line_parser *lp, struct ftstat *ftstat);
1244 int parse_include_mask(struct line_parser *lp, struct ftstat *ftstat);
1245
1246 void ftstat_free(struct ftstat *ftstat);
1247 static int load_masks(struct ftstat *ftstat);
1248 static int load_filters(struct ftstat *ftstat);
1249 static int load_tags(struct ftstat *ftstat);
1250 static int resolve_reports(struct ftstat *ftstat);
1251 static int dump_ascii_header(FILE *fp, struct ftio *ftio,
1252 struct ftstat_def *active_def, struct ftstat_rpt *rpt);
1253
1254 static int recn_dump(FILE *fp, int fields, char *key, char *key1,
1255 char *key2, char *key3, char *key4, char *key5, char *key6);
1256
1257 static int sort_cmp64(const void *a, const void *b);
1258 static int sort_cmp_double(const void *a, const void *b);
1259 void bucket_free(struct flow_bucket *b);
1260 int bucket_alloc(struct flow_bucket *b, uint32_t n, struct ftstat_rpt *rpt);
1261 static int bucket_dump1(FILE *fp, struct ftstat_rpt *rpt, struct flow_bucket *b,
1262 uint32_t nindex, const char *symfile);
1263 static int chash_c64_dump(FILE *fp, struct ftstat_rpt *rpt,
1264 struct ftchash *ftch);
1265 static int chash_c32_dump(FILE *fp, struct ftstat_rpt *rpt,
1266 struct ftchash *ftch, const char *sym1);
1267 static int chash_c322_dump(FILE *fp, struct ftstat_rpt *rpt,
1268 struct ftchash *ftch, const char *sym1, const char *sym2);
1269 static int chash_c162_dump(FILE *fp, struct ftstat_rpt *rpt,
1270 struct ftchash *ftch, const char *sym1, const char *sym2);
1271 static int chash_c163_dump(FILE *fp, struct ftstat_rpt *rpt,
1272 struct ftchash *ftch, const char *sym1, const char *sym2, const char *sym3);
1273 static int chash_c164_dump(FILE *fp, struct ftstat_rpt *rpt,
1274 struct ftchash *ftch, const char *sym1, const char *sym2, const char *sym3, const char *sym4);
1275 static int chash_ip_dump(FILE *fp, struct ftstat_rpt *rpt,
1276 struct ftchash *ftch);
1277 static int chash_prefix_dump(FILE *fp, struct ftstat_rpt *rpt,
1278 struct ftchash *ftch, int f1);
1279 static int chash_prefix2_dump(FILE *fp, struct ftstat_rpt *rpt,
1280 struct ftchash *ftch);
1281 static int chash_prefix16_dump(FILE *fp, struct ftstat_rpt *rpt,
1282 struct ftchash *ftch, const char *sym1, int f1);
1283 static int chash_prefix162_dump(FILE *fp, struct ftstat_rpt *rpt,
1284 struct ftchash *ftch, const char *sym1, const char *sym2, int f1 );
1285 static int chash_prefix216_dump(FILE *fp, struct ftstat_rpt *rpt,
1286 struct ftchash *ftch, const char *sym1);
1287 static int chash_prefix2162_dump(FILE *fp, struct ftstat_rpt *rpt,
1288 struct ftchash *ftch, const char *sym1, const char *sym2);
1289 static int chash_flow1_dump(FILE *fp, struct ftstat_rpt *rpt,
1290 struct ftchash *ftch, const char *sym1, const char *sym2);
1291 static int chash_flow12_dump(FILE *fp, struct ftstat_rpt *rpt,
1292 struct ftchash *ftch, const char *sym1);
1293 static int chash_prefixh_dump(FILE *fp, struct ftstat_rpt *rpt,
1294 struct ftchash *ftch, int f1);
1295 static int chash_prefix_tag_dump(FILE *fp, struct ftstat_rpt *rpt,
1296 struct ftchash *ftch, const char *sym1, int f1);
1297 static int chash_prefix2tag2_dump(FILE *fp, struct ftstat_rpt *rpt,
1298 struct ftchash *ftch, const char *sym1);
1299 static int chash_int_dump(FILE *fp, struct ftstat_rpt *rpt,
1300 struct ftchash *ftch);
1301
1302 struct ftstat_rpt_1 *ftstat_rpt_1_new(struct ftstat_rpt *rpt);
1303 int ftstat_rpt_1_accum(struct ftstat_rpt *rpt, char *rec,
1304 struct fts3rec_offsets *fo);
1305 int ftstat_rpt_1_calc(struct ftstat_rpt *rpt);
1306 int ftstat_rpt_1_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1307 void ftstat_rpt_1_free(struct ftstat_rpt_1 *rpt);
1308
1309 struct ftstat_rpt_2 *ftstat_rpt_2_new(struct ftstat_rpt *rpt);
1310 int ftstat_rpt_2_accum(struct ftstat_rpt *rpt, char *rec,
1311 struct fts3rec_offsets *fo);
1312 int ftstat_rpt_2_calc(struct ftstat_rpt *rpt);
1313 int ftstat_rpt_2_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1314 void ftstat_rpt_2_free(struct ftstat_rpt_2 *rpt);
1315
1316 struct ftstat_rpt_3 *ftstat_rpt_3_new(struct ftstat_rpt *rpt);
1317 int ftstat_rpt_3_accum(struct ftstat_rpt *rpt, char *rec,
1318 struct fts3rec_offsets *fo);
1319 int ftstat_rpt_3_calc(struct ftstat_rpt *rpt);
1320 int ftstat_rpt_3_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1321 void ftstat_rpt_3_free(struct ftstat_rpt_3 *rpt);
1322
1323 struct ftstat_rpt_4 *ftstat_rpt_4_new(struct ftstat_rpt *rpt);
1324 int ftstat_rpt_4_accum(struct ftstat_rpt *rpt, char *rec,
1325 struct fts3rec_offsets *fo);
1326 int ftstat_rpt_4_calc(struct ftstat_rpt *rpt);
1327 int ftstat_rpt_4_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1328 void ftstat_rpt_4_free(struct ftstat_rpt_4 *rpt);
1329
1330 struct ftstat_rpt_5 *ftstat_rpt_5_new(struct ftstat_rpt *rpt);
1331 int ftstat_rpt_5_accum(struct ftstat_rpt *rpt, char *rec,
1332 struct fts3rec_offsets *fo);
1333 int ftstat_rpt_5_calc(struct ftstat_rpt *rpt);
1334 int ftstat_rpt_5_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1335 void ftstat_rpt_5_free(struct ftstat_rpt_5 *rpt);
1336
1337 struct ftstat_rpt_6 *ftstat_rpt_6_new(struct ftstat_rpt *rpt);
1338 int ftstat_rpt_6_accum(struct ftstat_rpt *rpt, char *rec,
1339 struct fts3rec_offsets *fo);
1340 int ftstat_rpt_6_calc(struct ftstat_rpt *rpt);
1341 int ftstat_rpt_6_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1342 void ftstat_rpt_6_free(struct ftstat_rpt_6 *rpt);
1343
1344 struct ftstat_rpt_7 *ftstat_rpt_7_new(struct ftstat_rpt *rpt);
1345 int ftstat_rpt_7_accum(struct ftstat_rpt *rpt, char *rec,
1346 struct fts3rec_offsets *fo);
1347 int ftstat_rpt_7_calc(struct ftstat_rpt *rpt);
1348 int ftstat_rpt_7_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1349 void ftstat_rpt_7_free(struct ftstat_rpt_7 *rpt);
1350
1351 struct ftstat_rpt_8 *ftstat_rpt_8_new(struct ftstat_rpt *rpt);
1352 int ftstat_rpt_8_accum(struct ftstat_rpt *rpt, char *rec,
1353 struct fts3rec_offsets *fo);
1354 int ftstat_rpt_8_calc(struct ftstat_rpt *rpt);
1355 int ftstat_rpt_8_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1356 void ftstat_rpt_8_free(struct ftstat_rpt_8 *rpt);
1357
1358 struct ftstat_rpt_9 *ftstat_rpt_9_new(struct ftstat_rpt *rpt);
1359 int ftstat_rpt_9_accum(struct ftstat_rpt *rpt, char *rec,
1360 struct fts3rec_offsets *fo);
1361 int ftstat_rpt_9_calc(struct ftstat_rpt *rpt);
1362 int ftstat_rpt_9_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1363 void ftstat_rpt_9_free(struct ftstat_rpt_9 *rpt);
1364
1365 struct ftstat_rpt_10 *ftstat_rpt_10_new(struct ftstat_rpt *rpt);
1366 int ftstat_rpt_10_accum(struct ftstat_rpt *rpt, char *rec,
1367 struct fts3rec_offsets *fo);
1368 int ftstat_rpt_10_calc(struct ftstat_rpt *rpt);
1369 int ftstat_rpt_10_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1370 void ftstat_rpt_10_free(struct ftstat_rpt_10 *rpt);
1371
1372 struct ftstat_rpt_11 *ftstat_rpt_11_new(struct ftstat_rpt *rpt);
1373 int ftstat_rpt_11_accum(struct ftstat_rpt *rpt, char *rec,
1374 struct fts3rec_offsets *fo);
1375 int ftstat_rpt_11_calc(struct ftstat_rpt *rpt);
1376 int ftstat_rpt_11_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1377 void ftstat_rpt_11_free(struct ftstat_rpt_11 *rpt);
1378
1379 struct ftstat_rpt_12 *ftstat_rpt_12_new(struct ftstat_rpt *rpt);
1380 int ftstat_rpt_12_accum(struct ftstat_rpt *rpt, char *rec,
1381 struct fts3rec_offsets *fo);
1382 int ftstat_rpt_12_calc(struct ftstat_rpt *rpt);
1383 int ftstat_rpt_12_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1384 void ftstat_rpt_12_free(struct ftstat_rpt_12 *rpt);
1385
1386 struct ftstat_rpt_13 *ftstat_rpt_13_new(struct ftstat_rpt *rpt);
1387 int ftstat_rpt_13_accum(struct ftstat_rpt *rpt, char *rec,
1388 struct fts3rec_offsets *fo);
1389 int ftstat_rpt_13_calc(struct ftstat_rpt *rpt);
1390 int ftstat_rpt_13_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1391 void ftstat_rpt_13_free(struct ftstat_rpt_13 *rpt);
1392
1393 struct ftstat_rpt_14 *ftstat_rpt_14_new(struct ftstat_rpt *rpt);
1394 int ftstat_rpt_14_accum(struct ftstat_rpt *rpt, char *rec,
1395 struct fts3rec_offsets *fo);
1396 int ftstat_rpt_14_calc(struct ftstat_rpt *rpt);
1397 int ftstat_rpt_14_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1398 void ftstat_rpt_14_free(struct ftstat_rpt_14 *rpt);
1399
1400 struct ftstat_rpt_15 *ftstat_rpt_15_new(struct ftstat_rpt *rpt);
1401 int ftstat_rpt_15_accum(struct ftstat_rpt *rpt, char *rec,
1402 struct fts3rec_offsets *fo);
1403 int ftstat_rpt_15_calc(struct ftstat_rpt *rpt);
1404 int ftstat_rpt_15_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1405 void ftstat_rpt_15_free(struct ftstat_rpt_15 *rpt);
1406
1407 struct ftstat_rpt_16 *ftstat_rpt_16_new(struct ftstat_rpt *rpt);
1408 int ftstat_rpt_16_accum(struct ftstat_rpt *rpt, char *rec,
1409 struct fts3rec_offsets *fo);
1410 int ftstat_rpt_16_calc(struct ftstat_rpt *rpt);
1411 int ftstat_rpt_16_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1412 void ftstat_rpt_16_free(struct ftstat_rpt_16 *rpt);
1413
1414 struct ftstat_rpt_17 *ftstat_rpt_17_new(struct ftstat_rpt *rpt);
1415 int ftstat_rpt_17_accum(struct ftstat_rpt *rpt, char *rec,
1416 struct fts3rec_offsets *fo);
1417 int ftstat_rpt_17_calc(struct ftstat_rpt *rpt);
1418 int ftstat_rpt_17_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1419 void ftstat_rpt_17_free(struct ftstat_rpt_17 *rpt);
1420
1421 struct ftstat_rpt_18 *ftstat_rpt_18_new(struct ftstat_rpt *rpt);
1422 int ftstat_rpt_18_accum(struct ftstat_rpt *rpt, char *rec,
1423 struct fts3rec_offsets *fo);
1424 int ftstat_rpt_18_calc(struct ftstat_rpt *rpt);
1425 int ftstat_rpt_18_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1426 void ftstat_rpt_18_free(struct ftstat_rpt_18 *rpt);
1427
1428 struct ftstat_rpt_19 *ftstat_rpt_19_new(struct ftstat_rpt *rpt);
1429 int ftstat_rpt_19_accum(struct ftstat_rpt *rpt, char *rec,
1430 struct fts3rec_offsets *fo);
1431 int ftstat_rpt_19_calc(struct ftstat_rpt *rpt);
1432 int ftstat_rpt_19_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1433 void ftstat_rpt_19_free(struct ftstat_rpt_19 *rpt);
1434
1435 struct ftstat_rpt_20 *ftstat_rpt_20_new(struct ftstat_rpt *rpt);
1436 int ftstat_rpt_20_accum(struct ftstat_rpt *rpt, char *rec,
1437 struct fts3rec_offsets *fo);
1438 int ftstat_rpt_20_calc(struct ftstat_rpt *rpt);
1439 int ftstat_rpt_20_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1440 void ftstat_rpt_20_free(struct ftstat_rpt_20 *rpt);
1441
1442 struct ftstat_rpt_21 *ftstat_rpt_21_new(struct ftstat_rpt *rpt);
1443 int ftstat_rpt_21_accum(struct ftstat_rpt *rpt, char *rec,
1444 struct fts3rec_offsets *fo);
1445 int ftstat_rpt_21_calc(struct ftstat_rpt *rpt);
1446 int ftstat_rpt_21_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1447 void ftstat_rpt_21_free(struct ftstat_rpt_21 *rpt);
1448
1449 struct ftstat_rpt_22 *ftstat_rpt_22_new(struct ftstat_rpt *rpt);
1450 int ftstat_rpt_22_accum(struct ftstat_rpt *rpt, char *rec,
1451 struct fts3rec_offsets *fo);
1452 int ftstat_rpt_22_calc(struct ftstat_rpt *rpt);
1453 int ftstat_rpt_22_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1454 void ftstat_rpt_22_free(struct ftstat_rpt_22 *rpt);
1455
1456 struct ftstat_rpt_23 *ftstat_rpt_23_new(struct ftstat_rpt *rpt);
1457 int ftstat_rpt_23_accum(struct ftstat_rpt *rpt, char *rec,
1458 struct fts3rec_offsets *fo);
1459 int ftstat_rpt_23_calc(struct ftstat_rpt *rpt);
1460 int ftstat_rpt_23_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1461 void ftstat_rpt_23_free(struct ftstat_rpt_23 *rpt);
1462
1463 struct ftstat_rpt_24 *ftstat_rpt_24_new(struct ftstat_rpt *rpt);
1464 int ftstat_rpt_24_accum(struct ftstat_rpt *rpt, char *rec,
1465 struct fts3rec_offsets *fo);
1466 int ftstat_rpt_24_calc(struct ftstat_rpt *rpt);
1467 int ftstat_rpt_24_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1468 void ftstat_rpt_24_free(struct ftstat_rpt_24 *rpt);
1469
1470 struct ftstat_rpt_25 *ftstat_rpt_25_new(struct ftstat_rpt *rpt);
1471 int ftstat_rpt_25_accum(struct ftstat_rpt *rpt, char *rec,
1472 struct fts3rec_offsets *fo);
1473 int ftstat_rpt_25_calc(struct ftstat_rpt *rpt);
1474 int ftstat_rpt_25_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1475 void ftstat_rpt_25_free(struct ftstat_rpt_25 *rpt);
1476
1477 struct ftstat_rpt_26 *ftstat_rpt_26_new(struct ftstat_rpt *rpt);
1478 int ftstat_rpt_26_accum(struct ftstat_rpt *rpt, char *rec,
1479 struct fts3rec_offsets *fo);
1480 int ftstat_rpt_26_calc(struct ftstat_rpt *rpt);
1481 int ftstat_rpt_26_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1482 void ftstat_rpt_26_free(struct ftstat_rpt_26 *rpt);
1483
1484 struct ftstat_rpt_27 *ftstat_rpt_27_new(struct ftstat_rpt *rpt);
1485 int ftstat_rpt_27_accum(struct ftstat_rpt *rpt, char *rec,
1486 struct fts3rec_offsets *fo);
1487 int ftstat_rpt_27_calc(struct ftstat_rpt *rpt);
1488 int ftstat_rpt_27_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1489 void ftstat_rpt_27_free(struct ftstat_rpt_27 *rpt);
1490
1491 struct ftstat_rpt_28 *ftstat_rpt_28_new(struct ftstat_rpt *rpt);
1492 int ftstat_rpt_28_accum(struct ftstat_rpt *rpt, char *rec,
1493 struct fts3rec_offsets *fo);
1494 int ftstat_rpt_28_calc(struct ftstat_rpt *rpt);
1495 int ftstat_rpt_28_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1496 void ftstat_rpt_28_free(struct ftstat_rpt_28 *rpt);
1497
1498 struct ftstat_rpt_29 *ftstat_rpt_29_new(struct ftstat_rpt *rpt);
1499 int ftstat_rpt_29_accum(struct ftstat_rpt *rpt, char *rec,
1500 struct fts3rec_offsets *fo);
1501 int ftstat_rpt_29_calc(struct ftstat_rpt *rpt);
1502 int ftstat_rpt_29_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1503 void ftstat_rpt_29_free(struct ftstat_rpt_29 *rpt);
1504
1505 struct ftstat_rpt_30 *ftstat_rpt_30_new(struct ftstat_rpt *rpt);
1506 int ftstat_rpt_30_accum(struct ftstat_rpt *rpt, char *rec,
1507 struct fts3rec_offsets *fo);
1508 int ftstat_rpt_30_calc(struct ftstat_rpt *rpt);
1509 int ftstat_rpt_30_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1510 void ftstat_rpt_30_free(struct ftstat_rpt_30 *rpt);
1511
1512 struct ftstat_rpt_31 *ftstat_rpt_31_new(struct ftstat_rpt *rpt);
1513 int ftstat_rpt_31_accum(struct ftstat_rpt *rpt, char *rec,
1514 struct fts3rec_offsets *fo);
1515 int ftstat_rpt_31_calc(struct ftstat_rpt *rpt);
1516 int ftstat_rpt_31_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1517 void ftstat_rpt_31_free(struct ftstat_rpt_31 *rpt);
1518
1519 struct ftstat_rpt_32 *ftstat_rpt_32_new(struct ftstat_rpt *rpt);
1520 int ftstat_rpt_32_accum(struct ftstat_rpt *rpt, char *rec,
1521 struct fts3rec_offsets *fo);
1522 int ftstat_rpt_32_calc(struct ftstat_rpt *rpt);
1523 int ftstat_rpt_32_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1524 void ftstat_rpt_32_free(struct ftstat_rpt_32 *rpt);
1525
1526 struct ftstat_rpt_33 *ftstat_rpt_33_new(struct ftstat_rpt *rpt);
1527 int ftstat_rpt_33_accum(struct ftstat_rpt *rpt, char *rec,
1528 struct fts3rec_offsets *fo);
1529 int ftstat_rpt_33_calc(struct ftstat_rpt *rpt);
1530 int ftstat_rpt_33_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1531 void ftstat_rpt_33_free(struct ftstat_rpt_33 *rpt);
1532
1533 struct ftstat_rpt_34 *ftstat_rpt_34_new(struct ftstat_rpt *rpt);
1534 int ftstat_rpt_34_accum(struct ftstat_rpt *rpt, char *rec,
1535 struct fts3rec_offsets *fo);
1536 int ftstat_rpt_34_calc(struct ftstat_rpt *rpt);
1537 int ftstat_rpt_34_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1538 void ftstat_rpt_34_free(struct ftstat_rpt_34 *rpt);
1539
1540 struct ftstat_rpt_35 *ftstat_rpt_35_new(struct ftstat_rpt *rpt);
1541 int ftstat_rpt_35_accum(struct ftstat_rpt *rpt, char *rec,
1542 struct fts3rec_offsets *fo);
1543 int ftstat_rpt_35_calc(struct ftstat_rpt *rpt);
1544 int ftstat_rpt_35_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1545 void ftstat_rpt_35_free(struct ftstat_rpt_35 *rpt);
1546
1547 struct ftstat_rpt_36 *ftstat_rpt_36_new(struct ftstat_rpt *rpt);
1548 int ftstat_rpt_36_accum(struct ftstat_rpt *rpt, char *rec,
1549 struct fts3rec_offsets *fo);
1550 int ftstat_rpt_36_calc(struct ftstat_rpt *rpt);
1551 int ftstat_rpt_36_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1552 void ftstat_rpt_36_free(struct ftstat_rpt_36 *rpt);
1553
1554 struct ftstat_rpt_37 *ftstat_rpt_37_new(struct ftstat_rpt *rpt);
1555 int ftstat_rpt_37_accum(struct ftstat_rpt *rpt, char *rec,
1556 struct fts3rec_offsets *fo);
1557 int ftstat_rpt_37_calc(struct ftstat_rpt *rpt);
1558 int ftstat_rpt_37_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1559 void ftstat_rpt_37_free(struct ftstat_rpt_37 *rpt);
1560
1561 struct ftstat_rpt_38 *ftstat_rpt_38_new(struct ftstat_rpt *rpt);
1562 int ftstat_rpt_38_accum(struct ftstat_rpt *rpt, char *rec,
1563 struct fts3rec_offsets *fo);
1564 int ftstat_rpt_38_calc(struct ftstat_rpt *rpt);
1565 int ftstat_rpt_38_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1566 void ftstat_rpt_38_free(struct ftstat_rpt_38 *rpt);
1567
1568 struct ftstat_rpt_39 *ftstat_rpt_39_new(struct ftstat_rpt *rpt);
1569 int ftstat_rpt_39_accum(struct ftstat_rpt *rpt, char *rec,
1570 struct fts3rec_offsets *fo);
1571 int ftstat_rpt_39_calc(struct ftstat_rpt *rpt);
1572 int ftstat_rpt_39_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1573 void ftstat_rpt_39_free(struct ftstat_rpt_39 *rpt);
1574
1575 struct ftstat_rpt_40 *ftstat_rpt_40_new(struct ftstat_rpt *rpt);
1576 int ftstat_rpt_40_accum(struct ftstat_rpt *rpt, char *rec,
1577 struct fts3rec_offsets *fo);
1578 int ftstat_rpt_40_calc(struct ftstat_rpt *rpt);
1579 int ftstat_rpt_40_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1580 void ftstat_rpt_40_free(struct ftstat_rpt_40 *rpt);
1581
1582 struct ftstat_rpt_41 *ftstat_rpt_41_new(struct ftstat_rpt *rpt);
1583 int ftstat_rpt_41_accum(struct ftstat_rpt *rpt, char *rec,
1584 struct fts3rec_offsets *fo);
1585 int ftstat_rpt_41_calc(struct ftstat_rpt *rpt);
1586 int ftstat_rpt_41_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1587 void ftstat_rpt_41_free(struct ftstat_rpt_41 *rpt);
1588
1589 struct ftstat_rpt_42 *ftstat_rpt_42_new(struct ftstat_rpt *rpt);
1590 int ftstat_rpt_42_accum(struct ftstat_rpt *rpt, char *rec,
1591 struct fts3rec_offsets *fo);
1592 int ftstat_rpt_42_calc(struct ftstat_rpt *rpt);
1593 int ftstat_rpt_42_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1594 void ftstat_rpt_42_free(struct ftstat_rpt_42 *rpt);
1595
1596 struct ftstat_rpt_43 *ftstat_rpt_43_new(struct ftstat_rpt *rpt);
1597 int ftstat_rpt_43_accum(struct ftstat_rpt *rpt, char *rec,
1598 struct fts3rec_offsets *fo);
1599 int ftstat_rpt_43_calc(struct ftstat_rpt *rpt);
1600 int ftstat_rpt_43_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1601 void ftstat_rpt_43_free(struct ftstat_rpt_43 *rpt);
1602
1603 struct ftstat_rpt_44 *ftstat_rpt_44_new(struct ftstat_rpt *rpt);
1604 int ftstat_rpt_44_accum(struct ftstat_rpt *rpt, char *rec,
1605 struct fts3rec_offsets *fo);
1606 int ftstat_rpt_44_calc(struct ftstat_rpt *rpt);
1607 int ftstat_rpt_44_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1608 void ftstat_rpt_44_free(struct ftstat_rpt_44 *rpt);
1609
1610 struct ftstat_rpt_45 *ftstat_rpt_45_new(struct ftstat_rpt *rpt);
1611 int ftstat_rpt_45_accum(struct ftstat_rpt *rpt, char *rec,
1612 struct fts3rec_offsets *fo);
1613 int ftstat_rpt_45_calc(struct ftstat_rpt *rpt);
1614 int ftstat_rpt_45_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1615 void ftstat_rpt_45_free(struct ftstat_rpt_45 *rpt);
1616
1617 struct ftstat_rpt_46 *ftstat_rpt_46_new(struct ftstat_rpt *rpt);
1618 int ftstat_rpt_46_accum(struct ftstat_rpt *rpt, char *rec,
1619 struct fts3rec_offsets *fo);
1620 int ftstat_rpt_46_calc(struct ftstat_rpt *rpt);
1621 int ftstat_rpt_46_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1622 void ftstat_rpt_46_free(struct ftstat_rpt_46 *rpt);
1623
1624 struct ftstat_rpt_47 *ftstat_rpt_47_new(struct ftstat_rpt *rpt);
1625 int ftstat_rpt_47_accum(struct ftstat_rpt *rpt, char *rec,
1626 struct fts3rec_offsets *fo);
1627 int ftstat_rpt_47_calc(struct ftstat_rpt *rpt);
1628 int ftstat_rpt_47_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1629 void ftstat_rpt_47_free(struct ftstat_rpt_47 *rpt);
1630
1631 struct ftstat_rpt_48 *ftstat_rpt_48_new(struct ftstat_rpt *rpt);
1632 int ftstat_rpt_48_accum(struct ftstat_rpt *rpt, char *rec,
1633 struct fts3rec_offsets *fo);
1634 int ftstat_rpt_48_calc(struct ftstat_rpt *rpt);
1635 int ftstat_rpt_48_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1636 void ftstat_rpt_48_free(struct ftstat_rpt_48 *rpt);
1637
1638 struct ftstat_rpt_49 *ftstat_rpt_49_new(struct ftstat_rpt *rpt);
1639 int ftstat_rpt_49_accum(struct ftstat_rpt *rpt, char *rec,
1640 struct fts3rec_offsets *fo);
1641 int ftstat_rpt_49_calc(struct ftstat_rpt *rpt);
1642 int ftstat_rpt_49_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1643 void ftstat_rpt_49_free(struct ftstat_rpt_49 *rpt);
1644
1645 struct ftstat_rpt_50 *ftstat_rpt_50_new(struct ftstat_rpt *rpt);
1646 int ftstat_rpt_50_accum(struct ftstat_rpt *rpt, char *rec,
1647 struct fts3rec_offsets *fo);
1648 int ftstat_rpt_50_calc(struct ftstat_rpt *rpt);
1649 int ftstat_rpt_50_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1650 void ftstat_rpt_50_free(struct ftstat_rpt_50 *rpt);
1651
1652 struct ftstat_rpt_51 *ftstat_rpt_51_new(struct ftstat_rpt *rpt);
1653 int ftstat_rpt_51_accum(struct ftstat_rpt *rpt, char *rec,
1654 struct fts3rec_offsets *fo);
1655 int ftstat_rpt_51_calc(struct ftstat_rpt *rpt);
1656 int ftstat_rpt_51_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1657 void ftstat_rpt_51_free(struct ftstat_rpt_51 *rpt);
1658
1659 struct ftstat_rpt_52 *ftstat_rpt_52_new(struct ftstat_rpt *rpt);
1660 int ftstat_rpt_52_accum(struct ftstat_rpt *rpt, char *rec,
1661 struct fts3rec_offsets *fo);
1662 int ftstat_rpt_52_calc(struct ftstat_rpt *rpt);
1663 int ftstat_rpt_52_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1664 void ftstat_rpt_52_free(struct ftstat_rpt_52 *rpt);
1665
1666 struct ftstat_rpt_53 *ftstat_rpt_53_new(struct ftstat_rpt *rpt);
1667 int ftstat_rpt_53_accum(struct ftstat_rpt *rpt, char *rec,
1668 struct fts3rec_offsets *fo);
1669 int ftstat_rpt_53_calc(struct ftstat_rpt *rpt);
1670 int ftstat_rpt_53_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1671 void ftstat_rpt_53_free(struct ftstat_rpt_53 *rpt);
1672
1673 struct ftstat_rpt_54 *ftstat_rpt_54_new(struct ftstat_rpt *rpt);
1674 int ftstat_rpt_54_accum(struct ftstat_rpt *rpt, char *rec,
1675 struct fts3rec_offsets *fo);
1676 int ftstat_rpt_54_calc(struct ftstat_rpt *rpt);
1677 int ftstat_rpt_54_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1678 void ftstat_rpt_54_free(struct ftstat_rpt_54 *rpt);
1679
1680 struct ftstat_rpt_55 *ftstat_rpt_55_new(struct ftstat_rpt *rpt);
1681 int ftstat_rpt_55_accum(struct ftstat_rpt *rpt, char *rec,
1682 struct fts3rec_offsets *fo);
1683 int ftstat_rpt_55_calc(struct ftstat_rpt *rpt);
1684 int ftstat_rpt_55_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1685 void ftstat_rpt_55_free(struct ftstat_rpt_55 *rpt);
1686
1687 struct ftstat_rpt_56 *ftstat_rpt_56_new(struct ftstat_rpt *rpt);
1688 int ftstat_rpt_56_accum(struct ftstat_rpt *rpt, char *rec,
1689 struct fts3rec_offsets *fo);
1690 int ftstat_rpt_56_calc(struct ftstat_rpt *rpt);
1691 int ftstat_rpt_56_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1692 void ftstat_rpt_56_free(struct ftstat_rpt_56 *rpt);
1693
1694 struct ftstat_rpt_57 *ftstat_rpt_57_new(struct ftstat_rpt *rpt);
1695 int ftstat_rpt_57_accum(struct ftstat_rpt *rpt, char *rec,
1696 struct fts3rec_offsets *fo);
1697 int ftstat_rpt_57_calc(struct ftstat_rpt *rpt);
1698 int ftstat_rpt_57_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1699 void ftstat_rpt_57_free(struct ftstat_rpt_57 *rpt);
1700
1701 struct ftstat_rpt_58 *ftstat_rpt_58_new(struct ftstat_rpt *rpt);
1702 int ftstat_rpt_58_accum(struct ftstat_rpt *rpt, char *rec,
1703 struct fts3rec_offsets *fo);
1704 int ftstat_rpt_58_calc(struct ftstat_rpt *rpt);
1705 int ftstat_rpt_58_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1706 void ftstat_rpt_58_free(struct ftstat_rpt_58 *rpt);
1707
1708 struct ftstat_rpt_59 *ftstat_rpt_59_new(struct ftstat_rpt *rpt);
1709 int ftstat_rpt_59_accum(struct ftstat_rpt *rpt, char *rec,
1710 struct fts3rec_offsets *fo);
1711 int ftstat_rpt_59_calc(struct ftstat_rpt *rpt);
1712 int ftstat_rpt_59_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1713 void ftstat_rpt_59_free(struct ftstat_rpt_59 *rpt);
1714
1715 struct ftstat_rpt_60 *ftstat_rpt_60_new(struct ftstat_rpt *rpt);
1716 int ftstat_rpt_60_accum(struct ftstat_rpt *rpt, char *rec,
1717 struct fts3rec_offsets *fo);
1718 int ftstat_rpt_60_calc(struct ftstat_rpt *rpt);
1719 int ftstat_rpt_60_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1720 void ftstat_rpt_60_free(struct ftstat_rpt_60 *rpt);
1721
1722 struct ftstat_rpt_61 *ftstat_rpt_61_new(struct ftstat_rpt *rpt);
1723 int ftstat_rpt_61_accum(struct ftstat_rpt *rpt, char *rec,
1724 struct fts3rec_offsets *fo);
1725 int ftstat_rpt_61_calc(struct ftstat_rpt *rpt);
1726 int ftstat_rpt_61_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1727 void ftstat_rpt_61_free(struct ftstat_rpt_61 *rpt);
1728
1729 struct ftstat_rpt_62 *ftstat_rpt_62_new(struct ftstat_rpt *rpt);
1730 int ftstat_rpt_62_accum(struct ftstat_rpt *rpt, char *rec,
1731 struct fts3rec_offsets *fo);
1732 int ftstat_rpt_62_calc(struct ftstat_rpt *rpt);
1733 int ftstat_rpt_62_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1734 void ftstat_rpt_62_free(struct ftstat_rpt_62 *rpt);
1735
1736 struct ftstat_rpt_63 *ftstat_rpt_63_new(struct ftstat_rpt *rpt);
1737 int ftstat_rpt_63_accum(struct ftstat_rpt *rpt, char *rec,
1738 struct fts3rec_offsets *fo);
1739 int ftstat_rpt_63_calc(struct ftstat_rpt *rpt);
1740 int ftstat_rpt_63_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1741 void ftstat_rpt_63_free(struct ftstat_rpt_63 *rpt);
1742
1743 struct ftstat_rpt_64 *ftstat_rpt_64_new(struct ftstat_rpt *rpt);
1744 int ftstat_rpt_64_accum(struct ftstat_rpt *rpt, char *rec,
1745 struct fts3rec_offsets *fo);
1746 int ftstat_rpt_64_calc(struct ftstat_rpt *rpt);
1747 int ftstat_rpt_64_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1748 void ftstat_rpt_64_free(struct ftstat_rpt_64 *rpt);
1749
1750 struct ftstat_rpt_65 *ftstat_rpt_65_new(struct ftstat_rpt *rpt);
1751 int ftstat_rpt_65_accum(struct ftstat_rpt *rpt, char *rec,
1752 struct fts3rec_offsets *fo);
1753 int ftstat_rpt_65_calc(struct ftstat_rpt *rpt);
1754 int ftstat_rpt_65_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1755 void ftstat_rpt_65_free(struct ftstat_rpt_65 *rpt);
1756
1757 struct ftstat_rpt_66 *ftstat_rpt_66_new(struct ftstat_rpt *rpt);
1758 int ftstat_rpt_66_accum(struct ftstat_rpt *rpt, char *rec,
1759 struct fts3rec_offsets *fo);
1760 int ftstat_rpt_66_calc(struct ftstat_rpt *rpt);
1761 int ftstat_rpt_66_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1762 void ftstat_rpt_66_free(struct ftstat_rpt_66 *rpt);
1763
1764 struct ftstat_rpt_67 *ftstat_rpt_67_new(struct ftstat_rpt *rpt);
1765 int ftstat_rpt_67_accum(struct ftstat_rpt *rpt, char *rec,
1766 struct fts3rec_offsets *fo);
1767 int ftstat_rpt_67_calc(struct ftstat_rpt *rpt);
1768 int ftstat_rpt_67_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1769 void ftstat_rpt_67_free(struct ftstat_rpt_67 *rpt);
1770
1771 struct ftstat_rpt_68 *ftstat_rpt_68_new(struct ftstat_rpt *rpt);
1772 int ftstat_rpt_68_accum(struct ftstat_rpt *rpt, char *rec,
1773 struct fts3rec_offsets *fo);
1774 int ftstat_rpt_68_calc(struct ftstat_rpt *rpt);
1775 int ftstat_rpt_68_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1776 void ftstat_rpt_68_free(struct ftstat_rpt_68 *rpt);
1777
1778 struct ftstat_rpt_69 *ftstat_rpt_69_new(struct ftstat_rpt *rpt);
1779 int ftstat_rpt_69_accum(struct ftstat_rpt *rpt, char *rec,
1780 struct fts3rec_offsets *fo);
1781 int ftstat_rpt_69_calc(struct ftstat_rpt *rpt);
1782 int ftstat_rpt_69_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1783 void ftstat_rpt_69_free(struct ftstat_rpt_69 *rpt);
1784
1785 struct ftstat_rpt_70 *ftstat_rpt_70_new(struct ftstat_rpt *rpt);
1786 int ftstat_rpt_70_accum(struct ftstat_rpt *rpt, char *rec,
1787 struct fts3rec_offsets *fo);
1788 int ftstat_rpt_70_calc(struct ftstat_rpt *rpt);
1789 int ftstat_rpt_70_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1790 void ftstat_rpt_70_free(struct ftstat_rpt_70 *rpt);
1791
1792 struct ftstat_rpt_71 *ftstat_rpt_71_new(struct ftstat_rpt *rpt);
1793 int ftstat_rpt_71_accum(struct ftstat_rpt *rpt, char *rec,
1794 struct fts3rec_offsets *fo);
1795 int ftstat_rpt_71_calc(struct ftstat_rpt *rpt);
1796 int ftstat_rpt_71_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1797 void ftstat_rpt_71_free(struct ftstat_rpt_71 *rpt);
1798
1799 struct ftstat_rpt_72 *ftstat_rpt_72_new(struct ftstat_rpt *rpt);
1800 int ftstat_rpt_72_accum(struct ftstat_rpt *rpt, char *rec,
1801 struct fts3rec_offsets *fo);
1802 int ftstat_rpt_72_calc(struct ftstat_rpt *rpt);
1803 int ftstat_rpt_72_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1804 void ftstat_rpt_72_free(struct ftstat_rpt_72 *rpt);
1805
1806 struct ftstat_rpt_73 *ftstat_rpt_73_new(struct ftstat_rpt *rpt);
1807 int ftstat_rpt_73_accum(struct ftstat_rpt *rpt, char *rec,
1808 struct fts3rec_offsets *fo);
1809 int ftstat_rpt_73_calc(struct ftstat_rpt *rpt);
1810 int ftstat_rpt_73_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1811 void ftstat_rpt_73_free(struct ftstat_rpt_73 *rpt);
1812
1813 struct ftstat_rpt_74 *ftstat_rpt_74_new(struct ftstat_rpt *rpt);
1814 int ftstat_rpt_74_accum(struct ftstat_rpt *rpt, char *rec,
1815 struct fts3rec_offsets *fo);
1816 int ftstat_rpt_74_calc(struct ftstat_rpt *rpt);
1817 int ftstat_rpt_74_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1818 void ftstat_rpt_74_free(struct ftstat_rpt_74 *rpt);
1819
1820 struct ftstat_rpt_75 *ftstat_rpt_75_new(struct ftstat_rpt *rpt);
1821 int ftstat_rpt_75_accum(struct ftstat_rpt *rpt, char *rec,
1822 struct fts3rec_offsets *fo);
1823 int ftstat_rpt_75_calc(struct ftstat_rpt *rpt);
1824 int ftstat_rpt_75_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1825 void ftstat_rpt_75_free(struct ftstat_rpt_75 *rpt);
1826
1827 struct ftstat_rpt_76 *ftstat_rpt_76_new(struct ftstat_rpt *rpt);
1828 int ftstat_rpt_76_accum(struct ftstat_rpt *rpt, char *rec,
1829 struct fts3rec_offsets *fo);
1830 int ftstat_rpt_76_calc(struct ftstat_rpt *rpt);
1831 int ftstat_rpt_76_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1832 void ftstat_rpt_76_free(struct ftstat_rpt_76 *rpt);
1833
1834 struct ftstat_rpt_77 *ftstat_rpt_77_new(struct ftstat_rpt *rpt);
1835 int ftstat_rpt_77_accum(struct ftstat_rpt *rpt, char *rec,
1836 struct fts3rec_offsets *fo);
1837 int ftstat_rpt_77_calc(struct ftstat_rpt *rpt);
1838 int ftstat_rpt_77_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1839 void ftstat_rpt_77_free(struct ftstat_rpt_77 *rpt);
1840
1841 struct ftstat_rpt_78 *ftstat_rpt_78_new(struct ftstat_rpt *rpt);
1842 int ftstat_rpt_78_accum(struct ftstat_rpt *rpt, char *rec,
1843 struct fts3rec_offsets *fo);
1844 int ftstat_rpt_78_calc(struct ftstat_rpt *rpt);
1845 int ftstat_rpt_78_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt);
1846 void ftstat_rpt_78_free(struct ftstat_rpt_78 *rpt);
1847
1848 struct typelookup tlookup[] = {
1849 {"summary-detail",
1850 (void*)ftstat_rpt_1_new,
1851 (void*)ftstat_rpt_1_accum,
1852 (void*)ftstat_rpt_1_calc,
1853 (void*)ftstat_rpt_1_dump,
1854 (void*)ftstat_rpt_1_free,
1855 FT_STAT_FIELD_OTHER|FT_STAT_FIELD_PS,
1856 FT_STAT_OPT_GENERIC,
1857 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1858 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1859 {"summary-counters",
1860 (void*)ftstat_rpt_2_new,
1861 (void*)ftstat_rpt_2_accum,
1862 (void*)ftstat_rpt_2_calc,
1863 (void*)ftstat_rpt_2_dump,
1864 (void*)ftstat_rpt_2_free,
1865 FT_STAT_FIELD_PS,
1866 FT_STAT_OPT_HEADER|FT_STAT_OPT_XHEADER|FT_STAT_OPT_TOTALS,
1867 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1868 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1869 {"packet-size",
1870 (void*)ftstat_rpt_3_new,
1871 (void*)ftstat_rpt_3_accum,
1872 (void*)ftstat_rpt_3_calc,
1873 (void*)ftstat_rpt_3_dump,
1874 (void*)ftstat_rpt_3_free,
1875 FT_STAT_FIELD_GENERIC,
1876 FT_STAT_OPT_GENERIC,
1877 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1878 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1879 {"octets",
1880 (void*)ftstat_rpt_4_new,
1881 (void*)ftstat_rpt_4_accum,
1882 (void*)ftstat_rpt_4_calc,
1883 (void*)ftstat_rpt_4_dump,
1884 (void*)ftstat_rpt_4_free,
1885 FT_STAT_FIELD_GENERIC,
1886 FT_STAT_OPT_GENERIC,
1887 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1888 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1889 {"packets",
1890 (void*)ftstat_rpt_5_new,
1891 (void*)ftstat_rpt_5_accum,
1892 (void*)ftstat_rpt_5_calc,
1893 (void*)ftstat_rpt_5_dump,
1894 (void*)ftstat_rpt_5_free,
1895 FT_STAT_FIELD_GENERIC,
1896 FT_STAT_OPT_GENERIC,
1897 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1898 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1899 {"ip-source-port",
1900 (void*)ftstat_rpt_6_new,
1901 (void*)ftstat_rpt_6_accum,
1902 (void*)ftstat_rpt_6_calc,
1903 (void*)ftstat_rpt_6_dump,
1904 (void*)ftstat_rpt_6_free,
1905 FT_STAT_FIELD_GENERIC,
1906 FT_STAT_OPT_GENERIC,
1907 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1908 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCPORT},
1909 {"ip-destination-port",
1910 (void*)ftstat_rpt_7_new,
1911 (void*)ftstat_rpt_7_accum,
1912 (void*)ftstat_rpt_7_calc,
1913 (void*)ftstat_rpt_7_dump,
1914 (void*)ftstat_rpt_7_free,
1915 FT_STAT_FIELD_GENERIC,
1916 FT_STAT_OPT_GENERIC,
1917 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1918 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTPORT},
1919 {"ip-source/destination-port",
1920 (void*)ftstat_rpt_8_new,
1921 (void*)ftstat_rpt_8_accum,
1922 (void*)ftstat_rpt_8_calc,
1923 (void*)ftstat_rpt_8_dump,
1924 (void*)ftstat_rpt_8_free,
1925 FT_STAT_FIELD_GENERIC2,
1926 FT_STAT_OPT_GENERIC,
1927 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1928 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCPORT|
1929 FT_XFIELD_DSTPORT},
1930 {"bps",
1931 (void*)ftstat_rpt_9_new,
1932 (void*)ftstat_rpt_9_accum,
1933 (void*)ftstat_rpt_9_calc,
1934 (void*)ftstat_rpt_9_dump,
1935 (void*)ftstat_rpt_9_free,
1936 FT_STAT_FIELD_GENERIC,
1937 FT_STAT_OPT_GENERIC,
1938 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1939 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1940 {"pps",
1941 (void*)ftstat_rpt_10_new,
1942 (void*)ftstat_rpt_10_accum,
1943 (void*)ftstat_rpt_10_calc,
1944 (void*)ftstat_rpt_10_dump,
1945 (void*)ftstat_rpt_10_free,
1946 FT_STAT_FIELD_GENERIC,
1947 FT_STAT_OPT_GENERIC,
1948 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1949 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
1950 {"ip-destination-address-type",
1951 (void*)ftstat_rpt_11_new,
1952 (void*)ftstat_rpt_11_accum,
1953 (void*)ftstat_rpt_11_calc,
1954 (void*)ftstat_rpt_11_dump,
1955 (void*)ftstat_rpt_11_free,
1956 FT_STAT_FIELD_GENERIC,
1957 FT_STAT_OPT_GENERIC,
1958 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1959 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR},
1960 {"ip-protocol",
1961 (void*)ftstat_rpt_12_new,
1962 (void*)ftstat_rpt_12_accum,
1963 (void*)ftstat_rpt_12_calc,
1964 (void*)ftstat_rpt_12_dump,
1965 (void*)ftstat_rpt_12_free,
1966 FT_STAT_FIELD_GENERIC,
1967 FT_STAT_OPT_GENERIC,
1968 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1969 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_PROT},
1970 {"ip-tos",
1971 (void*)ftstat_rpt_13_new,
1972 (void*)ftstat_rpt_13_accum,
1973 (void*)ftstat_rpt_13_calc,
1974 (void*)ftstat_rpt_13_dump,
1975 (void*)ftstat_rpt_13_free,
1976 FT_STAT_FIELD_GENERIC,
1977 FT_STAT_OPT_GENERIC,
1978 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1979 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_TOS},
1980 {"ip-next-hop-address",
1981 (void*)ftstat_rpt_14_new,
1982 (void*)ftstat_rpt_14_accum,
1983 (void*)ftstat_rpt_14_calc,
1984 (void*)ftstat_rpt_14_dump,
1985 (void*)ftstat_rpt_14_free,
1986 FT_STAT_FIELD_GENERIC,
1987 FT_STAT_OPT_GENERIC,
1988 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1989 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_NEXTHOP},
1990 {"ip-source-address",
1991 (void*)ftstat_rpt_15_new,
1992 (void*)ftstat_rpt_15_accum,
1993 (void*)ftstat_rpt_15_calc,
1994 (void*)ftstat_rpt_15_dump,
1995 (void*)ftstat_rpt_15_free,
1996 FT_STAT_FIELD_GENERIC,
1997 FT_STAT_OPT_GENERIC_IP_ADDR,
1998 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
1999 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR},
2000 {"ip-destination-address",
2001 (void*)ftstat_rpt_16_new,
2002 (void*)ftstat_rpt_16_accum,
2003 (void*)ftstat_rpt_16_calc,
2004 (void*)ftstat_rpt_16_dump,
2005 (void*)ftstat_rpt_16_free,
2006 FT_STAT_FIELD_GENERIC,
2007 FT_STAT_OPT_GENERIC_IP_ADDR,
2008 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2009 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR},
2010 {"ip-source/destination-address",
2011 (void*)ftstat_rpt_17_new,
2012 (void*)ftstat_rpt_17_accum,
2013 (void*)ftstat_rpt_17_calc,
2014 (void*)ftstat_rpt_17_dump,
2015 (void*)ftstat_rpt_17_free,
2016 FT_STAT_FIELD_GENERIC2,
2017 FT_STAT_OPT_GENERIC_IP_ADDR,
2018 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2019 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2020 FT_XFIELD_DSTADDR},
2021 {"ip-exporter-address",
2022 (void*)ftstat_rpt_18_new,
2023 (void*)ftstat_rpt_18_accum,
2024 (void*)ftstat_rpt_18_calc,
2025 (void*)ftstat_rpt_18_dump,
2026 (void*)ftstat_rpt_18_free,
2027 FT_STAT_FIELD_GENERIC,
2028 FT_STAT_OPT_GENERIC,
2029 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2030 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_EXADDR},
2031 {"input-interface",
2032 (void*)ftstat_rpt_19_new,
2033 (void*)ftstat_rpt_19_accum,
2034 (void*)ftstat_rpt_19_calc,
2035 (void*)ftstat_rpt_19_dump,
2036 (void*)ftstat_rpt_19_free,
2037 FT_STAT_FIELD_GENERIC,
2038 FT_STAT_OPT_GENERIC,
2039 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2040 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT},
2041 {"output-interface",
2042 (void*)ftstat_rpt_20_new,
2043 (void*)ftstat_rpt_20_accum,
2044 (void*)ftstat_rpt_20_calc,
2045 (void*)ftstat_rpt_20_dump,
2046 (void*)ftstat_rpt_20_free,
2047 FT_STAT_FIELD_GENERIC,
2048 FT_STAT_OPT_GENERIC,
2049 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2050 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT},
2051 {"input/output-interface",
2052 (void*)ftstat_rpt_21_new,
2053 (void*)ftstat_rpt_21_accum,
2054 (void*)ftstat_rpt_21_calc,
2055 (void*)ftstat_rpt_21_dump,
2056 (void*)ftstat_rpt_21_free,
2057 FT_STAT_FIELD_GENERIC2,
2058 FT_STAT_OPT_GENERIC,
2059 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2060 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2061 FT_XFIELD_OUTPUT},
2062 {"source-as",
2063 (void*)ftstat_rpt_22_new,
2064 (void*)ftstat_rpt_22_accum,
2065 (void*)ftstat_rpt_22_calc,
2066 (void*)ftstat_rpt_22_dump,
2067 (void*)ftstat_rpt_22_free,
2068 FT_STAT_FIELD_GENERIC,
2069 FT_STAT_OPT_GENERIC,
2070 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2071 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS},
2072 {"destination-as",
2073 (void*)ftstat_rpt_23_new,
2074 (void*)ftstat_rpt_23_accum,
2075 (void*)ftstat_rpt_23_calc,
2076 (void*)ftstat_rpt_23_dump,
2077 (void*)ftstat_rpt_23_free,
2078 FT_STAT_FIELD_GENERIC,
2079 FT_STAT_OPT_GENERIC,
2080 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2081 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DST_AS},
2082 {"source/destination-as",
2083 (void*)ftstat_rpt_24_new,
2084 (void*)ftstat_rpt_24_accum,
2085 (void*)ftstat_rpt_24_calc,
2086 (void*)ftstat_rpt_24_dump,
2087 (void*)ftstat_rpt_24_free,
2088 FT_STAT_FIELD_GENERIC2,
2089 FT_STAT_OPT_GENERIC,
2090 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2091 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS|
2092 FT_XFIELD_DST_AS},
2093 {"ip-source-address/source-as",
2094 (void*)ftstat_rpt_25_new,
2095 (void*)ftstat_rpt_25_accum,
2096 (void*)ftstat_rpt_25_calc,
2097 (void*)ftstat_rpt_25_dump,
2098 (void*)ftstat_rpt_25_free,
2099 FT_STAT_FIELD_GENERIC2,
2100 FT_STAT_OPT_GENERIC_IP_ADDR,
2101 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2102 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS|
2103 FT_XFIELD_SRCADDR},
2104 {"ip-destination-address/source-as",
2105 (void*)ftstat_rpt_26_new,
2106 (void*)ftstat_rpt_26_accum,
2107 (void*)ftstat_rpt_26_calc,
2108 (void*)ftstat_rpt_26_dump,
2109 (void*)ftstat_rpt_26_free,
2110 FT_STAT_FIELD_GENERIC2,
2111 FT_STAT_OPT_GENERIC_IP_ADDR,
2112 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2113 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS|
2114 FT_XFIELD_DSTADDR},
2115 {"ip-source-address/destination-as",
2116 (void*)ftstat_rpt_27_new,
2117 (void*)ftstat_rpt_27_accum,
2118 (void*)ftstat_rpt_27_calc,
2119 (void*)ftstat_rpt_27_dump,
2120 (void*)ftstat_rpt_27_free,
2121 FT_STAT_FIELD_GENERIC2,
2122 FT_STAT_OPT_GENERIC_IP_ADDR,
2123 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2124 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DST_AS|
2125 FT_XFIELD_SRCADDR},
2126 {"ip-destination-address/destination-as",
2127 (void*)ftstat_rpt_28_new,
2128 (void*)ftstat_rpt_28_accum,
2129 (void*)ftstat_rpt_28_calc,
2130 (void*)ftstat_rpt_28_dump,
2131 (void*)ftstat_rpt_28_free,
2132 FT_STAT_FIELD_GENERIC2,
2133 FT_STAT_OPT_GENERIC_IP_ADDR,
2134 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2135 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DST_AS|
2136 FT_XFIELD_DSTADDR},
2137 {"ip-source/destination-address/source-as",
2138 (void*)ftstat_rpt_29_new,
2139 (void*)ftstat_rpt_29_accum,
2140 (void*)ftstat_rpt_29_calc,
2141 (void*)ftstat_rpt_29_dump,
2142 (void*)ftstat_rpt_29_free,
2143 FT_STAT_FIELD_GENERIC3,
2144 FT_STAT_OPT_GENERIC_IP_ADDR,
2145 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2146 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS|
2147 FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2148 {"ip-source/destination-address/destination-as",
2149 (void*)ftstat_rpt_30_new,
2150 (void*)ftstat_rpt_30_accum,
2151 (void*)ftstat_rpt_30_calc,
2152 (void*)ftstat_rpt_30_dump,
2153 (void*)ftstat_rpt_30_free,
2154 FT_STAT_FIELD_GENERIC3,
2155 FT_STAT_OPT_GENERIC_IP_ADDR,
2156 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2157 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DST_AS|
2158 FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2159 {"ip-source/destination-address/source/destination-as",
2160 (void*)ftstat_rpt_31_new,
2161 (void*)ftstat_rpt_31_accum,
2162 (void*)ftstat_rpt_31_calc,
2163 (void*)ftstat_rpt_31_dump,
2164 (void*)ftstat_rpt_31_free,
2165 FT_STAT_FIELD_GENERIC4,
2166 FT_STAT_OPT_GENERIC_IP_ADDR,
2167 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2168 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_AS|
2169 FT_XFIELD_DST_AS|FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2170 {"ip-source-address/input-interface",
2171 (void*)ftstat_rpt_32_new,
2172 (void*)ftstat_rpt_32_accum,
2173 (void*)ftstat_rpt_32_calc,
2174 (void*)ftstat_rpt_32_dump,
2175 (void*)ftstat_rpt_32_free,
2176 FT_STAT_FIELD_GENERIC2,
2177 FT_STAT_OPT_GENERIC_IP_ADDR,
2178 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2179 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2180 FT_XFIELD_SRCADDR},
2181 {"ip-destination-address/input-interface",
2182 (void*)ftstat_rpt_33_new,
2183 (void*)ftstat_rpt_33_accum,
2184 (void*)ftstat_rpt_33_calc,
2185 (void*)ftstat_rpt_33_dump,
2186 (void*)ftstat_rpt_33_free,
2187 FT_STAT_FIELD_GENERIC2,
2188 FT_STAT_OPT_GENERIC_IP_ADDR,
2189 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2190 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2191 FT_XFIELD_DSTADDR},
2192 {"ip-source-address/output-interface",
2193 (void*)ftstat_rpt_34_new,
2194 (void*)ftstat_rpt_34_accum,
2195 (void*)ftstat_rpt_34_calc,
2196 (void*)ftstat_rpt_34_dump,
2197 (void*)ftstat_rpt_34_free,
2198 FT_STAT_FIELD_GENERIC2,
2199 FT_STAT_OPT_GENERIC_IP_ADDR,
2200 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2201 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2202 FT_XFIELD_SRCADDR},
2203 {"ip-destination-address/output-interface",
2204 (void*)ftstat_rpt_35_new,
2205 (void*)ftstat_rpt_35_accum,
2206 (void*)ftstat_rpt_35_calc,
2207 (void*)ftstat_rpt_35_dump,
2208 (void*)ftstat_rpt_35_free,
2209 FT_STAT_FIELD_GENERIC2,
2210 FT_STAT_OPT_GENERIC_IP_ADDR,
2211 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2212 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2213 FT_XFIELD_DSTADDR},
2214 {"ip-source/destination-address/input-interface",
2215 (void*)ftstat_rpt_36_new,
2216 (void*)ftstat_rpt_36_accum,
2217 (void*)ftstat_rpt_36_calc,
2218 (void*)ftstat_rpt_36_dump,
2219 (void*)ftstat_rpt_36_free,
2220 FT_STAT_FIELD_GENERIC3,
2221 FT_STAT_OPT_GENERIC_IP_ADDR,
2222 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2223 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2224 FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2225 {"ip-source/destination-address/output-interface",
2226 (void*)ftstat_rpt_37_new,
2227 (void*)ftstat_rpt_37_accum,
2228 (void*)ftstat_rpt_37_calc,
2229 (void*)ftstat_rpt_37_dump,
2230 (void*)ftstat_rpt_37_free,
2231 FT_STAT_FIELD_GENERIC3,
2232 FT_STAT_OPT_GENERIC_IP_ADDR,
2233 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2234 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2235 FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2236 {"ip-source/destination-address/input/output-interface",
2237 (void*)ftstat_rpt_38_new,
2238 (void*)ftstat_rpt_38_accum,
2239 (void*)ftstat_rpt_38_calc,
2240 (void*)ftstat_rpt_38_dump,
2241 (void*)ftstat_rpt_38_free,
2242 FT_STAT_FIELD_GENERIC4,
2243 FT_STAT_OPT_GENERIC_IP_ADDR,
2244 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2245 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2246 FT_XFIELD_OUTPUT|FT_XFIELD_SRCADDR|FT_XFIELD_DSTADDR},
2247 {"input-interface/source-as",
2248 (void*)ftstat_rpt_39_new,
2249 (void*)ftstat_rpt_39_accum,
2250 (void*)ftstat_rpt_39_calc,
2251 (void*)ftstat_rpt_39_dump,
2252 (void*)ftstat_rpt_39_free,
2253 FT_STAT_FIELD_GENERIC2,
2254 FT_STAT_OPT_GENERIC,
2255 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2256 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2257 FT_XFIELD_SRC_AS},
2258 {"input-interface/destination-as",
2259 (void*)ftstat_rpt_40_new,
2260 (void*)ftstat_rpt_40_accum,
2261 (void*)ftstat_rpt_40_calc,
2262 (void*)ftstat_rpt_40_dump,
2263 (void*)ftstat_rpt_40_free,
2264 FT_STAT_FIELD_GENERIC2,
2265 FT_STAT_OPT_GENERIC,
2266 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2267 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2268 FT_XFIELD_DST_AS},
2269 {"output-interface/source-as",
2270 (void*)ftstat_rpt_41_new,
2271 (void*)ftstat_rpt_41_accum,
2272 (void*)ftstat_rpt_41_calc,
2273 (void*)ftstat_rpt_41_dump,
2274 (void*)ftstat_rpt_41_free,
2275 FT_STAT_FIELD_GENERIC2,
2276 FT_STAT_OPT_GENERIC,
2277 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2278 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2279 FT_XFIELD_SRC_AS},
2280 {"output-interface/destination-as",
2281 (void*)ftstat_rpt_42_new,
2282 (void*)ftstat_rpt_42_accum,
2283 (void*)ftstat_rpt_42_calc,
2284 (void*)ftstat_rpt_42_dump,
2285 (void*)ftstat_rpt_42_free,
2286 FT_STAT_FIELD_GENERIC2,
2287 FT_STAT_OPT_GENERIC,
2288 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2289 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2290 FT_XFIELD_DST_AS},
2291 {"input-interface/source/destination-as",
2292 (void*)ftstat_rpt_43_new,
2293 (void*)ftstat_rpt_43_accum,
2294 (void*)ftstat_rpt_43_calc,
2295 (void*)ftstat_rpt_43_dump,
2296 (void*)ftstat_rpt_43_free,
2297 FT_STAT_FIELD_GENERIC3,
2298 FT_STAT_OPT_GENERIC,
2299 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2300 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2301 FT_XFIELD_SRC_AS|FT_XFIELD_DST_AS},
2302 {"output-interface/source/destination-as",
2303 (void*)ftstat_rpt_44_new,
2304 (void*)ftstat_rpt_44_accum,
2305 (void*)ftstat_rpt_44_calc,
2306 (void*)ftstat_rpt_44_dump,
2307 (void*)ftstat_rpt_44_free,
2308 FT_STAT_FIELD_GENERIC3,
2309 FT_STAT_OPT_GENERIC,
2310 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2311 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_OUTPUT|
2312 FT_XFIELD_SRC_AS|FT_XFIELD_DST_AS},
2313 {"input/output-interface/source/destination-as",
2314 (void*)ftstat_rpt_45_new,
2315 (void*)ftstat_rpt_45_accum,
2316 (void*)ftstat_rpt_45_calc,
2317 (void*)ftstat_rpt_45_dump,
2318 (void*)ftstat_rpt_45_free,
2319 FT_STAT_FIELD_GENERIC4,
2320 FT_STAT_OPT_GENERIC,
2321 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2322 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_INPUT|
2323 FT_XFIELD_OUTPUT|FT_XFIELD_SRC_AS|FT_XFIELD_DST_AS},
2324 {"engine-id",
2325 (void*)ftstat_rpt_46_new,
2326 (void*)ftstat_rpt_46_accum,
2327 (void*)ftstat_rpt_46_calc,
2328 (void*)ftstat_rpt_46_dump,
2329 (void*)ftstat_rpt_46_free,
2330 FT_STAT_FIELD_GENERIC,
2331 FT_STAT_OPT_GENERIC,
2332 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2333 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_ENGINE_ID},
2334 {"engine-type",
2335 (void*)ftstat_rpt_47_new,
2336 (void*)ftstat_rpt_47_accum,
2337 (void*)ftstat_rpt_47_calc,
2338 (void*)ftstat_rpt_47_dump,
2339 (void*)ftstat_rpt_47_free,
2340 FT_STAT_FIELD_GENERIC,
2341 FT_STAT_OPT_GENERIC,
2342 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2343 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_ENGINE_TYPE},
2344 {"source-tag",
2345 (void*)ftstat_rpt_48_new,
2346 (void*)ftstat_rpt_48_accum,
2347 (void*)ftstat_rpt_48_calc,
2348 (void*)ftstat_rpt_48_dump,
2349 (void*)ftstat_rpt_48_free,
2350 FT_STAT_FIELD_GENERIC,
2351 FT_STAT_OPT_GENERIC,
2352 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2353 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_TAG},
2354 {"destination-tag",
2355 (void*)ftstat_rpt_49_new,
2356 (void*)ftstat_rpt_49_accum,
2357 (void*)ftstat_rpt_49_calc,
2358 (void*)ftstat_rpt_49_dump,
2359 (void*)ftstat_rpt_49_free,
2360 FT_STAT_FIELD_GENERIC,
2361 FT_STAT_OPT_GENERIC,
2362 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2363 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DST_TAG},
2364 {"source/destination-tag",
2365 (void*)ftstat_rpt_50_new,
2366 (void*)ftstat_rpt_50_accum,
2367 (void*)ftstat_rpt_50_calc,
2368 (void*)ftstat_rpt_50_dump,
2369 (void*)ftstat_rpt_50_free,
2370 FT_STAT_FIELD_GENERIC2,
2371 FT_STAT_OPT_GENERIC,
2372 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2373 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRC_TAG|
2374 FT_XFIELD_DST_TAG},
2375 {"ip-source-address/ip-source-port",
2376 (void*)ftstat_rpt_51_new,
2377 (void*)ftstat_rpt_51_accum,
2378 (void*)ftstat_rpt_51_calc,
2379 (void*)ftstat_rpt_51_dump,
2380 (void*)ftstat_rpt_51_free,
2381 FT_STAT_FIELD_GENERIC2,
2382 FT_STAT_OPT_GENERIC_IP_ADDR,
2383 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2384 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2385 FT_XFIELD_SRCPORT},
2386 {"ip-source-address/ip-destination-port",
2387 (void*)ftstat_rpt_52_new,
2388 (void*)ftstat_rpt_52_accum,
2389 (void*)ftstat_rpt_52_calc,
2390 (void*)ftstat_rpt_52_dump,
2391 (void*)ftstat_rpt_52_free,
2392 FT_STAT_FIELD_GENERIC2,
2393 FT_STAT_OPT_GENERIC_IP_ADDR,
2394 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2395 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2396 FT_XFIELD_DSTPORT},
2397 {"ip-destination-address/ip-source-port",
2398 (void*)ftstat_rpt_53_new,
2399 (void*)ftstat_rpt_53_accum,
2400 (void*)ftstat_rpt_53_calc,
2401 (void*)ftstat_rpt_53_dump,
2402 (void*)ftstat_rpt_53_free,
2403 FT_STAT_FIELD_GENERIC2,
2404 FT_STAT_OPT_GENERIC_IP_ADDR,
2405 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2406 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2407 FT_XFIELD_SRCPORT},
2408 {"ip-destination-address/ip-destination-port",
2409 (void*)ftstat_rpt_54_new,
2410 (void*)ftstat_rpt_54_accum,
2411 (void*)ftstat_rpt_54_calc,
2412 (void*)ftstat_rpt_54_dump,
2413 (void*)ftstat_rpt_54_free,
2414 FT_STAT_FIELD_GENERIC2,
2415 FT_STAT_OPT_GENERIC_IP_ADDR,
2416 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2417 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2418 FT_XFIELD_DSTPORT},
2419 {"ip-source-address/ip-source/destination-port",
2420 (void*)ftstat_rpt_55_new,
2421 (void*)ftstat_rpt_55_accum,
2422 (void*)ftstat_rpt_55_calc,
2423 (void*)ftstat_rpt_55_dump,
2424 (void*)ftstat_rpt_55_free,
2425 FT_STAT_FIELD_GENERIC3,
2426 FT_STAT_OPT_GENERIC_IP_ADDR,
2427 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2428 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2429 FT_XFIELD_SRCPORT|FT_XFIELD_DSTPORT},
2430 {"ip-destination-address/ip-source/destination-port",
2431 (void*)ftstat_rpt_56_new,
2432 (void*)ftstat_rpt_56_accum,
2433 (void*)ftstat_rpt_56_calc,
2434 (void*)ftstat_rpt_56_dump,
2435 (void*)ftstat_rpt_56_free,
2436 FT_STAT_FIELD_GENERIC3,
2437 FT_STAT_OPT_GENERIC_IP_ADDR,
2438 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2439 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2440 FT_XFIELD_SRCPORT|FT_XFIELD_DSTPORT},
2441 {"ip-source/destination-address/ip-source-port",
2442 (void*)ftstat_rpt_57_new,
2443 (void*)ftstat_rpt_57_accum,
2444 (void*)ftstat_rpt_57_calc,
2445 (void*)ftstat_rpt_57_dump,
2446 (void*)ftstat_rpt_57_free,
2447 FT_STAT_FIELD_GENERIC3,
2448 FT_STAT_OPT_GENERIC_IP_ADDR,
2449 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2450 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2451 FT_XFIELD_DSTADDR|FT_XFIELD_DSTPORT},
2452 {"ip-source/destination-address/ip-destination-port",
2453 (void*)ftstat_rpt_58_new,
2454 (void*)ftstat_rpt_58_accum,
2455 (void*)ftstat_rpt_58_calc,
2456 (void*)ftstat_rpt_58_dump,
2457 (void*)ftstat_rpt_58_free,
2458 FT_STAT_FIELD_GENERIC3,
2459 FT_STAT_OPT_GENERIC_IP_ADDR,
2460 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2461 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2462 FT_XFIELD_DSTADDR|FT_XFIELD_DSTPORT},
2463 {"ip-source/destination-address/ip-source/destination-port",
2464 (void*)ftstat_rpt_59_new,
2465 (void*)ftstat_rpt_59_accum,
2466 (void*)ftstat_rpt_59_calc,
2467 (void*)ftstat_rpt_59_dump,
2468 (void*)ftstat_rpt_59_free,
2469 FT_STAT_FIELD_GENERIC4,
2470 FT_STAT_OPT_GENERIC_IP_ADDR,
2471 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2472 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2473 FT_XFIELD_DSTADDR|FT_XFIELD_SRCPORT|FT_XFIELD_DSTPORT},
2474 {"ip-source-address/input/output-interface",
2475 (void*)ftstat_rpt_60_new,
2476 (void*)ftstat_rpt_60_accum,
2477 (void*)ftstat_rpt_60_calc,
2478 (void*)ftstat_rpt_60_dump,
2479 (void*)ftstat_rpt_60_free,
2480 FT_STAT_FIELD_GENERIC3,
2481 FT_STAT_OPT_GENERIC_IP_ADDR,
2482 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2483 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2484 FT_XFIELD_INPUT|FT_XFIELD_OUTPUT},
2485 {"ip-destination-address/input/output-interface",
2486 (void*)ftstat_rpt_61_new,
2487 (void*)ftstat_rpt_61_accum,
2488 (void*)ftstat_rpt_61_calc,
2489 (void*)ftstat_rpt_61_dump,
2490 (void*)ftstat_rpt_61_free,
2491 FT_STAT_FIELD_GENERIC3,
2492 FT_STAT_OPT_GENERIC_IP_ADDR,
2493 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2494 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2495 FT_XFIELD_INPUT|FT_XFIELD_OUTPUT},
2496 {"ip-source-address/source/destination-as",
2497 (void*)ftstat_rpt_62_new,
2498 (void*)ftstat_rpt_62_accum,
2499 (void*)ftstat_rpt_62_calc,
2500 (void*)ftstat_rpt_62_dump,
2501 (void*)ftstat_rpt_62_free,
2502 FT_STAT_FIELD_GENERIC3,
2503 FT_STAT_OPT_GENERIC_IP_ADDR,
2504 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2505 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2506 FT_XFIELD_SRC_AS|FT_XFIELD_DST_AS},
2507 {"ip-destination-address/source/destination-as",
2508 (void*)ftstat_rpt_63_new,
2509 (void*)ftstat_rpt_63_accum,
2510 (void*)ftstat_rpt_63_calc,
2511 (void*)ftstat_rpt_63_dump,
2512 (void*)ftstat_rpt_63_free,
2513 FT_STAT_FIELD_GENERIC3,
2514 FT_STAT_OPT_GENERIC_IP_ADDR,
2515 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2516 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2517 FT_XFIELD_SRC_AS|FT_XFIELD_DST_AS},
2518 {"ip-address",
2519 (void*)ftstat_rpt_64_new,
2520 (void*)ftstat_rpt_64_accum,
2521 (void*)ftstat_rpt_64_calc,
2522 (void*)ftstat_rpt_64_dump,
2523 (void*)ftstat_rpt_64_free,
2524 FT_STAT_FIELD_GENERIC,
2525 FT_STAT_OPT_GENERIC_IP_ADDR,
2526 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2527 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2528 FT_XFIELD_SRCADDR},
2529 {"ip-port",
2530 (void*)ftstat_rpt_65_new,
2531 (void*)ftstat_rpt_65_accum,
2532 (void*)ftstat_rpt_65_calc,
2533 (void*)ftstat_rpt_65_dump,
2534 (void*)ftstat_rpt_65_free,
2535 FT_STAT_FIELD_GENERIC,
2536 FT_STAT_OPT_GENERIC,
2537 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2538 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTPORT|
2539 FT_XFIELD_SRCPORT},
2540 {"ip-source-address-destination-count",
2541 (void*)ftstat_rpt_66_new,
2542 (void*)ftstat_rpt_66_accum,
2543 (void*)ftstat_rpt_66_calc,
2544 (void*)ftstat_rpt_66_dump,
2545 (void*)ftstat_rpt_66_free,
2546 FT_STAT_FIELD_GENERIC|FT_STAT_FIELD_COUNT,
2547 FT_STAT_OPT_GENERIC_IP_ADDR,
2548 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2549 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2550 FT_XFIELD_SRCADDR},
2551 {"ip-destination-address-source-count",
2552 (void*)ftstat_rpt_67_new,
2553 (void*)ftstat_rpt_67_accum,
2554 (void*)ftstat_rpt_67_calc,
2555 (void*)ftstat_rpt_67_dump,
2556 (void*)ftstat_rpt_67_free,
2557 FT_STAT_FIELD_GENERIC|FT_STAT_FIELD_COUNT,
2558 FT_STAT_OPT_GENERIC_IP_ADDR,
2559 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2560 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2561 FT_XFIELD_SRCADDR},
2562 {"ip-source/destination-address/ip-protocol/ip-tos/ip-source/destination-port",
2563 (void*)ftstat_rpt_68_new,
2564 (void*)ftstat_rpt_68_accum,
2565 (void*)ftstat_rpt_68_calc,
2566 (void*)ftstat_rpt_68_dump,
2567 (void*)ftstat_rpt_68_free,
2568 FT_STAT_FIELD_GENERIC6,
2569 FT_STAT_OPT_GENERIC_IP_ADDR,
2570 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2571 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2572 FT_XFIELD_SRCADDR|FT_XFIELD_PROT|FT_XFIELD_TOS|FT_XFIELD_SRCPORT|
2573 FT_XFIELD_DSTPORT},
2574 {"ip-source/destination-address/ip-protocol/ip-tos",
2575 (void*)ftstat_rpt_69_new,
2576 (void*)ftstat_rpt_69_accum,
2577 (void*)ftstat_rpt_69_calc,
2578 (void*)ftstat_rpt_69_dump,
2579 (void*)ftstat_rpt_69_free,
2580 FT_STAT_FIELD_GENERIC4,
2581 FT_STAT_OPT_GENERIC_IP_ADDR,
2582 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2583 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2584 FT_XFIELD_SRCADDR|FT_XFIELD_PROT|FT_XFIELD_TOS},
2585 {"ip-source-address/source-tag",
2586 (void*)ftstat_rpt_70_new,
2587 (void*)ftstat_rpt_70_accum,
2588 (void*)ftstat_rpt_70_calc,
2589 (void*)ftstat_rpt_70_dump,
2590 (void*)ftstat_rpt_70_free,
2591 FT_STAT_FIELD_GENERIC2,
2592 FT_STAT_OPT_GENERIC_IP_ADDR,
2593 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2594 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2595 FT_XFIELD_SRC_TAG},
2596 {"ip-source-address/destination-tag",
2597 (void*)ftstat_rpt_71_new,
2598 (void*)ftstat_rpt_71_accum,
2599 (void*)ftstat_rpt_71_calc,
2600 (void*)ftstat_rpt_71_dump,
2601 (void*)ftstat_rpt_71_free,
2602 FT_STAT_FIELD_GENERIC2,
2603 FT_STAT_OPT_GENERIC_IP_ADDR,
2604 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2605 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_SRCADDR|
2606 FT_XFIELD_DST_TAG},
2607 {"ip-destination-address/source-tag",
2608 (void*)ftstat_rpt_72_new,
2609 (void*)ftstat_rpt_72_accum,
2610 (void*)ftstat_rpt_72_calc,
2611 (void*)ftstat_rpt_72_dump,
2612 (void*)ftstat_rpt_72_free,
2613 FT_STAT_FIELD_GENERIC2,
2614 FT_STAT_OPT_GENERIC_IP_ADDR,
2615 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2616 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2617 FT_XFIELD_SRC_TAG},
2618 {"ip-destination-address/destination-tag",
2619 (void*)ftstat_rpt_73_new,
2620 (void*)ftstat_rpt_73_accum,
2621 (void*)ftstat_rpt_73_calc,
2622 (void*)ftstat_rpt_73_dump,
2623 (void*)ftstat_rpt_73_free,
2624 FT_STAT_FIELD_GENERIC2,
2625 FT_STAT_OPT_GENERIC_IP_ADDR,
2626 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2627 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2628 FT_XFIELD_DST_TAG},
2629 {"ip-source/destination-address/source/destination-tag",
2630 (void*)ftstat_rpt_74_new,
2631 (void*)ftstat_rpt_74_accum,
2632 (void*)ftstat_rpt_74_calc,
2633 (void*)ftstat_rpt_74_dump,
2634 (void*)ftstat_rpt_74_free,
2635 FT_STAT_FIELD_GENERIC4,
2636 FT_STAT_OPT_GENERIC_IP_ADDR,
2637 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2638 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS|FT_XFIELD_DSTADDR|
2639 FT_XFIELD_SRCADDR|FT_XFIELD_SRC_TAG|FT_XFIELD_DST_TAG},
2640 {"linear-interpolated-flows-octets-packets",
2641 (void*)ftstat_rpt_75_new,
2642 (void*)ftstat_rpt_75_accum,
2643 (void*)ftstat_rpt_75_calc,
2644 (void*)ftstat_rpt_75_dump,
2645 (void*)ftstat_rpt_75_free,
2646 FT_STAT_FIELD_FLOWS|FT_STAT_FIELD_OCTETS|FT_STAT_FIELD_PACKETS|
2647 FT_STAT_FIELD_KEY,
2648 FT_STAT_OPT_GENERIC,
2649 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2650 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
2651 {"first",
2652 (void*)ftstat_rpt_76_new,
2653 (void*)ftstat_rpt_76_accum,
2654 (void*)ftstat_rpt_76_calc,
2655 (void*)ftstat_rpt_76_dump,
2656 (void*)ftstat_rpt_76_free,
2657 FT_STAT_FIELD_GENERIC,
2658 FT_STAT_OPT_GENERIC,
2659 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2660 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
2661 {"last",
2662 (void*)ftstat_rpt_77_new,
2663 (void*)ftstat_rpt_77_accum,
2664 (void*)ftstat_rpt_77_calc,
2665 (void*)ftstat_rpt_77_dump,
2666 (void*)ftstat_rpt_77_free,
2667 FT_STAT_FIELD_GENERIC,
2668 FT_STAT_OPT_GENERIC,
2669 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2670 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
2671 {"duration",
2672 (void*)ftstat_rpt_78_new,
2673 (void*)ftstat_rpt_78_accum,
2674 (void*)ftstat_rpt_78_calc,
2675 (void*)ftstat_rpt_78_dump,
2676 (void*)ftstat_rpt_78_free,
2677 FT_STAT_FIELD_GENERIC,
2678 FT_STAT_OPT_GENERIC,
2679 FT_XFIELD_DPKTS|FT_XFIELD_DOCTETS|FT_XFIELD_FIRST|FT_XFIELD_LAST|
2680 FT_XFIELD_UNIX_SECS|FT_XFIELD_UNIX_NSECS},
2681
2682 {(char*)0L, 0, (void*)0L},
2683 };
2684
2685
2686 static struct jump pjump[] = {
2687 {"include-mask", 0, parse_include_mask},
2688 {"include-tag", 0, parse_include_tag},
2689 {"include-filter", 0, parse_include_filter},
2690 {"stat-report", 0, parse_rpt},
2691 {"type", PARSE_STATE_REPORT, parse_rpt_type},
2692 {"filter", PARSE_STATE_REPORT, parse_rpt_filter},
2693 {"scale", PARSE_STATE_REPORT, parse_rpt_scale},
2694 {"output", PARSE_STATE_REPORT, parse_rpt_output},
2695 {"tag-mask", PARSE_STATE_REPORT, parse_rpt_tag_mask},
2696 {"ip-source-address-format", PARSE_STATE_REPORT,
2697 parse_rpt_ip_src_addr_fmt},
2698 {"ip-destination-address-format", PARSE_STATE_REPORT,
2699 parse_rpt_ip_dst_addr_fmt},
2700 {"format", PARSE_STATE_OUTPUT, parse_rpt_out_format},
2701 {"sort", PARSE_STATE_OUTPUT, parse_rpt_out_sort},
2702 {"records", PARSE_STATE_OUTPUT, parse_rpt_out_records},
2703 {"tally", PARSE_STATE_OUTPUT, parse_rpt_out_tally},
2704 {"fields", PARSE_STATE_OUTPUT, parse_rpt_out_fields},
2705 {"options", PARSE_STATE_OUTPUT, parse_rpt_out_options},
2706 {"path", PARSE_STATE_OUTPUT, parse_rpt_out_path},
2707 {"time", PARSE_STATE_OUTPUT, parse_rpt_out_time},
2708 {"stat-definition", 0, parse_def},
2709 {"filter", PARSE_STATE_DEFINITION, parse_def_filter},
2710 {"tag", PARSE_STATE_DEFINITION, parse_def_tag},
2711 {"mask", PARSE_STATE_DEFINITION, parse_def_mask},
2712 {"report", PARSE_STATE_DEFINITION, parse_def_report},
2713 {"time-series", PARSE_STATE_DEFINITION, parse_def_time_series},
2714 {0, 0, 0},
2715 };
2716
2717 /*
2718 *************************************************************************
2719 public ftstat_*
2720 *************************************************************************
2721 */
2722
2723
2724 /*
2725 * function: ftstat_load
2726 *
2727 * Process fname into ftstat.
2728 *
2729 * returns: 0 ok
2730 * <0 fail
2731 */
ftstat_load(struct ftstat * ftstat,struct ftvar * ftvar,const char * fname)2732 int ftstat_load(struct ftstat *ftstat, struct ftvar *ftvar, const char *fname)
2733 {
2734 struct stat sb;
2735 struct jump *jmp;
2736 struct line_parser lp;
2737 int fd, ret, found;
2738 char *buf, *buf2, *c;
2739 char sbuf[FT_LP_MAXLINE];
2740
2741 ret = -1;
2742 buf = (char*)0L;
2743 bzero(&lp, sizeof lp);
2744 bzero(ftstat, sizeof *ftstat);
2745
2746 FT_SLIST_INIT(&ftstat->defs);
2747 FT_SLIST_INIT(&ftstat->rpts);
2748
2749 ftstat->ftvar = ftvar;
2750
2751 lp.fname = fname;
2752
2753 if ((fd = open(fname, O_RDONLY, 0)) < 0) {
2754 fterr_warn("open(%s)", fname);
2755 goto load_stat_out;
2756 }
2757
2758 if (fstat(fd, &sb) < 0) {
2759 fterr_warn("stat(%s)", fname);
2760 goto load_stat_out;
2761 }
2762
2763 /* allocate storage for file */
2764 if (!(buf = malloc(sb.st_size+1))) {
2765 fterr_warn("malloc()");
2766 goto load_stat_out;
2767 }
2768
2769 /* read in file */
2770 if (read(fd, buf, sb.st_size) != sb.st_size) {
2771 fterr_warnx("read(%s): short", fname);
2772 goto load_stat_out;
2773 }
2774
2775 /* null terminate file */
2776 buf[sb.st_size] = 0;
2777
2778 buf2 = buf;
2779
2780 for (;;) {
2781
2782 /* rip a line */
2783 for (;;) {
2784 c = strsep(&buf2, "\n");
2785 ++lp.lineno;
2786 if ((c && *c != 0) || (!c))
2787 break;
2788 }
2789
2790 /* no more lines */
2791 if (!c) {
2792 goto load_stat_done;
2793 }
2794
2795 /* do variable substitutions first */
2796 if (ftvar) {
2797 if (ftvar_evalstr(ftvar, c, sbuf, sizeof(sbuf)) < 0) {
2798 fterr_warnx("ftvar_evalstr(): failed");
2799 goto load_stat_done;
2800 }
2801 } else {
2802 strncpy(sbuf, c, sizeof(sbuf));
2803 sbuf[sizeof(sbuf)-1] = 0;
2804 }
2805
2806 lp.buf = sbuf;
2807
2808 /* first word */
2809 NEXT_WORD(&lp.buf, c);
2810
2811 /* whitespace only line */
2812 if (!c) {
2813 continue;
2814 }
2815
2816 /* comment line */
2817 if (c && *c == '#')
2818 continue;
2819
2820 for (jmp = pjump; jmp->name; ++jmp) {
2821
2822 found = 0;
2823
2824 if (((!jmp->state) || (jmp->state & lp.state))
2825 && (!strcasecmp(c, jmp->name))) {
2826
2827 found = 1;
2828
2829 if (jmp->func(&lp, ftstat))
2830 goto load_stat_out;
2831
2832 NEXT_WORD(&lp.buf, c);
2833
2834 if (c) {
2835 fterr_warnx("%s line %d: Unexpected \"%s\".", lp.fname, lp.lineno, c);
2836 goto load_stat_out;
2837 }
2838
2839 break;
2840
2841 }
2842
2843 } /* test each word */
2844
2845 if (!found) {
2846 fterr_warnx("%s line %d: Unexpected \"%s\".", lp.fname, lp.lineno, c);
2847 goto load_stat_out;
2848 }
2849
2850 } /* more lines */
2851
2852 load_stat_done:
2853
2854 if (resolve_reports(ftstat)) {
2855 fterr_warnx("resolve_reports(): failed");
2856 goto load_stat_out;
2857 }
2858
2859 ret = 0;
2860
2861 load_stat_out:
2862
2863 if (fd != -1)
2864 close(fd);
2865
2866 if (buf)
2867 free(buf);
2868
2869 if (ret == -1)
2870 ftstat_free(ftstat);
2871
2872 return ret;
2873
2874 } /* ftstat_load */
2875
ftstat_free(struct ftstat * ftstat)2876 void ftstat_free(struct ftstat *ftstat)
2877 {
2878 struct ftstat_def *ftsd;
2879 struct ftstat_rpt *ftsr;
2880 struct ftstat_rpt_out *ftsro;
2881 struct ftstat_rpt_item *ftsrpti;
2882
2883 if (ftstat->ftfil_init)
2884 ftfil_free(&ftstat->ftfil);
2885
2886 if (ftstat->fttag_init)
2887 fttag_free(&ftstat->fttag);
2888
2889 if (ftstat->ftmask_init)
2890 ftmask_free(&ftstat->ftmask);
2891
2892 if (ftstat->filter_fname)
2893 free(ftstat->filter_fname);
2894
2895 if (ftstat->tag_fname)
2896 free(ftstat->tag_fname);
2897
2898 if (ftstat->mask_fname)
2899 free(ftstat->mask_fname);
2900
2901 /* free each definition */
2902 while (!FT_SLIST_EMPTY(&ftstat->defs)) {
2903
2904 ftsd = FT_SLIST_FIRST(&ftstat->defs);
2905 FT_SLIST_REMOVE_HEAD(&ftstat->defs, chain);
2906
2907 /* free each item in the definition */
2908 while (!FT_STAILQ_EMPTY(&ftsd->items)) {
2909
2910 ftsrpti = FT_STAILQ_FIRST(&ftsd->items);
2911 FT_STAILQ_REMOVE_HEAD(&ftsd->items, chain);
2912 free(ftsrpti->tmp_report);
2913 free(ftsrpti);
2914
2915 }
2916
2917 free(ftsd->name);
2918 free(ftsd);
2919
2920 } /* definitions */
2921
2922 /* free each report */
2923 while (!FT_SLIST_EMPTY(&ftstat->rpts)) {
2924
2925 ftsr = FT_SLIST_FIRST(&ftstat->rpts);
2926 FT_SLIST_REMOVE_HEAD(&ftstat->rpts, chain);
2927
2928 /* free each output in the report */
2929 while (!FT_STAILQ_EMPTY(&ftsr->outs)) {
2930
2931 ftsro = FT_STAILQ_FIRST(&ftsr->outs);
2932 FT_STAILQ_REMOVE_HEAD(&ftsr->outs, chain);
2933 if (ftsro->path)
2934 free(ftsro->path);
2935 free(ftsro);
2936
2937 }
2938
2939 free(ftsr->name);
2940 free(ftsr);
2941
2942 } /* reports */
2943
2944 } /* ftstat_free */
2945
ftstat_def_find(struct ftstat * ftstat,const char * name)2946 struct ftstat_def *ftstat_def_find(struct ftstat *ftstat, const char *name)
2947 {
2948 struct ftstat_def *ftsd;
2949 int found;
2950
2951 found = 0;
2952
2953 FT_SLIST_FOREACH(ftsd, &ftstat->defs, chain) {
2954
2955 if (!strcasecmp(name, ftsd->name))
2956 return ftsd;
2957
2958 } /* ftsd */
2959
2960 return (struct ftstat_def*)0L;
2961
2962 } /* ftstat_def_find */
2963
2964 /*
2965 * function: ftstat_def_test_xfields
2966 *
2967 * Check if fields in current flow are valid for a stat definition -- ie
2968 * the filter does not reference a field not contained in the flow.
2969 *
2970 * returns: 0 okay
2971 * 1 fail
2972 */
ftstat_def_test_xfields(struct ftstat_def * active_def,uint64_t test)2973 int ftstat_def_test_xfields(struct ftstat_def *active_def, uint64_t test)
2974 {
2975
2976 /* if the definition has tagging enabled _accum() will add the tags */
2977 if (active_def->ftd)
2978 test |= FT_XFIELD_SRC_TAG|FT_XFIELD_DST_TAG;
2979
2980 if ((active_def->xfields & test) != active_def->xfields)
2981 return 1;
2982 else
2983 return 0;
2984
2985 } /* ftstat_def_test_xfields */
2986
2987 /*
2988 * function: ftstat_def_new
2989 *
2990 * Call the new method for each report.
2991 *
2992 * returns: 0 okay
2993 * 1 fail
2994 */
ftstat_def_new(struct ftstat_def * active_def)2995 int ftstat_def_new(struct ftstat_def *active_def)
2996 {
2997 struct ftstat_rpt *ftsrpt;
2998 struct ftstat_rpt_item *ftsrpti;
2999 struct ftstat_rpt_out *ftsro;
3000 int ret;
3001
3002 ret = 1; /* err */
3003
3004 /* foreach report in the definition */
3005 FT_STAILQ_FOREACH(ftsrpti, &active_def->items, chain) {
3006
3007 ftsrpt = ftsrpti->rpt;
3008
3009 /* initialize */
3010 ftsrpt->t_ignores = 0;
3011 ftsrpt->t_recs = 0;
3012 ftsrpt->t_flows = 0;
3013 ftsrpt->t_octets = 0;
3014 ftsrpt->t_packets = 0;
3015 ftsrpt->t_duration = 0;
3016 ftsrpt->t_count = 0;
3017 ftsrpt->time_start = 0xFFFFFFFF;
3018 ftsrpt->time_end = 0;
3019 ftsrpt->recs = 0;
3020 ftsrpt->avg_pps = 0;
3021 ftsrpt->avg_bps = 0;
3022 ftsrpt->max_pps = 0;
3023 ftsrpt->max_bps = 0;
3024 ftsrpt->min_pps = 0;
3025 ftsrpt->min_bps = 0;
3026 ftsrpt->all_fields = 0;
3027
3028 /* foreach output in the report, sum the fields */
3029 FT_STAILQ_FOREACH(ftsro, &ftsrpt->outs, chain) {
3030 ftsrpt->all_fields |= ftsro->fields;
3031 /* could sort and not display */
3032 ftsrpt->all_fields |= ftsro->sort_field;
3033 }
3034
3035 /* run the new function */
3036 if (!(ftsrpt->data = ftsrpt->f_new(ftsrpt))) {
3037 fterr_warnx("f_new(%s): failed.", ftsrpt->name);
3038 goto out;
3039 }
3040
3041 }
3042
3043 ret = 0;
3044
3045 out:
3046
3047 return ret;
3048
3049 } /* ftstat_def_new */
3050
3051 /*
3052 * function: ftstat_def_accum
3053 *
3054 * Call the accum method for each report.
3055 *
3056 * returns: 0 okay
3057 * <0 fail
3058 * 1 next report.
3059 */
ftstat_def_accum(struct ftstat_def * active_def,char * rec,struct fts3rec_offsets * fo)3060 int ftstat_def_accum(struct ftstat_def *active_def,
3061 char *rec, struct fts3rec_offsets *fo)
3062 {
3063 struct ftver ftv;
3064 struct ftstat_rpt *ftsrpt;
3065 struct ftstat_rpt_item *ftsrpti;
3066 struct fts3rec_all2 cur;
3067 char xl_rec[FT_IO_MAXREC];
3068 int ret;
3069
3070 FT_RECGET_UNIX_SECS(cur,rec,*fo);
3071
3072 if (!active_def->start_time)
3073 active_def->start_time = cur.unix_secs;
3074
3075 /* time series split? */
3076 if ((active_def->max_time && (cur.unix_secs > active_def->start_time) &&
3077 (cur.unix_secs - active_def->start_time) > active_def->max_time)) {
3078
3079 active_def->start_time = cur.unix_secs;
3080 return 1;
3081
3082 }
3083
3084 ret = -1; /* err */
3085
3086 /* if mask replacement is enabled, do it */
3087 if (active_def->ftmd)
3088 ftmask_def_eval(active_def->ftmd, rec, fo);
3089
3090 /* if tagging is enabled, translate and tag */
3091 if (active_def->ftd) {
3092
3093 /* translate to 1005 is not allready */
3094 if (fo->ftv.d_version != 1005) {
3095
3096 ftv.d_version = 1005;
3097 ftrec_xlate(rec, &fo->ftv, &xl_rec, &ftv);
3098 rec = (char*)&xl_rec;
3099 fo = &nfo;
3100
3101 }
3102
3103 fttag_def_eval(active_def->ftd, (void*)rec);
3104
3105 }
3106
3107 /* if a filter is defined, evaluate it first */
3108 if (active_def->ftfd)
3109 if (ftfil_def_eval(active_def->ftfd, rec, fo) == FT_FIL_MODE_DENY)
3110 goto done;
3111
3112 /* foreach report in the definition */
3113 FT_STAILQ_FOREACH(ftsrpti, &active_def->items, chain) {
3114
3115 ftsrpt = ftsrpti->rpt;
3116
3117 /*
3118 * if the tag mask option is set apply the masks, not this can only
3119 * be set if the tags exist.
3120 *
3121 */
3122 if (ftsrpt->options & FT_STAT_OPT_TAG_MASK) {
3123
3124 /* preserve tags */
3125 FT_RECGET_SRC_TAG(cur,rec,*fo);
3126 FT_RECGET_DST_TAG(cur,rec,*fo);
3127
3128 *((uint32_t*)(rec+(*fo).src_tag)) &= ftsrpt->tag_mask_src;
3129 *((uint32_t*)(rec+(*fo).dst_tag)) &= ftsrpt->tag_mask_dst;
3130
3131 }
3132
3133 /* if a filter is defined, evaluate */
3134 if (ftsrpt->ftfd)
3135 if (ftfil_def_eval(ftsrpt->ftfd, rec, fo) == FT_FIL_MODE_DENY)
3136 goto restore_tag;
3137
3138 /* run the accum function */
3139 if (ftsrpt->f_accum(ftsrpt, rec, fo)) {
3140 fterr_warnx("f_accum(%s): failed.", ftsrpt->name);
3141 goto out;
3142 }
3143
3144 /* restore tags */
3145 restore_tag:
3146 if (ftsrpt->options & FT_STAT_OPT_TAG_MASK) {
3147
3148 *((uint32_t*)(rec+(*fo).src_tag)) = cur.src_tag;
3149 *((uint32_t*)(rec+(*fo).dst_tag)) = cur.dst_tag;
3150
3151 }
3152
3153 }
3154
3155 done:
3156
3157 ret = 0;
3158
3159 out:
3160
3161 return ret;
3162
3163 } /* ftstat_def_accum */
3164
3165 /*
3166 * function: ftstat_def_calc
3167 *
3168 * Call the calc method for each report.
3169 *
3170 * returns: 0 okay
3171 * 1 fail
3172 */
ftstat_def_calc(struct ftstat_def * active_def)3173 int ftstat_def_calc(struct ftstat_def *active_def)
3174 {
3175 struct ftstat_rpt *ftsrpt;
3176 struct ftstat_rpt_item *ftsrpti;
3177 int ret;
3178
3179 ret = 1; /* err */
3180
3181 /* foreach report in the definition */
3182 FT_STAILQ_FOREACH(ftsrpti, &active_def->items, chain) {
3183
3184 ftsrpt = ftsrpti->rpt;
3185
3186 /* run the new function */
3187 if (ftsrpt->f_calc(ftsrpt)) {
3188 fterr_warnx("f_calc(%s): failed.", ftsrpt->name);
3189 goto out;
3190 }
3191
3192 }
3193
3194 ret = 0;
3195
3196 out:
3197
3198 return ret;
3199
3200 } /* ftstat_def_calc */
3201
3202 /*
3203 * function: ftstat_def_dump
3204 *
3205 * Call the dump method for each report.
3206 *
3207 * returns: 0 okay
3208 * 1 fail
3209 */
ftstat_def_dump(struct ftio * ftio,struct ftstat_def * active_def)3210 int ftstat_def_dump(struct ftio *ftio, struct ftstat_def *active_def)
3211 {
3212 struct tm *tm;
3213 time_t now;
3214 FILE *fp;
3215 struct ftstat_rpt *ftsrpt;
3216 struct ftstat_rpt_item *ftsrpti;
3217 struct ftstat_rpt_out *ftsro;
3218 int ret, noclose, pipe, status;
3219 char fmt_tmp[64], fmt_buf[1024], path_buf[1024], *path_run;
3220 char *mode;
3221
3222 noclose = 0; /* fclose fp */
3223 ret = 1; /* err */
3224 fp = (FILE*)0L;
3225
3226 /* foreach report in the definition */
3227 FT_STAILQ_FOREACH(ftsrpti, &active_def->items, chain) {
3228
3229 ftsrpt = ftsrpti->rpt;
3230
3231 /* foreach output listed */
3232 FT_STAILQ_FOREACH(ftsro, &ftsrpt->outs, chain) {
3233
3234 /* current output is this one */
3235 ftsrpt->out = ftsro;
3236
3237 if (ftsro->path) {
3238
3239 strncpy(fmt_buf, ftsro->path, sizeof(fmt_buf));
3240 fmt_buf[sizeof(fmt_buf)-1] = 0;
3241
3242 if (ftsro->time == FT_STAT_TIME_NOW)
3243 now = time((time_t*)0L);
3244 else if (ftsro->time == FT_STAT_TIME_START)
3245 now = ftsrpt->time_start;
3246 else if (ftsro->time == FT_STAT_TIME_END)
3247 now = ftsrpt->time_end;
3248 else if (ftsro->time == FT_STAT_TIME_MID)
3249 now = ftsrpt->time_start + (ftsrpt->time_end - ftsrpt->time_start)/2;
3250
3251 tm = localtime(&now);
3252
3253 if (!(strftime(path_buf, sizeof path_buf, fmt_buf, tm))) {
3254 fterr_warnx("strftime(): failed");
3255 goto out;
3256 }
3257
3258 if (path_buf[0] == '|') {
3259 pipe = 1;
3260 path_run = path_buf+1;
3261 } else {
3262 pipe = 0;
3263 path_run = path_buf;
3264 }
3265
3266 if (!pipe) {
3267
3268 if (mkpath(path_run, 0755) < 0) {
3269 fterr_warnx("mkpath(%s): failed", path_run);
3270 goto out;
3271 }
3272
3273 /* write first interval, append the rest */
3274 if (!active_def->interval)
3275 mode = "w";
3276 else
3277 mode = "a";
3278
3279 if (!(fp = fopen(path_run, mode))) {
3280 fterr_warn("fopen(%s)", path_run);
3281 goto out;
3282 }
3283
3284 noclose = 0;
3285
3286 } else { /* pipe */
3287
3288 if (!(fp = popen(path_run, "w"))) {
3289 fterr_warn("popen(%s)", path_run);
3290 goto out;
3291 }
3292
3293 noclose = 0;
3294
3295 } /* !pipe */
3296
3297 } else { /* path specified */
3298
3299 fp = stdout;
3300 pipe = 0;
3301 noclose = 1;
3302
3303 }
3304
3305 /* display header bits */
3306 dump_ascii_header(fp, ftio, active_def, ftsrpt);
3307
3308 /* display totals? */
3309 if (ftsro->options & FT_STAT_OPT_TOTALS) {
3310 STD_DUMP_TOTALS_HEADER;
3311 STD_DUMP_TOTALS_VAL;
3312 }
3313
3314 /* run the dump function */
3315 if (ftsro->f_dump(fp, ftio, ftsrpt)) {
3316 fterr_warnx("f_dump(%s): failed.", path_run);
3317 goto out;
3318 }
3319
3320 if ((!noclose) && fp) {
3321
3322 if (!pipe) {
3323 if (fclose(fp))
3324 fterr_warn("fclose(%s)", path_run);
3325 } else {
3326 status = pclose(fp);
3327 if (status == -1)
3328 fterr_warn("pclose(%s)", path_run);
3329 if (WIFEXITED(status))
3330 if (WEXITSTATUS(status) != 0)
3331 fterr_warnx("pclose(%s): failed exit code=%d.", path_run,
3332 WEXITSTATUS(status));
3333 }
3334
3335 } /* !noclose && fp */
3336
3337 } /* foreach output */
3338
3339 } /* foreach report */
3340
3341 ret = 0;
3342
3343 out:
3344
3345 return ret;
3346
3347 } /* ftstat_def_dump */
3348
3349 /*
3350 * function: ftstat_def_free
3351 *
3352 * Call the free method for each report.
3353 *
3354 * returns: 0 okay
3355 * 1 fail
3356 */
ftstat_def_free(struct ftstat_def * active_def)3357 int ftstat_def_free(struct ftstat_def *active_def)
3358 {
3359 struct ftstat_rpt *ftsrpt;
3360 struct ftstat_rpt_item *ftsrpti;
3361
3362 /* foreach report in the definition */
3363 FT_STAILQ_FOREACH(ftsrpti, &active_def->items, chain) {
3364
3365 ftsrpt = ftsrpti->rpt;
3366
3367 /* run the free function */
3368 ftsrpt->f_free(ftsrpt->data);
3369
3370 }
3371
3372 return 0;
3373
3374 } /* ftstat_def_free */
3375
3376 /*
3377 * function: ftstat_def_reset
3378 *
3379 * Reset reports between time series intervals
3380 *
3381 * returns: 0 okay
3382 * 1 fail
3383 */
ftstat_def_reset(struct ftstat_def * active_def)3384 int ftstat_def_reset(struct ftstat_def *active_def)
3385 {
3386
3387 if (ftstat_def_free(active_def)) {
3388 fterr_warnx("ftstat_def_free(%s): failed.", active_def->name);
3389 return -1;
3390 }
3391
3392 if (ftstat_def_new(active_def)) {
3393 fterr_warnx("ftstat_def_new(%s): failed.", active_def->name);
3394 return -1;
3395 }
3396
3397 ++active_def->interval;
3398
3399 return 0;
3400
3401 } /* ftstat_def_reset */
3402
3403 /*
3404 * function: ftstat_list_reports
3405 *
3406 * List available reports
3407 *
3408 */
3409
ftstat_list_reports(FILE * out)3410 void ftstat_list_reports(FILE *out)
3411 {
3412 struct typelookup *tl;
3413
3414 for (tl = tlookup; tl->name; ++tl)
3415 fprintf(out, " %s\n", tl->name);
3416
3417 } /* ftstat_list_reports */
3418
3419 /*
3420 *************************************************************************
3421 parse_rpt_*
3422 *************************************************************************
3423 */
3424
3425 /*
3426 * function: parse_rpt
3427 *
3428 * process the 'stat-report' line. Each report has a unique name
3429 * which is added to the ftstat->rpts linked list. The current
3430 * report is updated in lp. Reports by themself do nothing,
3431 * they must be invoked by a definition.
3432 *
3433 * returns: 0 ok
3434 * <0 fail
3435 */
parse_rpt(struct line_parser * lp,struct ftstat * ftstat)3436 int parse_rpt(struct line_parser *lp, struct ftstat *ftstat)
3437 {
3438
3439 char *c;
3440 struct ftstat_rpt *ftsr;
3441
3442 NEXT_WORD(&lp->buf, c);
3443
3444 if (!c) {
3445 fterr_warnx("%s line %d: Expecting name.", lp->fname, lp->lineno);
3446 return -1;
3447 }
3448
3449 /* check if it exists */
3450 FT_SLIST_FOREACH(ftsr, &ftstat->rpts, chain) {
3451
3452 if (!strcasecmp(c, ftsr->name)) {
3453 fterr_warnx("%s line %d: Name (%s) previously defined.", lp->fname,
3454 lp->lineno, c);
3455 return -1;
3456 }
3457
3458 }
3459
3460 /* no, add a new entry to the list */
3461 if (!(ftsr = (struct ftstat_rpt*)malloc(sizeof *ftsr))) {
3462 fterr_warn("malloc()");
3463 return -1;
3464 }
3465
3466 bzero(ftsr, sizeof *ftsr);
3467
3468 FT_STAILQ_INIT(&ftsr->outs);
3469
3470 if (!(ftsr->name = (char*)malloc(strlen(c)+1))) {
3471 fterr_warn("malloc()");
3472 free(ftsr);
3473 return -1;
3474 }
3475
3476 strcpy(ftsr->name, c);
3477
3478 FT_SLIST_INSERT_HEAD(&ftstat->rpts, ftsr, chain);
3479
3480 lp->state = PARSE_STATE_REPORT;
3481 lp->cur_rpt = ftsr;
3482 lp->cur_rpt_out = (struct ftstat_rpt_out*)0L;
3483
3484 return 0;
3485
3486 } /* parse_rpt */
3487
3488 /*
3489 * function: parse_rpt_type
3490 *
3491 * process the 'type' line.
3492 *
3493 * returns: 0 ok
3494 * <0 fail
3495 */
parse_rpt_type(struct line_parser * lp,struct ftstat * ftstat)3496 int parse_rpt_type(struct line_parser *lp, struct ftstat *ftstat)
3497 {
3498 struct typelookup *tl;
3499 int found;
3500
3501 if (!lp->cur_rpt) {
3502 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
3503 return -1;
3504 }
3505
3506 NEXT_WORD(&lp->buf, lp->word);
3507
3508 if (!lp->word) {
3509 fterr_warnx("%s line %d: Expecting type.", lp->fname, lp->lineno);
3510 return -1;
3511 }
3512
3513 if (lp->cur_rpt->f_new) {
3514 fterr_warnx("%s line %d: Type previously defined.", lp->fname,
3515 lp->lineno);
3516 return -1;
3517 }
3518
3519 found = 0;
3520
3521 for (tl = tlookup; tl->name; ++tl) {
3522
3523 if (!strcasecmp(lp->word, tl->name)) {
3524
3525 lp->cur_rpt->allowed_fields = tl->allowed_fields;
3526 lp->cur_rpt->allowed_options = tl->allowed_options;
3527 lp->cur_rpt->xfields = tl->xfields;
3528 lp->cur_rpt->f_new = tl->f_new;
3529 lp->cur_rpt->f_accum = tl->f_accum;
3530 lp->cur_rpt->f_calc = tl->f_calc;
3531 lp->cur_rpt->f_dump = tl->f_dump;
3532 lp->cur_rpt->f_free = tl->f_free;
3533 lp->cur_rpt->format_name = tl->name;
3534
3535 found = 1;
3536
3537 break;
3538
3539 }
3540
3541 } /* for */
3542
3543 if (!found) {
3544 fterr_warnx("%s line %d: Unrecognized type.", lp->fname, lp->lineno);
3545 return -1;
3546 }
3547
3548 return 0;
3549
3550 } /* parse_rpt_type */
3551
3552 /*
3553 * function: parse_rpt_filter
3554 *
3555 * process the 'filter' line.
3556 *
3557 * returns: 0 ok
3558 * <0 fail
3559 */
parse_rpt_filter(struct line_parser * lp,struct ftstat * ftstat)3560 int parse_rpt_filter(struct line_parser *lp, struct ftstat *ftstat)
3561 {
3562
3563 if (!lp->cur_rpt) {
3564 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
3565 return -1;
3566 }
3567
3568 NEXT_WORD(&lp->buf, lp->word);
3569
3570 if (!lp->word) {
3571 fterr_warnx("%s line %d: Expecting filter name.", lp->fname, lp->lineno);
3572 return -1;
3573 }
3574
3575 if (lp->cur_rpt->ftfd) {
3576 fterr_warnx("%s line %d: Filter previously defined for report .",
3577 lp->fname, lp->lineno);
3578 return -1;
3579 }
3580
3581 /* delay loading the filters until one is requested */
3582 if (load_filters(ftstat)) {
3583 fterr_warnx("%s line %d: Filters not loaded.", lp->fname, lp->lineno);
3584 return -1;
3585 }
3586
3587 if (!(lp->cur_rpt->ftfd = ftfil_def_find(&ftstat->ftfil,
3588 lp->word))) {
3589 fterr_warnx("%s line %d: Filter definition not found.", lp->fname,
3590 lp->lineno);
3591 return -1;
3592 }
3593
3594 return 0;
3595
3596 } /* parse_rpt_filter */
3597
3598 /*
3599 * function: parse_rpt_tag_mask
3600 *
3601 * process the 'output' line.
3602 *
3603 * returns: 0 ok
3604 * <0 fail
3605 */
parse_rpt_tag_mask(struct line_parser * lp,struct ftstat * ftstat)3606 int parse_rpt_tag_mask(struct line_parser *lp, struct ftstat *ftstat)
3607 {
3608
3609 if (!lp->cur_rpt) {
3610 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
3611 return -1;
3612 }
3613
3614 NEXT_WORD(&lp->buf, lp->word);
3615
3616 if (!lp->word) {
3617 fterr_warnx("%s line %d: Expecting source mask.", lp->fname,
3618 lp->lineno);
3619 return -1;
3620 }
3621
3622 lp->cur_rpt->tag_mask_src = strtoul(lp->word, (char**)0L, 0);
3623
3624 NEXT_WORD(&lp->buf, lp->word);
3625
3626 if (!lp->word) {
3627 fterr_warnx("%s line %d: Expecting destination mask.", lp->fname,
3628 lp->lineno);
3629 return -1;
3630 }
3631
3632 lp->cur_rpt->tag_mask_dst = strtoul(lp->word, (char**)0L, 0);
3633
3634 lp->cur_rpt->options |= FT_STAT_OPT_TAG_MASK;
3635 lp->cur_rpt->xfields |= FT_XFIELD_SRC_TAG|FT_XFIELD_DST_TAG;
3636
3637 return 0;
3638
3639 } /* parse_rpt_tag_mask */
3640
3641
3642 /*
3643 * function: parse_rpt_scale
3644 *
3645 * process the 'scale' line.
3646 *
3647 * returns: 0 ok
3648 * <0 fail
3649 */
parse_rpt_scale(struct line_parser * lp,struct ftstat * ftstat)3650 int parse_rpt_scale(struct line_parser *lp, struct ftstat *ftstat)
3651 {
3652
3653 if (!lp->cur_rpt) {
3654 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
3655 return -1;
3656 }
3657
3658 NEXT_WORD(&lp->buf, lp->word);
3659
3660 if (!lp->word) {
3661 fterr_warnx("%s line %d: Expecting scaling factor.", lp->fname,
3662 lp->lineno);
3663 return -1;
3664 }
3665
3666 lp->cur_rpt->scale = atoi(lp->word);
3667
3668 return 0;
3669
3670 } /* parse_rpt_scale */
3671
3672 /*
3673 * function: parse_rpt_ip_src_addr_fmt
3674 *
3675 * process the 'ip-source-address-format' line.
3676 *
3677 * returns: 0 ok
3678 * <0 fail
3679 */
parse_rpt_ip_src_addr_fmt(struct line_parser * lp,struct ftstat * ftstat)3680 int parse_rpt_ip_src_addr_fmt(struct line_parser *lp, struct ftstat *ftstat)
3681 {
3682
3683 if (!lp->cur_rpt) {
3684 fterr_warnx("%s line %d: Not in report.", lp->fname, lp->lineno);
3685 return -1;
3686 }
3687
3688 NEXT_WORD(&lp->buf, lp->word);
3689
3690 if (!lp->word) {
3691 fterr_warnx("%s line %d: Expecting address format.", lp->fname,
3692 lp->lineno);
3693 return -1;
3694 }
3695
3696 if (!(strcasecmp(lp->word, "prefix-len")))
3697 lp->cur_rpt->options |= FT_STAT_OPT_SRC_PREFIX_LEN;
3698 else if (!(strcasecmp(lp->word, "prefix-mask")))
3699 lp->cur_rpt->options |= FT_STAT_OPT_SRC_PREFIX_MASK;
3700 else if (!(strcasecmp(lp->word, "address")))
3701 lp->cur_rpt->options &=
3702 ~(FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN);
3703 else {
3704 fterr_warnx("%s line %d: Invalid address format.", lp->fname, lp->lineno);
3705 return -1;
3706 }
3707
3708 /*
3709 * if the PREFIX_LEN or PREFIX_MASK option is set then this report
3710 * requires the FT_XFIELD_XXX_MASK bits.
3711 */
3712
3713 if (lp->cur_rpt->options &
3714 (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
3715
3716 if (lp->cur_rpt->xfields & FT_XFIELD_SRCADDR)
3717 lp->cur_rpt->xfields |= FT_XFIELD_SRC_MASK;
3718
3719 } else {
3720
3721 lp->cur_rpt->xfields &= ~ FT_XFIELD_SRC_MASK;
3722
3723 } /* OPT_PREFIX_* */
3724
3725 return 0;
3726
3727 } /* parse_rpt_ip_src_addr_fmt */
3728
3729 /*
3730 * function: parse_rpt_ip_dst_addr_fmt
3731 *
3732 * process the 'ip-address-format' line.
3733 *
3734 * returns: 0 ok
3735 * <0 fail
3736 */
parse_rpt_ip_dst_addr_fmt(struct line_parser * lp,struct ftstat * ftstat)3737 int parse_rpt_ip_dst_addr_fmt(struct line_parser *lp, struct ftstat *ftstat)
3738 {
3739
3740 if (!lp->cur_rpt) {
3741 fterr_warnx("%s line %d: Not in report.", lp->fname, lp->lineno);
3742 return -1;
3743 }
3744
3745 NEXT_WORD(&lp->buf, lp->word);
3746
3747 if (!lp->word) {
3748 fterr_warnx("%s line %d: Expecting address format.", lp->fname,
3749 lp->lineno);
3750 return -1;
3751 }
3752
3753 if (!(strcasecmp(lp->word, "prefix-len")))
3754 lp->cur_rpt->options |= FT_STAT_OPT_DST_PREFIX_LEN;
3755 else if (!(strcasecmp(lp->word, "prefix-mask")))
3756 lp->cur_rpt->options |= FT_STAT_OPT_DST_PREFIX_MASK;
3757 else if (!(strcasecmp(lp->word, "address")))
3758 lp->cur_rpt->options
3759 &= ~(FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN);
3760 else {
3761 fterr_warnx("%s line %d: Invalid address format.", lp->fname, lp->lineno);
3762 return -1;
3763 }
3764
3765 /*
3766 * if the PREFIX_LEN or PREFIX_MASK option is set then this report
3767 * requires the FT_XFIELD_XXX_MASK bits.
3768 */
3769
3770 if (lp->cur_rpt->options &
3771 (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
3772
3773 if (lp->cur_rpt->xfields & FT_XFIELD_DSTADDR)
3774 lp->cur_rpt->xfields |= FT_XFIELD_DST_MASK;
3775
3776 } else {
3777
3778 lp->cur_rpt->xfields &= ~ FT_XFIELD_DST_MASK;
3779
3780 } /* OPT_PREFIX_* */
3781
3782 return 0;
3783
3784 } /* parse_rpt_ip_dst_addr_fmt */
3785
3786 /*
3787 *************************************************************************
3788 parse_rpt_output and friends
3789 *************************************************************************
3790 */
3791
3792 /*
3793 * function: parse_rpt_output
3794 *
3795 * process the 'output' line.
3796 *
3797 * returns: 0 ok
3798 * <0 fail
3799 */
parse_rpt_output(struct line_parser * lp,struct ftstat * ftstat)3800 int parse_rpt_output(struct line_parser *lp, struct ftstat *ftstat)
3801 {
3802 struct ftstat_rpt_out *ftsro;
3803
3804 if (!lp->cur_rpt) {
3805 fterr_warnx("%s line %d: Not in a report.", lp->fname, lp->lineno);
3806 return -1;
3807 }
3808
3809 /* add a new entry to the list */
3810 if (!(ftsro = (struct ftstat_rpt_out*)malloc(sizeof *ftsro))) {
3811 fterr_warn("malloc()");
3812 return -1;
3813 }
3814
3815 bzero(ftsro, sizeof *ftsro);
3816 ftsro->f_dump = lp->cur_rpt->f_dump;
3817 ftsro->fields = lp->cur_rpt->allowed_fields;
3818 ftsro->fields &= ~(FT_STAT_FIELD_FRECS|
3819 FT_STAT_FIELD_INDEX|
3820 FT_STAT_FIELD_FIRST|
3821 FT_STAT_FIELD_LAST|
3822 FT_STAT_FIELD_PPS|
3823 FT_STAT_FIELD_BPS); /* default some off */
3824 ftsro->time = FT_STAT_TIME_MID;
3825 lp->cur_rpt_out = ftsro;
3826
3827 FT_STAILQ_INSERT_TAIL(&lp->cur_rpt->outs, ftsro, chain);
3828
3829 return 0;
3830
3831 } /* parse_rpt_output */
3832
3833 /*
3834 * function: parse_rpt_out_format
3835 *
3836 * process the 'format' line.
3837 *
3838 * returns: 0 ok
3839 * <0 fail
3840 */
parse_rpt_out_format(struct line_parser * lp,struct ftstat * ftstat)3841 int parse_rpt_out_format(struct line_parser *lp, struct ftstat *ftstat)
3842 {
3843 enum ftstat_rpt_format format;
3844
3845 if (!lp->cur_rpt_out) {
3846 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
3847 return -1;
3848 }
3849
3850 NEXT_WORD(&lp->buf, lp->word);
3851
3852 if (!lp->word) {
3853 fterr_warnx("%s line %d: Expecting format.", lp->fname,
3854 lp->lineno);
3855 return -1;
3856 }
3857
3858 if (!(strcasecmp(lp->word, "ascii")))
3859 format = FT_STAT_FMT_ASCII;
3860 else if (!(strcasecmp(lp->word, "binary")))
3861 format = FT_STAT_FMT_BINARY;
3862 else {
3863 fterr_warnx("%s line %d: Unrecognized format.", lp->fname, lp->lineno);
3864 return -1;
3865 }
3866
3867 lp->cur_rpt->format = format;
3868
3869 return 0;
3870
3871 } /* parse_rpt_out_format */
3872
3873 /*
3874 * function: parse_rpt_out_sort
3875 *
3876 * process the 'sort' line.
3877 *
3878 * returns: 0 ok
3879 * <0 fail
3880 */
parse_rpt_out_sort(struct line_parser * lp,struct ftstat * ftstat)3881 int parse_rpt_out_sort(struct line_parser *lp, struct ftstat *ftstat)
3882 {
3883 int sort_field, sort_order;
3884 char *c;
3885
3886 if (!lp->cur_rpt_out) {
3887 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
3888 return -1;
3889 }
3890
3891 NEXT_WORD(&lp->buf, lp->word);
3892
3893 if (!lp->word) {
3894 fterr_warnx("%s line %d: Expecting sort field.", lp->fname,
3895 lp->lineno);
3896 return -1;
3897 }
3898
3899 c = lp->word;
3900
3901 if (*c == '+')
3902 sort_order = FT_STAT_SORT_ASCEND;
3903 else if (*c == '-')
3904 sort_order = FT_STAT_SORT_DESCEND;
3905 else {
3906 fterr_warnx("%s line %d: Expecting + or -.", lp->fname, lp->lineno);
3907 return -1;
3908 }
3909
3910 ++c;
3911
3912 if (!(strcasecmp(c, "key")))
3913 sort_field = FT_STAT_FIELD_KEY;
3914 else if (!(strcasecmp(c, "key1")))
3915 sort_field = FT_STAT_FIELD_KEY1;
3916 else if (!(strcasecmp(c, "key2")))
3917 sort_field = FT_STAT_FIELD_KEY2;
3918 else if (!(strcasecmp(c, "key3")))
3919 sort_field = FT_STAT_FIELD_KEY3;
3920 else if (!(strcasecmp(c, "key4")))
3921 sort_field = FT_STAT_FIELD_KEY4;
3922 else if (!(strcasecmp(c, "key5")))
3923 sort_field = FT_STAT_FIELD_KEY5;
3924 else if (!(strcasecmp(c, "key6")))
3925 sort_field = FT_STAT_FIELD_KEY6;
3926 else if (!(strcasecmp(c, "flows")))
3927 sort_field = FT_STAT_FIELD_FLOWS;
3928 else if (!(strcasecmp(c, "octets")))
3929 sort_field = FT_STAT_FIELD_OCTETS;
3930 else if (!(strcasecmp(c, "packets")))
3931 sort_field = FT_STAT_FIELD_PACKETS;
3932 else if (!(strcasecmp(c, "duration")))
3933 sort_field = FT_STAT_FIELD_DURATION;
3934 else if (!(strcasecmp(c, "avg-pps")))
3935 sort_field = FT_STAT_FIELD_AVG_PPS;
3936 else if (!(strcasecmp(c, "min-pps")))
3937 sort_field = FT_STAT_FIELD_MIN_PPS;
3938 else if (!(strcasecmp(c, "max-pps")))
3939 sort_field = FT_STAT_FIELD_MAX_PPS;
3940 else if (!(strcasecmp(c, "avg-bps")))
3941 sort_field = FT_STAT_FIELD_AVG_BPS;
3942 else if (!(strcasecmp(c, "min-bps")))
3943 sort_field = FT_STAT_FIELD_MIN_BPS;
3944 else if (!(strcasecmp(c, "max-bps")))
3945 sort_field = FT_STAT_FIELD_MAX_BPS;
3946 else if (!(strcasecmp(c, "other")))
3947 sort_field = FT_STAT_FIELD_OTHER;
3948 else if (!(strcasecmp(c, "count")))
3949 sort_field = FT_STAT_FIELD_COUNT;
3950 else if (!(strcasecmp(c, "")))
3951 sort_field = 0;
3952 else {
3953 fterr_warnx("%s line %d: Unrecognized field.", lp->fname, lp->lineno);
3954 return -1;
3955 }
3956
3957 if (sort_field) {
3958
3959 /* make sure that the field selected is valid for this report type */
3960 if ((lp->cur_rpt->allowed_fields & sort_field) != sort_field) {
3961 fterr_warnx("%s line %d: field \"%s\" selected not available for report.",
3962 lp->fname, lp->lineno, c);
3963 return -1;
3964 }
3965
3966 lp->cur_rpt_out->sort_field = sort_field;
3967 lp->cur_rpt_out->sort_order = sort_order;
3968 lp->cur_rpt_out->options |= FT_STAT_OPT_SORT;
3969
3970 }
3971
3972 return 0;
3973
3974 } /* parse_rpt_out_sort */
3975
3976 /*
3977 * function: parse_rpt_out_records
3978 *
3979 * process the 'records' line.
3980 *
3981 * returns: 0 ok
3982 * <0 fail
3983 */
parse_rpt_out_records(struct line_parser * lp,struct ftstat * ftstat)3984 int parse_rpt_out_records(struct line_parser *lp, struct ftstat *ftstat)
3985 {
3986
3987 if (!lp->cur_rpt_out) {
3988 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
3989 return -1;
3990 }
3991
3992 NEXT_WORD(&lp->buf, lp->word);
3993
3994 if (!lp->word) {
3995 fterr_warnx("%s line %d: Expecting num records.", lp->fname,
3996 lp->lineno);
3997 return -1;
3998 }
3999
4000 lp->cur_rpt_out->records = strtoull(lp->word, (char**)0L, 0);
4001
4002 return 0;
4003
4004 } /* parse_rpt_out_records */
4005
4006 /*
4007 * function: parse_rpt_out_tally
4008 *
4009 * process the 'tally' line.
4010 *
4011 * returns: 0 ok
4012 * <0 fail
4013 */
parse_rpt_out_tally(struct line_parser * lp,struct ftstat * ftstat)4014 int parse_rpt_out_tally(struct line_parser *lp, struct ftstat *ftstat)
4015 {
4016
4017 if (!lp->cur_rpt_out) {
4018 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
4019 return -1;
4020 }
4021
4022 NEXT_WORD(&lp->buf, lp->word);
4023
4024 if (!lp->word) {
4025 fterr_warnx("%s line %d: Expecting tally increment.", lp->fname,
4026 lp->lineno);
4027 return -1;
4028 }
4029
4030 lp->cur_rpt_out->tally = strtoul(lp->word, (char**)0L, 0);
4031
4032 if (lp->cur_rpt_out->tally)
4033 lp->cur_rpt_out->options |= FT_STAT_OPT_TALLY;
4034 else
4035 lp->cur_rpt_out->options &= ~FT_STAT_OPT_TALLY;
4036
4037 return 0;
4038
4039 } /* parse_rpt_out_tally */
4040
4041 /*
4042 * function: parse_rpt_out_fields
4043 *
4044 * process the 'fields' line.
4045 *
4046 * returns: 0 ok
4047 * <0 fail
4048 */
parse_rpt_out_fields(struct line_parser * lp,struct ftstat * ftstat)4049 int parse_rpt_out_fields(struct line_parser *lp, struct ftstat *ftstat)
4050 {
4051 char *c, op;
4052 uint32_t nfields;
4053
4054 if (!lp->cur_rpt_out) {
4055 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
4056 return -1;
4057 }
4058
4059 if (!lp->buf) {
4060 fterr_warnx("%s line %d: Expecting display fields.", lp->fname,
4061 lp->lineno);
4062 return -1;
4063 }
4064
4065 c = lp->buf;
4066
4067 while (c) {
4068
4069 for (;;) {
4070 c = strsep(&lp->buf, " ,");
4071 if ((c && *c) || (!c))
4072 break;
4073 }
4074
4075 if (!c)
4076 break;
4077
4078 /* + to select, - to remove */
4079 op = *c++;
4080
4081 if ((op != '+') && (op != '-')) {
4082 fterr_warnx("%s line %d: Expecting +field or -field.", lp->fname,
4083 lp->lineno);
4084 return -1;
4085 }
4086
4087 nfields = 0;
4088
4089 if (!(strcasecmp(c, "index")))
4090 nfields |= FT_STAT_FIELD_INDEX;
4091 else if (!(strcasecmp(c, "first")))
4092 nfields |= FT_STAT_FIELD_FIRST;
4093 else if (!(strcasecmp(c, "last")))
4094 nfields |= FT_STAT_FIELD_LAST;
4095 else if (!(strcasecmp(c, "key")))
4096 nfields |= FT_STAT_FIELD_KEY;
4097 else if (!(strcasecmp(c, "key1")))
4098 nfields |= FT_STAT_FIELD_KEY1;
4099 else if (!(strcasecmp(c, "key2")))
4100 nfields |= FT_STAT_FIELD_KEY2;
4101 else if (!(strcasecmp(c, "key3")))
4102 nfields |= FT_STAT_FIELD_KEY3;
4103 else if (!(strcasecmp(c, "key4")))
4104 nfields |= FT_STAT_FIELD_KEY4;
4105 else if (!(strcasecmp(c, "key5")))
4106 nfields |= FT_STAT_FIELD_KEY5;
4107 else if (!(strcasecmp(c, "key6")))
4108 nfields |= FT_STAT_FIELD_KEY6;
4109 else if (!(strcasecmp(c, "flows")))
4110 nfields |= FT_STAT_FIELD_FLOWS;
4111 else if (!(strcasecmp(c, "octets")))
4112 nfields |= FT_STAT_FIELD_OCTETS;
4113 else if (!(strcasecmp(c, "packets")))
4114 nfields |= FT_STAT_FIELD_PACKETS;
4115 else if (!(strcasecmp(c, "duration")))
4116 nfields |= FT_STAT_FIELD_DURATION;
4117 else if (!(strcasecmp(c, "pps")))
4118 nfields |= FT_STAT_FIELD_PPS;
4119 else if (!(strcasecmp(c, "avg-pps")))
4120 nfields |= FT_STAT_FIELD_AVG_PPS;
4121 else if (!(strcasecmp(c, "min-pps")))
4122 nfields |= FT_STAT_FIELD_MIN_PPS;
4123 else if (!(strcasecmp(c, "max-pps")))
4124 nfields |= FT_STAT_FIELD_MAX_PPS;
4125 else if (!(strcasecmp(c, "bps")))
4126 nfields |= FT_STAT_FIELD_BPS;
4127 else if (!(strcasecmp(c, "avg-bps")))
4128 nfields |= FT_STAT_FIELD_AVG_BPS;
4129 else if (!(strcasecmp(c, "min-bps")))
4130 nfields |= FT_STAT_FIELD_MIN_BPS;
4131 else if (!(strcasecmp(c, "max-bps")))
4132 nfields |= FT_STAT_FIELD_MAX_BPS;
4133 else if (!(strcasecmp(c, "other")))
4134 nfields |= FT_STAT_FIELD_OTHER;
4135 else if (!(strcasecmp(c, "generic")))
4136 nfields |= FT_STAT_FIELD_GENERIC;
4137 else if (!(strcasecmp(c, "count")))
4138 nfields |= FT_STAT_FIELD_COUNT;
4139 else if (!(strcasecmp(c, "frecs")))
4140 nfields |= FT_STAT_FIELD_FRECS;
4141 else if (!(strcasecmp(c, "")))
4142 nfields |= 0;
4143 else {
4144 fterr_warnx("%s line %d: Unrecognized field.", lp->fname, lp->lineno);
4145 return -1;
4146 }
4147
4148 /* make sure that the field is valid for this report type */
4149
4150 if ((lp->cur_rpt->allowed_fields & nfields) != nfields) {
4151 fterr_warnx(
4152 "%s line %d: field \"%s\" selected not available for report.",
4153 lp->fname, lp->lineno, c);
4154 return -1;
4155 }
4156
4157 if (op == '+')
4158 lp->cur_rpt_out->fields |= nfields;
4159 else if (op == '-')
4160 lp->cur_rpt_out->fields &= ~nfields;
4161
4162 nfields = 0;
4163
4164 } /* c */
4165
4166 return 0;
4167
4168 } /* parse_rpt_out_fields */
4169
4170 /*
4171 * function: parse_rpt_out_options
4172 *
4173 * process the 'options' line.
4174 *
4175 * returns: 0 ok
4176 * <0 fail
4177 */
parse_rpt_out_options(struct line_parser * lp,struct ftstat * ftstat)4178 int parse_rpt_out_options(struct line_parser *lp, struct ftstat *ftstat)
4179 {
4180 int options;
4181 char *c, op;
4182
4183 if (!lp->cur_rpt_out) {
4184 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
4185 return -1;
4186 }
4187
4188 if (!lp->buf) {
4189 fterr_warnx("%s line %d: Expecting options.", lp->fname,
4190 lp->lineno);
4191 return -1;
4192 }
4193
4194 c = lp->buf;
4195
4196 while (c) {
4197
4198 for (;;) {
4199 c = strsep(&lp->buf, " ,");
4200 if ((c && *c) || (!c))
4201 break;
4202 }
4203
4204 if (!c)
4205 break;
4206
4207 /* + to select, - to remove */
4208 op = *c++;
4209
4210 if ((op != '+') && (op != '-')) {
4211 fterr_warnx("%s line %d: Expecting +option or -option.", lp->fname,
4212 lp->lineno);
4213 return -1;
4214 }
4215
4216 options = 0;
4217
4218 if (!(strcasecmp(c, "percent-total")))
4219 options |= FT_STAT_OPT_PERCENT;
4220 else if (!(strcasecmp(c, "names")))
4221 options |= FT_STAT_OPT_NAMES;
4222 else if (!(strcasecmp(c, "header")))
4223 options |= FT_STAT_OPT_HEADER;
4224 else if (!(strcasecmp(c, "xheader")))
4225 options |= FT_STAT_OPT_XHEADER;
4226 else if (!(strcasecmp(c, "totals")))
4227 options |= FT_STAT_OPT_TOTALS;
4228 else {
4229 fterr_warnx("%s line %d: Unrecognized option.", lp->fname, lp->lineno);
4230 return -1;
4231 }
4232
4233 /* make sure that the option is valid for this report type */
4234
4235 if ((lp->cur_rpt->allowed_options & options) != options) {
4236 fterr_warnx("%s line %d: option selected not available for report.",
4237 lp->fname, lp->lineno);
4238 return -1;
4239 }
4240
4241 if (op == '+')
4242 lp->cur_rpt_out->options |= options;
4243 else if (op == '-')
4244 lp->cur_rpt_out->options &= ~options;
4245
4246 options = 0;
4247
4248 } /* c */
4249
4250 return 0;
4251
4252 } /* parse_rpt_out_options */
4253
4254 /*
4255 * function: parse_rpt_out_path
4256 *
4257 * process the 'path' line.
4258 *
4259 * returns: 0 ok
4260 * <0 fail
4261 */
parse_rpt_out_path(struct line_parser * lp,struct ftstat * ftstat)4262 int parse_rpt_out_path(struct line_parser *lp, struct ftstat *ftstat)
4263 {
4264 char *c;
4265 int len;
4266
4267 if (!lp->cur_rpt_out) {
4268 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
4269 return -1;
4270 }
4271
4272 if (!lp->buf) {
4273 fterr_warnx("%s line %d: Expecting pathname.", lp->fname, lp->lineno);
4274 return -1;
4275 }
4276
4277 len = strlen(lp->buf);
4278
4279 if (!(c = malloc(len+1))) {
4280 fterr_warn("malloc()");
4281 return -1;
4282 }
4283
4284 strcpy(c, lp->buf);
4285
4286 lp->cur_rpt_out->path = c;
4287
4288 /* eat the line */
4289 for (; *(lp->buf); ++lp->buf);
4290
4291 return 0;
4292
4293 } /* parse_rpt_out_path */
4294
4295 /*
4296 * function: parse_rpt_out_time
4297 *
4298 * process the 'time' line.
4299 *
4300 * returns: 0 ok
4301 * <0 fail
4302 */
parse_rpt_out_time(struct line_parser * lp,struct ftstat * ftstat)4303 int parse_rpt_out_time(struct line_parser *lp, struct ftstat *ftstat)
4304 {
4305
4306 if (!lp->cur_rpt_out) {
4307 fterr_warnx("%s line %d: Not in report output.", lp->fname, lp->lineno);
4308 return -1;
4309 }
4310
4311 NEXT_WORD(&lp->buf, lp->word);
4312
4313 if (!lp->word) {
4314 fterr_warnx("%s line %d: Expecting time specifier.", lp->fname,
4315 lp->lineno);
4316 return -1;
4317 }
4318
4319 if (!(strcasecmp(lp->word, "now")))
4320 lp->cur_rpt_out->time = FT_STAT_TIME_NOW;
4321 else if (!(strcasecmp(lp->word, "start")))
4322 lp->cur_rpt_out->time = FT_STAT_TIME_START;
4323 else if (!(strcasecmp(lp->word, "end")))
4324 lp->cur_rpt_out->time = FT_STAT_TIME_END;
4325 else if (!(strcasecmp(lp->word, "mid")))
4326 lp->cur_rpt_out->time = FT_STAT_TIME_MID;
4327 else {
4328 fterr_warnx("%s line %d: Invalid time specifier.", lp->fname, lp->lineno);
4329 return -1;
4330 }
4331
4332 return 0;
4333
4334 } /* parse_rpt_out_time */
4335
4336 /*
4337 *************************************************************************
4338 parse_def_*
4339 *************************************************************************
4340 */
4341
4342 /*
4343 * function: parse_def
4344 *
4345 * process the 'stat-definition' line. Each definition has a unique name
4346 * which is added to the ftstat->defs linked list. The current
4347 * definition is updated in lp. Definitions reference reports
4348 *
4349 * returns: 0 ok
4350 * <0 fail
4351 */
parse_def(struct line_parser * lp,struct ftstat * ftstat)4352 int parse_def(struct line_parser *lp, struct ftstat *ftstat)
4353 {
4354 char *c;
4355 struct ftstat_def *ftsd;
4356
4357 NEXT_WORD(&lp->buf, c);
4358
4359 if (!c) {
4360 fterr_warnx("%s line %d: Expecting name.", lp->fname, lp->lineno);
4361 return -1;
4362 }
4363
4364 /* check if it exists */
4365 FT_SLIST_FOREACH(ftsd, &ftstat->defs, chain) {
4366
4367 if (!strcasecmp(c, ftsd->name)) {
4368 fterr_warnx("%s line %d: Name (%s) previously defined.", lp->fname,
4369 lp->lineno, c);
4370 return -1;
4371 }
4372
4373 }
4374
4375 /* no, add a new entry to the list */
4376 if (!(ftsd = (struct ftstat_def*)malloc(sizeof *ftsd))) {
4377 fterr_warn("malloc()");
4378 return -1;
4379 }
4380
4381 bzero(ftsd, sizeof *ftsd);
4382 FT_STAILQ_INIT(&ftsd->items);
4383
4384 if (!(ftsd->name = (char*)malloc(strlen(c)+1))) {
4385 fterr_warn("malloc()");
4386 free(ftsd);
4387 return -1;
4388 }
4389
4390 strcpy(ftsd->name, c);
4391 ftsd->ftstat = ftstat;
4392
4393 FT_SLIST_INSERT_HEAD(&ftstat->defs, ftsd, chain);
4394
4395 lp->state = PARSE_STATE_DEFINITION;
4396 lp->cur_def = ftsd;
4397
4398 return 0;
4399
4400 } /* parse_def */
4401
4402 /*
4403 * function: parse_def_filter
4404 *
4405 * process the 'filter' line.
4406 *
4407 * returns: 0 ok
4408 * <0 fail
4409 */
parse_def_filter(struct line_parser * lp,struct ftstat * ftstat)4410 int parse_def_filter(struct line_parser *lp, struct ftstat *ftstat)
4411 {
4412
4413 if (!lp->cur_def) {
4414 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
4415 return -1;
4416 }
4417
4418 NEXT_WORD(&lp->buf, lp->word);
4419
4420 if (!lp->word) {
4421 fterr_warnx("%s line %d: Expecting filter name.", lp->fname,
4422 lp->lineno);
4423 return -1;
4424 }
4425
4426 if (lp->cur_def->ftfd) {
4427 fterr_warnx("%s line %d: Filter previously defined for definition.",
4428 lp->fname, lp->lineno);
4429 return -1;
4430 }
4431
4432 /* delay loading the filters until one is requested */
4433 if (load_filters(ftstat)) {
4434 fterr_warnx("%s line %d: Filters not loaded.", lp->fname, lp->lineno);
4435 return -1;
4436 }
4437
4438 if (!(lp->cur_def->ftfd = ftfil_def_find(&ftstat->ftfil,
4439 lp->word))) {
4440 fterr_warnx("%s line %d: Filter definition not found.", lp->fname,
4441 lp->lineno);
4442 return -1;
4443 }
4444
4445 return 0;
4446
4447 } /* parse_def_filter */
4448
4449 /*
4450 * function: parse_def_tag
4451 *
4452 * process the 'tag' line.
4453 *
4454 * returns: 0 ok
4455 * <0 fail
4456 */
parse_def_tag(struct line_parser * lp,struct ftstat * ftstat)4457 int parse_def_tag(struct line_parser *lp, struct ftstat *ftstat)
4458 {
4459
4460 if (!lp->cur_def) {
4461 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
4462 return -1;
4463 }
4464
4465 NEXT_WORD(&lp->buf, lp->word);
4466
4467 if (!lp->word) {
4468 fterr_warnx("%s line %d: Expecting tag name.", lp->fname,
4469 lp->lineno);
4470 return -1;
4471 }
4472
4473 if (lp->cur_def->ftd) {
4474 fterr_warnx("%s line %d: Tag previously defined for definition.",
4475 lp->fname, lp->lineno);
4476 return -1;
4477 }
4478
4479 /* delay loading the tags until one is requested */
4480 if (load_tags(ftstat)) {
4481 fterr_warnx("%s line %d: Tags not loaded.", lp->fname, lp->lineno);
4482 return -1;
4483 }
4484
4485 if (!(lp->cur_def->ftd = fttag_def_find(&ftstat->fttag, lp->word))) {
4486 fterr_warnx("%s line %d: Tag definition not found.", lp->fname,
4487 lp->lineno);
4488 return -1;
4489 }
4490
4491 return 0;
4492
4493 } /* parse_def_tag */
4494
4495 /*
4496 * function: parse_def_mask
4497 *
4498 * process the 'mask' line.
4499 *
4500 * returns: 0 ok
4501 * <0 fail
4502 */
parse_def_mask(struct line_parser * lp,struct ftstat * ftstat)4503 int parse_def_mask(struct line_parser *lp, struct ftstat *ftstat)
4504 {
4505
4506 if (!lp->cur_def) {
4507 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
4508 return -1;
4509 }
4510
4511 NEXT_WORD(&lp->buf, lp->word);
4512
4513 if (!lp->word) {
4514 fterr_warnx("%s line %d: Expecting mask name.", lp->fname,
4515 lp->lineno);
4516 return -1;
4517 }
4518
4519 if (lp->cur_def->ftd) {
4520 fterr_warnx("%s line %d: Mask previously defined for definition.",
4521 lp->fname, lp->lineno);
4522 return -1;
4523 }
4524
4525 /* delay loading the tags until one is requested */
4526 if (load_masks(ftstat)) {
4527 fterr_warnx("%s line %d: Masks not loaded.", lp->fname, lp->lineno);
4528 return -1;
4529 }
4530
4531 if (!(lp->cur_def->ftmd = ftmask_def_find(&ftstat->ftmask, lp->word))) {
4532 fterr_warnx("%s line %d: Mask definition not found.", lp->fname,
4533 lp->lineno);
4534 return -1;
4535 }
4536
4537 return 0;
4538
4539 } /* parse_def_mask */
4540
4541 /*
4542 * function: parse_def_time_series
4543 *
4544 * process the 'time-series' line.
4545 *
4546 * returns: 0 ok
4547 * <0 fail
4548 */
parse_def_time_series(struct line_parser * lp,struct ftstat * ftstat)4549 int parse_def_time_series(struct line_parser *lp, struct ftstat *ftstat)
4550 {
4551
4552 if (!lp->cur_def) {
4553 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
4554 return -1;
4555 }
4556
4557 NEXT_WORD(&lp->buf, lp->word);
4558
4559 if (!lp->word) {
4560 fterr_warnx("%s line %d: Expecting time in seconds.", lp->fname,
4561 lp->lineno);
4562 return -1;
4563 }
4564
4565 if (lp->cur_def->max_time) {
4566 fterr_warnx("%s line %d: Time previously defined for definition.",
4567 lp->fname, lp->lineno);
4568 return -1;
4569 }
4570
4571 lp->cur_def->max_time = strtoul(lp->word, (char**)0L, 0);
4572 lp->cur_def->xfields |= FT_XFIELD_UNIX_SECS;
4573
4574 return 0;
4575
4576 } /* parse_def_time_series */
4577
4578
4579 /*
4580 * function: parse_def_report
4581 *
4582 * process the 'report' line.
4583 *
4584 * resolve_reports() _must_ be called after the configuration file has
4585 * been parsed and before the parse buffer is released.
4586 *
4587 * returns: 0 ok
4588 * <0 fail
4589 */
parse_def_report(struct line_parser * lp,struct ftstat * ftstat)4590 int parse_def_report(struct line_parser *lp, struct ftstat *ftstat)
4591 {
4592 struct ftstat_rpt_item *ftsrpti;
4593 int n;
4594
4595 if (!lp->cur_def) {
4596 fterr_warnx("%s line %d: Must set name first.", lp->fname, lp->lineno);
4597 return -1;
4598 }
4599
4600 NEXT_WORD(&lp->buf, lp->word);
4601
4602 if (!lp->word) {
4603 fterr_warnx("%s line %d: Expecting report name.", lp->fname,
4604 lp->lineno);
4605 return -1;
4606 }
4607
4608 /* make sure this report is only added once */
4609 FT_STAILQ_FOREACH(ftsrpti, &lp->cur_def->items, chain) {
4610
4611 if (!(strcasecmp(lp->word, ftsrpti->tmp_report))) {
4612 fterr_warnx("%s line %d: Duplicate report in definition.", lp->fname,
4613 lp->lineno);
4614 return -1;
4615 }
4616
4617 }
4618
4619 /* add this report to the list */
4620 if (!(ftsrpti = (struct ftstat_rpt_item*)malloc (sizeof *ftsrpti))) {
4621 fterr_warn("malloc()");
4622 return -1;
4623 }
4624
4625 bzero(ftsrpti, sizeof *ftsrpti);
4626
4627 /* resolve this later in resolve_reports(); */
4628 n = strlen(lp->word);
4629 if (!(ftsrpti->tmp_report = malloc(n+1)))
4630 fterr_errx(1, "malloc(tmp_report): failed");
4631 strcpy(ftsrpti->tmp_report, lp->word);
4632
4633 FT_STAILQ_INSERT_TAIL(&lp->cur_def->items, ftsrpti, chain);
4634
4635 return 0;
4636
4637 } /* parse_def_report */
4638
4639
4640 /*
4641 * function: parse_include_tag
4642 *
4643 * process the 'include-tag' line. Allow the default tag location
4644 * to be changed.
4645 *
4646 * returns: 0 ok
4647 * <0 fail
4648 */
parse_include_tag(struct line_parser * lp,struct ftstat * ftstat)4649 int parse_include_tag(struct line_parser *lp, struct ftstat *ftstat)
4650 {
4651
4652 NEXT_WORD(&lp->buf, lp->word);
4653
4654 if (!lp->word) {
4655 fterr_warnx("%s line %d: Expecting pathname.", lp->fname, lp->lineno);
4656 return -1;
4657 }
4658
4659 if (ftstat->tag_fname) {
4660 fterr_warnx("%s line %d: Tag pathname previously specified.",
4661 lp->fname, lp->lineno);
4662 return -1;
4663 }
4664
4665 if (!(ftstat->tag_fname = malloc(strlen(lp->word)+1)))
4666 fterr_errx(1, "malloc(tag_fname): failed");
4667 strcpy(ftstat->tag_fname, lp->word);
4668
4669 return 0;
4670
4671 } /* parse_include_tag */
4672
4673 /*
4674 * function: parse_include_filter
4675 *
4676 * process the 'include-filter' line. Allow the default filter location
4677 * to be changed.
4678 *
4679 * returns: 0 ok
4680 * <0 fail
4681 */
parse_include_filter(struct line_parser * lp,struct ftstat * ftstat)4682 int parse_include_filter(struct line_parser *lp, struct ftstat *ftstat)
4683 {
4684
4685 NEXT_WORD(&lp->buf, lp->word);
4686
4687 if (!lp->word) {
4688 fterr_warnx("%s line %d: Expecting pathname.", lp->fname, lp->lineno);
4689 return -1;
4690 }
4691
4692 if (ftstat->filter_fname) {
4693 fterr_warnx("%s line %d: Filter pathname previously specified.",
4694 lp->fname, lp->lineno);
4695 return -1;
4696 }
4697
4698 if (!(ftstat->filter_fname = malloc(strlen(lp->word)+1)))
4699 fterr_errx(1, "malloc(filter_fname): failed");
4700 strcpy(ftstat->filter_fname, lp->word);
4701
4702 return 0;
4703
4704 } /* parse_include_filter */
4705
4706 /*
4707 * function: parse_include_mask
4708 *
4709 * process the 'include-mask' line. Allow the default mask location
4710 * to be changed.
4711 *
4712 * returns: 0 ok
4713 * <0 fail
4714 */
parse_include_mask(struct line_parser * lp,struct ftstat * ftstat)4715 int parse_include_mask(struct line_parser *lp, struct ftstat *ftstat)
4716 {
4717
4718 NEXT_WORD(&lp->buf, lp->word);
4719
4720 if (!lp->word) {
4721 fterr_warnx("%s line %d: Expecting pathname.", lp->fname, lp->lineno);
4722 return -1;
4723 }
4724
4725 if (ftstat->mask_fname) {
4726 fterr_warnx("%s line %d: Mask pathname previously specified.",
4727 lp->fname, lp->lineno);
4728 return -1;
4729 }
4730
4731 if (!(ftstat->mask_fname = malloc(strlen(lp->word)+1)))
4732 fterr_errx(1, "malloc(mask_fname): failed");
4733 strcpy(ftstat->mask_fname, lp->word);
4734
4735 return 0;
4736
4737 } /* parse_include_mask */
4738
4739 /*
4740 *************************************************************************
4741 ftstat_rpt_*_new/free/accum/dump
4742 *************************************************************************
4743 */
4744
4745
4746 /* function: ftstat_rpt_1_new
4747 *
4748 * Allocate and initialize data structures for rpt 1.
4749 *
4750 * returns allocated struct or 0L for error
4751 */
ftstat_rpt_1_new(struct ftstat_rpt * rpt)4752 struct ftstat_rpt_1 *ftstat_rpt_1_new(struct ftstat_rpt *rpt)
4753 {
4754 struct ftstat_rpt_1 *rpt1;
4755
4756 if (!(rpt1 = (struct ftstat_rpt_1*)malloc(sizeof (*rpt1)))) {
4757 fterr_warnx("malloc(rpt1): failed");
4758 return (struct ftstat_rpt_1*)0L;
4759 }
4760
4761 bzero(rpt1, sizeof *rpt1);
4762
4763 return rpt1;
4764
4765 } /* ftstat_rpt_1_new */
4766
4767
4768 /* function: ftstat_rpt_1_accum
4769 *
4770 * Accumulate counters for report by processing flow.
4771 *
4772 * returns 0: ok
4773 * !0: error
4774 */
ftstat_rpt_1_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)4775 int ftstat_rpt_1_accum(struct ftstat_rpt *rpt, char *rec,
4776 struct fts3rec_offsets *fo)
4777 {
4778 struct ftstat_rpt_1 *rpt1;
4779 struct fts3rec_all2 cur;
4780 uint32_t time_tmp, duration_tmp;
4781 double pps_tmp, bps_tmp;
4782 uint32_t p;
4783
4784 STD_ACCUM;
4785
4786 rpt1 = rpt->data;
4787
4788 time_tmp = cur.unix_secs;
4789
4790 if (time_tmp < rpt1->time_start)
4791 rpt1->time_start = time_tmp;
4792
4793 if (time_tmp > rpt1->time_end)
4794 rpt1->time_end = time_tmp;
4795
4796 if (cur.First < rpt1->start)
4797 rpt1->start = cur.First;
4798
4799 if (cur.Last > rpt1->end)
4800 rpt1->end = cur.Last;
4801
4802 p = cur.dOctets64 / cur.dPkts64;
4803
4804 if (p <= 32) ++ rpt1->psize32;
4805 else if (p <= 64) ++ rpt1->psize64;
4806 else if (p <= 96) ++ rpt1->psize96;
4807 else if (p <= 128) ++ rpt1->psize128;
4808 else if (p <= 160) ++ rpt1->psize160;
4809 else if (p <= 192) ++ rpt1->psize192;
4810 else if (p <= 224) ++ rpt1->psize224;
4811 else if (p <= 256) ++ rpt1->psize256;
4812 else if (p <= 288) ++ rpt1->psize288;
4813 else if (p <= 320) ++ rpt1->psize320;
4814 else if (p <= 352) ++ rpt1->psize352;
4815 else if (p <= 384) ++ rpt1->psize384;
4816 else if (p <= 416) ++ rpt1->psize416;
4817 else if (p <= 448) ++ rpt1->psize448;
4818 else if (p <= 480) ++ rpt1->psize480;
4819 else if (p <= 512) ++ rpt1->psize512;
4820 else if (p <= 544) ++ rpt1->psize544;
4821 else if (p <= 576) ++ rpt1->psize576;
4822 else if (p <= 1024) ++ rpt1->psize1024;
4823 else if (p <= 1536) ++ rpt1->psize1536;
4824 else if (p <= 2048) ++ rpt1->psize2048;
4825 else if (p <= 2560) ++ rpt1->psize2560;
4826 else if (p <= 3072) ++ rpt1->psize3072;
4827 else if (p <= 3584) ++ rpt1->psize3584;
4828 else if (p <= 4096) ++ rpt1->psize4096;
4829 else if (p <= 4608) ++ rpt1->psize4608;
4830
4831 p = cur.dPkts64;
4832
4833 if (p <= 1) ++ rpt1->fpsize1;
4834 else if (p <= 2) ++ rpt1->fpsize2;
4835 else if (p <= 4) ++ rpt1->fpsize4;
4836 else if (p <= 8) ++ rpt1->fpsize8;
4837 else if (p <= 12) ++ rpt1->fpsize12;
4838 else if (p <= 16) ++ rpt1->fpsize16;
4839 else if (p <= 20) ++ rpt1->fpsize20;
4840 else if (p <= 24) ++ rpt1->fpsize24;
4841 else if (p <= 28) ++ rpt1->fpsize28;
4842 else if (p <= 32) ++ rpt1->fpsize32;
4843 else if (p <= 36) ++ rpt1->fpsize36;
4844 else if (p <= 40) ++ rpt1->fpsize40;
4845 else if (p <= 44) ++ rpt1->fpsize44;
4846 else if (p <= 48) ++ rpt1->fpsize48;
4847 else if (p <= 52) ++ rpt1->fpsize52;
4848 else if (p <= 60) ++ rpt1->fpsize60;
4849 else if (p <= 100) ++ rpt1->fpsize100;
4850 else if (p <= 200) ++ rpt1->fpsize200;
4851 else if (p <= 300) ++ rpt1->fpsize300;
4852 else if (p <= 400) ++ rpt1->fpsize400;
4853 else if (p <= 500) ++ rpt1->fpsize500;
4854 else if (p <= 600) ++ rpt1->fpsize600;
4855 else if (p <= 700) ++ rpt1->fpsize700;
4856 else if (p <= 800) ++ rpt1->fpsize800;
4857 else if (p <= 900) ++ rpt1->fpsize900;
4858 else ++ rpt1->fpsize_other;
4859
4860 p = cur.dOctets64;
4861
4862 if (p <= 32) ++ rpt1->fosize32;
4863 else if (p <= 64) ++ rpt1->fosize64;
4864 else if (p <= 128) ++ rpt1->fosize128;
4865 else if (p <= 256) ++ rpt1->fosize256;
4866 else if (p <= 512) ++ rpt1->fosize512;
4867 else if (p <= 1280) ++ rpt1->fosize1280;
4868 else if (p <= 2048) ++ rpt1->fosize2048;
4869 else if (p <= 2816) ++ rpt1->fosize2816;
4870 else if (p <= 3584) ++ rpt1->fosize3584;
4871 else if (p <= 4352) ++ rpt1->fosize4352;
4872 else if (p <= 5120) ++ rpt1->fosize5120;
4873 else if (p <= 5888) ++ rpt1->fosize5888;
4874 else if (p <= 6656) ++ rpt1->fosize6656;
4875 else if (p <= 7424) ++ rpt1->fosize7424;
4876 else if (p <= 8192) ++ rpt1->fosize8192;
4877 else if (p <= 8960) ++ rpt1->fosize8960;
4878 else if (p <= 9728) ++ rpt1->fosize9728;
4879 else if (p <= 10496) ++ rpt1->fosize10496;
4880 else if (p <= 11264) ++ rpt1->fosize11264;
4881 else if (p <= 12032) ++ rpt1->fosize12032;
4882 else if (p <= 12800) ++ rpt1->fosize12800;
4883 else if (p <= 13568) ++ rpt1->fosize13568;
4884 else if (p <= 14336) ++ rpt1->fosize14336;
4885 else if (p <= 15104) ++ rpt1->fosize15104;
4886 else if (p <= 15872) ++ rpt1->fosize15872;
4887 else ++ rpt1->fosize_other;
4888
4889 p = cur.Last - cur.First;
4890 rpt1->time += p;
4891
4892 if (p <= 10) ++ rpt1->ftime10;
4893 else if (p <= 50) ++ rpt1->ftime50;
4894 else if (p <= 100) ++ rpt1->ftime100;
4895 else if (p <= 200) ++ rpt1->ftime200;
4896 else if (p <= 500) ++ rpt1->ftime500;
4897 else if (p <= 1000) ++ rpt1->ftime1000;
4898 else if (p <= 2000) ++ rpt1->ftime2000;
4899 else if (p <= 3000) ++ rpt1->ftime3000;
4900 else if (p <= 4000) ++ rpt1->ftime4000;
4901 else if (p <= 5000) ++ rpt1->ftime5000;
4902 else if (p <= 6000) ++ rpt1->ftime6000;
4903 else if (p <= 7000) ++ rpt1->ftime7000;
4904 else if (p <= 8000) ++ rpt1->ftime8000;
4905 else if (p <= 9000) ++ rpt1->ftime9000;
4906 else if (p <= 10000) ++ rpt1->ftime10000;
4907 else if (p <= 12000) ++ rpt1->ftime12000;
4908 else if (p <= 14000) ++ rpt1->ftime14000;
4909 else if (p <= 16000) ++ rpt1->ftime16000;
4910 else if (p <= 18000) ++ rpt1->ftime18000;
4911 else if (p <= 20000) ++ rpt1->ftime20000;
4912 else if (p <= 22000) ++ rpt1->ftime22000;
4913 else if (p <= 24000) ++ rpt1->ftime24000;
4914 else if (p <= 26000) ++ rpt1->ftime26000;
4915 else if (p <= 28000) ++ rpt1->ftime28000;
4916 else if (p <= 30000) ++ rpt1->ftime30000;
4917 else ++ rpt1->ftime_other;
4918
4919 return 0;
4920
4921 } /* ftstat_rpt_1_accum */
4922
4923 /* function: ftstat_rpt_1_calc
4924 *
4925 * Perform final calculations for rpt1
4926 *
4927 * returns allocated struct or 0L for error
4928 */
ftstat_rpt_1_calc(struct ftstat_rpt * rpt)4929 int ftstat_rpt_1_calc(struct ftstat_rpt *rpt)
4930 {
4931 struct ftstat_rpt_1 *rpt1;
4932 uint32_t dif;
4933
4934 rpt1 = rpt->data;
4935
4936 STD_CALC;
4937
4938 rpt1->time_real = rpt1->time_end - rpt1->time_start;
4939 dif = rpt1->end - rpt1->start;
4940
4941 if (rpt->t_flows) {
4942 rpt1->aflowtime = rpt1->time / rpt->t_flows;
4943 rpt1->afs = rpt->t_octets / rpt->t_flows;
4944 rpt1->apf = rpt->t_packets / rpt->t_flows;
4945 }
4946
4947 if (rpt->t_packets)
4948 rpt1->aps = rpt->t_octets / rpt->t_packets;
4949
4950 if (dif)
4951 rpt1->fps = (double)rpt->t_flows / (dif / 1000.0);
4952
4953 if (rpt1->time_real)
4954 rpt1->fps_real = (double)rpt->t_flows / (double)rpt1->time_real;
4955
4956 return 0;
4957
4958 } /* ftstat_rpt_1_calc */
4959
4960 /* function: ftstat_rpt_1_dump
4961 *
4962 * Dump data for report.
4963 *
4964 */
ftstat_rpt_1_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)4965 int ftstat_rpt_1_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
4966 {
4967 struct ftstat_rpt_1 *rpt1;
4968 char fmt_buf[1024];
4969
4970 rpt1 = rpt->data;
4971
4972 fprintf(fp, "# rec2: time_real,aflowtime,aps,afs,apf,fps,fps_real,");
4973 fprintf(fp, "psize32,psize64,psize96,psize128,psize160,psize192,psize224,psize256,psize288,psize320,psize352,psize384,psize416,psize448,psize480,psize512,psize544,psize576,psize1024,psize1536,psize2048,psize2560,psize3072,psize3584,>psize4096,psize4608,");
4974 fprintf(fp, "fpsize1,fpsize2,fpsize4,fpsize8,fpsize12,fpsize16,fpsize20,fpsize24,fpsize28,fpsize32,fpsize36,fpsize40,fpsize44,fpsize48,fpsize52,fpsize60,fpsize100,fpsize200,fpsize300,fpsize400,fpsize500,fpsize600,fpsize700,fpsize800,fpsize900,fpsize_other,");
4975 fprintf(fp, "fosize32,fosize64,fosize128,fosize256,fosize512,fosize1280,fosize2048,fosize2816,fosize3584,fosize4352,fosize5120,fosize5888,fosize6656,fosize7424,fosize8192,fosize8960,fosize9728,fosize10496,fosize11264,fosize12032,fosize12800,fosize13568,fosize14336,fosize15104,fosize15872,fosize_other,");
4976 fprintf(fp, "ftime10,ftime50,ftime100,ftime200,ftime500,ftime1000,ftime2000,ftime3000,ftime4000,ftime5000,ftime6000,ftime7000,ftime8000,ftime9000,ftime10000,ftime12000,ftime14000,ftime16000,ftime18000,ftime20000,ftime22000,ftime24000,ftime26000,ftime28000,ftime30000,ftime_other\n");
4977
4978 fmt_uint64(fmt_buf, rpt1->time_real, FMT_JUST_LEFT);
4979
4980 fprintf(fp, "%s,%f,%f,%f,%f,%f,%f,", fmt_buf, rpt1->aflowtime,
4981 rpt1->aps, rpt1->afs, rpt1->apf, rpt1->fps, rpt1->fps_real);
4982
4983 fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,",
4984 (double)rpt1->psize32 / (double)rpt->t_flows,
4985 (double)rpt1->psize64 / (double)rpt->t_flows,
4986 (double)rpt1->psize96 / (double)rpt->t_flows,
4987 (double)rpt1->psize128 / (double)rpt->t_flows,
4988 (double)rpt1->psize160 / (double)rpt->t_flows,
4989 (double)rpt1->psize192 / (double)rpt->t_flows,
4990 (double)rpt1->psize224 / (double)rpt->t_flows,
4991 (double)rpt1->psize256 / (double)rpt->t_flows,
4992 (double)rpt1->psize288 / (double)rpt->t_flows,
4993 (double)rpt1->psize320 / (double)rpt->t_flows,
4994 (double)rpt1->psize352 / (double)rpt->t_flows,
4995 (double)rpt1->psize384 / (double)rpt->t_flows,
4996 (double)rpt1->psize416 / (double)rpt->t_flows,
4997 (double)rpt1->psize448 / (double)rpt->t_flows,
4998 (double)rpt1->psize480 / (double)rpt->t_flows,
4999 (double)rpt1->psize512 / (double)rpt->t_flows,
5000 (double)rpt1->psize544 / (double)rpt->t_flows,
5001 (double)rpt1->psize576 / (double)rpt->t_flows,
5002 (double)rpt1->psize1024 / (double)rpt->t_flows,
5003 (double)rpt1->psize1536 / (double)rpt->t_flows,
5004 (double)rpt1->psize2048 / (double)rpt->t_flows,
5005 (double)rpt1->psize2560 / (double)rpt->t_flows,
5006 (double)rpt1->psize3072 / (double)rpt->t_flows,
5007 (double)rpt1->psize3584 / (double)rpt->t_flows,
5008 (double)rpt1->psize4096 / (double)rpt->t_flows,
5009 (double)rpt1->psize4608 / (double)rpt->t_flows);
5010
5011 fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,",
5012 (double)rpt1->fpsize1 / (double)rpt->t_flows,
5013 (double)rpt1->fpsize2 / (double)rpt->t_flows,
5014 (double)rpt1->fpsize4 / (double)rpt->t_flows,
5015 (double)rpt1->fpsize8 / (double)rpt->t_flows,
5016 (double)rpt1->fpsize12 / (double)rpt->t_flows,
5017 (double)rpt1->fpsize16 / (double)rpt->t_flows,
5018 (double)rpt1->fpsize20 / (double)rpt->t_flows,
5019 (double)rpt1->fpsize24 / (double)rpt->t_flows,
5020 (double)rpt1->fpsize28 / (double)rpt->t_flows,
5021 (double)rpt1->fpsize32 / (double)rpt->t_flows,
5022 (double)rpt1->fpsize36 / (double)rpt->t_flows,
5023 (double)rpt1->fpsize40 / (double)rpt->t_flows,
5024 (double)rpt1->fpsize44 / (double)rpt->t_flows,
5025 (double)rpt1->fpsize48 / (double)rpt->t_flows,
5026 (double)rpt1->fpsize52 / (double)rpt->t_flows,
5027 (double)rpt1->fpsize60 / (double)rpt->t_flows,
5028 (double)rpt1->fpsize100 / (double)rpt->t_flows,
5029 (double)rpt1->fpsize200 / (double)rpt->t_flows,
5030 (double)rpt1->fpsize300 / (double)rpt->t_flows,
5031 (double)rpt1->fpsize400 / (double)rpt->t_flows,
5032 (double)rpt1->fpsize500 / (double)rpt->t_flows,
5033 (double)rpt1->fpsize600 / (double)rpt->t_flows,
5034 (double)rpt1->fpsize700 / (double)rpt->t_flows,
5035 (double)rpt1->fpsize800 / (double)rpt->t_flows,
5036 (double)rpt1->fpsize900 / (double)rpt->t_flows,
5037 (double)rpt1->fpsize_other / (double)rpt->t_flows);
5038
5039 fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,",
5040 (double)rpt1->fosize32 / (double)rpt->t_flows,
5041 (double)rpt1->fosize64 / (double)rpt->t_flows,
5042 (double)rpt1->fosize128 / (double)rpt->t_flows,
5043 (double)rpt1->fosize256 / (double)rpt->t_flows,
5044 (double)rpt1->fosize512 / (double)rpt->t_flows,
5045 (double)rpt1->fosize1280 / (double)rpt->t_flows,
5046 (double)rpt1->fosize2048 / (double)rpt->t_flows,
5047 (double)rpt1->fosize2816 / (double)rpt->t_flows,
5048 (double)rpt1->fosize3584 / (double)rpt->t_flows,
5049 (double)rpt1->fosize4352 / (double)rpt->t_flows,
5050 (double)rpt1->fosize5120 / (double)rpt->t_flows,
5051 (double)rpt1->fosize5888 / (double)rpt->t_flows,
5052 (double)rpt1->fosize6656 / (double)rpt->t_flows,
5053 (double)rpt1->fosize7424 / (double)rpt->t_flows,
5054 (double)rpt1->fosize8192 / (double)rpt->t_flows,
5055 (double)rpt1->fosize8960 / (double)rpt->t_flows,
5056 (double)rpt1->fosize9728 / (double)rpt->t_flows,
5057 (double)rpt1->fosize10496 / (double)rpt->t_flows,
5058 (double)rpt1->fosize11264 / (double)rpt->t_flows,
5059 (double)rpt1->fosize12032 / (double)rpt->t_flows,
5060 (double)rpt1->fosize12800 / (double)rpt->t_flows,
5061 (double)rpt1->fosize13568 / (double)rpt->t_flows,
5062 (double)rpt1->fosize14336 / (double)rpt->t_flows,
5063 (double)rpt1->fosize15104 / (double)rpt->t_flows,
5064 (double)rpt1->fosize15872 / (double)rpt->t_flows,
5065 (double)rpt1->fosize_other / (double)rpt->t_flows);
5066
5067 fprintf(fp, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f\n",
5068 (double)rpt1->ftime10 / (double)rpt->t_flows,
5069 (double)rpt1->ftime50 / (double)rpt->t_flows,
5070 (double)rpt1->ftime100 / (double)rpt->t_flows,
5071 (double)rpt1->ftime200 / (double)rpt->t_flows,
5072 (double)rpt1->ftime500 / (double)rpt->t_flows,
5073 (double)rpt1->ftime1000 / (double)rpt->t_flows,
5074 (double)rpt1->ftime2000 / (double)rpt->t_flows,
5075 (double)rpt1->ftime3000 / (double)rpt->t_flows,
5076 (double)rpt1->ftime4000 / (double)rpt->t_flows,
5077 (double)rpt1->ftime5000 / (double)rpt->t_flows,
5078 (double)rpt1->ftime6000 / (double)rpt->t_flows,
5079 (double)rpt1->ftime7000 / (double)rpt->t_flows,
5080 (double)rpt1->ftime8000 / (double)rpt->t_flows,
5081 (double)rpt1->ftime9000 / (double)rpt->t_flows,
5082 (double)rpt1->ftime10000 / (double)rpt->t_flows,
5083 (double)rpt1->ftime12000 / (double)rpt->t_flows,
5084 (double)rpt1->ftime14000 / (double)rpt->t_flows,
5085 (double)rpt1->ftime16000 / (double)rpt->t_flows,
5086 (double)rpt1->ftime18000 / (double)rpt->t_flows,
5087 (double)rpt1->ftime20000 / (double)rpt->t_flows,
5088 (double)rpt1->ftime22000 / (double)rpt->t_flows,
5089 (double)rpt1->ftime24000 / (double)rpt->t_flows,
5090 (double)rpt1->ftime26000 / (double)rpt->t_flows,
5091 (double)rpt1->ftime28000 / (double)rpt->t_flows,
5092 (double)rpt1->ftime30000 / (double)rpt->t_flows,
5093 (double)rpt1->ftime_other / (double)rpt->t_flows);
5094
5095
5096 return 0;
5097
5098 } /* ftstat_rpt_1_dump */
5099
5100
5101 /* function: ftstat_rpt_1_free
5102 *
5103 * Free data structures for report allocated by ftstat_rpt_1_new
5104 *
5105 */
ftstat_rpt_1_free(struct ftstat_rpt_1 * rpt1)5106 void ftstat_rpt_1_free(struct ftstat_rpt_1 *rpt1)
5107 {
5108 if (rpt1)
5109 free(rpt1);
5110 } /* ftstat_rpt_1_free */
5111
5112
5113 /* function: ftstat_rpt_2_new
5114 *
5115 * Allocate and initialize data structures for rpt 2.
5116 *
5117 * returns allocated struct or 0L for error
5118 */
ftstat_rpt_2_new(struct ftstat_rpt * rpt)5119 struct ftstat_rpt_2 *ftstat_rpt_2_new(struct ftstat_rpt *rpt)
5120 {
5121 struct ftstat_rpt_2 *rpt2;
5122
5123 if (!(rpt2 = (struct ftstat_rpt_2*)malloc(sizeof (*rpt2)))) {
5124 fterr_warnx("malloc(rpt2): failed");
5125 return (struct ftstat_rpt_2*)0L;
5126 }
5127
5128 bzero(rpt2, sizeof *rpt2);
5129
5130 return rpt2;
5131
5132 } /* ftstat_rpt_2_new */
5133
5134
5135 /* function: ftstat_rpt_2_accum
5136 *
5137 * Accumulate counters for report by processing flow.
5138 *
5139 * returns 0: ok
5140 * !0: error
5141 */
ftstat_rpt_2_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5142 int ftstat_rpt_2_accum(struct ftstat_rpt *rpt, char *rec,
5143 struct fts3rec_offsets *fo)
5144 {
5145 struct fts3rec_all2 cur;
5146 uint32_t duration_tmp;
5147 double pps_tmp, bps_tmp;
5148
5149 STD_ACCUM;
5150
5151 return 0;
5152 } /* ftstat_rpt_2_accum */
5153
5154 /* function: ftstat_rpt_2_calc
5155 *
5156 * Perform final calculations for rpt2
5157 *
5158 * returns allocated struct or 0L for error
5159 */
ftstat_rpt_2_calc(struct ftstat_rpt * rpt)5160 int ftstat_rpt_2_calc(struct ftstat_rpt *rpt)
5161 {
5162
5163 STD_CALC;
5164
5165 return 0;
5166
5167 } /* ftstat_rpt_2_calc */
5168
5169
5170 /* function: ftstat_rpt_2_dump
5171 *
5172 * Dump data for report.
5173 *
5174 */
ftstat_rpt_2_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5175 int ftstat_rpt_2_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5176 {
5177 return 0;
5178 } /* ftstat_rpt_2_dump */
5179
5180
5181 /* function: ftstat_rpt_2_free
5182 *
5183 * Free data structures for report allocated by ftstat_rpt_2_new
5184 *
5185 */
ftstat_rpt_2_free(struct ftstat_rpt_2 * rpt2)5186 void ftstat_rpt_2_free(struct ftstat_rpt_2 *rpt2)
5187 {
5188 if (rpt2)
5189 free(rpt2);
5190 } /* ftstat_rpt_2_free */
5191
5192
5193 /* function: ftstat_rpt_3_new
5194 *
5195 * Allocate and initialize data structures for rpt 3.
5196 *
5197 * returns allocated struct or 0L for error
5198 */
ftstat_rpt_3_new(struct ftstat_rpt * rpt)5199 struct ftstat_rpt_3 *ftstat_rpt_3_new(struct ftstat_rpt *rpt)
5200 {
5201
5202 STD_NEW_HASH(ftstat_rpt_3, rpt3, 65536, ftchash_rec_c32, 4, 65536);
5203
5204 } /* ftstat_rpt_3_new */
5205
5206
5207 /* function: ftstat_rpt_3_accum
5208 *
5209 * Accumulate counters for report by processing flow.
5210 *
5211 * returns 0: ok
5212 * !0: error
5213 */
ftstat_rpt_3_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5214 int ftstat_rpt_3_accum(struct ftstat_rpt *rpt, char *rec,
5215 struct fts3rec_offsets *fo)
5216 {
5217
5218 STD_ACCUM_HASH1(ftstat_rpt_3, rpt3, ftchash_rec_c32, ftch_recc32,
5219 ftch_recc32p);
5220
5221 ftch_recc32.c32 = cur.dOctets64 / cur.dPkts64;
5222
5223 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
5224
5225 STD_ACCUM_HASH2(rpt3, ftch_recc32, ftch_recc32p);
5226
5227 return 0;
5228
5229 } /* ftstat_rpt_3_accum */
5230
5231 /* function: ftstat_rpt_3_calc
5232 *
5233 * Perform final calculations for rpt3
5234 *
5235 * returns allocated struct or 0L for error
5236 */
ftstat_rpt_3_calc(struct ftstat_rpt * rpt)5237 int ftstat_rpt_3_calc(struct ftstat_rpt *rpt)
5238 {
5239
5240 STD_CALC_HASH(ftstat_rpt_3, rpt3, ftchash_rec_c32, ftch_recc32);
5241
5242 } /* ftstat_rpt_3_calc */
5243
5244 /* function: ftstat_rpt_3_dump
5245 *
5246 * Dump data for report.
5247 *
5248 */
ftstat_rpt_3_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5249 int ftstat_rpt_3_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5250 {
5251
5252 STD_DUMP_HASH1(ftstat_rpt_3, rpt3, chash_c32_dump, (char*)0L,
5253 "packet size/flow", "", "", "", "", "", "");
5254
5255 } /* ftstat_rpt_3_dump */
5256
5257
5258 /* function: ftstat_rpt_3_free
5259 *
5260 * Free data structures for report allocated by ftstat_rpt_3_new
5261 *
5262 */
ftstat_rpt_3_free(struct ftstat_rpt_3 * rpt3)5263 void ftstat_rpt_3_free(struct ftstat_rpt_3 *rpt3)
5264 {
5265
5266 STD_FREE_HASH(rpt3);
5267
5268 } /* ftstat_rpt_3_free */
5269
5270
5271 /* function: ftstat_rpt_4_new
5272 *
5273 * Allocate and initialize data structures for rpt 4.
5274 *
5275 * returns allocated struct or 0L for error
5276 */
ftstat_rpt_4_new(struct ftstat_rpt * rpt)5277 struct ftstat_rpt_4 *ftstat_rpt_4_new(struct ftstat_rpt *rpt)
5278 {
5279
5280 STD_NEW_HASH(ftstat_rpt_4, rpt4, 65536, ftchash_rec_c64, 8, 65536);
5281
5282 } /* ftstat_rpt_4_new */
5283
5284
5285 /* function: ftstat_rpt_4_accum
5286 *
5287 * Accumulate counters for report by processing flow.
5288 *
5289 * returns 0: ok
5290 * !0: error
5291 */
ftstat_rpt_4_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5292 int ftstat_rpt_4_accum(struct ftstat_rpt *rpt, char *rec,
5293 struct fts3rec_offsets *fo)
5294 {
5295
5296 STD_ACCUM_HASH1(ftstat_rpt_4, rpt4, ftchash_rec_c64, ftch_recc64,
5297 ftch_recc64p);
5298
5299 ftch_recc64.c64 = cur.dOctets64;
5300
5301 hash = ftch_recc64.c64 & 0x000000FFFFFFLL;
5302 hash = (hash>>16) ^ (hash & 0xFFFF);
5303
5304 STD_ACCUM_HASH2(rpt4, ftch_recc64, ftch_recc64p);
5305
5306 return 0;
5307
5308 } /* ftstat_rpt_4_accum */
5309
5310 /* function: ftstat_rpt_4_calc
5311 *
5312 * Perform final calculations for rpt4
5313 *
5314 * returns allocated struct or 0L for error
5315 */
ftstat_rpt_4_calc(struct ftstat_rpt * rpt)5316 int ftstat_rpt_4_calc(struct ftstat_rpt *rpt)
5317 {
5318
5319 STD_CALC_HASH(ftstat_rpt_4, rpt4, ftchash_rec_c64, ftch_recc64);
5320
5321 } /* ftstat_rpt_4_calc */
5322
5323 /* function: ftstat_rpt_4_dump
5324 *
5325 * Dump data for report.
5326 *
5327 */
ftstat_rpt_4_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5328 int ftstat_rpt_4_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5329 {
5330
5331 STD_DUMP_HASH0(ftstat_rpt_4, rpt4, chash_c64_dump,
5332 "octets/flow", "", "", "", "", "", "");
5333
5334 } /* ftstat_rpt_4_dump */
5335
5336
5337 /* function: ftstat_rpt_4_free
5338 *
5339 * Free data structures for report allocated by ftstat_rpt_4_new
5340 *
5341 */
ftstat_rpt_4_free(struct ftstat_rpt_4 * rpt4)5342 void ftstat_rpt_4_free(struct ftstat_rpt_4 *rpt4)
5343 {
5344
5345 STD_FREE_HASH(rpt4);
5346
5347 } /* ftstat_rpt_4_free */
5348
5349
5350 /* function: ftstat_rpt_5_new
5351 *
5352 * Allocate and initialize data structures for rpt 5.
5353 *
5354 * returns allocated struct or 0L for error
5355 */
ftstat_rpt_5_new(struct ftstat_rpt * rpt)5356 struct ftstat_rpt_5 *ftstat_rpt_5_new(struct ftstat_rpt *rpt)
5357 {
5358
5359 STD_NEW_HASH(ftstat_rpt_5, rpt5, 65536, ftchash_rec_c64, 8, 65536);
5360
5361 } /* ftstat_rpt_5_new */
5362
5363
5364 /* function: ftstat_rpt_5_accum
5365 *
5366 * Accumulate counters for report by processing flow.
5367 *
5368 * returns 0: ok
5369 * !0: error
5370 */
ftstat_rpt_5_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5371 int ftstat_rpt_5_accum(struct ftstat_rpt *rpt, char *rec,
5372 struct fts3rec_offsets *fo)
5373 {
5374
5375 STD_ACCUM_HASH1(ftstat_rpt_5, rpt5, ftchash_rec_c64, ftch_recc64,
5376 ftch_recc64p);
5377
5378 ftch_recc64.c64 = cur.dPkts64;
5379
5380 hash = ftch_recc64.c64 & 0x000000FFFFFFLL;
5381 hash = (hash>>16) ^ (hash & 0xFFFF);
5382
5383 STD_ACCUM_HASH2(rpt5, ftch_recc64, ftch_recc64p);
5384
5385 return 0;
5386
5387 } /* ftstat_rpt_5_accum */
5388
5389 /* function: ftstat_rpt_5_calc
5390 *
5391 * Perform final calculations for rpt5
5392 *
5393 * returns allocated struct or 0L for error
5394 */
ftstat_rpt_5_calc(struct ftstat_rpt * rpt)5395 int ftstat_rpt_5_calc(struct ftstat_rpt *rpt)
5396 {
5397
5398 STD_CALC_HASH(ftstat_rpt_5, rpt5, ftchash_rec_c64, ftch_recc64);
5399
5400 } /* ftstat_rpt_5_calc */
5401
5402 /* function: ftstat_rpt_5_dump
5403 *
5404 * Dump data for report.
5405 *
5406 */
ftstat_rpt_5_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5407 int ftstat_rpt_5_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5408 {
5409
5410 STD_DUMP_HASH0(ftstat_rpt_5, rpt5, chash_c64_dump,
5411 "packets/flow", "", "", "", "", "", "");
5412
5413 } /* ftstat_rpt_5_dump */
5414
5415
5416 /* function: ftstat_rpt_5_free
5417 *
5418 * Free data structures for report allocated by ftstat_rpt_5_new
5419 *
5420 */
ftstat_rpt_5_free(struct ftstat_rpt_5 * rpt5)5421 void ftstat_rpt_5_free(struct ftstat_rpt_5 *rpt5)
5422 {
5423
5424 STD_FREE_HASH(rpt5);
5425
5426 } /* ftstat_rpt_5_free */
5427
5428
5429 /* function: ftstat_rpt_6_new
5430 *
5431 * Allocate and initialize data structures for rpt 6.
5432 *
5433 * returns allocated struct or 0L for error
5434 */
ftstat_rpt_6_new(struct ftstat_rpt * rpt)5435 struct ftstat_rpt_6 *ftstat_rpt_6_new(struct ftstat_rpt *rpt)
5436 {
5437
5438 STD_NEW_BUCKET(ftstat_rpt_6, rpt6, 65536, rpt);
5439
5440 } /* ftstat_rpt_6_new */
5441
5442
5443 /* function: ftstat_rpt_6_accum
5444 *
5445 * Accumulate counters for report by processing flow.
5446 *
5447 * returns 0: ok
5448 * !0: error
5449 */
ftstat_rpt_6_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5450 int ftstat_rpt_6_accum(struct ftstat_rpt *rpt, char *rec,
5451 struct fts3rec_offsets *fo)
5452 {
5453
5454 STD_ACCUM_BUCKET1(ftstat_rpt_6, rpt6);
5455
5456 FT_RECGET_SRCPORT(cur,rec,*fo);
5457
5458 STD_ACCUM_BUCKET2(rpt6->bucket, cur.srcport);
5459
5460 return 0;
5461
5462 } /* ftstat_rpt_6_accum */
5463
5464 /* function: ftstat_rpt_6_calc
5465 *
5466 * Perform final calculations for rpt6
5467 *
5468 * returns allocated struct or 0L for error
5469 */
ftstat_rpt_6_calc(struct ftstat_rpt * rpt)5470 int ftstat_rpt_6_calc(struct ftstat_rpt *rpt)
5471 {
5472
5473 STD_CALC_BUCKET(ftstat_rpt_6, rpt6, 65536);
5474
5475 } /* ftstat_rpt_6_calc */
5476
5477 /* function: ftstat_rpt_6_dump
5478 *
5479 * Dump data for report.
5480 *
5481 */
ftstat_rpt_6_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5482 int ftstat_rpt_6_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5483 {
5484
5485 STD_DUMP_BUCKET(ftstat_rpt_6, rpt6, 65536, FT_PATH_SYM_TCP_PORT,
5486 "ip-source-port", "", "", "", "", "", "");
5487
5488 } /* ftstat_rpt_6_dump */
5489
5490
5491 /* function: ftstat_rpt_6_free
5492 *
5493 * Free data structures for report allocated by ftstat_rpt_6_new
5494 *
5495 */
ftstat_rpt_6_free(struct ftstat_rpt_6 * rpt6)5496 void ftstat_rpt_6_free(struct ftstat_rpt_6 *rpt6)
5497 {
5498
5499 STD_FREE_BUCKET(rpt6);
5500
5501 } /* ftstat_rpt_6_free */
5502
5503
5504 /* function: ftstat_rpt_7_new
5505 *
5506 * Allocate and initialize data structures for rpt 7.
5507 *
5508 * returns allocated struct or 0L for error
5509 */
ftstat_rpt_7_new(struct ftstat_rpt * rpt)5510 struct ftstat_rpt_7 *ftstat_rpt_7_new(struct ftstat_rpt *rpt)
5511 {
5512
5513 STD_NEW_BUCKET(ftstat_rpt_7, rpt7, 65536, rpt);
5514
5515 } /* ftstat_rpt_7_new */
5516
5517
5518 /* function: ftstat_rpt_7_accum
5519 *
5520 * Accumulate counters for report by processing flow.
5521 *
5522 * returns 0: ok
5523 * !0: error
5524 */
ftstat_rpt_7_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5525 int ftstat_rpt_7_accum(struct ftstat_rpt *rpt, char *rec,
5526 struct fts3rec_offsets *fo)
5527 {
5528
5529 STD_ACCUM_BUCKET1(ftstat_rpt_7, rpt7);
5530
5531 FT_RECGET_DSTPORT(cur,rec,*fo);
5532
5533 STD_ACCUM_BUCKET2(rpt7->bucket, cur.dstport);
5534
5535 return 0;
5536
5537 } /* ftstat_rpt_7_accum */
5538
5539 /* function: ftstat_rpt_7_calc
5540 *
5541 * Perform final calculations for rpt7
5542 *
5543 * returns allocated struct or 0L for error
5544 */
ftstat_rpt_7_calc(struct ftstat_rpt * rpt)5545 int ftstat_rpt_7_calc(struct ftstat_rpt *rpt)
5546 {
5547
5548 STD_CALC_BUCKET(ftstat_rpt_7, rpt7, 65536);
5549
5550 } /* ftstat_rpt_7_calc */
5551
5552 /* function: ftstat_rpt_7_dump
5553 *
5554 * Dump data for report.
5555 *
5556 */
ftstat_rpt_7_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5557 int ftstat_rpt_7_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5558 {
5559
5560 STD_DUMP_BUCKET(ftstat_rpt_7, rpt7, 65536, FT_PATH_SYM_TCP_PORT,
5561 "ip-destination-port", "", "", "", "", "", "");
5562
5563 } /* ftstat_rpt_7_dump */
5564
5565
5566 /* function: ftstat_rpt_7_free
5567 *
5568 * Free data structures for report allocated by ftstat_rpt_7_new
5569 *
5570 */
ftstat_rpt_7_free(struct ftstat_rpt_7 * rpt7)5571 void ftstat_rpt_7_free(struct ftstat_rpt_7 *rpt7)
5572 {
5573 } /* ftstat_rpt_7_free */
5574
5575
5576 /* function: ftstat_rpt_8_new
5577 *
5578 * Allocate and initialize data structures for rpt 8.
5579 *
5580 * returns allocated struct or 0L for error
5581 */
ftstat_rpt_8_new(struct ftstat_rpt * rpt)5582 struct ftstat_rpt_8 *ftstat_rpt_8_new(struct ftstat_rpt *rpt)
5583 {
5584
5585 STD_NEW_HASH(ftstat_rpt_8, rpt8, 65536, ftchash_rec_c162, 4, 65536);
5586
5587 } /* ftstat_rpt_8_new */
5588
5589
5590 /* function: ftstat_rpt_8_accum
5591 *
5592 * Accumulate counters for report by processing flow.
5593 *
5594 * returns 0: ok
5595 * !0: error
5596 */
ftstat_rpt_8_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5597 int ftstat_rpt_8_accum(struct ftstat_rpt *rpt, char *rec,
5598 struct fts3rec_offsets *fo)
5599 {
5600
5601 STD_ACCUM_HASH1(ftstat_rpt_8, rpt8, ftchash_rec_c162, ftch_recc162,
5602 ftch_recc162p);
5603
5604 FT_RECGET_DSTPORT(cur,rec,*fo);
5605 FT_RECGET_SRCPORT(cur,rec,*fo);
5606
5607 ftch_recc162.c16a = cur.srcport;
5608 ftch_recc162.c16b = cur.dstport;
5609
5610 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
5611 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
5612
5613
5614 STD_ACCUM_HASH2(rpt8, ftch_recc162, ftch_recc162p);
5615
5616 return 0;
5617
5618 } /* ftstat_rpt_8_accum */
5619
5620 /* function: ftstat_rpt_8_calc
5621 *
5622 * Perform final calculations for rpt8
5623 *
5624 * returns allocated struct or 0L for error
5625 */
ftstat_rpt_8_calc(struct ftstat_rpt * rpt)5626 int ftstat_rpt_8_calc(struct ftstat_rpt *rpt)
5627 {
5628
5629 STD_CALC_HASH(ftstat_rpt_8, rpt8, ftchash_rec_c162, ftch_recc162);
5630
5631 } /* ftstat_rpt_8_calc */
5632
5633 /* function: ftstat_rpt_8_dump
5634 *
5635 * Dump data for report.
5636 *
5637 */
ftstat_rpt_8_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5638 int ftstat_rpt_8_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5639 {
5640
5641 STD_DUMP_HASH2(ftstat_rpt_8, rpt8, chash_c162_dump,
5642 FT_PATH_SYM_TCP_PORT, FT_PATH_SYM_TCP_PORT,
5643 "", "ip-source-port", "ip-destination-port", "", "", "", "");
5644
5645 } /* ftstat_rpt_8_dump */
5646
5647
5648 /* function: ftstat_rpt_8_free
5649 *
5650 * Free data structures for report allocated by ftstat_rpt_8_new
5651 *
5652 */
ftstat_rpt_8_free(struct ftstat_rpt_8 * rpt8)5653 void ftstat_rpt_8_free(struct ftstat_rpt_8 *rpt8)
5654 {
5655
5656 STD_FREE_HASH(rpt8);
5657
5658 } /* ftstat_rpt_8_free */
5659
5660
5661 /* function: ftstat_rpt_9_new
5662 *
5663 * Allocate and initialize data structures for rpt 9.
5664 *
5665 * returns allocated struct or 0L for error
5666 */
ftstat_rpt_9_new(struct ftstat_rpt * rpt)5667 struct ftstat_rpt_9 *ftstat_rpt_9_new(struct ftstat_rpt *rpt)
5668 {
5669
5670 STD_NEW_HASH(ftstat_rpt_9, rpt9, 65536, ftchash_rec_c64, 8, 65536);
5671
5672 } /* ftstat_rpt_9_new */
5673
5674
5675 /* function: ftstat_rpt_9_accum
5676 *
5677 * Accumulate counters for report by processing flow.
5678 *
5679 * returns 0: ok
5680 * !0: error
5681 */
ftstat_rpt_9_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5682 int ftstat_rpt_9_accum(struct ftstat_rpt *rpt, char *rec,
5683 struct fts3rec_offsets *fo)
5684 {
5685
5686 STD_ACCUM_HASH1(ftstat_rpt_9, rpt9, ftchash_rec_c64, ftch_recc64,
5687 ftch_recc64p);
5688
5689 ftch_recc64.c64 = (duration_tmp) ?
5690 (double)cur.dOctets64*8/((double)(duration_tmp)/1000.0) : 0;
5691
5692 hash = ftch_recc64.c64 & 0x000000FFFFFFLL;
5693 hash = (hash>>16) ^ (hash & 0xFFFF);
5694
5695 STD_ACCUM_HASH2(rpt9, ftch_recc64, ftch_recc64p);
5696
5697 return 0;
5698
5699 } /* ftstat_rpt_9_accum */
5700
5701 /* function: ftstat_rpt_9_calc
5702 *
5703 * Perform final calculations for rpt9
5704 *
5705 * returns allocated struct or 0L for error
5706 */
ftstat_rpt_9_calc(struct ftstat_rpt * rpt)5707 int ftstat_rpt_9_calc(struct ftstat_rpt *rpt)
5708 {
5709
5710 STD_CALC_HASH(ftstat_rpt_9, rpt9, ftchash_rec_c64, ftch_recc64);
5711
5712 } /* ftstat_rpt_9_calc */
5713
5714
5715 /* function: ftstat_rpt_9_dump
5716 *
5717 * Dump data for report.
5718 *
5719 */
ftstat_rpt_9_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5720 int ftstat_rpt_9_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5721 {
5722
5723 STD_DUMP_HASH0(ftstat_rpt_9, rpt9, chash_c64_dump,
5724 "bps/flow", "", "", "", "", "", "");
5725
5726 } /* ftstat_rpt_9_dump */
5727
5728
5729 /* function: ftstat_rpt_9_free
5730 *
5731 * Free data structures for report allocated by ftstat_rpt_9_new
5732 *
5733 */
ftstat_rpt_9_free(struct ftstat_rpt_9 * rpt9)5734 void ftstat_rpt_9_free(struct ftstat_rpt_9 *rpt9)
5735 {
5736
5737 STD_FREE_HASH(rpt9);
5738
5739 } /* ftstat_rpt_9_free */
5740
5741
5742 /* function: ftstat_rpt_10_new
5743 *
5744 * Allocate and initialize data structures for rpt 10.
5745 *
5746 * returns allocated struct or 0L for error
5747 */
ftstat_rpt_10_new(struct ftstat_rpt * rpt)5748 struct ftstat_rpt_10 *ftstat_rpt_10_new(struct ftstat_rpt *rpt)
5749 {
5750
5751 STD_NEW_HASH(ftstat_rpt_10, rpt10, 65536, ftchash_rec_c64, 8, 65536);
5752
5753 } /* ftstat_rpt_10_new */
5754
5755
5756 /* function: ftstat_rpt_10_accum
5757 *
5758 * Accumulate counters for report by processing flow.
5759 *
5760 * returns 0: ok
5761 * !0: error
5762 */
ftstat_rpt_10_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5763 int ftstat_rpt_10_accum(struct ftstat_rpt *rpt, char *rec,
5764 struct fts3rec_offsets *fo)
5765 {
5766
5767 STD_ACCUM_HASH1(ftstat_rpt_10, rpt10, ftchash_rec_c64, ftch_recc64,
5768 ftch_recc64p);
5769
5770 ftch_recc64.c64 = (duration_tmp) ?
5771 (double)cur.dPkts64/((double)(duration_tmp)/1000.0) : 0;
5772
5773 hash = ftch_recc64.c64 & 0x000000FFFFFFLL;
5774 hash = (hash>>16) ^ (hash & 0xFFFF);
5775
5776 STD_ACCUM_HASH2(rpt10, ftch_recc64, ftch_recc64p);
5777
5778 return 0;
5779
5780 } /* ftstat_rpt_10_accum */
5781
5782 /* function: ftstat_rpt_10_calc
5783 *
5784 * Perform final calculations for rpt10
5785 *
5786 * returns allocated struct or 0L for error
5787 */
ftstat_rpt_10_calc(struct ftstat_rpt * rpt)5788 int ftstat_rpt_10_calc(struct ftstat_rpt *rpt)
5789 {
5790
5791 STD_CALC_HASH(ftstat_rpt_10, rpt10, ftchash_rec_c64, ftch_recc64);
5792
5793 } /* ftstat_rpt_10_calc */
5794
5795 /* function: ftstat_rpt_10_dump
5796 *
5797 * Dump data for report.
5798 *
5799 */
ftstat_rpt_10_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5800 int ftstat_rpt_10_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5801 {
5802
5803 STD_DUMP_HASH0(ftstat_rpt_10, rpt10, chash_c64_dump,
5804 "pps/flow", "", "", "", "", "", "");
5805
5806 } /* ftstat_rpt_10_dump */
5807
5808
5809 /* function: ftstat_rpt_10_free
5810 *
5811 * Free data structures for report allocated by ftstat_rpt_10_new
5812 *
5813 */
ftstat_rpt_10_free(struct ftstat_rpt_10 * rpt10)5814 void ftstat_rpt_10_free(struct ftstat_rpt_10 *rpt10)
5815 {
5816
5817 STD_FREE_HASH(rpt10);
5818
5819 } /* ftstat_rpt_10_free */
5820
5821
5822 /* function: ftstat_rpt_11_new
5823 *
5824 * Allocate and initialize data structures for rpt 11.
5825 *
5826 * returns allocated struct or 0L for error
5827 */
ftstat_rpt_11_new(struct ftstat_rpt * rpt)5828 struct ftstat_rpt_11 *ftstat_rpt_11_new(struct ftstat_rpt *rpt)
5829 {
5830
5831 STD_NEW_BUCKET(ftstat_rpt_11, rpt11, 7, rpt);
5832
5833 } /* ftstat_rpt_11_new */
5834
5835
5836 /* function: ftstat_rpt_11_accum
5837 *
5838 * Accumulate counters for report by processing flow.
5839 *
5840 * returns 0: ok
5841 * !0: error
5842 */
ftstat_rpt_11_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5843 int ftstat_rpt_11_accum(struct ftstat_rpt *rpt, char *rec,
5844 struct fts3rec_offsets *fo)
5845 {
5846 uint16_t tmp;
5847
5848 STD_ACCUM_BUCKET1(ftstat_rpt_11, rpt11);
5849
5850 FT_RECGET_DSTADDR(cur,rec,*fo);
5851
5852 if ((cur.dstaddr & 0xf0000000) == 0xf0000000)
5853 tmp = 5; /* Class E Reserved */
5854 else if ((cur.dstaddr & 0xff000000) == 0xe8000000)
5855 tmp = 4; /* Class D Multicast-SSM */
5856 else if ((cur.dstaddr & 0xf0000000) == 0xe0000000)
5857 tmp = 3; /* Class D Multicast-ASM */
5858 else if ((cur.dstaddr & 0xe0000000) == 0xc0000000)
5859 tmp = 2; /* Class C Unicast */
5860 else if ((cur.dstaddr & 0xc0000000) == 0x80000000)
5861 tmp = 1; /* Class B Unicast */
5862 else if ((cur.dstaddr & 0x80000000) == 0x00000000)
5863 tmp = 0; /* Class A Unicast */
5864 else
5865 tmp = 6; /* not reached */
5866
5867 STD_ACCUM_BUCKET2(rpt11->bucket, tmp);
5868
5869 return 0;
5870
5871 } /* ftstat_rpt_11_accum */
5872
5873 /* function: ftstat_rpt_11_calc
5874 *
5875 * Perform final calculations for rpt11
5876 *
5877 * returns allocated struct or 0L for error
5878 */
ftstat_rpt_11_calc(struct ftstat_rpt * rpt)5879 int ftstat_rpt_11_calc(struct ftstat_rpt *rpt)
5880 {
5881
5882 STD_CALC_BUCKET(ftstat_rpt_11, rpt11, 7);
5883
5884 } /* ftstat_rpt_11_calc */
5885
5886 /* function: ftstat_rpt_11_dump
5887 *
5888 * Dump data for report.
5889 *
5890 */
ftstat_rpt_11_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5891 int ftstat_rpt_11_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5892 {
5893
5894 STD_DUMP_BUCKET(ftstat_rpt_11, rpt11, 7, FT_PATH_SYM_IP_TYPE,
5895 "ip-destination-address-type", "", "", "", "", "", "");
5896
5897 } /* ftstat_rpt_11_dump */
5898
5899
5900 /* function: ftstat_rpt_11_free
5901 *
5902 * Free data structures for report allocated by ftstat_rpt_11_new
5903 *
5904 */
ftstat_rpt_11_free(struct ftstat_rpt_11 * rpt11)5905 void ftstat_rpt_11_free(struct ftstat_rpt_11 *rpt11)
5906 {
5907
5908 STD_FREE_BUCKET(rpt11);
5909
5910 } /* ftstat_rpt_11_free */
5911
5912
5913 /* function: ftstat_rpt_12_new
5914 *
5915 * Allocate and initialize data structures for rpt 12.
5916 *
5917 * returns allocated struct or 0L for error
5918 */
ftstat_rpt_12_new(struct ftstat_rpt * rpt)5919 struct ftstat_rpt_12 *ftstat_rpt_12_new(struct ftstat_rpt *rpt)
5920 {
5921
5922 STD_NEW_BUCKET(ftstat_rpt_12, rpt12, 256, rpt);
5923
5924 } /* ftstat_rpt_12_new */
5925
5926
5927 /* function: ftstat_rpt_12_accum
5928 *
5929 * Accumulate counters for report by processing flow.
5930 *
5931 * returns 0: ok
5932 * !0: error
5933 */
ftstat_rpt_12_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)5934 int ftstat_rpt_12_accum(struct ftstat_rpt *rpt, char *rec,
5935 struct fts3rec_offsets *fo)
5936 {
5937
5938 STD_ACCUM_BUCKET1(ftstat_rpt_12, rpt12);
5939
5940 FT_RECGET_PROT(cur,rec,*fo);
5941
5942 STD_ACCUM_BUCKET2(rpt12->bucket, cur.prot);
5943
5944 return 0;
5945
5946 } /* ftstat_rpt_12_accum */
5947
5948 /* function: ftstat_rpt_12_calc
5949 *
5950 * Perform final calculations for rpt12
5951 *
5952 * returns allocated struct or 0L for error
5953 */
ftstat_rpt_12_calc(struct ftstat_rpt * rpt)5954 int ftstat_rpt_12_calc(struct ftstat_rpt *rpt)
5955 {
5956
5957 STD_CALC_BUCKET(ftstat_rpt_12, rpt12, 256);
5958
5959 } /* ftstat_rpt_12_calc */
5960
5961 /* function: ftstat_rpt_12_dump
5962 *
5963 * Dump data for report.
5964 *
5965 */
ftstat_rpt_12_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)5966 int ftstat_rpt_12_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
5967 {
5968
5969 STD_DUMP_BUCKET(ftstat_rpt_12, rpt12, 256, FT_PATH_SYM_IP_PROT,
5970 "ip-protocol", "", "", "", "", "", "");
5971 } /* ftstat_rpt_12_dump */
5972
5973
5974 /* function: ftstat_rpt_12_free
5975 *
5976 * Free data structures for report allocated by ftstat_rpt_12_new
5977 *
5978 */
ftstat_rpt_12_free(struct ftstat_rpt_12 * rpt12)5979 void ftstat_rpt_12_free(struct ftstat_rpt_12 *rpt12)
5980 {
5981
5982 STD_FREE_BUCKET(rpt12);
5983
5984 } /* ftstat_rpt_12_free */
5985
5986
5987 /* function: ftstat_rpt_13_new
5988 *
5989 * Allocate and initialize data structures for rpt 13.
5990 *
5991 * returns allocated struct or 0L for error
5992 */
ftstat_rpt_13_new(struct ftstat_rpt * rpt)5993 struct ftstat_rpt_13 *ftstat_rpt_13_new(struct ftstat_rpt *rpt)
5994 {
5995
5996 STD_NEW_BUCKET(ftstat_rpt_13, rpt13, 256, rpt);
5997
5998 } /* ftstat_rpt_13_new */
5999
6000
6001 /* function: ftstat_rpt_13_accum
6002 *
6003 * Accumulate counters for report by processing flow.
6004 *
6005 * returns 0: ok
6006 * !0: error
6007 */
ftstat_rpt_13_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6008 int ftstat_rpt_13_accum(struct ftstat_rpt *rpt, char *rec,
6009 struct fts3rec_offsets *fo)
6010 {
6011
6012 STD_ACCUM_BUCKET1(ftstat_rpt_13, rpt13);
6013
6014 FT_RECGET_TOS(cur,rec,*fo);
6015
6016 STD_ACCUM_BUCKET2(rpt13->bucket, cur.tos);
6017
6018 return 0;
6019
6020 } /* ftstat_rpt_13_accum */
6021
6022 /* function: ftstat_rpt_13_calc
6023 *
6024 * Perform final calculations for rpt13
6025 *
6026 * returns allocated struct or 0L for error
6027 */
ftstat_rpt_13_calc(struct ftstat_rpt * rpt)6028 int ftstat_rpt_13_calc(struct ftstat_rpt *rpt)
6029 {
6030
6031 STD_CALC_BUCKET(ftstat_rpt_13, rpt13, 256);
6032
6033 } /* ftstat_rpt_13_calc */
6034
6035 /* function: ftstat_rpt_13_dump
6036 *
6037 * Dump data for report.
6038 *
6039 */
ftstat_rpt_13_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6040 int ftstat_rpt_13_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6041 {
6042
6043 STD_DUMP_BUCKET(ftstat_rpt_13, rpt13, 256, (char*)0L,
6044 "ip-tos", "", "", "", "", "", "");
6045
6046 } /* ftstat_rpt_13_dump */
6047
6048
6049 /* function: ftstat_rpt_13_free
6050 *
6051 * Free data structures for report allocated by ftstat_rpt_13_new
6052 *
6053 */
ftstat_rpt_13_free(struct ftstat_rpt_13 * rpt13)6054 void ftstat_rpt_13_free(struct ftstat_rpt_13 *rpt13)
6055 {
6056
6057 STD_FREE_BUCKET(rpt13);
6058
6059 } /* ftstat_rpt_13_free */
6060
6061
6062 /* function: ftstat_rpt_14_new
6063 *
6064 * Allocate and initialize data structures for rpt 14.
6065 *
6066 * returns allocated struct or 0L for error
6067 */
ftstat_rpt_14_new(struct ftstat_rpt * rpt)6068 struct ftstat_rpt_14 *ftstat_rpt_14_new(struct ftstat_rpt *rpt)
6069 {
6070
6071 STD_NEW_HASH(ftstat_rpt_14, rpt14, 65536, ftchash_rec_c32, 4, 65536);
6072
6073 } /* ftstat_rpt_14_new */
6074
6075
6076 /* function: ftstat_rpt_14_accum
6077 *
6078 * Accumulate counters for report by processing flow.
6079 *
6080 * returns 0: ok
6081 * !0: error
6082 */
ftstat_rpt_14_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6083 int ftstat_rpt_14_accum(struct ftstat_rpt *rpt, char *rec,
6084 struct fts3rec_offsets *fo)
6085 {
6086
6087 STD_ACCUM_HASH1(ftstat_rpt_14, rpt14, ftchash_rec_c32, ftch_recc32,
6088 ftch_recc32p);
6089
6090 FT_RECGET_NEXTHOP(cur,rec,*fo);
6091
6092 ftch_recc32.c32 = cur.nexthop;
6093
6094 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
6095
6096 STD_ACCUM_HASH2(rpt14, ftch_recc32, ftch_recc32p);
6097
6098 return 0;
6099
6100 } /* ftstat_rpt_14_accum */
6101
6102 /* function: ftstat_rpt_14_calc
6103 *
6104 * Perform final calculations for rpt14
6105 *
6106 * returns allocated struct or 0L for error
6107 */
ftstat_rpt_14_calc(struct ftstat_rpt * rpt)6108 int ftstat_rpt_14_calc(struct ftstat_rpt *rpt)
6109 {
6110
6111 STD_CALC_HASH(ftstat_rpt_14, rpt14, ftchash_rec_c32, ftch_recc32);
6112
6113 } /* ftstat_rpt_14_calc */
6114
6115 /* function: ftstat_rpt_14_dump
6116 *
6117 * Dump data for report.
6118 *
6119 */
ftstat_rpt_14_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6120 int ftstat_rpt_14_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6121 {
6122
6123 STD_DUMP_HASH0(ftstat_rpt_14, rpt14, chash_ip_dump,
6124 "ip-next-hop-address", "", "", "", "", "", "");
6125
6126 } /* ftstat_rpt_14_dump */
6127
6128
6129 /* function: ftstat_rpt_14_free
6130 *
6131 * Free data structures for report allocated by ftstat_rpt_14_new
6132 *
6133 */
ftstat_rpt_14_free(struct ftstat_rpt_14 * rpt14)6134 void ftstat_rpt_14_free(struct ftstat_rpt_14 *rpt14)
6135 {
6136
6137 STD_FREE_HASH(rpt14);
6138
6139 } /* ftstat_rpt_14_free */
6140
6141
6142 /* function: ftstat_rpt_15_new
6143 *
6144 * Allocate and initialize data structures for rpt 15.
6145 *
6146 * returns allocated struct or 0L for error
6147 */
ftstat_rpt_15_new(struct ftstat_rpt * rpt)6148 struct ftstat_rpt_15 *ftstat_rpt_15_new(struct ftstat_rpt *rpt)
6149 {
6150
6151 STD_NEW_HASH(ftstat_rpt_15, rpt15, 65536, ftchash_rec_prefix, 5, 65536);
6152
6153 } /* ftstat_rpt_15_new */
6154
6155
6156 /* function: ftstat_rpt_15_accum
6157 *
6158 * Accumulate counters for report by processing flow.
6159 *
6160 * returns 0: ok
6161 * !0: error
6162 */
ftstat_rpt_15_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6163 int ftstat_rpt_15_accum(struct ftstat_rpt *rpt, char *rec,
6164 struct fts3rec_offsets *fo)
6165 {
6166
6167 STD_ACCUM_HASH1(ftstat_rpt_15, rpt15, ftchash_rec_prefix, ftch_recprefix,
6168 ftch_recprefixp);
6169
6170 FT_RECGET_SRCADDR(cur,rec,*fo);
6171
6172 ftch_recprefix.prefix = cur.srcaddr;
6173
6174 /* only use mask if option set */
6175 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
6176 FT_RECGET_SRC_MASK(cur,rec,*fo);
6177 ftch_recprefix.mask = cur.src_mask;
6178 }
6179
6180 /* remove host bits */
6181 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
6182 ftch_recprefix.prefix &= ipv4_len2mask(ftch_recprefix.mask);
6183
6184 hash = (ftch_recprefix.prefix>>16) ^ (ftch_recprefix.prefix & 0xFFFF);
6185 hash = hash ^ (ftch_recprefix.mask);
6186
6187 STD_ACCUM_HASH2(rpt15, ftch_recprefix, ftch_recprefixp);
6188
6189 return 0;
6190
6191 } /* ftstat_rpt_15_accum */
6192
6193 /* function: ftstat_rpt_15_calc
6194 *
6195 * Perform final calculations for rpt15
6196 *
6197 * returns allocated struct or 0L for error
6198 */
ftstat_rpt_15_calc(struct ftstat_rpt * rpt)6199 int ftstat_rpt_15_calc(struct ftstat_rpt *rpt)
6200 {
6201
6202 STD_CALC_HASH(ftstat_rpt_15, rpt15, ftchash_rec_prefix, ftch_recprefix);
6203
6204 } /* ftstat_rpt_15_calc */
6205
6206 /* function: ftstat_rpt_15_dump
6207 *
6208 * Dump data for report.
6209 *
6210 */
ftstat_rpt_15_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6211 int ftstat_rpt_15_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6212 {
6213
6214 STD_DUMP_HASH0P(ftstat_rpt_15, rpt15, chash_prefix_dump,
6215 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
6216 "ip-source-address", "", "", "", "", "", "");
6217
6218 } /* ftstat_rpt_15_dump */
6219
6220
6221 /* function: ftstat_rpt_15_free
6222 *
6223 * Free data structures for report allocated by ftstat_rpt_15_new
6224 *
6225 */
ftstat_rpt_15_free(struct ftstat_rpt_15 * rpt15)6226 void ftstat_rpt_15_free(struct ftstat_rpt_15 *rpt15)
6227 {
6228
6229 STD_FREE_HASH(rpt15);
6230
6231 } /* ftstat_rpt_15_free */
6232
6233
6234 /* function: ftstat_rpt_16_new
6235 *
6236 * Allocate and initialize data structures for rpt 16.
6237 *
6238 * returns allocated struct or 0L for error
6239 */
ftstat_rpt_16_new(struct ftstat_rpt * rpt)6240 struct ftstat_rpt_16 *ftstat_rpt_16_new(struct ftstat_rpt *rpt)
6241 {
6242
6243 STD_NEW_HASH(ftstat_rpt_16, rpt16, 65536, ftchash_rec_prefix, 5, 65536);
6244
6245 } /* ftstat_rpt_16_new */
6246
6247
6248 /* function: ftstat_rpt_16_accum
6249 *
6250 * Accumulate counters for report by processing flow.
6251 *
6252 * returns 0: ok
6253 * !0: error
6254 */
ftstat_rpt_16_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6255 int ftstat_rpt_16_accum(struct ftstat_rpt *rpt, char *rec,
6256 struct fts3rec_offsets *fo)
6257 {
6258
6259 STD_ACCUM_HASH1(ftstat_rpt_16, rpt16, ftchash_rec_prefix, ftch_recprefix,
6260 ftch_recprefixp);
6261
6262 FT_RECGET_DSTADDR(cur,rec,*fo);
6263
6264 ftch_recprefix.prefix = cur.dstaddr;
6265
6266 /* only use mask if option set */
6267 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
6268 FT_RECGET_DST_MASK(cur,rec,*fo);
6269 ftch_recprefix.mask = cur.dst_mask;
6270 }
6271
6272 /* remove host bits */
6273 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
6274 ftch_recprefix.prefix &= ipv4_len2mask(ftch_recprefix.mask);
6275
6276 hash = (ftch_recprefix.prefix>>16) ^ (ftch_recprefix.prefix & 0xFFFF);
6277 hash = hash ^ (ftch_recprefix.mask);
6278
6279 STD_ACCUM_HASH2(rpt16, ftch_recprefix, ftch_recprefixp);
6280
6281 return 0;
6282
6283 } /* ftstat_rpt_16_accum */
6284
6285 /* function: ftstat_rpt_16_calc
6286 *
6287 * Perform final calculations for rpt16
6288 *
6289 * returns allocated struct or 0L for error
6290 */
ftstat_rpt_16_calc(struct ftstat_rpt * rpt)6291 int ftstat_rpt_16_calc(struct ftstat_rpt *rpt)
6292 {
6293
6294 STD_CALC_HASH(ftstat_rpt_16, rpt16, ftchash_rec_prefix, ftch_recprefix);
6295
6296 } /* ftstat_rpt_16_calc */
6297
6298 /* function: ftstat_rpt_16_dump
6299 *
6300 * Dump data for report.
6301 *
6302 */
ftstat_rpt_16_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6303 int ftstat_rpt_16_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6304 {
6305
6306 STD_DUMP_HASH0P(ftstat_rpt_16, rpt16, chash_prefix_dump,
6307 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
6308 "ip-destination-address", "", "", "", "", "", "");
6309
6310 } /* ftstat_rpt_16_dump */
6311
6312
6313 /* function: ftstat_rpt_16_free
6314 *
6315 * Free data structures for report allocated by ftstat_rpt_16_new
6316 *
6317 */
ftstat_rpt_16_free(struct ftstat_rpt_16 * rpt16)6318 void ftstat_rpt_16_free(struct ftstat_rpt_16 *rpt16)
6319 {
6320
6321 STD_FREE_HASH(rpt16);
6322
6323 } /* ftstat_rpt_16_free */
6324
6325
6326 /* function: ftstat_rpt_17_new
6327 *
6328 * Allocate and initialize data structures for rpt 17.
6329 *
6330 * returns allocated struct or 0L for error
6331 */
ftstat_rpt_17_new(struct ftstat_rpt * rpt)6332 struct ftstat_rpt_17 *ftstat_rpt_17_new(struct ftstat_rpt *rpt)
6333 {
6334
6335 STD_NEW_HASH(ftstat_rpt_17, rpt17, 65536, ftchash_rec_prefix2, 16, 65536);
6336
6337 } /* ftstat_rpt_17_new */
6338
6339
6340 /* function: ftstat_rpt_17_accum
6341 *
6342 * Accumulate counters for report by processing flow.
6343 *
6344 * returns 0: ok
6345 * !0: error
6346 */
ftstat_rpt_17_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6347 int ftstat_rpt_17_accum(struct ftstat_rpt *rpt, char *rec,
6348 struct fts3rec_offsets *fo)
6349 {
6350
6351 STD_ACCUM_HASH1(ftstat_rpt_17, rpt17, ftchash_rec_prefix2, ftch_recprefix2,
6352 ftch_recprefix2p);
6353
6354 FT_RECGET_DSTADDR(cur,rec,*fo);
6355 FT_RECGET_SRCADDR(cur,rec,*fo);
6356
6357 ftch_recprefix2.src_prefix = cur.srcaddr;
6358 ftch_recprefix2.dst_prefix = cur.dstaddr;
6359
6360 /* only use mask if option set */
6361 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
6362 FT_RECGET_SRC_MASK(cur,rec,*fo);
6363 ftch_recprefix2.src_mask = cur.src_mask;
6364 }
6365
6366 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
6367 FT_RECGET_DST_MASK(cur,rec,*fo);
6368 ftch_recprefix2.dst_mask = cur.dst_mask;
6369 }
6370
6371 /* remove host bits */
6372 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
6373 ftch_recprefix2.src_prefix &= ipv4_len2mask(ftch_recprefix2.src_mask);
6374 }
6375
6376 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
6377 ftch_recprefix2.dst_prefix &= ipv4_len2mask(ftch_recprefix2.dst_mask);
6378 }
6379
6380 hash = (ftch_recprefix2.src_prefix>>16)^
6381 (ftch_recprefix2.src_prefix & 0xFFFF)^
6382 (ftch_recprefix2.dst_prefix>>16)^
6383 (ftch_recprefix2.dst_prefix & 0xFFFF)^
6384 (ftch_recprefix2.src_mask)^
6385 (uint32_t)(ftch_recprefix2.dst_mask<<8);
6386
6387 STD_ACCUM_HASH2(rpt17, ftch_recprefix2, ftch_recprefix2p);
6388
6389 return 0;
6390
6391 } /* ftstat_rpt_17_accum */
6392
6393 /* function: ftstat_rpt_17_calc
6394 *
6395 * Perform final calculations for rpt17
6396 *
6397 * returns allocated struct or 0L for error
6398 */
ftstat_rpt_17_calc(struct ftstat_rpt * rpt)6399 int ftstat_rpt_17_calc(struct ftstat_rpt *rpt)
6400 {
6401
6402 STD_CALC_HASH(ftstat_rpt_17, rpt17, ftchash_rec_prefix2, ftch_recprefix2);
6403
6404 } /* ftstat_rpt_17_calc */
6405
6406 /* function: ftstat_rpt_17_dump
6407 *
6408 * Dump data for report.
6409 *
6410 */
ftstat_rpt_17_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6411 int ftstat_rpt_17_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6412 {
6413
6414 STD_DUMP_HASH0(ftstat_rpt_17, rpt17, chash_prefix2_dump,
6415 "", "ip-source-address", "ip-destination-address", "", "", "", "");
6416
6417 } /* ftstat_rpt_17_dump */
6418
6419
6420 /* function: ftstat_rpt_17_free
6421 *
6422 * Free data structures for report allocated by ftstat_rpt_17_new
6423 *
6424 */
ftstat_rpt_17_free(struct ftstat_rpt_17 * rpt17)6425 void ftstat_rpt_17_free(struct ftstat_rpt_17 *rpt17)
6426 {
6427 } /* ftstat_rpt_17_free */
6428
6429
6430 /* function: ftstat_rpt_18_new
6431 *
6432 * Allocate and initialize data structures for rpt 18.
6433 *
6434 * returns allocated struct or 0L for error
6435 */
ftstat_rpt_18_new(struct ftstat_rpt * rpt)6436 struct ftstat_rpt_18 *ftstat_rpt_18_new(struct ftstat_rpt *rpt)
6437 {
6438
6439 STD_NEW_HASH(ftstat_rpt_18, rpt18, 65536, ftchash_rec_c32, 4, 65536);
6440
6441 } /* ftstat_rpt_18_new */
6442
6443
6444 /* function: ftstat_rpt_18_accum
6445 *
6446 * Accumulate counters for report by processing flow.
6447 *
6448 * returns 0: ok
6449 * !0: error
6450 */
ftstat_rpt_18_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6451 int ftstat_rpt_18_accum(struct ftstat_rpt *rpt, char *rec,
6452 struct fts3rec_offsets *fo)
6453 {
6454
6455 STD_ACCUM_HASH1(ftstat_rpt_18, rpt18, ftchash_rec_c32, ftch_recc32,
6456 ftch_recc32p);
6457
6458 FT_RECGET_EXADDR(cur,rec,*fo);
6459
6460 ftch_recc32.c32 = cur.exaddr;
6461
6462 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
6463
6464 STD_ACCUM_HASH2(rpt18, ftch_recc32, ftch_recc32p);
6465
6466 return 0;
6467
6468 } /* ftstat_rpt_18_accum */
6469
6470 /* function: ftstat_rpt_18_calc
6471 *
6472 * Perform final calculations for rpt18
6473 *
6474 * returns allocated struct or 0L for error
6475 */
ftstat_rpt_18_calc(struct ftstat_rpt * rpt)6476 int ftstat_rpt_18_calc(struct ftstat_rpt *rpt)
6477 {
6478
6479 STD_CALC_HASH(ftstat_rpt_18, rpt18, ftchash_rec_c32, ftch_recc32);
6480
6481 } /* ftstat_rpt_18_calc */
6482
6483 /* function: ftstat_rpt_18_dump
6484 *
6485 * Dump data for report.
6486 *
6487 */
ftstat_rpt_18_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6488 int ftstat_rpt_18_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6489 {
6490
6491 STD_DUMP_HASH0(ftstat_rpt_18, rpt18, chash_ip_dump,
6492 "ip-exporter-address", "", "", "", "", "", "");
6493
6494 } /* ftstat_rpt_18_dump */
6495
6496
6497 /* function: ftstat_rpt_18_free
6498 *
6499 * Free data structures for report allocated by ftstat_rpt_18_new
6500 *
6501 */
ftstat_rpt_18_free(struct ftstat_rpt_18 * rpt18)6502 void ftstat_rpt_18_free(struct ftstat_rpt_18 *rpt18)
6503 {
6504
6505 STD_FREE_HASH(rpt18);
6506
6507 } /* ftstat_rpt_18_free */
6508
6509
6510 /* function: ftstat_rpt_19_new
6511 *
6512 * Allocate and initialize data structures for rpt 19.
6513 *
6514 * returns allocated struct or 0L for error
6515 */
ftstat_rpt_19_new(struct ftstat_rpt * rpt)6516 struct ftstat_rpt_19 *ftstat_rpt_19_new(struct ftstat_rpt *rpt)
6517 {
6518
6519 STD_NEW_BUCKET(ftstat_rpt_19, rpt19, 65536, rpt);
6520
6521 } /* ftstat_rpt_19_new */
6522
6523
6524 /* function: ftstat_rpt_19_accum
6525 *
6526 * Accumulate counters for report by processing flow.
6527 *
6528 * returns 0: ok
6529 * !0: error
6530 */
ftstat_rpt_19_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6531 int ftstat_rpt_19_accum(struct ftstat_rpt *rpt, char *rec,
6532 struct fts3rec_offsets *fo)
6533 {
6534
6535 STD_ACCUM_BUCKET1(ftstat_rpt_19, rpt19);
6536
6537 FT_RECGET_INPUT(cur,rec,*fo);
6538
6539 STD_ACCUM_BUCKET2(rpt19->bucket, cur.input);
6540
6541 return 0;
6542
6543 } /* ftstat_rpt_19_accum */
6544
6545 /* function: ftstat_rpt_19_calc
6546 *
6547 * Perform final calculations for rpt19
6548 *
6549 * returns allocated struct or 0L for error
6550 */
ftstat_rpt_19_calc(struct ftstat_rpt * rpt)6551 int ftstat_rpt_19_calc(struct ftstat_rpt *rpt)
6552 {
6553
6554 STD_CALC_BUCKET(ftstat_rpt_19, rpt19, 65536);
6555
6556 } /* ftstat_rpt_19_calc */
6557
6558 /* function: ftstat_rpt_19_dump
6559 *
6560 * Dump data for report.
6561 *
6562 */
ftstat_rpt_19_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6563 int ftstat_rpt_19_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6564 {
6565
6566 STD_DUMP_BUCKET(ftstat_rpt_19, rpt19, 65536, (char*)0L,
6567 "input-interface", "", "", "", "", "", "");
6568
6569 } /* ftstat_rpt_19_dump */
6570
6571
6572 /* function: ftstat_rpt_19_free
6573 *
6574 * Free data structures for report allocated by ftstat_rpt_19_new
6575 *
6576 */
ftstat_rpt_19_free(struct ftstat_rpt_19 * rpt19)6577 void ftstat_rpt_19_free(struct ftstat_rpt_19 *rpt19)
6578 {
6579
6580 STD_FREE_BUCKET(rpt19);
6581
6582 } /* ftstat_rpt_19_free */
6583
6584
6585 /* function: ftstat_rpt_20_new
6586 *
6587 * Allocate and initialize data structures for rpt 20.
6588 *
6589 * returns allocated struct or 0L for error
6590 */
ftstat_rpt_20_new(struct ftstat_rpt * rpt)6591 struct ftstat_rpt_20 *ftstat_rpt_20_new(struct ftstat_rpt *rpt)
6592 {
6593
6594 STD_NEW_BUCKET(ftstat_rpt_20, rpt20, 65536, rpt);
6595
6596 } /* ftstat_rpt_20_new */
6597
6598
6599 /* function: ftstat_rpt_20_accum
6600 *
6601 * Accumulate counters for report by processing flow.
6602 *
6603 * returns 0: ok
6604 * !0: error
6605 */
ftstat_rpt_20_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6606 int ftstat_rpt_20_accum(struct ftstat_rpt *rpt, char *rec,
6607 struct fts3rec_offsets *fo)
6608 {
6609
6610 STD_ACCUM_BUCKET1(ftstat_rpt_20, rpt20);
6611
6612 FT_RECGET_OUTPUT(cur,rec,*fo);
6613
6614 STD_ACCUM_BUCKET2(rpt20->bucket, cur.output);
6615
6616 return 0;
6617
6618 } /* ftstat_rpt_20_accum */
6619
6620 /* function: ftstat_rpt_20_calc
6621 *
6622 * Perform final calculations for rpt20
6623 *
6624 * returns allocated struct or 0L for error
6625 */
ftstat_rpt_20_calc(struct ftstat_rpt * rpt)6626 int ftstat_rpt_20_calc(struct ftstat_rpt *rpt)
6627 {
6628
6629 STD_CALC_BUCKET(ftstat_rpt_20, rpt20, 65536);
6630
6631 } /* ftstat_rpt_20_calc */
6632
6633 /* function: ftstat_rpt_20_dump
6634 *
6635 * Dump data for report.
6636 *
6637 */
ftstat_rpt_20_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6638 int ftstat_rpt_20_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6639 {
6640
6641 STD_DUMP_BUCKET(ftstat_rpt_20, rpt20, 65536, (char*)0L,
6642 "output-interface", "", "", "", "", "", "");
6643
6644 } /* ftstat_rpt_20_dump */
6645
6646
6647 /* function: ftstat_rpt_20_free
6648 *
6649 * Free data structures for report allocated by ftstat_rpt_20_new
6650 *
6651 */
ftstat_rpt_20_free(struct ftstat_rpt_20 * rpt20)6652 void ftstat_rpt_20_free(struct ftstat_rpt_20 *rpt20)
6653 {
6654 } /* ftstat_rpt_20_free */
6655
6656
6657 /* function: ftstat_rpt_21_new
6658 *
6659 * Allocate and initialize data structures for rpt 21.
6660 *
6661 * returns allocated struct or 0L for error
6662 */
ftstat_rpt_21_new(struct ftstat_rpt * rpt)6663 struct ftstat_rpt_21 *ftstat_rpt_21_new(struct ftstat_rpt *rpt)
6664 {
6665
6666 STD_NEW_HASH(ftstat_rpt_21, rpt21, 65536, ftchash_rec_c162, 4, 65536);
6667
6668 } /* ftstat_rpt_21_new */
6669
6670
6671 /* function: ftstat_rpt_21_accum
6672 *
6673 * Accumulate counters for report by processing flow.
6674 *
6675 * returns 0: ok
6676 * !0: error
6677 */
ftstat_rpt_21_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6678 int ftstat_rpt_21_accum(struct ftstat_rpt *rpt, char *rec,
6679 struct fts3rec_offsets *fo)
6680 {
6681
6682 STD_ACCUM_HASH1(ftstat_rpt_21, rpt21, ftchash_rec_c162, ftch_recc162,
6683 ftch_recc162p);
6684
6685 FT_RECGET_INPUT(cur,rec,*fo);
6686 FT_RECGET_OUTPUT(cur,rec,*fo);
6687
6688 ftch_recc162.c16a = cur.input;
6689 ftch_recc162.c16b = cur.output;
6690
6691 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
6692 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
6693
6694 STD_ACCUM_HASH2(rpt21, ftch_recc162, ftch_recc162p);
6695
6696 return 0;
6697
6698 } /* ftstat_rpt_21_accum */
6699
6700 /* function: ftstat_rpt_21_calc
6701 *
6702 * Perform final calculations for rpt21
6703 *
6704 * returns allocated struct or 0L for error
6705 */
ftstat_rpt_21_calc(struct ftstat_rpt * rpt)6706 int ftstat_rpt_21_calc(struct ftstat_rpt *rpt)
6707 {
6708
6709 STD_CALC_HASH(ftstat_rpt_21, rpt21, ftchash_rec_c162, ftch_recc162);
6710
6711 } /* ftstat_rpt_21_calc */
6712
6713 /* function: ftstat_rpt_21_dump
6714 *
6715 * Dump data for report.
6716 *
6717 */
ftstat_rpt_21_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6718 int ftstat_rpt_21_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6719 {
6720
6721 STD_DUMP_HASH2(ftstat_rpt_21, rpt21, chash_c162_dump,
6722 (char*)0L, (char*)0L,
6723 "", "input-interface", "output-interface", "", "", "", "");
6724
6725 } /* ftstat_rpt_21_dump */
6726
6727
6728 /* function: ftstat_rpt_21_free
6729 *
6730 * Free data structures for report allocated by ftstat_rpt_21_new
6731 *
6732 */
ftstat_rpt_21_free(struct ftstat_rpt_21 * rpt21)6733 void ftstat_rpt_21_free(struct ftstat_rpt_21 *rpt21)
6734 {
6735
6736 STD_FREE_HASH(rpt21);
6737
6738 } /* ftstat_rpt_21_free */
6739
6740
6741 /* function: ftstat_rpt_22_new
6742 *
6743 * Allocate and initialize data structures for rpt 22.
6744 *
6745 * returns allocated struct or 0L for error
6746 */
ftstat_rpt_22_new(struct ftstat_rpt * rpt)6747 struct ftstat_rpt_22 *ftstat_rpt_22_new(struct ftstat_rpt *rpt)
6748 {
6749
6750 STD_NEW_BUCKET(ftstat_rpt_22, rpt22, 65536, rpt);
6751
6752 } /* ftstat_rpt_22_new */
6753
6754
6755 /* function: ftstat_rpt_22_accum
6756 *
6757 * Accumulate counters for report by processing flow.
6758 *
6759 * returns 0: ok
6760 * !0: error
6761 */
ftstat_rpt_22_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6762 int ftstat_rpt_22_accum(struct ftstat_rpt *rpt, char *rec,
6763 struct fts3rec_offsets *fo)
6764 {
6765
6766 STD_ACCUM_BUCKET1(ftstat_rpt_22, rpt22);
6767
6768 FT_RECGET_SRC_AS(cur,rec,*fo);
6769
6770 STD_ACCUM_BUCKET2(rpt22->bucket, cur.src_as);
6771
6772 return 0;
6773
6774 } /* ftstat_rpt_22_accum */
6775
6776 /* function: ftstat_rpt_22_calc
6777 *
6778 * Perform final calculations for rpt22
6779 *
6780 * returns allocated struct or 0L for error
6781 */
ftstat_rpt_22_calc(struct ftstat_rpt * rpt)6782 int ftstat_rpt_22_calc(struct ftstat_rpt *rpt)
6783 {
6784
6785 STD_CALC_BUCKET(ftstat_rpt_22, rpt22, 65536);
6786
6787 } /* ftstat_rpt_22_calc */
6788
6789 /* function: ftstat_rpt_22_dump
6790 *
6791 * Dump data for report.
6792 *
6793 */
ftstat_rpt_22_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6794 int ftstat_rpt_22_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6795 {
6796
6797 STD_DUMP_BUCKET(ftstat_rpt_22, rpt22, 65536, FT_PATH_SYM_ASN,
6798 "source-as", "", "", "", "", "", "");
6799
6800 } /* ftstat_rpt_22_dump */
6801
6802
6803 /* function: ftstat_rpt_22_free
6804 *
6805 * Free data structures for report allocated by ftstat_rpt_22_new
6806 *
6807 */
ftstat_rpt_22_free(struct ftstat_rpt_22 * rpt22)6808 void ftstat_rpt_22_free(struct ftstat_rpt_22 *rpt22)
6809 {
6810
6811 STD_FREE_BUCKET(rpt22);
6812
6813 } /* ftstat_rpt_22_free */
6814
6815
6816 /* function: ftstat_rpt_23_new
6817 *
6818 * Allocate and initialize data structures for rpt 23.
6819 *
6820 * returns allocated struct or 0L for error
6821 */
ftstat_rpt_23_new(struct ftstat_rpt * rpt)6822 struct ftstat_rpt_23 *ftstat_rpt_23_new(struct ftstat_rpt *rpt)
6823 {
6824
6825 STD_NEW_BUCKET(ftstat_rpt_23, rpt23, 65536, rpt);
6826
6827 } /* ftstat_rpt_23_new */
6828
6829
6830 /* function: ftstat_rpt_23_accum
6831 *
6832 * Accumulate counters for report by processing flow.
6833 *
6834 * returns 0: ok
6835 * !0: error
6836 */
ftstat_rpt_23_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6837 int ftstat_rpt_23_accum(struct ftstat_rpt *rpt, char *rec,
6838 struct fts3rec_offsets *fo)
6839 {
6840
6841 STD_ACCUM_BUCKET1(ftstat_rpt_23, rpt23);
6842
6843 FT_RECGET_DST_AS(cur,rec,*fo);
6844
6845 STD_ACCUM_BUCKET2(rpt23->bucket, cur.dst_as);
6846
6847 return 0;
6848
6849 } /* ftstat_rpt_23_accum */
6850
6851 /* function: ftstat_rpt_23_calc
6852 *
6853 * Perform final calculations for rpt23
6854 *
6855 * returns allocated struct or 0L for error
6856 */
ftstat_rpt_23_calc(struct ftstat_rpt * rpt)6857 int ftstat_rpt_23_calc(struct ftstat_rpt *rpt)
6858 {
6859
6860 STD_CALC_BUCKET(ftstat_rpt_23, rpt23, 65536);
6861
6862 } /* ftstat_rpt_23_calc */
6863
6864 /* function: ftstat_rpt_23_dump
6865 *
6866 * Dump data for report.
6867 *
6868 */
ftstat_rpt_23_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6869 int ftstat_rpt_23_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6870 {
6871
6872 STD_DUMP_BUCKET(ftstat_rpt_23, rpt23, 65536, FT_PATH_SYM_ASN,
6873 "destination-as", "", "", "", "", "", "");
6874
6875 } /* ftstat_rpt_23_dump */
6876
6877
6878 /* function: ftstat_rpt_23_free
6879 *
6880 * Free data structures for report allocated by ftstat_rpt_23_new
6881 *
6882 */
ftstat_rpt_23_free(struct ftstat_rpt_23 * rpt23)6883 void ftstat_rpt_23_free(struct ftstat_rpt_23 *rpt23)
6884 {
6885
6886 STD_FREE_BUCKET(rpt23);
6887
6888 } /* ftstat_rpt_23_free */
6889
6890
6891 /* function: ftstat_rpt_24_new
6892 *
6893 * Allocate and initialize data structures for rpt 24.
6894 *
6895 * returns allocated struct or 0L for error
6896 */
ftstat_rpt_24_new(struct ftstat_rpt * rpt)6897 struct ftstat_rpt_24 *ftstat_rpt_24_new(struct ftstat_rpt *rpt)
6898 {
6899
6900 STD_NEW_HASH(ftstat_rpt_24, rpt24, 65536, ftchash_rec_c162, 4, 65536);
6901
6902 } /* ftstat_rpt_24_new */
6903
6904
6905 /* function: ftstat_rpt_24_accum
6906 *
6907 * Accumulate counters for report by processing flow.
6908 *
6909 * returns 0: ok
6910 * !0: error
6911 */
ftstat_rpt_24_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6912 int ftstat_rpt_24_accum(struct ftstat_rpt *rpt, char *rec,
6913 struct fts3rec_offsets *fo)
6914 {
6915
6916 STD_ACCUM_HASH1(ftstat_rpt_24, rpt24, ftchash_rec_c162, ftch_recc162,
6917 ftch_recc162p);
6918
6919 FT_RECGET_SRC_AS(cur,rec,*fo);
6920 FT_RECGET_DST_AS(cur,rec,*fo);
6921
6922 ftch_recc162.c16a = cur.src_as;
6923 ftch_recc162.c16b = cur.dst_as;
6924
6925 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
6926 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
6927
6928 STD_ACCUM_HASH2(rpt24, ftch_recc162, ftch_recc162p);
6929
6930 return 0;
6931
6932 } /* ftstat_rpt_24_accum */
6933
6934 /* function: ftstat_rpt_24_calc
6935 *
6936 * Perform final calculations for rpt24
6937 *
6938 * returns allocated struct or 0L for error
6939 */
ftstat_rpt_24_calc(struct ftstat_rpt * rpt)6940 int ftstat_rpt_24_calc(struct ftstat_rpt *rpt)
6941 {
6942
6943 STD_CALC_HASH(ftstat_rpt_24, rpt24, ftchash_rec_c162, ftch_recc162);
6944
6945 } /* ftstat_rpt_24_calc */
6946
6947 /* function: ftstat_rpt_24_dump
6948 *
6949 * Dump data for report.
6950 *
6951 */
ftstat_rpt_24_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)6952 int ftstat_rpt_24_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
6953 {
6954
6955 STD_DUMP_HASH2(ftstat_rpt_24, rpt24, chash_c162_dump,
6956 FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
6957 "", "source-as", "destination-AS", "", "", "", "");
6958
6959 } /* ftstat_rpt_24_dump */
6960
6961
6962 /* function: ftstat_rpt_24_free
6963 *
6964 * Free data structures for report allocated by ftstat_rpt_24_new
6965 *
6966 */
ftstat_rpt_24_free(struct ftstat_rpt_24 * rpt24)6967 void ftstat_rpt_24_free(struct ftstat_rpt_24 *rpt24)
6968 {
6969
6970 STD_FREE_HASH(rpt24);
6971
6972 } /* ftstat_rpt_24_free */
6973
6974
6975 /* function: ftstat_rpt_25_new
6976 *
6977 * Allocate and initialize data structures for rpt 25.
6978 *
6979 * returns allocated struct or 0L for error
6980 */
ftstat_rpt_25_new(struct ftstat_rpt * rpt)6981 struct ftstat_rpt_25 *ftstat_rpt_25_new(struct ftstat_rpt *rpt)
6982 {
6983
6984 STD_NEW_HASH(ftstat_rpt_25, rpt25, 65536, ftchash_rec_prefix16, 8, 65536);
6985
6986 } /* ftstat_rpt_25_new */
6987
6988
6989 /* function: ftstat_rpt_25_accum
6990 *
6991 * Accumulate counters for report by processing flow.
6992 *
6993 * returns 0: ok
6994 * !0: error
6995 */
ftstat_rpt_25_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)6996 int ftstat_rpt_25_accum(struct ftstat_rpt *rpt, char *rec,
6997 struct fts3rec_offsets *fo)
6998 {
6999
7000 STD_ACCUM_HASH1(ftstat_rpt_25, rpt25, ftchash_rec_prefix16, ftch_recprefix16,
7001 ftch_prefix16p);
7002
7003 FT_RECGET_SRC_AS(cur,rec,*fo);
7004 FT_RECGET_SRCADDR(cur,rec,*fo);
7005
7006 ftch_recprefix16.prefix = cur.srcaddr;
7007 ftch_recprefix16.c16 = cur.src_as;
7008
7009 /* only use mask if option set */
7010 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7011 FT_RECGET_SRC_MASK(cur,rec,*fo);
7012 ftch_recprefix16.mask = cur.src_mask;
7013 }
7014
7015 /* remove host bits */
7016 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
7017 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7018
7019 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7020 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7021
7022 STD_ACCUM_HASH2(rpt25, ftch_recprefix16, ftch_prefix16p);
7023
7024 return 0;
7025
7026 } /* ftstat_rpt_25_accum */
7027
7028 /* function: ftstat_rpt_25_calc
7029 *
7030 * Perform final calculations for rpt25
7031 *
7032 * returns allocated struct or 0L for error
7033 */
ftstat_rpt_25_calc(struct ftstat_rpt * rpt)7034 int ftstat_rpt_25_calc(struct ftstat_rpt *rpt)
7035 {
7036
7037 STD_CALC_HASH(ftstat_rpt_25, rpt25, ftchash_rec_prefix16, ftch_recprefix16);
7038
7039 } /* ftstat_rpt_25_calc */
7040
7041 /* function: ftstat_rpt_25_dump
7042 *
7043 * Dump data for report.
7044 *
7045 */
ftstat_rpt_25_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7046 int ftstat_rpt_25_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7047 {
7048
7049 STD_DUMP_HASH1P(ftstat_rpt_25, rpt25, chash_prefix16_dump,
7050 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
7051 FT_PATH_SYM_ASN,
7052 "", "ip-source-address", "source-as", "", "", "", "");
7053
7054 } /* ftstat_rpt_25_dump */
7055
7056
7057 /* function: ftstat_rpt_25_free
7058 *
7059 * Free data structures for report allocated by ftstat_rpt_25_new
7060 *
7061 */
ftstat_rpt_25_free(struct ftstat_rpt_25 * rpt25)7062 void ftstat_rpt_25_free(struct ftstat_rpt_25 *rpt25)
7063 {
7064
7065 STD_FREE_HASH(rpt25);
7066
7067 } /* ftstat_rpt_25_free */
7068
7069
7070 /* function: ftstat_rpt_26_new
7071 *
7072 * Allocate and initialize data structures for rpt 26.
7073 *
7074 * returns allocated struct or 0L for error
7075 */
ftstat_rpt_26_new(struct ftstat_rpt * rpt)7076 struct ftstat_rpt_26 *ftstat_rpt_26_new(struct ftstat_rpt *rpt)
7077 {
7078
7079 STD_NEW_HASH(ftstat_rpt_26, rpt26, 65536, ftchash_rec_prefix16, 8, 65536);
7080
7081 } /* ftstat_rpt_26_new */
7082
7083
7084 /* function: ftstat_rpt_26_accum
7085 *
7086 * Accumulate counters for report by processing flow.
7087 *
7088 * returns 0: ok
7089 * !0: error
7090 */
ftstat_rpt_26_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7091 int ftstat_rpt_26_accum(struct ftstat_rpt *rpt, char *rec,
7092 struct fts3rec_offsets *fo)
7093 {
7094
7095 STD_ACCUM_HASH1(ftstat_rpt_26, rpt26, ftchash_rec_prefix16, ftch_recprefix16,
7096 ftch_recprefix16p);
7097
7098 FT_RECGET_SRC_AS(cur,rec,*fo);
7099 FT_RECGET_DSTADDR(cur,rec,*fo);
7100
7101 ftch_recprefix16.prefix = cur.dstaddr;
7102 ftch_recprefix16.c16 = cur.src_as;
7103
7104 /* only use mask if option set */
7105 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7106 FT_RECGET_DST_MASK(cur,rec,*fo);
7107 ftch_recprefix16.mask = cur.dst_mask;
7108 }
7109
7110 /* remove host bits */
7111 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
7112 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7113
7114 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7115 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7116
7117 STD_ACCUM_HASH2(rpt26, ftch_recprefix16, ftch_recprefix16p);
7118
7119 return 0;
7120
7121 } /* ftstat_rpt_26_accum */
7122
7123 /* function: ftstat_rpt_26_calc
7124 *
7125 * Perform final calculations for rpt26
7126 *
7127 * returns allocated struct or 0L for error
7128 */
ftstat_rpt_26_calc(struct ftstat_rpt * rpt)7129 int ftstat_rpt_26_calc(struct ftstat_rpt *rpt)
7130 {
7131
7132 STD_CALC_HASH(ftstat_rpt_26, rpt26, ftchash_rec_prefix16, ftch_recprefix16);
7133
7134 } /* ftstat_rpt_26_calc */
7135
7136 /* function: ftstat_rpt_26_dump
7137 *
7138 * Dump data for report.
7139 *
7140 */
ftstat_rpt_26_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7141 int ftstat_rpt_26_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7142 {
7143
7144 STD_DUMP_HASH1P(ftstat_rpt_26, rpt26, chash_prefix16_dump,
7145 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
7146 FT_PATH_SYM_ASN,
7147 "", "ip-source-address", "destination-as", "", "", "", "");
7148
7149 } /* ftstat_rpt_26_dump */
7150
7151
7152 /* function: ftstat_rpt_26_free
7153 *
7154 * Free data structures for report allocated by ftstat_rpt_26_new
7155 *
7156 */
ftstat_rpt_26_free(struct ftstat_rpt_26 * rpt26)7157 void ftstat_rpt_26_free(struct ftstat_rpt_26 *rpt26)
7158 {
7159
7160 STD_FREE_HASH(rpt26);
7161
7162 } /* ftstat_rpt_26_free */
7163
7164
7165 /* function: ftstat_rpt_27_new
7166 *
7167 * Allocate and initialize data structures for rpt 27.
7168 *
7169 * returns allocated struct or 0L for error
7170 */
ftstat_rpt_27_new(struct ftstat_rpt * rpt)7171 struct ftstat_rpt_27 *ftstat_rpt_27_new(struct ftstat_rpt *rpt)
7172 {
7173
7174 STD_NEW_HASH(ftstat_rpt_27, rpt27, 65536, ftchash_rec_prefix16, 8, 65536);
7175
7176 } /* ftstat_rpt_27_new */
7177
7178
7179 /* function: ftstat_rpt_27_accum
7180 *
7181 * Accumulate counters for report by processing flow.
7182 *
7183 * returns 0: ok
7184 * !0: error
7185 */
ftstat_rpt_27_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7186 int ftstat_rpt_27_accum(struct ftstat_rpt *rpt, char *rec,
7187 struct fts3rec_offsets *fo)
7188 {
7189
7190 STD_ACCUM_HASH1(ftstat_rpt_26, rpt26, ftchash_rec_prefix16, ftch_recprefix16,
7191 ftch_recprefix16p);
7192
7193 FT_RECGET_DST_AS(cur,rec,*fo);
7194 FT_RECGET_SRCADDR(cur,rec,*fo);
7195
7196 ftch_recprefix16.prefix = cur.srcaddr;
7197 ftch_recprefix16.c16 = cur.dst_as;
7198
7199 /* only use mask if option set */
7200 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7201 FT_RECGET_SRC_MASK(cur,rec,*fo);
7202 ftch_recprefix16.mask = cur.src_mask;
7203 }
7204
7205 /* remove host bits */
7206 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
7207 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7208
7209 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7210 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7211
7212 STD_ACCUM_HASH2(rpt26, ftch_recprefix16, ftch_recprefix16p);
7213
7214 return 0;
7215
7216 } /* ftstat_rpt_27_accum */
7217
7218 /* function: ftstat_rpt_27_calc
7219 *
7220 * Perform final calculations for rpt27
7221 *
7222 * returns allocated struct or 0L for error
7223 */
ftstat_rpt_27_calc(struct ftstat_rpt * rpt)7224 int ftstat_rpt_27_calc(struct ftstat_rpt *rpt)
7225 {
7226
7227 STD_CALC_HASH(ftstat_rpt_27, rpt27, ftchash_rec_prefix16, ftch_recprefix16);
7228
7229 } /* ftstat_rpt_27_calc */
7230
7231 /* function: ftstat_rpt_27_dump
7232 *
7233 * Dump data for report.
7234 *
7235 */
ftstat_rpt_27_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7236 int ftstat_rpt_27_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7237 {
7238
7239 STD_DUMP_HASH1P(ftstat_rpt_27, rpt27, chash_prefix16_dump,
7240 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
7241 FT_PATH_SYM_ASN,
7242 "", "ip-source-address", "destination-as", "", "", "", "");
7243
7244
7245 } /* ftstat_rpt_27_dump */
7246
7247
7248 /* function: ftstat_rpt_27_free
7249 *
7250 * Free data structures for report allocated by ftstat_rpt_27_new
7251 *
7252 */
ftstat_rpt_27_free(struct ftstat_rpt_27 * rpt27)7253 void ftstat_rpt_27_free(struct ftstat_rpt_27 *rpt27)
7254 {
7255
7256 STD_FREE_HASH(rpt27);
7257
7258 } /* ftstat_rpt_27_free */
7259
7260
7261 /* function: ftstat_rpt_28_new
7262 *
7263 * Allocate and initialize data structures for rpt 28.
7264 *
7265 * returns allocated struct or 0L for error
7266 */
ftstat_rpt_28_new(struct ftstat_rpt * rpt)7267 struct ftstat_rpt_28 *ftstat_rpt_28_new(struct ftstat_rpt *rpt)
7268 {
7269
7270 STD_NEW_HASH(ftstat_rpt_28, rpt28, 65536, ftchash_rec_prefix16, 8, 65536);
7271
7272 } /* ftstat_rpt_28_new */
7273
7274
7275 /* function: ftstat_rpt_28_accum
7276 *
7277 * Accumulate counters for report by processing flow.
7278 *
7279 * returns 0: ok
7280 * !0: error
7281 */
ftstat_rpt_28_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7282 int ftstat_rpt_28_accum(struct ftstat_rpt *rpt, char *rec,
7283 struct fts3rec_offsets *fo)
7284 {
7285
7286 STD_ACCUM_HASH1(ftstat_rpt_28, rpt28, ftchash_rec_prefix16, ftch_recprefix16,
7287 ftch_recprefix16p);
7288
7289 FT_RECGET_DST_AS(cur,rec,*fo);
7290 FT_RECGET_DSTADDR(cur,rec,*fo);
7291
7292 ftch_recprefix16.prefix = cur.dstaddr;
7293 ftch_recprefix16.c16 = cur.dst_as;
7294
7295 /* only use mask if option set */
7296 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7297 FT_RECGET_DST_MASK(cur,rec,*fo);
7298 ftch_recprefix16.mask = cur.dst_mask;
7299 }
7300
7301 /* remove host bits */
7302 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
7303 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7304
7305 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7306 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7307
7308 STD_ACCUM_HASH2(rpt28, ftch_recprefix16, ftch_recprefix16p);
7309
7310 return 0;
7311
7312 } /* ftstat_rpt_28_accum */
7313
7314 /* function: ftstat_rpt_28_calc
7315 *
7316 * Perform final calculations for rpt28
7317 *
7318 * returns allocated struct or 0L for error
7319 */
ftstat_rpt_28_calc(struct ftstat_rpt * rpt)7320 int ftstat_rpt_28_calc(struct ftstat_rpt *rpt)
7321 {
7322
7323 STD_CALC_HASH(ftstat_rpt_28, rpt28, ftchash_rec_prefix16, ftch_recprefix16);
7324
7325 } /* ftstat_rpt_28_calc */
7326
7327 /* function: ftstat_rpt_28_dump
7328 *
7329 * Dump data for report.
7330 *
7331 */
ftstat_rpt_28_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7332 int ftstat_rpt_28_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7333 {
7334
7335 STD_DUMP_HASH1P(ftstat_rpt_28, rpt28, chash_prefix16_dump,
7336 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
7337 FT_PATH_SYM_ASN,
7338 "", "ip-destination-address", "source-as", "", "", "", "");
7339
7340 } /* ftstat_rpt_28_dump */
7341
7342
7343 /* function: ftstat_rpt_28_free
7344 *
7345 * Free data structures for report allocated by ftstat_rpt_28_new
7346 *
7347 */
ftstat_rpt_28_free(struct ftstat_rpt_28 * rpt28)7348 void ftstat_rpt_28_free(struct ftstat_rpt_28 *rpt28)
7349 {
7350
7351 STD_FREE_HASH(rpt28);
7352
7353 } /* ftstat_rpt_28_free */
7354
7355
7356 /* function: ftstat_rpt_29_new
7357 *
7358 * Allocate and initialize data structures for rpt 29.
7359 *
7360 * returns allocated struct or 0L for error
7361 */
ftstat_rpt_29_new(struct ftstat_rpt * rpt)7362 struct ftstat_rpt_29 *ftstat_rpt_29_new(struct ftstat_rpt *rpt)
7363 {
7364
7365 STD_NEW_HASH(ftstat_rpt_29, rpt29, 65536, ftchash_rec_prefix216, 13, 65536);
7366
7367 } /* ftstat_rpt_29_new */
7368
7369
7370 /* function: ftstat_rpt_29_accum
7371 *
7372 * Accumulate counters for report by processing flow.
7373 *
7374 * returns 0: ok
7375 * !0: error
7376 */
ftstat_rpt_29_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7377 int ftstat_rpt_29_accum(struct ftstat_rpt *rpt, char *rec,
7378 struct fts3rec_offsets *fo)
7379 {
7380
7381 STD_ACCUM_HASH1(ftstat_rpt_29, rpt29, ftchash_rec_prefix216,
7382 ftch_recprefix216, ftch_recprefix216p);
7383
7384 FT_RECGET_SRC_AS(cur,rec,*fo);
7385 FT_RECGET_SRCADDR(cur,rec,*fo);
7386 FT_RECGET_DSTADDR(cur,rec,*fo);
7387
7388 ftch_recprefix216.src_prefix = cur.srcaddr;
7389 ftch_recprefix216.dst_prefix = cur.dstaddr;
7390 ftch_recprefix216.c16 = cur.src_as;
7391
7392 /* only use mask if option set */
7393 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7394 FT_RECGET_SRC_MASK(cur,rec,*fo);
7395 ftch_recprefix216.src_mask = cur.src_mask;
7396 }
7397
7398 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7399 FT_RECGET_DST_MASK(cur,rec,*fo);
7400 ftch_recprefix216.dst_mask = cur.dst_mask;
7401 }
7402
7403 /* remove host bits */
7404 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
7405 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
7406 }
7407
7408 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
7409 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
7410 }
7411
7412 hash = (ftch_recprefix216.src_prefix>>16)^
7413 (ftch_recprefix216.src_prefix & 0xFFFF)^
7414 (ftch_recprefix216.dst_prefix>>16)^
7415 (ftch_recprefix216.dst_prefix & 0xFFFF)^
7416 (ftch_recprefix216.c16)^
7417 (ftch_recprefix216.src_mask)^
7418 (uint32_t)(ftch_recprefix216.dst_mask<<8);
7419
7420 STD_ACCUM_HASH2(rpt29, ftch_recprefix216, ftch_recprefix216p);
7421
7422 return 0;
7423
7424 } /* ftstat_rpt_29_accum */
7425
7426 /* function: ftstat_rpt_29_calc
7427 *
7428 * Perform final calculations for rpt29
7429 *
7430 * returns allocated struct or 0L for error
7431 */
ftstat_rpt_29_calc(struct ftstat_rpt * rpt)7432 int ftstat_rpt_29_calc(struct ftstat_rpt *rpt)
7433 {
7434
7435 STD_CALC_HASH(ftstat_rpt_29, rpt29, ftchash_rec_prefix216, ftch_recprefix216);
7436
7437 } /* ftstat_rpt_29_calc */
7438
7439 /* function: ftstat_rpt_29_dump
7440 *
7441 * Dump data for report.
7442 *
7443 */
ftstat_rpt_29_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7444 int ftstat_rpt_29_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7445 {
7446
7447 STD_DUMP_HASH1(ftstat_rpt_29, rpt29, chash_prefix216_dump, FT_PATH_SYM_ASN,
7448 "", "ip-source-address", "ip-destination-address", "source-as", "", "", "");
7449
7450 } /* ftstat_rpt_29_dump */
7451
7452
7453 /* function: ftstat_rpt_29_free
7454 *
7455 * Free data structures for report allocated by ftstat_rpt_29_new
7456 *
7457 */
ftstat_rpt_29_free(struct ftstat_rpt_29 * rpt29)7458 void ftstat_rpt_29_free(struct ftstat_rpt_29 *rpt29)
7459 {
7460
7461 STD_FREE_HASH(rpt29);
7462
7463 } /* ftstat_rpt_29_free */
7464
7465
7466 /* function: ftstat_rpt_30_new
7467 *
7468 * Allocate and initialize data structures for rpt 30.
7469 *
7470 * returns allocated struct or 0L for error
7471 */
ftstat_rpt_30_new(struct ftstat_rpt * rpt)7472 struct ftstat_rpt_30 *ftstat_rpt_30_new(struct ftstat_rpt *rpt)
7473 {
7474
7475 STD_NEW_HASH(ftstat_rpt_30, rpt30, 65536, ftchash_rec_prefix216, 13, 65536);
7476
7477 } /* ftstat_rpt_30_new */
7478
7479
7480 /* function: ftstat_rpt_30_accum
7481 *
7482 * Accumulate counters for report by processing flow.
7483 *
7484 * returns 0: ok
7485 * !0: error
7486 */
ftstat_rpt_30_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7487 int ftstat_rpt_30_accum(struct ftstat_rpt *rpt, char *rec,
7488 struct fts3rec_offsets *fo)
7489 {
7490
7491 STD_ACCUM_HASH1(ftstat_rpt_30, rpt30, ftchash_rec_prefix216,
7492 ftch_recprefix216, ftch_recprefix216p);
7493
7494 FT_RECGET_DST_AS(cur,rec,*fo);
7495 FT_RECGET_SRCADDR(cur,rec,*fo);
7496 FT_RECGET_DSTADDR(cur,rec,*fo);
7497
7498 ftch_recprefix216.src_prefix = cur.srcaddr;
7499 ftch_recprefix216.dst_prefix = cur.dstaddr;
7500 ftch_recprefix216.c16 = cur.dst_as;
7501
7502 /* only use mask if option set */
7503 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7504 FT_RECGET_SRC_MASK(cur,rec,*fo);
7505 ftch_recprefix216.src_mask = cur.src_mask;
7506 }
7507 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7508 FT_RECGET_DST_MASK(cur,rec,*fo);
7509 ftch_recprefix216.dst_mask = cur.dst_mask;
7510 }
7511
7512 /* remove host bits */
7513 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
7514 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
7515 }
7516
7517 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
7518 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
7519 }
7520
7521 hash = (ftch_recprefix216.src_prefix>>16)^
7522 (ftch_recprefix216.src_prefix & 0xFFFF)^
7523 (ftch_recprefix216.dst_prefix>>16)^
7524 (ftch_recprefix216.dst_prefix & 0xFFFF)^
7525 (ftch_recprefix216.c16)^
7526 (ftch_recprefix216.src_mask)^
7527 (uint32_t)(ftch_recprefix216.dst_mask<<8);
7528
7529 STD_ACCUM_HASH2(rpt30, ftch_recprefix216, ftch_recprefix216p);
7530
7531 return 0;
7532
7533 } /* ftstat_rpt_30_accum */
7534
7535 /* function: ftstat_rpt_30_calc
7536 *
7537 * Perform final calculations for rpt30
7538 *
7539 * returns allocated struct or 0L for error
7540 */
ftstat_rpt_30_calc(struct ftstat_rpt * rpt)7541 int ftstat_rpt_30_calc(struct ftstat_rpt *rpt)
7542 {
7543
7544 STD_CALC_HASH(ftstat_rpt_30, rpt30, ftchash_rec_prefix216, ftch_recprefix216);
7545
7546 } /* ftstat_rpt_30_calc */
7547
7548 /* function: ftstat_rpt_30_dump
7549 *
7550 * Dump data for report.
7551 *
7552 */
ftstat_rpt_30_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7553 int ftstat_rpt_30_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7554 {
7555
7556 STD_DUMP_HASH1(ftstat_rpt_30, rpt30, chash_prefix216_dump, FT_PATH_SYM_ASN,
7557 "", "ip-source-address", "ip-destination-address", "destination-as", "",
7558 "", "");
7559
7560 } /* ftstat_rpt_30_dump */
7561
7562
7563 /* function: ftstat_rpt_30_free
7564 *
7565 * Free data structures for report allocated by ftstat_rpt_30_new
7566 *
7567 */
ftstat_rpt_30_free(struct ftstat_rpt_30 * rpt30)7568 void ftstat_rpt_30_free(struct ftstat_rpt_30 *rpt30)
7569 {
7570
7571 STD_FREE_HASH(rpt30);
7572
7573 } /* ftstat_rpt_30_free */
7574
7575
7576 /* function: ftstat_rpt_31_new
7577 *
7578 * Allocate and initialize data structures for rpt 31.
7579 *
7580 * returns allocated struct or 0L for error
7581 */
ftstat_rpt_31_new(struct ftstat_rpt * rpt)7582 struct ftstat_rpt_31 *ftstat_rpt_31_new(struct ftstat_rpt *rpt)
7583 {
7584
7585 STD_NEW_HASH(ftstat_rpt_31, rpt31, 65536, ftchash_rec_prefix2162, 16, 65536);
7586
7587 } /* ftstat_rpt_31_new */
7588
7589
7590 /* function: ftstat_rpt_31_accum
7591 *
7592 * Accumulate counters for report by processing flow.
7593 *
7594 * returns 0: ok
7595 * !0: error
7596 */
ftstat_rpt_31_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7597 int ftstat_rpt_31_accum(struct ftstat_rpt *rpt, char *rec,
7598 struct fts3rec_offsets *fo)
7599 {
7600
7601 STD_ACCUM_HASH1(ftstat_rpt_31, rpt31, ftchash_rec_prefix2162,
7602 ftch_recprefix2162, ftch_recprefix2162p);
7603
7604 FT_RECGET_SRC_AS(cur,rec,*fo);
7605 FT_RECGET_DST_AS(cur,rec,*fo);
7606 FT_RECGET_SRCADDR(cur,rec,*fo);
7607 FT_RECGET_DSTADDR(cur,rec,*fo);
7608
7609 ftch_recprefix2162.src_prefix = cur.srcaddr;
7610 ftch_recprefix2162.dst_prefix = cur.dstaddr;
7611 ftch_recprefix2162.c16a = cur.src_as;
7612 ftch_recprefix2162.c16b = cur.dst_as;
7613
7614 /* only use mask if option set */
7615 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7616 FT_RECGET_SRC_MASK(cur,rec,*fo);
7617 ftch_recprefix2162.src_mask = cur.src_mask;
7618 }
7619
7620 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7621 FT_RECGET_DST_MASK(cur,rec,*fo);
7622 ftch_recprefix2162.dst_mask = cur.dst_mask;
7623 }
7624
7625 /* remove host bits */
7626 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
7627 ftch_recprefix2162.src_prefix &= ipv4_len2mask(ftch_recprefix2162.src_mask);
7628 }
7629
7630 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
7631 ftch_recprefix2162.dst_prefix &= ipv4_len2mask(ftch_recprefix2162.dst_mask);
7632 }
7633
7634 hash = (ftch_recprefix2162.src_prefix>>16)^
7635 (ftch_recprefix2162.src_prefix & 0xFFFF)^
7636 (ftch_recprefix2162.dst_prefix>>16)^
7637 (ftch_recprefix2162.dst_prefix & 0xFFFF)^
7638 (ftch_recprefix2162.c16b)^
7639 (ftch_recprefix2162.c16a)^
7640 (ftch_recprefix2162.src_mask)^
7641 (uint32_t)(ftch_recprefix2162.dst_mask<<8);
7642
7643 STD_ACCUM_HASH2(rpt31, ftch_recprefix2162, ftch_recprefix2162p);
7644
7645 return 0;
7646
7647 } /* ftstat_rpt_31_accum */
7648
7649 /* function: ftstat_rpt_31_calc
7650 *
7651 * Perform final calculations for rpt31
7652 *
7653 * returns allocated struct or 0L for error
7654 */
ftstat_rpt_31_calc(struct ftstat_rpt * rpt)7655 int ftstat_rpt_31_calc(struct ftstat_rpt *rpt)
7656 {
7657
7658 STD_CALC_HASH(ftstat_rpt_31, rpt31, ftchash_rec_prefix2162,
7659 ftch_recprefix2162);
7660
7661 } /* ftstat_rpt_31_calc */
7662
7663 /* function: ftstat_rpt_31_dump
7664 *
7665 * Dump data for report.
7666 *
7667 */
ftstat_rpt_31_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7668 int ftstat_rpt_31_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7669 {
7670
7671 STD_DUMP_HASH2(ftstat_rpt_31, rpt31, chash_prefix2162_dump,
7672 FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
7673 "", "ip-source-address", "ip-destination-address", "source-as",
7674 "destination-as", "", "");
7675
7676 } /* ftstat_rpt_31_dump */
7677
7678
7679 /* function: ftstat_rpt_31_free
7680 *
7681 * Free data structures for report allocated by ftstat_rpt_31_new
7682 *
7683 */
ftstat_rpt_31_free(struct ftstat_rpt_31 * rpt31)7684 void ftstat_rpt_31_free(struct ftstat_rpt_31 *rpt31)
7685 {
7686
7687 STD_FREE_HASH(rpt31);
7688
7689 } /* ftstat_rpt_31_free */
7690
7691
7692 /* function: ftstat_rpt_32_new
7693 *
7694 * Allocate and initialize data structures for rpt 32.
7695 *
7696 * returns allocated struct or 0L for error
7697 */
ftstat_rpt_32_new(struct ftstat_rpt * rpt)7698 struct ftstat_rpt_32 *ftstat_rpt_32_new(struct ftstat_rpt *rpt)
7699 {
7700
7701 STD_NEW_HASH(ftstat_rpt_32, rpt32, 65536, ftchash_rec_prefix16, 8, 65536);
7702
7703 } /* ftstat_rpt_32_new */
7704
7705
7706 /* function: ftstat_rpt_32_accum
7707 *
7708 * Accumulate counters for report by processing flow.
7709 *
7710 * returns 0: ok
7711 * !0: error
7712 */
ftstat_rpt_32_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7713 int ftstat_rpt_32_accum(struct ftstat_rpt *rpt, char *rec,
7714 struct fts3rec_offsets *fo)
7715 {
7716
7717 STD_ACCUM_HASH1(ftstat_rpt_32, rpt32, ftchash_rec_prefix16,
7718 ftch_recprefix16, ftch_recprefix16p);
7719
7720 FT_RECGET_INPUT(cur,rec,*fo);
7721 FT_RECGET_SRCADDR(cur,rec,*fo);
7722
7723 ftch_recprefix16.prefix = cur.srcaddr;
7724 ftch_recprefix16.c16 = cur.input;
7725
7726 /* only use mask if option set */
7727 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7728 FT_RECGET_SRC_MASK(cur,rec,*fo);
7729 ftch_recprefix16.mask = cur.src_mask;
7730 }
7731
7732 /* remove host bits */
7733 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
7734 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7735
7736 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7737 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7738
7739 STD_ACCUM_HASH2(rpt32, ftch_recprefix16, ftch_recprefix16p);
7740
7741 return 0;
7742
7743 } /* ftstat_rpt_32_accum */
7744
7745 /* function: ftstat_rpt_32_calc
7746 *
7747 * Perform final calculations for rpt32
7748 *
7749 * returns allocated struct or 0L for error
7750 */
ftstat_rpt_32_calc(struct ftstat_rpt * rpt)7751 int ftstat_rpt_32_calc(struct ftstat_rpt *rpt)
7752 {
7753
7754 STD_CALC_HASH(ftstat_rpt_32, rpt32, ftchash_rec_prefix16, ftch_recprefix16);
7755
7756 } /* ftstat_rpt_32_calc */
7757
7758 /* function: ftstat_rpt_32_dump
7759 *
7760 * Dump data for report.
7761 *
7762 */
ftstat_rpt_32_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7763 int ftstat_rpt_32_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7764 {
7765
7766 STD_DUMP_HASH1P(ftstat_rpt_32, rpt32, chash_prefix16_dump,
7767 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
7768 (char*)0L,
7769 "", "ip-source-address", "input-interface", "", "", "", "");
7770
7771 } /* ftstat_rpt_32_dump */
7772
7773
7774 /* function: ftstat_rpt_32_free
7775 *
7776 * Free data structures for report allocated by ftstat_rpt_32_new
7777 *
7778 */
ftstat_rpt_32_free(struct ftstat_rpt_32 * rpt32)7779 void ftstat_rpt_32_free(struct ftstat_rpt_32 *rpt32)
7780 {
7781
7782 STD_FREE_HASH(rpt32);
7783
7784 } /* ftstat_rpt_32_free */
7785
7786
7787 /* function: ftstat_rpt_33_new
7788 *
7789 * Allocate and initialize data structures for rpt 33.
7790 *
7791 * returns allocated struct or 0L for error
7792 */
ftstat_rpt_33_new(struct ftstat_rpt * rpt)7793 struct ftstat_rpt_33 *ftstat_rpt_33_new(struct ftstat_rpt *rpt)
7794 {
7795
7796 STD_NEW_HASH(ftstat_rpt_33, rpt33, 65536, ftchash_rec_prefix16, 8, 65536);
7797
7798 } /* ftstat_rpt_33_new */
7799
7800
7801 /* function: ftstat_rpt_33_accum
7802 *
7803 * Accumulate counters for report by processing flow.
7804 *
7805 * returns 0: ok
7806 * !0: error
7807 */
ftstat_rpt_33_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7808 int ftstat_rpt_33_accum(struct ftstat_rpt *rpt, char *rec,
7809 struct fts3rec_offsets *fo)
7810 {
7811
7812 STD_ACCUM_HASH1(ftstat_rpt_33, rpt33, ftchash_rec_prefix16,
7813 ftch_recprefix16, ftch_recprefix16p);
7814
7815 FT_RECGET_INPUT(cur,rec,*fo);
7816 FT_RECGET_DSTADDR(cur,rec,*fo);
7817
7818 ftch_recprefix16.prefix = cur.dstaddr;
7819 ftch_recprefix16.c16 = cur.input;
7820
7821 /* only use mask if option set */
7822 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
7823 FT_RECGET_DST_MASK(cur,rec,*fo);
7824 ftch_recprefix16.mask = cur.dst_mask;
7825 }
7826
7827 /* remove host bits */
7828 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
7829 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7830
7831 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7832 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7833
7834 STD_ACCUM_HASH2(rpt33, ftch_recprefix16, ftch_recprefix16p);
7835
7836 return 0;
7837
7838 } /* ftstat_rpt_33_accum */
7839
7840 /* function: ftstat_rpt_33_calc
7841 *
7842 * Perform final calculations for rpt33
7843 *
7844 * returns allocated struct or 0L for error
7845 */
ftstat_rpt_33_calc(struct ftstat_rpt * rpt)7846 int ftstat_rpt_33_calc(struct ftstat_rpt *rpt)
7847 {
7848
7849 STD_CALC_HASH(ftstat_rpt_33, rpt33, ftchash_rec_prefix16, ftch_recprefix16);
7850
7851 } /* ftstat_rpt_33_calc */
7852
7853 /* function: ftstat_rpt_33_dump
7854 *
7855 * Dump data for report.
7856 *
7857 */
ftstat_rpt_33_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7858 int ftstat_rpt_33_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7859 {
7860
7861 STD_DUMP_HASH1P(ftstat_rpt_33, rpt33, chash_prefix16_dump,
7862 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
7863 (char*)0L,
7864 "", "ip-destination-address", "input-interface", "", "", "", "");
7865
7866 } /* ftstat_rpt_33_dump */
7867
7868
7869 /* function: ftstat_rpt_33_free
7870 *
7871 * Free data structures for report allocated by ftstat_rpt_33_new
7872 *
7873 */
ftstat_rpt_33_free(struct ftstat_rpt_33 * rpt33)7874 void ftstat_rpt_33_free(struct ftstat_rpt_33 *rpt33)
7875 {
7876 } /* ftstat_rpt_33_free */
7877
7878
7879 /* function: ftstat_rpt_34_new
7880 *
7881 * Allocate and initialize data structures for rpt 34.
7882 *
7883 * returns allocated struct or 0L for error
7884 */
ftstat_rpt_34_new(struct ftstat_rpt * rpt)7885 struct ftstat_rpt_34 *ftstat_rpt_34_new(struct ftstat_rpt *rpt)
7886 {
7887
7888 STD_NEW_HASH(ftstat_rpt_34, rpt34, 65536, ftchash_rec_prefix16, 8, 65536);
7889
7890 } /* ftstat_rpt_34_new */
7891
7892
7893 /* function: ftstat_rpt_34_accum
7894 *
7895 * Accumulate counters for report by processing flow.
7896 *
7897 * returns 0: ok
7898 * !0: error
7899 */
ftstat_rpt_34_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7900 int ftstat_rpt_34_accum(struct ftstat_rpt *rpt, char *rec,
7901 struct fts3rec_offsets *fo)
7902 {
7903
7904 STD_ACCUM_HASH1(ftstat_rpt_33, rpt33, ftchash_rec_prefix16,
7905 ftch_recprefix16, ftch_recprefix16p);
7906
7907 FT_RECGET_OUTPUT(cur,rec,*fo);
7908 FT_RECGET_SRCADDR(cur,rec,*fo);
7909
7910 ftch_recprefix16.prefix = cur.srcaddr;
7911 ftch_recprefix16.c16 = cur.output;
7912
7913 /* only use mask if option set */
7914 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
7915 FT_RECGET_SRC_MASK(cur,rec,*fo);
7916 ftch_recprefix16.mask = cur.src_mask;
7917 }
7918
7919 /* remove host bits */
7920 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
7921 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
7922
7923 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
7924 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
7925
7926 STD_ACCUM_HASH2(rpt33, ftch_recprefix16, ftch_recprefix16p);
7927
7928 return 0;
7929
7930 } /* ftstat_rpt_34_accum */
7931
7932 /* function: ftstat_rpt_34_calc
7933 *
7934 * Perform final calculations for rpt34
7935 *
7936 * returns allocated struct or 0L for error
7937 */
ftstat_rpt_34_calc(struct ftstat_rpt * rpt)7938 int ftstat_rpt_34_calc(struct ftstat_rpt *rpt)
7939 {
7940
7941 STD_CALC_HASH(ftstat_rpt_34, rpt34, ftchash_rec_prefix16, ftch_recprefix16);
7942
7943 } /* ftstat_rpt_34_calc */
7944
7945 /* function: ftstat_rpt_34_dump
7946 *
7947 * Dump data for report.
7948 *
7949 */
ftstat_rpt_34_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)7950 int ftstat_rpt_34_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
7951 {
7952
7953 STD_DUMP_HASH1P(ftstat_rpt_28, rpt28, chash_prefix16_dump,
7954 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
7955 (char*)0L,
7956 "", "ip-source-address", "output-interface", "", "", "", "");
7957
7958 } /* ftstat_rpt_34_dump */
7959
7960
7961 /* function: ftstat_rpt_34_free
7962 *
7963 * Free data structures for report allocated by ftstat_rpt_34_new
7964 *
7965 */
ftstat_rpt_34_free(struct ftstat_rpt_34 * rpt34)7966 void ftstat_rpt_34_free(struct ftstat_rpt_34 *rpt34)
7967 {
7968
7969 STD_FREE_HASH(rpt34);
7970
7971 } /* ftstat_rpt_34_free */
7972
7973
7974 /* function: ftstat_rpt_35_new
7975 *
7976 * Allocate and initialize data structures for rpt 35.
7977 *
7978 * returns allocated struct or 0L for error
7979 */
ftstat_rpt_35_new(struct ftstat_rpt * rpt)7980 struct ftstat_rpt_35 *ftstat_rpt_35_new(struct ftstat_rpt *rpt)
7981 {
7982
7983 STD_NEW_HASH(ftstat_rpt_35, rpt35, 65536, ftchash_rec_prefix16, 8, 65536);
7984
7985 } /* ftstat_rpt_35_new */
7986
7987
7988 /* function: ftstat_rpt_35_accum
7989 *
7990 * Accumulate counters for report by processing flow.
7991 *
7992 * returns 0: ok
7993 * !0: error
7994 */
ftstat_rpt_35_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)7995 int ftstat_rpt_35_accum(struct ftstat_rpt *rpt, char *rec,
7996 struct fts3rec_offsets *fo)
7997 {
7998
7999 STD_ACCUM_HASH1(ftstat_rpt_35, rpt35, ftchash_rec_prefix16,
8000 ftch_recprefix16, ftch_recprefix16p);
8001
8002 FT_RECGET_OUTPUT(cur,rec,*fo);
8003 FT_RECGET_DSTADDR(cur,rec,*fo);
8004
8005 ftch_recprefix16.prefix = cur.dstaddr;
8006 ftch_recprefix16.c16 = cur.output;
8007
8008 /* only use mask if option set */
8009 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
8010 FT_RECGET_DST_MASK(cur,rec,*fo);
8011 ftch_recprefix16.mask = cur.dst_mask;
8012 }
8013
8014 /* remove host bits */
8015 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
8016 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
8017
8018 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
8019 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
8020
8021 STD_ACCUM_HASH2(rpt35, ftch_recprefix16, ftch_recprefix16p);
8022
8023 return 0;
8024
8025 } /* ftstat_rpt_35_accum */
8026
8027 /* function: ftstat_rpt_35_calc
8028 *
8029 * Perform final calculations for rpt35
8030 *
8031 * returns allocated struct or 0L for error
8032 */
ftstat_rpt_35_calc(struct ftstat_rpt * rpt)8033 int ftstat_rpt_35_calc(struct ftstat_rpt *rpt)
8034 {
8035
8036 STD_CALC_HASH(ftstat_rpt_35, rpt35, ftchash_rec_prefix16, ftch_recprefix16);
8037
8038 } /* ftstat_rpt_35_calc */
8039
8040 /* function: ftstat_rpt_35_dump
8041 *
8042 * Dump data for report.
8043 *
8044 */
ftstat_rpt_35_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8045 int ftstat_rpt_35_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8046 {
8047
8048 STD_DUMP_HASH1P(ftstat_rpt_35, rpt35, chash_prefix16_dump,
8049 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
8050 (char*)0L,
8051 "", "ip-destination-address", "output-interface", "", "", "", "");
8052
8053 } /* ftstat_rpt_35_dump */
8054
8055
8056 /* function: ftstat_rpt_35_free
8057 *
8058 * Free data structures for report allocated by ftstat_rpt_35_new
8059 *
8060 */
ftstat_rpt_35_free(struct ftstat_rpt_35 * rpt35)8061 void ftstat_rpt_35_free(struct ftstat_rpt_35 *rpt35)
8062 {
8063
8064 STD_FREE_HASH(rpt35);
8065
8066 } /* ftstat_rpt_35_free */
8067
8068
8069 /* function: ftstat_rpt_36_new
8070 *
8071 * Allocate and initialize data structures for rpt 36.
8072 *
8073 * returns allocated struct or 0L for error
8074 */
ftstat_rpt_36_new(struct ftstat_rpt * rpt)8075 struct ftstat_rpt_36 *ftstat_rpt_36_new(struct ftstat_rpt *rpt)
8076 {
8077
8078 STD_NEW_HASH(ftstat_rpt_36, rpt36, 65536, ftchash_rec_prefix216, 13, 65536);
8079
8080 } /* ftstat_rpt_36_new */
8081
8082
8083 /* function: ftstat_rpt_36_accum
8084 *
8085 * Accumulate counters for report by processing flow.
8086 *
8087 * returns 0: ok
8088 * !0: error
8089 */
ftstat_rpt_36_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8090 int ftstat_rpt_36_accum(struct ftstat_rpt *rpt, char *rec,
8091 struct fts3rec_offsets *fo)
8092 {
8093
8094 STD_ACCUM_HASH1(ftstat_rpt_36, rpt36, ftchash_rec_prefix216,
8095 ftch_recprefix216, ftch_recprefix216p);
8096
8097 FT_RECGET_INPUT(cur,rec,*fo);
8098 FT_RECGET_SRCADDR(cur,rec,*fo);
8099 FT_RECGET_DSTADDR(cur,rec,*fo);
8100
8101 ftch_recprefix216.src_prefix = cur.srcaddr;
8102 ftch_recprefix216.dst_prefix = cur.dstaddr;
8103 ftch_recprefix216.c16 = cur.input;
8104
8105 /* only use mask if option set */
8106 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
8107 FT_RECGET_SRC_MASK(cur,rec,*fo);
8108 ftch_recprefix216.src_mask = cur.src_mask;
8109 }
8110
8111 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
8112 FT_RECGET_DST_MASK(cur,rec,*fo);
8113 ftch_recprefix216.dst_mask = cur.dst_mask;
8114 }
8115
8116 /* remove host bits */
8117 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
8118 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
8119 }
8120
8121 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
8122 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
8123 }
8124
8125 hash = (ftch_recprefix216.src_prefix>>16)^
8126 (ftch_recprefix216.src_prefix & 0xFFFF)^
8127 (ftch_recprefix216.dst_prefix>>16)^
8128 (ftch_recprefix216.dst_prefix & 0xFFFF)^
8129 (ftch_recprefix216.c16)^
8130 (ftch_recprefix216.src_mask)^
8131 (uint32_t)(ftch_recprefix216.dst_mask<<8);
8132
8133 STD_ACCUM_HASH2(rpt36, ftch_recprefix216, ftch_recprefix216p);
8134
8135 return 0;
8136
8137 } /* ftstat_rpt_36_accum */
8138
8139 /* function: ftstat_rpt_36_calc
8140 *
8141 * Perform final calculations for rpt36
8142 *
8143 * returns allocated struct or 0L for error
8144 */
ftstat_rpt_36_calc(struct ftstat_rpt * rpt)8145 int ftstat_rpt_36_calc(struct ftstat_rpt *rpt)
8146 {
8147
8148 STD_CALC_HASH(ftstat_rpt_36, rpt36, ftchash_rec_prefix216, ftch_recprefix216);
8149
8150 } /* ftstat_rpt_36_calc */
8151
8152 /* function: ftstat_rpt_36_dump
8153 *
8154 * Dump data for report.
8155 *
8156 */
ftstat_rpt_36_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8157 int ftstat_rpt_36_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8158 {
8159
8160 STD_DUMP_HASH1(ftstat_rpt_36, rpt36, chash_prefix216_dump,
8161 (char*)0L,
8162 "", "ip-source-address", "ip-destination-address", "input-interface", "",
8163 "", "");
8164
8165 } /* ftstat_rpt_36_dump */
8166
8167
8168 /* function: ftstat_rpt_36_free
8169 *
8170 * Free data structures for report allocated by ftstat_rpt_36_new
8171 *
8172 */
ftstat_rpt_36_free(struct ftstat_rpt_36 * rpt36)8173 void ftstat_rpt_36_free(struct ftstat_rpt_36 *rpt36)
8174 {
8175
8176 STD_FREE_HASH(rpt36);
8177
8178 } /* ftstat_rpt_36_free */
8179
8180
8181 /* function: ftstat_rpt_37_new
8182 *
8183 * Allocate and initialize data structures for rpt 37.
8184 *
8185 * returns allocated struct or 0L for error
8186 */
ftstat_rpt_37_new(struct ftstat_rpt * rpt)8187 struct ftstat_rpt_37 *ftstat_rpt_37_new(struct ftstat_rpt *rpt)
8188 {
8189
8190 STD_NEW_HASH(ftstat_rpt_37, rpt37, 65536, ftchash_rec_prefix216, 13, 65536);
8191
8192 } /* ftstat_rpt_37_new */
8193
8194
8195 /* function: ftstat_rpt_37_accum
8196 *
8197 * Accumulate counters for report by processing flow.
8198 *
8199 * returns 0: ok
8200 * !0: error
8201 */
ftstat_rpt_37_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8202 int ftstat_rpt_37_accum(struct ftstat_rpt *rpt, char *rec,
8203 struct fts3rec_offsets *fo)
8204 {
8205
8206 STD_ACCUM_HASH1(ftstat_rpt_37, rpt37, ftchash_rec_prefix216,
8207 ftch_recprefix216, ftch_recprefix216p);
8208
8209 FT_RECGET_OUTPUT(cur,rec,*fo);
8210 FT_RECGET_SRCADDR(cur,rec,*fo);
8211 FT_RECGET_DSTADDR(cur,rec,*fo);
8212
8213 ftch_recprefix216.src_prefix = cur.srcaddr;
8214 ftch_recprefix216.dst_prefix = cur.dstaddr;
8215 ftch_recprefix216.c16 = cur.output;
8216
8217 /* only use mask if option set */
8218 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
8219 FT_RECGET_SRC_MASK(cur,rec,*fo);
8220 ftch_recprefix216.src_mask = cur.src_mask;
8221 }
8222
8223 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
8224 FT_RECGET_DST_MASK(cur,rec,*fo);
8225 ftch_recprefix216.dst_mask = cur.dst_mask;
8226 }
8227
8228 /* remove host bits */
8229 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
8230 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
8231 }
8232
8233 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
8234 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
8235 }
8236
8237 hash = (ftch_recprefix216.src_prefix>>16)^
8238 (ftch_recprefix216.src_prefix & 0xFFFF)^
8239 (ftch_recprefix216.dst_prefix>>16)^
8240 (ftch_recprefix216.dst_prefix & 0xFFFF)^
8241 (ftch_recprefix216.c16)^
8242 (ftch_recprefix216.src_mask)^
8243 (uint32_t)(ftch_recprefix216.dst_mask<<8);
8244
8245 STD_ACCUM_HASH2(rpt37, ftch_recprefix216, ftch_recprefix216p);
8246
8247 return 0;
8248
8249 } /* ftstat_rpt_37_accum */
8250
8251 /* function: ftstat_rpt_37_calc
8252 *
8253 * Perform final calculations for rpt37
8254 *
8255 * returns allocated struct or 0L for error
8256 */
ftstat_rpt_37_calc(struct ftstat_rpt * rpt)8257 int ftstat_rpt_37_calc(struct ftstat_rpt *rpt)
8258 {
8259
8260 STD_CALC_HASH(ftstat_rpt_37, rpt37, ftchash_rec_prefix216, ftch_recprefix216);
8261
8262 } /* ftstat_rpt_37_calc */
8263
8264 /* function: ftstat_rpt_37_dump
8265 *
8266 * Dump data for report.
8267 *
8268 */
ftstat_rpt_37_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8269 int ftstat_rpt_37_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8270 {
8271
8272 STD_DUMP_HASH1(ftstat_rpt_37, rpt37, chash_prefix216_dump,
8273 (char*)0L,
8274 "", "ip-source-address", "ip-destination-address", "output-interface", "",
8275 "", "");
8276
8277 } /* ftstat_rpt_37_dump */
8278
8279
8280 /* function: ftstat_rpt_37_free
8281 *
8282 * Free data structures for report allocated by ftstat_rpt_37_new
8283 *
8284 */
ftstat_rpt_37_free(struct ftstat_rpt_37 * rpt37)8285 void ftstat_rpt_37_free(struct ftstat_rpt_37 *rpt37)
8286 {
8287
8288 STD_FREE_HASH(rpt37);
8289
8290 } /* ftstat_rpt_37_free */
8291
8292
8293 /* function: ftstat_rpt_38_new
8294 *
8295 * Allocate and initialize data structures for rpt 38.
8296 *
8297 * returns allocated struct or 0L for error
8298 */
ftstat_rpt_38_new(struct ftstat_rpt * rpt)8299 struct ftstat_rpt_38 *ftstat_rpt_38_new(struct ftstat_rpt *rpt)
8300 {
8301
8302 STD_NEW_HASH(ftstat_rpt_38, rpt38, 65536, ftchash_rec_prefix2162, 16, 65536);
8303
8304 } /* ftstat_rpt_38_new */
8305
8306
8307 /* function: ftstat_rpt_38_accum
8308 *
8309 * Accumulate counters for report by processing flow.
8310 *
8311 * returns 0: ok
8312 * !0: error
8313 */
ftstat_rpt_38_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8314 int ftstat_rpt_38_accum(struct ftstat_rpt *rpt, char *rec,
8315 struct fts3rec_offsets *fo)
8316 {
8317
8318 STD_ACCUM_HASH1(ftstat_rpt_38, rpt38, ftchash_rec_prefix2162,
8319 ftch_recprefix2162, ftch_recprefix2162p);
8320
8321 FT_RECGET_INPUT(cur,rec,*fo);
8322 FT_RECGET_OUTPUT(cur,rec,*fo);
8323 FT_RECGET_SRCADDR(cur,rec,*fo);
8324 FT_RECGET_DSTADDR(cur,rec,*fo);
8325
8326 ftch_recprefix2162.src_prefix = cur.srcaddr;
8327 ftch_recprefix2162.dst_prefix = cur.dstaddr;
8328 ftch_recprefix2162.c16a = cur.input;
8329 ftch_recprefix2162.c16b = cur.output;
8330
8331 /* only use mask if option set */
8332 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
8333 FT_RECGET_SRC_MASK(cur,rec,*fo);
8334 ftch_recprefix2162.src_mask = cur.src_mask;
8335 }
8336
8337 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
8338 FT_RECGET_DST_MASK(cur,rec,*fo);
8339 ftch_recprefix2162.dst_mask = cur.dst_mask;
8340 }
8341
8342 /* remove host bits */
8343 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
8344 ftch_recprefix2162.src_prefix &= ipv4_len2mask(ftch_recprefix2162.src_mask);
8345 }
8346
8347 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
8348 ftch_recprefix2162.dst_prefix &= ipv4_len2mask(ftch_recprefix2162.dst_mask);
8349 }
8350
8351 hash = (ftch_recprefix2162.src_prefix>>16)^
8352 (ftch_recprefix2162.src_prefix & 0xFFFF)^
8353 (ftch_recprefix2162.dst_prefix>>16)^
8354 (ftch_recprefix2162.dst_prefix & 0xFFFF)^
8355 (ftch_recprefix2162.c16b)^
8356 (ftch_recprefix2162.c16a)^
8357 (ftch_recprefix2162.src_mask)^
8358 (uint32_t)(ftch_recprefix2162.dst_mask<<8);
8359
8360 STD_ACCUM_HASH2(rpt38, ftch_recprefix2162, ftch_recprefix2162p);
8361
8362 return 0;
8363
8364 } /* ftstat_rpt_38_accum */
8365
8366 /* function: ftstat_rpt_38_calc
8367 *
8368 * Perform final calculations for rpt38
8369 *
8370 * returns allocated struct or 0L for error
8371 */
ftstat_rpt_38_calc(struct ftstat_rpt * rpt)8372 int ftstat_rpt_38_calc(struct ftstat_rpt *rpt)
8373 {
8374
8375 STD_CALC_HASH(ftstat_rpt_38, rpt38, ftchash_rec_prefix2162,
8376 ftch_recprefix2162);
8377
8378 } /* ftstat_rpt_38_calc */
8379
8380 /* function: ftstat_rpt_38_dump
8381 *
8382 * Dump data for report.
8383 *
8384 */
ftstat_rpt_38_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8385 int ftstat_rpt_38_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8386 {
8387
8388 STD_DUMP_HASH2(ftstat_rpt_31, rpt31, chash_prefix2162_dump,
8389 (char*)0L, (char*)0L,
8390 "", "ip-source-address", "ip-destination-address", "input-interface",
8391 "output-interface", "", "");
8392
8393 } /* ftstat_rpt_38_dump */
8394
8395
8396 /* function: ftstat_rpt_38_free
8397 *
8398 * Free data structures for report allocated by ftstat_rpt_38_new
8399 *
8400 */
ftstat_rpt_38_free(struct ftstat_rpt_38 * rpt38)8401 void ftstat_rpt_38_free(struct ftstat_rpt_38 *rpt38)
8402 {
8403
8404 STD_FREE_HASH(rpt38);
8405
8406 } /* ftstat_rpt_38_free */
8407
8408
8409 /* function: ftstat_rpt_39_new
8410 *
8411 * Allocate and initialize data structures for rpt 39.
8412 *
8413 * returns allocated struct or 0L for error
8414 */
ftstat_rpt_39_new(struct ftstat_rpt * rpt)8415 struct ftstat_rpt_39 *ftstat_rpt_39_new(struct ftstat_rpt *rpt)
8416 {
8417
8418 STD_NEW_HASH(ftstat_rpt_39, rpt39, 65536, ftchash_rec_c162, 4, 65536);
8419
8420 } /* ftstat_rpt_39_new */
8421
8422
8423 /* function: ftstat_rpt_39_accum
8424 *
8425 * Accumulate counters for report by processing flow.
8426 *
8427 * returns 0: ok
8428 * !0: error
8429 */
ftstat_rpt_39_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8430 int ftstat_rpt_39_accum(struct ftstat_rpt *rpt, char *rec,
8431 struct fts3rec_offsets *fo)
8432 {
8433
8434 STD_ACCUM_HASH1(ftstat_rpt_39, rpt39, ftchash_rec_c162,
8435 ftch_recc162, ftch_recc162p);
8436
8437 FT_RECGET_INPUT(cur,rec,*fo);
8438 FT_RECGET_SRC_AS(cur,rec,*fo);
8439
8440 ftch_recc162.c16a = cur.input;
8441 ftch_recc162.c16b = cur.src_as;
8442
8443 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
8444 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
8445
8446 STD_ACCUM_HASH2(rpt39, ftch_recc162, ftch_recc162p);
8447
8448 return 0;
8449
8450 } /* ftstat_rpt_39_accum */
8451
8452 /* function: ftstat_rpt_39_calc
8453 *
8454 * Perform final calculations for rpt39
8455 *
8456 * returns allocated struct or 0L for error
8457 */
ftstat_rpt_39_calc(struct ftstat_rpt * rpt)8458 int ftstat_rpt_39_calc(struct ftstat_rpt *rpt)
8459 {
8460
8461 STD_CALC_HASH(ftstat_rpt_39, rpt39, ftchash_rec_c162, ftch_recc162);
8462
8463 } /* ftstat_rpt_39_calc */
8464
8465 /* function: ftstat_rpt_39_dump
8466 *
8467 * Dump data for report.
8468 *
8469 */
ftstat_rpt_39_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8470 int ftstat_rpt_39_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8471 {
8472
8473 STD_DUMP_HASH2(ftstat_rpt_8, rpt8, chash_c162_dump,
8474 (char*)0L, FT_PATH_SYM_ASN,
8475 "", "input-interface", "source-as", "", "", "", "");
8476
8477 } /* ftstat_rpt_39_dump */
8478
8479
8480 /* function: ftstat_rpt_39_free
8481 *
8482 * Free data structures for report allocated by ftstat_rpt_39_new
8483 *
8484 */
ftstat_rpt_39_free(struct ftstat_rpt_39 * rpt39)8485 void ftstat_rpt_39_free(struct ftstat_rpt_39 *rpt39)
8486 {
8487
8488 STD_FREE_HASH(rpt39);
8489
8490 } /* ftstat_rpt_39_free */
8491
8492
8493 /* function: ftstat_rpt_40_new
8494 *
8495 * Allocate and initialize data structures for rpt 40.
8496 *
8497 * returns allocated struct or 0L for error
8498 */
ftstat_rpt_40_new(struct ftstat_rpt * rpt)8499 struct ftstat_rpt_40 *ftstat_rpt_40_new(struct ftstat_rpt *rpt)
8500 {
8501
8502 STD_NEW_HASH(ftstat_rpt_40, rpt40, 65536, ftchash_rec_c162, 4, 65536);
8503
8504 } /* ftstat_rpt_40_new */
8505
8506
8507 /* function: ftstat_rpt_40_accum
8508 *
8509 * Accumulate counters for report by processing flow.
8510 *
8511 * returns 0: ok
8512 * !0: error
8513 */
ftstat_rpt_40_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8514 int ftstat_rpt_40_accum(struct ftstat_rpt *rpt, char *rec,
8515 struct fts3rec_offsets *fo)
8516 {
8517
8518 STD_ACCUM_HASH1(ftstat_rpt_40, rpt40, ftchash_rec_c162,
8519 ftch_recc162, ftch_recc162p);
8520
8521 FT_RECGET_INPUT(cur,rec,*fo);
8522 FT_RECGET_DST_AS(cur,rec,*fo);
8523
8524 ftch_recc162.c16a = cur.input;
8525 ftch_recc162.c16b = cur.dst_as;
8526
8527 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
8528 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
8529
8530 STD_ACCUM_HASH2(rpt40, ftch_recc162, ftch_recc162p);
8531
8532 return 0;
8533
8534 } /* ftstat_rpt_40_accum */
8535
8536 /* function: ftstat_rpt_40_calc
8537 *
8538 * Perform final calculations for rpt40
8539 *
8540 * returns allocated struct or 0L for error
8541 */
ftstat_rpt_40_calc(struct ftstat_rpt * rpt)8542 int ftstat_rpt_40_calc(struct ftstat_rpt *rpt)
8543 {
8544
8545 STD_CALC_HASH(ftstat_rpt_40, rpt40, ftchash_rec_c162, ftch_recc162);
8546
8547 } /* ftstat_rpt_40_calc */
8548
8549 /* function: ftstat_rpt_40_dump
8550 *
8551 * Dump data for report.
8552 *
8553 */
ftstat_rpt_40_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8554 int ftstat_rpt_40_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8555 {
8556
8557 STD_DUMP_HASH2(ftstat_rpt_40, rpt40, chash_c162_dump,
8558 (char*)0L, FT_PATH_SYM_ASN,
8559 "", "input-interface", "destination-as", "", "", "", "");
8560
8561 } /* ftstat_rpt_40_dump */
8562
8563
8564 /* function: ftstat_rpt_40_free
8565 *
8566 * Free data structures for report allocated by ftstat_rpt_40_new
8567 *
8568 */
ftstat_rpt_40_free(struct ftstat_rpt_40 * rpt40)8569 void ftstat_rpt_40_free(struct ftstat_rpt_40 *rpt40)
8570 {
8571
8572 STD_FREE_HASH(rpt40);
8573
8574 } /* ftstat_rpt_40_free */
8575
8576
8577 /* function: ftstat_rpt_41_new
8578 *
8579 * Allocate and initialize data structures for rpt 41.
8580 *
8581 * returns allocated struct or 0L for error
8582 */
ftstat_rpt_41_new(struct ftstat_rpt * rpt)8583 struct ftstat_rpt_41 *ftstat_rpt_41_new(struct ftstat_rpt *rpt)
8584 {
8585
8586 STD_NEW_HASH(ftstat_rpt_41, rpt41, 65536, ftchash_rec_c162, 4, 65536);
8587
8588 } /* ftstat_rpt_41_new */
8589
8590
8591 /* function: ftstat_rpt_41_accum
8592 *
8593 * Accumulate counters for report by processing flow.
8594 *
8595 * returns 0: ok
8596 * !0: error
8597 */
ftstat_rpt_41_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8598 int ftstat_rpt_41_accum(struct ftstat_rpt *rpt, char *rec,
8599 struct fts3rec_offsets *fo)
8600 {
8601
8602 STD_ACCUM_HASH1(ftstat_rpt_41, rpt41, ftchash_rec_c162,
8603 ftch_recc162, ftch_recc162p);
8604
8605 FT_RECGET_OUTPUT(cur,rec,*fo);
8606 FT_RECGET_SRC_AS(cur,rec,*fo);
8607
8608 ftch_recc162.c16a = cur.output;
8609 ftch_recc162.c16b = cur.src_as;
8610
8611 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
8612 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
8613
8614 STD_ACCUM_HASH2(rpt41, ftch_recc162, ftch_recc162p);
8615
8616 return 0;
8617
8618 } /* ftstat_rpt_41_accum */
8619
8620 /* function: ftstat_rpt_41_calc
8621 *
8622 * Perform final calculations for rpt41
8623 *
8624 * returns allocated struct or 0L for error
8625 */
ftstat_rpt_41_calc(struct ftstat_rpt * rpt)8626 int ftstat_rpt_41_calc(struct ftstat_rpt *rpt)
8627 {
8628
8629 STD_CALC_HASH(ftstat_rpt_41, rpt41, ftchash_rec_c162, ftch_recc162);
8630
8631 } /* ftstat_rpt_41_calc */
8632
8633 /* function: ftstat_rpt_41_dump
8634 *
8635 * Dump data for report.
8636 *
8637 */
ftstat_rpt_41_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8638 int ftstat_rpt_41_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8639 {
8640
8641 STD_DUMP_HASH2(ftstat_rpt_41, rpt41, chash_c162_dump,
8642 (char*)0L, FT_PATH_SYM_ASN,
8643 "", "output-interface", "source-as", "", "", "", "");
8644
8645 } /* ftstat_rpt_41_dump */
8646
8647
8648 /* function: ftstat_rpt_41_free
8649 *
8650 * Free data structures for report allocated by ftstat_rpt_41_new
8651 *
8652 */
ftstat_rpt_41_free(struct ftstat_rpt_41 * rpt41)8653 void ftstat_rpt_41_free(struct ftstat_rpt_41 *rpt41)
8654 {
8655
8656 STD_FREE_HASH(rpt41);
8657
8658 } /* ftstat_rpt_41_free */
8659
8660
8661 /* function: ftstat_rpt_42_new
8662 *
8663 * Allocate and initialize data structures for rpt 42.
8664 *
8665 * returns allocated struct or 0L for error
8666 */
ftstat_rpt_42_new(struct ftstat_rpt * rpt)8667 struct ftstat_rpt_42 *ftstat_rpt_42_new(struct ftstat_rpt *rpt)
8668 {
8669
8670 STD_NEW_HASH(ftstat_rpt_42, rpt42, 65536, ftchash_rec_c162, 4, 65536);
8671
8672 } /* ftstat_rpt_42_new */
8673
8674
8675 /* function: ftstat_rpt_42_accum
8676 *
8677 * Accumulate counters for report by processing flow.
8678 *
8679 * returns 0: ok
8680 * !0: error
8681 */
ftstat_rpt_42_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8682 int ftstat_rpt_42_accum(struct ftstat_rpt *rpt, char *rec,
8683 struct fts3rec_offsets *fo)
8684 {
8685
8686 STD_ACCUM_HASH1(ftstat_rpt_42, rpt42, ftchash_rec_c162,
8687 ftch_recc162, ftch_recc162p);
8688
8689 FT_RECGET_OUTPUT(cur,rec,*fo);
8690 FT_RECGET_DST_AS(cur,rec,*fo);
8691
8692 ftch_recc162.c16a = cur.output;
8693 ftch_recc162.c16b = cur.dst_as;
8694
8695 hash = (ftch_recc162.c16a>>16) ^ (ftch_recc162.c16a & 0xFFFF) ^
8696 (ftch_recc162.c16b>>16) ^ (ftch_recc162.c16b & 0xFFFF);
8697
8698 STD_ACCUM_HASH2(rpt42, ftch_recc162, ftch_recc162p);
8699
8700 return 0;
8701
8702 } /* ftstat_rpt_42_accum */
8703
8704 /* function: ftstat_rpt_42_calc
8705 *
8706 * Perform final calculations for rpt42
8707 *
8708 * returns allocated struct or 0L for error
8709 */
ftstat_rpt_42_calc(struct ftstat_rpt * rpt)8710 int ftstat_rpt_42_calc(struct ftstat_rpt *rpt)
8711 {
8712
8713 STD_CALC_HASH(ftstat_rpt_42, rpt42, ftchash_rec_c162, ftch_recc162);
8714
8715 } /* ftstat_rpt_42_calc */
8716
8717 /* function: ftstat_rpt_42_dump
8718 *
8719 * Dump data for report.
8720 *
8721 */
ftstat_rpt_42_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8722 int ftstat_rpt_42_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8723 {
8724
8725
8726 STD_DUMP_HASH2(ftstat_rpt_42, rpt42, chash_c162_dump,
8727 (char*)0L, FT_PATH_SYM_ASN,
8728 "", "output-interface", "destination-as", "", "", "", "");
8729
8730
8731 } /* ftstat_rpt_42_dump */
8732
8733
8734 /* function: ftstat_rpt_42_free
8735 *
8736 * Free data structures for report allocated by ftstat_rpt_42_new
8737 *
8738 */
ftstat_rpt_42_free(struct ftstat_rpt_42 * rpt42)8739 void ftstat_rpt_42_free(struct ftstat_rpt_42 *rpt42)
8740 {
8741
8742 STD_FREE_HASH(rpt42);
8743
8744 } /* ftstat_rpt_42_free */
8745
8746
8747 /* function: ftstat_rpt_43_new
8748 *
8749 * Allocate and initialize data structures for rpt 43.
8750 *
8751 * returns allocated struct or 0L for error
8752 */
ftstat_rpt_43_new(struct ftstat_rpt * rpt)8753 struct ftstat_rpt_43 *ftstat_rpt_43_new(struct ftstat_rpt *rpt)
8754 {
8755
8756 STD_NEW_HASH(ftstat_rpt_43, rpt43, 65536, ftchash_rec_c163, 6, 65536);
8757
8758 } /* ftstat_rpt_43_new */
8759
8760
8761 /* function: ftstat_rpt_43_accum
8762 *
8763 * Accumulate counters for report by processing flow.
8764 *
8765 * returns 0: ok
8766 * !0: error
8767 */
ftstat_rpt_43_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8768 int ftstat_rpt_43_accum(struct ftstat_rpt *rpt, char *rec,
8769 struct fts3rec_offsets *fo)
8770 {
8771
8772 STD_ACCUM_HASH1(ftstat_rpt_43, rpt43, ftchash_rec_c163,
8773 ftch_recc163, ftch_recc163p);
8774
8775 FT_RECGET_INPUT(cur,rec,*fo);
8776 FT_RECGET_SRC_AS(cur,rec,*fo);
8777 FT_RECGET_DST_AS(cur,rec,*fo);
8778
8779 ftch_recc163.c16a = cur.input;
8780 ftch_recc163.c16b = cur.src_as;
8781 ftch_recc163.c16c = cur.dst_as;
8782
8783 hash = ftch_recc163.c16a ^ ftch_recc163.c16b ^ ftch_recc163.c16c;
8784
8785 STD_ACCUM_HASH2(rpt43, ftch_recc163, ftch_recc163p);
8786
8787 return 0;
8788
8789 } /* ftstat_rpt_43_accum */
8790
8791 /* function: ftstat_rpt_43_calc
8792 *
8793 * Perform final calculations for rpt43
8794 *
8795 * returns allocated struct or 0L for error
8796 */
ftstat_rpt_43_calc(struct ftstat_rpt * rpt)8797 int ftstat_rpt_43_calc(struct ftstat_rpt *rpt)
8798 {
8799
8800 STD_CALC_HASH(ftstat_rpt_43, rpt43, ftchash_rec_c163, ftch_recc163);
8801
8802 } /* ftstat_rpt_43_calc */
8803
8804 /* function: ftstat_rpt_43_dump
8805 *
8806 * Dump data for report.
8807 *
8808 */
ftstat_rpt_43_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8809 int ftstat_rpt_43_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8810 {
8811
8812 STD_DUMP_HASH3(ftstat_rpt_43, rpt43, chash_c163_dump,
8813 (char*)0L, FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
8814 "", "input-interface", "source-as", "destination-as", "", "", "");
8815
8816 } /* ftstat_rpt_43_dump */
8817
8818
8819 /* function: ftstat_rpt_43_free
8820 *
8821 * Free data structures for report allocated by ftstat_rpt_43_new
8822 *
8823 */
ftstat_rpt_43_free(struct ftstat_rpt_43 * rpt43)8824 void ftstat_rpt_43_free(struct ftstat_rpt_43 *rpt43)
8825 {
8826
8827 STD_FREE_HASH(rpt43);
8828
8829 } /* ftstat_rpt_43_free */
8830
8831
8832 /* function: ftstat_rpt_44_new
8833 *
8834 * Allocate and initialize data structures for rpt 44.
8835 *
8836 * returns allocated struct or 0L for error
8837 */
ftstat_rpt_44_new(struct ftstat_rpt * rpt)8838 struct ftstat_rpt_44 *ftstat_rpt_44_new(struct ftstat_rpt *rpt)
8839 {
8840
8841 STD_NEW_HASH(ftstat_rpt_44, rpt44, 65536, ftchash_rec_c163, 6, 65536);
8842
8843 } /* ftstat_rpt_44_new */
8844
8845
8846 /* function: ftstat_rpt_44_accum
8847 *
8848 * Accumulate counters for report by processing flow.
8849 *
8850 * returns 0: ok
8851 * !0: error
8852 */
ftstat_rpt_44_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8853 int ftstat_rpt_44_accum(struct ftstat_rpt *rpt, char *rec,
8854 struct fts3rec_offsets *fo)
8855 {
8856
8857 STD_ACCUM_HASH1(ftstat_rpt_44, rpt44, ftchash_rec_c163,
8858 ftch_recc163, ftch_recc163p);
8859
8860 FT_RECGET_OUTPUT(cur,rec,*fo);
8861 FT_RECGET_SRC_AS(cur,rec,*fo);
8862 FT_RECGET_DST_AS(cur,rec,*fo);
8863
8864 ftch_recc163.c16a = cur.output;
8865 ftch_recc163.c16b = cur.src_as;
8866 ftch_recc163.c16c = cur.dst_as;
8867
8868 hash = ftch_recc163.c16a ^ ftch_recc163.c16b ^ ftch_recc163.c16c;
8869
8870 STD_ACCUM_HASH2(rpt44, ftch_recc163, ftch_recc163p);
8871
8872 return 0;
8873
8874 } /* ftstat_rpt_44_accum */
8875
8876 /* function: ftstat_rpt_44_calc
8877 *
8878 * Perform final calculations for rpt44
8879 *
8880 * returns allocated struct or 0L for error
8881 */
ftstat_rpt_44_calc(struct ftstat_rpt * rpt)8882 int ftstat_rpt_44_calc(struct ftstat_rpt *rpt)
8883 {
8884
8885 STD_CALC_HASH(ftstat_rpt_44, rpt44, ftchash_rec_c163, ftch_recc163);
8886
8887 } /* ftstat_rpt_44_calc */
8888
8889 /* function: ftstat_rpt_44_dump
8890 *
8891 * Dump data for report.
8892 *
8893 */
ftstat_rpt_44_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8894 int ftstat_rpt_44_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8895 {
8896
8897 STD_DUMP_HASH3(ftstat_rpt_44, rpt44, chash_c163_dump,
8898 (char*)0L, FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
8899 "", "output-interface", "source-as", "destination-as", "", "", "");
8900
8901 } /* ftstat_rpt_44_dump */
8902
8903
8904 /* function: ftstat_rpt_44_free
8905 *
8906 * Free data structures for report allocated by ftstat_rpt_44_new
8907 *
8908 */
ftstat_rpt_44_free(struct ftstat_rpt_44 * rpt44)8909 void ftstat_rpt_44_free(struct ftstat_rpt_44 *rpt44)
8910 {
8911
8912 STD_FREE_HASH(rpt44);
8913
8914 } /* ftstat_rpt_44_free */
8915
8916
8917 /* function: ftstat_rpt_45_new
8918 *
8919 * Allocate and initialize data structures for rpt 45.
8920 *
8921 * returns allocated struct or 0L for error
8922 */
ftstat_rpt_45_new(struct ftstat_rpt * rpt)8923 struct ftstat_rpt_45 *ftstat_rpt_45_new(struct ftstat_rpt *rpt)
8924 {
8925
8926 STD_NEW_HASH(ftstat_rpt_45, rpt45, 65536, ftchash_rec_c164, 8, 65536);
8927
8928 } /* ftstat_rpt_45_new */
8929
8930
8931 /* function: ftstat_rpt_45_accum
8932 *
8933 * Accumulate counters for report by processing flow.
8934 *
8935 * returns 0: ok
8936 * !0: error
8937 */
ftstat_rpt_45_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)8938 int ftstat_rpt_45_accum(struct ftstat_rpt *rpt, char *rec,
8939 struct fts3rec_offsets *fo)
8940 {
8941
8942 STD_ACCUM_HASH1(ftstat_rpt_45, rpt45, ftchash_rec_c164,
8943 ftch_recc164, ftch_recc164p);
8944
8945 FT_RECGET_INPUT(cur,rec,*fo);
8946 FT_RECGET_OUTPUT(cur,rec,*fo);
8947 FT_RECGET_SRC_AS(cur,rec,*fo);
8948 FT_RECGET_DST_AS(cur,rec,*fo);
8949
8950 ftch_recc164.c16a = cur.input;
8951 ftch_recc164.c16b = cur.output;
8952 ftch_recc164.c16c = cur.src_as;
8953 ftch_recc164.c16d = cur.dst_as;
8954
8955 hash = ftch_recc164.c16a ^ ftch_recc164.c16b ^ ftch_recc164.c16c ^
8956 ftch_recc164.c16c;;
8957
8958 STD_ACCUM_HASH2(rpt45, ftch_recc164, ftch_recc164p);
8959
8960 return 0;
8961
8962 } /* ftstat_rpt_45_accum */
8963
8964 /* function: ftstat_rpt_45_calc
8965 *
8966 * Perform final calculations for rpt45
8967 *
8968 * returns allocated struct or 0L for error
8969 */
ftstat_rpt_45_calc(struct ftstat_rpt * rpt)8970 int ftstat_rpt_45_calc(struct ftstat_rpt *rpt)
8971 {
8972
8973 STD_CALC_HASH(ftstat_rpt_45, rpt45, ftchash_rec_c164, ftch_recc164);
8974
8975 } /* ftstat_rpt_45_calc */
8976
8977 /* function: ftstat_rpt_45_dump
8978 *
8979 * Dump data for report.
8980 *
8981 */
ftstat_rpt_45_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)8982 int ftstat_rpt_45_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
8983 {
8984
8985 STD_DUMP_HASH4(ftstat_rpt_45, rpt45, chash_c164_dump,
8986 (char*)0L, (char*)0L, FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
8987 "", "input-interface", "output-interface", "source-as", "destination-as",
8988 "", "");
8989
8990 } /* ftstat_rpt_45_dump */
8991
8992
8993 /* function: ftstat_rpt_45_free
8994 *
8995 * Free data structures for report allocated by ftstat_rpt_45_new
8996 *
8997 */
ftstat_rpt_45_free(struct ftstat_rpt_45 * rpt45)8998 void ftstat_rpt_45_free(struct ftstat_rpt_45 *rpt45)
8999 {
9000
9001 STD_FREE_HASH(rpt45);
9002
9003 } /* ftstat_rpt_45_free */
9004
9005
9006 /* function: ftstat_rpt_46_new
9007 *
9008 * Allocate and initialize data structures for rpt 46.
9009 *
9010 * returns allocated struct or 0L for error
9011 */
ftstat_rpt_46_new(struct ftstat_rpt * rpt)9012 struct ftstat_rpt_46 *ftstat_rpt_46_new(struct ftstat_rpt *rpt)
9013 {
9014
9015 STD_NEW_BUCKET(ftstat_rpt_46, rpt46, 256, rpt);
9016
9017 } /* ftstat_rpt_46_new */
9018
9019
9020 /* function: ftstat_rpt_46_accum
9021 *
9022 * Accumulate counters for report by processing flow.
9023 *
9024 * returns 0: ok
9025 * !0: error
9026 */
ftstat_rpt_46_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9027 int ftstat_rpt_46_accum(struct ftstat_rpt *rpt, char *rec,
9028 struct fts3rec_offsets *fo)
9029 {
9030
9031 STD_ACCUM_BUCKET1(ftstat_rpt_46, rpt46);
9032
9033 FT_RECGET_ENGINE_ID(cur,rec,*fo);
9034
9035 STD_ACCUM_BUCKET2(rpt46->bucket, cur.engine_id);
9036
9037 return 0;
9038
9039 } /* ftstat_rpt_46_accum */
9040
9041 /* function: ftstat_rpt_46_calc
9042 *
9043 * Perform final calculations for rpt46
9044 *
9045 * returns allocated struct or 0L for error
9046 */
ftstat_rpt_46_calc(struct ftstat_rpt * rpt)9047 int ftstat_rpt_46_calc(struct ftstat_rpt *rpt)
9048 {
9049
9050 STD_CALC_BUCKET(ftstat_rpt_46, rpt46, 256);
9051
9052 } /* ftstat_rpt_46_calc */
9053
9054 /* function: ftstat_rpt_46_dump
9055 *
9056 * Dump data for report.
9057 *
9058 */
ftstat_rpt_46_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9059 int ftstat_rpt_46_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9060 {
9061
9062 STD_DUMP_BUCKET(ftstat_rpt_46, rpt46, 256, (char*)0L,
9063 "engine-id", "", "", "", "", "", "");
9064
9065 } /* ftstat_rpt_46_dump */
9066
9067
9068 /* function: ftstat_rpt_46_free
9069 *
9070 * Free data structures for report allocated by ftstat_rpt_46_new
9071 *
9072 */
ftstat_rpt_46_free(struct ftstat_rpt_46 * rpt46)9073 void ftstat_rpt_46_free(struct ftstat_rpt_46 *rpt46)
9074 {
9075
9076 STD_FREE_BUCKET(rpt46);
9077
9078 } /* ftstat_rpt_46_free */
9079
9080
9081 /* function: ftstat_rpt_47_new
9082 *
9083 * Allocate and initialize data structures for rpt 47.
9084 *
9085 * returns allocated struct or 0L for error
9086 */
ftstat_rpt_47_new(struct ftstat_rpt * rpt)9087 struct ftstat_rpt_47 *ftstat_rpt_47_new(struct ftstat_rpt *rpt)
9088 {
9089
9090 STD_NEW_BUCKET(ftstat_rpt_47, rpt47, 256, rpt);
9091
9092 } /* ftstat_rpt_47_new */
9093
9094
9095 /* function: ftstat_rpt_47_accum
9096 *
9097 * Accumulate counters for report by processing flow.
9098 *
9099 * returns 0: ok
9100 * !0: error
9101 */
ftstat_rpt_47_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9102 int ftstat_rpt_47_accum(struct ftstat_rpt *rpt, char *rec,
9103 struct fts3rec_offsets *fo)
9104 {
9105
9106 STD_ACCUM_BUCKET1(ftstat_rpt_47, rpt47);
9107
9108 FT_RECGET_ENGINE_TYPE(cur,rec,*fo);
9109
9110 STD_ACCUM_BUCKET2(rpt47->bucket, cur.engine_type);
9111
9112 return 0;
9113
9114 } /* ftstat_rpt_47_accum */
9115
9116 /* function: ftstat_rpt_47_calc
9117 *
9118 * Perform final calculations for rpt47
9119 *
9120 * returns allocated struct or 0L for error
9121 */
ftstat_rpt_47_calc(struct ftstat_rpt * rpt)9122 int ftstat_rpt_47_calc(struct ftstat_rpt *rpt)
9123 {
9124
9125 STD_CALC_BUCKET(ftstat_rpt_47, rpt47, 256);
9126
9127 } /* ftstat_rpt_47_calc */
9128
9129 /* function: ftstat_rpt_47_dump
9130 *
9131 * Dump data for report.
9132 *
9133 */
ftstat_rpt_47_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9134 int ftstat_rpt_47_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9135 {
9136
9137 STD_DUMP_BUCKET(ftstat_rpt_47, rpt47, 256, (char*)0L,
9138 "engine-type", "", "", "", "", "", "");
9139
9140 } /* ftstat_rpt_47_dump */
9141
9142
9143 /* function: ftstat_rpt_47_free
9144 *
9145 * Free data structures for report allocated by ftstat_rpt_47_new
9146 *
9147 */
ftstat_rpt_47_free(struct ftstat_rpt_47 * rpt47)9148 void ftstat_rpt_47_free(struct ftstat_rpt_47 *rpt47)
9149 {
9150
9151 STD_FREE_BUCKET(rpt47);
9152
9153 } /* ftstat_rpt_47_free */
9154
9155
9156 /* function: ftstat_rpt_48_new
9157 *
9158 * Allocate and initialize data structures for rpt 48.
9159 *
9160 * returns allocated struct or 0L for error
9161 */
ftstat_rpt_48_new(struct ftstat_rpt * rpt)9162 struct ftstat_rpt_48 *ftstat_rpt_48_new(struct ftstat_rpt *rpt)
9163 {
9164
9165 STD_NEW_HASH(ftstat_rpt_48, rpt48, 65536, ftchash_rec_c32, 4, 65536);
9166
9167 } /* ftstat_rpt_48_new */
9168
9169
9170 /* function: ftstat_rpt_48_accum
9171 *
9172 * Accumulate counters for report by processing flow.
9173 *
9174 * returns 0: ok
9175 * !0: error
9176 */
ftstat_rpt_48_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9177 int ftstat_rpt_48_accum(struct ftstat_rpt *rpt, char *rec,
9178 struct fts3rec_offsets *fo)
9179 {
9180
9181 STD_ACCUM_HASH1(ftstat_rpt_48, rpt48, ftchash_rec_c32,
9182 ftch_recc32, ftch_recc32p);
9183
9184 FT_RECGET_SRC_TAG(cur,rec,*fo);
9185
9186 ftch_recc32.c32 = cur.src_tag;
9187
9188 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
9189
9190 STD_ACCUM_HASH2(rpt48, ftch_recc32, ftch_recc32p);
9191
9192 return 0;
9193
9194 } /* ftstat_rpt_48_accum */
9195
9196 /* function: ftstat_rpt_48_calc
9197 *
9198 * Perform final calculations for rpt48
9199 *
9200 * returns allocated struct or 0L for error
9201 */
ftstat_rpt_48_calc(struct ftstat_rpt * rpt)9202 int ftstat_rpt_48_calc(struct ftstat_rpt *rpt)
9203 {
9204
9205 STD_CALC_HASH(ftstat_rpt_48, rpt48, ftchash_rec_c32, ftch_recc32);
9206
9207 } /* ftstat_rpt_48_calc */
9208
9209 /* function: ftstat_rpt_48_dump
9210 *
9211 * Dump data for report.
9212 *
9213 */
ftstat_rpt_48_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9214 int ftstat_rpt_48_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9215 {
9216
9217 STD_DUMP_HASH1(ftstat_rpt_48, rpt48, chash_c32_dump, FT_PATH_SYM_TAG,
9218 "source-tag", "", "", "", "", "", "");
9219
9220 } /* ftstat_rpt_48_dump */
9221
9222
9223 /* function: ftstat_rpt_48_free
9224 *
9225 * Free data structures for report allocated by ftstat_rpt_48_new
9226 *
9227 */
ftstat_rpt_48_free(struct ftstat_rpt_48 * rpt48)9228 void ftstat_rpt_48_free(struct ftstat_rpt_48 *rpt48)
9229 {
9230
9231 STD_FREE_HASH(rpt48);
9232
9233 } /* ftstat_rpt_48_free */
9234
9235
9236 /* function: ftstat_rpt_49_new
9237 *
9238 * Allocate and initialize data structures for rpt 49.
9239 *
9240 * returns allocated struct or 0L for error
9241 */
ftstat_rpt_49_new(struct ftstat_rpt * rpt)9242 struct ftstat_rpt_49 *ftstat_rpt_49_new(struct ftstat_rpt *rpt)
9243 {
9244
9245 STD_NEW_HASH(ftstat_rpt_49, rpt49, 65536, ftchash_rec_c32, 4, 65536);
9246
9247 } /* ftstat_rpt_49_new */
9248
9249
9250 /* function: ftstat_rpt_49_accum
9251 *
9252 * Accumulate counters for report by processing flow.
9253 *
9254 * returns 0: ok
9255 * !0: error
9256 */
ftstat_rpt_49_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9257 int ftstat_rpt_49_accum(struct ftstat_rpt *rpt, char *rec,
9258 struct fts3rec_offsets *fo)
9259 {
9260
9261 STD_ACCUM_HASH1(ftstat_rpt_49, rpt49, ftchash_rec_c32,
9262 ftch_recc32, ftch_recc32p);
9263
9264 FT_RECGET_DST_TAG(cur,rec,*fo);
9265
9266 ftch_recc32.c32 = cur.dst_tag;
9267
9268 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
9269
9270 STD_ACCUM_HASH2(rpt49, ftch_recc32, ftch_recc32p);
9271
9272 return 0;
9273
9274 } /* ftstat_rpt_49_accum */
9275
9276 /* function: ftstat_rpt_49_calc
9277 *
9278 * Perform final calculations for rpt49
9279 *
9280 * returns allocated struct or 0L for error
9281 */
ftstat_rpt_49_calc(struct ftstat_rpt * rpt)9282 int ftstat_rpt_49_calc(struct ftstat_rpt *rpt)
9283 {
9284
9285 STD_CALC_HASH(ftstat_rpt_49, rpt49, ftchash_rec_c32, ftch_recc32);
9286
9287 } /* ftstat_rpt_49_calc */
9288
9289 /* function: ftstat_rpt_49_dump
9290 *
9291 * Dump data for report.
9292 *
9293 */
ftstat_rpt_49_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9294 int ftstat_rpt_49_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9295 {
9296
9297 STD_DUMP_HASH1(ftstat_rpt_49, rpt49, chash_c32_dump, FT_PATH_SYM_TAG,
9298 "destination-tag", "", "", "", "", "", "");
9299
9300 } /* ftstat_rpt_49_dump */
9301
9302
9303 /* function: ftstat_rpt_49_free
9304 *
9305 * Free data structures for report allocated by ftstat_rpt_49_new
9306 *
9307 */
ftstat_rpt_49_free(struct ftstat_rpt_49 * rpt49)9308 void ftstat_rpt_49_free(struct ftstat_rpt_49 *rpt49)
9309 {
9310
9311 STD_FREE_HASH(rpt49);
9312
9313 } /* ftstat_rpt_49_free */
9314
9315
9316 /* function: ftstat_rpt_50_new
9317 *
9318 * Allocate and initialize data structures for rpt 50.
9319 *
9320 * returns allocated struct or 0L for error
9321 */
ftstat_rpt_50_new(struct ftstat_rpt * rpt)9322 struct ftstat_rpt_50 *ftstat_rpt_50_new(struct ftstat_rpt *rpt)
9323 {
9324
9325 STD_NEW_HASH(ftstat_rpt_50, rpt50, 65536, ftchash_rec_c322, 8, 65536);
9326
9327 } /* ftstat_rpt_50_new */
9328
9329
9330 /* function: ftstat_rpt_50_accum
9331 *
9332 * Accumulate counters for report by processing flow.
9333 *
9334 * returns 0: ok
9335 * !0: error
9336 */
ftstat_rpt_50_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9337 int ftstat_rpt_50_accum(struct ftstat_rpt *rpt, char *rec,
9338 struct fts3rec_offsets *fo)
9339 {
9340
9341 STD_ACCUM_HASH1(ftstat_rpt_50, rpt50, ftchash_rec_c322,
9342 ftch_recc322, ftch_recc322p);
9343
9344 FT_RECGET_DST_TAG(cur,rec,*fo);
9345 FT_RECGET_SRC_TAG(cur,rec,*fo);
9346
9347 ftch_recc322.c32a = cur.src_tag;
9348 ftch_recc322.c32b = cur.dst_tag;
9349
9350 hash = (ftch_recc322.c32a>>16) ^ (ftch_recc322.c32a & 0xFFFF) ^
9351 (ftch_recc322.c32b>>16) ^ (ftch_recc322.c32b & 0xFFFF);
9352
9353 STD_ACCUM_HASH2(rpt50, ftch_recc322, ftch_recc322p);
9354
9355 return 0;
9356
9357 } /* ftstat_rpt_50_accum */
9358
9359 /* function: ftstat_rpt_50_calc
9360 *
9361 * Perform final calculations for rpt50
9362 *
9363 * returns allocated struct or 0L for error
9364 */
ftstat_rpt_50_calc(struct ftstat_rpt * rpt)9365 int ftstat_rpt_50_calc(struct ftstat_rpt *rpt)
9366 {
9367
9368 STD_CALC_HASH(ftstat_rpt_50, rpt50, ftchash_rec_c322, ftch_recc322);
9369
9370 } /* ftstat_rpt_50_calc */
9371
9372 /* function: ftstat_rpt_50_dump
9373 *
9374 * Dump data for report.
9375 *
9376 */
ftstat_rpt_50_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9377 int ftstat_rpt_50_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9378 {
9379
9380 STD_DUMP_HASH2(ftstat_rpt_50, rpt50, chash_c322_dump,
9381 FT_PATH_SYM_TAG, FT_PATH_SYM_TAG,
9382 "", "source-tag", "destination-tag", "", "", "", "");
9383
9384 } /* ftstat_rpt_50_dump */
9385
9386
9387 /* function: ftstat_rpt_50_free
9388 *
9389 * Free data structures for report allocated by ftstat_rpt_50_new
9390 *
9391 */
ftstat_rpt_50_free(struct ftstat_rpt_50 * rpt50)9392 void ftstat_rpt_50_free(struct ftstat_rpt_50 *rpt50)
9393 {
9394
9395 STD_FREE_HASH(rpt50);
9396
9397 } /* ftstat_rpt_50_free */
9398
9399 /* function: ftstat_rpt_51_new
9400 *
9401 * Allocate and initialize data structures for rpt 51.
9402 *
9403 * returns allocated struct or 0L for error
9404 */
ftstat_rpt_51_new(struct ftstat_rpt * rpt)9405 struct ftstat_rpt_51 *ftstat_rpt_51_new(struct ftstat_rpt *rpt)
9406 {
9407
9408 STD_NEW_HASH(ftstat_rpt_51, rpt51, 65536, ftchash_rec_prefix16, 8, 65536);
9409
9410 } /* ftstat_rpt_51_new */
9411
9412 /* function: ftstat_rpt_51_accum
9413 *
9414 * Accumulate counters for report by processing flow.
9415 *
9416 * returns 0: ok
9417 * !0: error
9418 */
ftstat_rpt_51_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9419 int ftstat_rpt_51_accum(struct ftstat_rpt *rpt, char *rec,
9420 struct fts3rec_offsets *fo)
9421 {
9422
9423 STD_ACCUM_HASH1(ftstat_rpt_51, rpt51, ftchash_rec_prefix16, ftch_recprefix16,
9424 ftch_prefix16p);
9425
9426 FT_RECGET_SRCPORT(cur,rec,*fo);
9427 FT_RECGET_SRCADDR(cur,rec,*fo);
9428
9429 ftch_recprefix16.prefix = cur.srcaddr;
9430 ftch_recprefix16.c16 = cur.srcport;
9431
9432 /* only use mask if option set */
9433 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
9434 FT_RECGET_SRC_MASK(cur,rec,*fo);
9435 ftch_recprefix16.mask = cur.src_mask;
9436 }
9437
9438 /* remove host bits */
9439 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
9440 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
9441
9442 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
9443 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
9444
9445 STD_ACCUM_HASH2(rpt51, ftch_recprefix16, ftch_prefix16p);
9446
9447 return 0;
9448
9449 } /* ftstat_rpt_51_accum */
9450
9451 /* function: ftstat_rpt_51_calc
9452 *
9453 * Perform final calculations for rpt51
9454 *
9455 * returns allocated struct or 0L for error
9456 */
ftstat_rpt_51_calc(struct ftstat_rpt * rpt)9457 int ftstat_rpt_51_calc(struct ftstat_rpt *rpt)
9458 {
9459
9460 STD_CALC_HASH(ftstat_rpt_51, rpt51, ftchash_rec_prefix16, ftch_recprefix16);
9461
9462 } /* ftstat_rpt_51_calc */
9463
9464 /* function: ftstat_rpt_51_dump
9465 *
9466 * Dump data for report.
9467 *
9468 */
ftstat_rpt_51_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9469 int ftstat_rpt_51_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9470 {
9471
9472 STD_DUMP_HASH1P(ftstat_rpt_51, rpt51, chash_prefix16_dump,
9473 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
9474 FT_PATH_SYM_TCP_PORT,
9475 "", "ip-source-address", "ip-source-port", "", "", "", "");
9476
9477 } /* ftstat_rpt_51_dump */
9478
9479 /* function: ftstat_rpt_51_free
9480 *
9481 * Free data structures for report allocated by ftstat_rpt_51_new
9482 *
9483 */
ftstat_rpt_51_free(struct ftstat_rpt_51 * rpt51)9484 void ftstat_rpt_51_free(struct ftstat_rpt_51 *rpt51)
9485 {
9486
9487 STD_FREE_HASH(rpt51);
9488
9489 } /* ftstat_rpt_51_free */
9490
9491
9492 /* function: ftstat_rpt_52_new
9493 *
9494 * Allocate and initialize data structures for rpt 52.
9495 *
9496 * returns allocated struct or 0L for error
9497 */
ftstat_rpt_52_new(struct ftstat_rpt * rpt)9498 struct ftstat_rpt_52 *ftstat_rpt_52_new(struct ftstat_rpt *rpt)
9499 {
9500
9501 STD_NEW_HASH(ftstat_rpt_52, rpt52, 65536, ftchash_rec_prefix16, 8, 65536);
9502
9503 } /* ftstat_rpt_52_new */
9504
9505 /* function: ftstat_rpt_52_accum
9506 *
9507 * Accumulate counters for report by processing flow.
9508 *
9509 * returns 0: ok
9510 * !0: error
9511 */
ftstat_rpt_52_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9512 int ftstat_rpt_52_accum(struct ftstat_rpt *rpt, char *rec,
9513 struct fts3rec_offsets *fo)
9514 {
9515
9516 STD_ACCUM_HASH1(ftstat_rpt_52, rpt52, ftchash_rec_prefix16, ftch_recprefix16,
9517 ftch_prefix16p);
9518
9519 FT_RECGET_DSTPORT(cur,rec,*fo);
9520 FT_RECGET_SRCADDR(cur,rec,*fo);
9521
9522 ftch_recprefix16.prefix = cur.srcaddr;
9523 ftch_recprefix16.c16 = cur.dstport;
9524
9525 /* only use mask if option set */
9526 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
9527 FT_RECGET_SRC_MASK(cur,rec,*fo);
9528 ftch_recprefix16.mask = cur.src_mask;
9529 }
9530
9531 /* remove host bits */
9532 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
9533 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
9534
9535 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
9536 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
9537
9538 STD_ACCUM_HASH2(rpt52, ftch_recprefix16, ftch_prefix16p);
9539
9540 return 0;
9541
9542 } /* ftstat_rpt_52_accum */
9543
9544 /* function: ftstat_rpt_52_calc
9545 *
9546 * Perform final calculations for rpt52
9547 *
9548 * returns allocated struct or 0L for error
9549 */
ftstat_rpt_52_calc(struct ftstat_rpt * rpt)9550 int ftstat_rpt_52_calc(struct ftstat_rpt *rpt)
9551 {
9552
9553 STD_CALC_HASH(ftstat_rpt_52, rpt52, ftchash_rec_prefix16, ftch_recprefix16);
9554
9555 } /* ftstat_rpt_52_calc */
9556
9557 /* function: ftstat_rpt_52_dump
9558 *
9559 * Dump data for report.
9560 *
9561 */
ftstat_rpt_52_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9562 int ftstat_rpt_52_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9563 {
9564
9565 STD_DUMP_HASH1P(ftstat_rpt_51, rpt51, chash_prefix16_dump,
9566 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
9567 FT_PATH_SYM_TCP_PORT,
9568 "", "ip-source-address", "ip-destination-port", "", "", "", "");
9569
9570 } /* ftstat_rpt_52_dump */
9571
9572 /* function: ftstat_rpt_52_free
9573 *
9574 * Free data structures for report allocated by ftstat_rpt_52_new
9575 *
9576 */
ftstat_rpt_52_free(struct ftstat_rpt_52 * rpt52)9577 void ftstat_rpt_52_free(struct ftstat_rpt_52 *rpt52)
9578 {
9579
9580 STD_FREE_HASH(rpt52);
9581
9582 } /* ftstat_rpt_52_free */
9583
9584 /* function: ftstat_rpt_53_new
9585 *
9586 * Allocate and initialize data structures for rpt 53.
9587 *
9588 * returns allocated struct or 0L for error
9589 */
ftstat_rpt_53_new(struct ftstat_rpt * rpt)9590 struct ftstat_rpt_53 *ftstat_rpt_53_new(struct ftstat_rpt *rpt)
9591 {
9592
9593 STD_NEW_HASH(ftstat_rpt_53, rpt53, 65536, ftchash_rec_prefix16, 8, 65536);
9594
9595 } /* ftstat_rpt_53_new */
9596
9597 /* function: ftstat_rpt_53_accum
9598 *
9599 * Accumulate counters for report by processing flow.
9600 *
9601 * returns 0: ok
9602 * !0: error
9603 */
ftstat_rpt_53_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9604 int ftstat_rpt_53_accum(struct ftstat_rpt *rpt, char *rec,
9605 struct fts3rec_offsets *fo)
9606 {
9607
9608 STD_ACCUM_HASH1(ftstat_rpt_53, rpt53, ftchash_rec_prefix16, ftch_recprefix16,
9609 ftch_prefix16p);
9610
9611 FT_RECGET_SRCPORT(cur,rec,*fo);
9612 FT_RECGET_DSTADDR(cur,rec,*fo);
9613
9614 ftch_recprefix16.prefix = cur.dstaddr;
9615 ftch_recprefix16.c16 = cur.srcport;
9616
9617 /* only use mask if option set */
9618 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
9619 FT_RECGET_DST_MASK(cur,rec,*fo);
9620 ftch_recprefix16.mask = cur.dst_mask;
9621 }
9622
9623 /* remove host bits */
9624 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
9625 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
9626
9627 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
9628 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
9629
9630 STD_ACCUM_HASH2(rpt53, ftch_recprefix16, ftch_prefix16p);
9631
9632 return 0;
9633
9634 } /* ftstat_rpt_53_accum */
9635
9636 /* function: ftstat_rpt_53_calc
9637 *
9638 * Perform final calculations for rpt53
9639 *
9640 * returns allocated struct or 0L for error
9641 */
ftstat_rpt_53_calc(struct ftstat_rpt * rpt)9642 int ftstat_rpt_53_calc(struct ftstat_rpt *rpt)
9643 {
9644
9645 STD_CALC_HASH(ftstat_rpt_53, rpt53, ftchash_rec_prefix16, ftch_recprefix16);
9646
9647 } /* ftstat_rpt_53_calc */
9648
9649 /* function: ftstat_rpt_53_dump
9650 *
9651 * Dump data for report.
9652 *
9653 */
ftstat_rpt_53_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9654 int ftstat_rpt_53_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9655 {
9656
9657 STD_DUMP_HASH1P(ftstat_rpt_53, rpt53, chash_prefix16_dump,
9658 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
9659 FT_PATH_SYM_TCP_PORT,
9660 "", "ip-destination-address", "ip-source-port", "", "", "", "");
9661
9662 } /* ftstat_rpt_53_dump */
9663
9664 /* function: ftstat_rpt_53_free
9665 *
9666 * Free data structures for report allocated by ftstat_rpt_53_new
9667 *
9668 */
ftstat_rpt_53_free(struct ftstat_rpt_53 * rpt53)9669 void ftstat_rpt_53_free(struct ftstat_rpt_53 *rpt53)
9670 {
9671
9672 STD_FREE_HASH(rpt53);
9673
9674 } /* ftstat_rpt_53_free */
9675
9676
9677 /* function: ftstat_rpt_54_new
9678 *
9679 * Allocate and initialize data structures for rpt 52.
9680 *
9681 * returns allocated struct or 0L for error
9682 */
ftstat_rpt_54_new(struct ftstat_rpt * rpt)9683 struct ftstat_rpt_54 *ftstat_rpt_54_new(struct ftstat_rpt *rpt)
9684 {
9685
9686 STD_NEW_HASH(ftstat_rpt_54, rpt54, 65536, ftchash_rec_prefix16, 8, 65536);
9687
9688 } /* ftstat_rpt_54_new */
9689
9690 /* function: ftstat_rpt_54_accum
9691 *
9692 * Accumulate counters for report by processing flow.
9693 *
9694 * returns 0: ok
9695 * !0: error
9696 */
ftstat_rpt_54_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9697 int ftstat_rpt_54_accum(struct ftstat_rpt *rpt, char *rec,
9698 struct fts3rec_offsets *fo)
9699 {
9700
9701 STD_ACCUM_HASH1(ftstat_rpt_54, rpt54, ftchash_rec_prefix16, ftch_recprefix16,
9702 ftch_prefix16p);
9703
9704 FT_RECGET_DSTPORT(cur,rec,*fo);
9705 FT_RECGET_DSTADDR(cur,rec,*fo);
9706
9707 ftch_recprefix16.prefix = cur.dstaddr;
9708 ftch_recprefix16.c16 = cur.dstport;
9709
9710 /* only use mask if option set */
9711 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
9712 FT_RECGET_DST_MASK(cur,rec,*fo);
9713 ftch_recprefix16.mask = cur.dst_mask;
9714 }
9715
9716 /* remove host bits */
9717 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
9718 ftch_recprefix16.prefix &= ipv4_len2mask(ftch_recprefix16.mask);
9719
9720 hash = (ftch_recprefix16.prefix>>16) ^ (ftch_recprefix16.prefix & 0xFFFF) ^
9721 (ftch_recprefix16.mask) ^ (ftch_recprefix16.c16);
9722
9723 STD_ACCUM_HASH2(rpt54, ftch_recprefix16, ftch_prefix16p);
9724
9725 return 0;
9726
9727 } /* ftstat_rpt_54_accum */
9728
9729 /* function: ftstat_rpt_54_calc
9730 *
9731 * Perform final calculations for rpt54
9732 *
9733 * returns allocated struct or 0L for error
9734 */
ftstat_rpt_54_calc(struct ftstat_rpt * rpt)9735 int ftstat_rpt_54_calc(struct ftstat_rpt *rpt)
9736 {
9737
9738 STD_CALC_HASH(ftstat_rpt_54, rpt54, ftchash_rec_prefix16, ftch_recprefix16);
9739
9740 } /* ftstat_rpt_54_calc */
9741
9742 /* function: ftstat_rpt_54_dump
9743 *
9744 * Dump data for report.
9745 *
9746 */
ftstat_rpt_54_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9747 int ftstat_rpt_54_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9748 {
9749
9750 STD_DUMP_HASH1P(ftstat_rpt_54, rpt54, chash_prefix16_dump,
9751 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
9752 FT_PATH_SYM_TCP_PORT,
9753 "", "ip-destination-address", "ip-destination-port", "", "", "", "");
9754
9755 } /* ftstat_rpt_54_dump */
9756
9757 /* function: ftstat_rpt_54_free
9758 *
9759 * Free data structures for report allocated by ftstat_rpt_54_new
9760 *
9761 */
ftstat_rpt_54_free(struct ftstat_rpt_54 * rpt54)9762 void ftstat_rpt_54_free(struct ftstat_rpt_54 *rpt54)
9763 {
9764
9765 STD_FREE_HASH(rpt54);
9766
9767 } /* ftstat_rpt_54_free */
9768
9769
9770 /* function: ftstat_rpt_55_new
9771 *
9772 * Allocate and initialize data structures for rpt 52.
9773 *
9774 * returns allocated struct or 0L for error
9775 */
ftstat_rpt_55_new(struct ftstat_rpt * rpt)9776 struct ftstat_rpt_55 *ftstat_rpt_55_new(struct ftstat_rpt *rpt)
9777 {
9778
9779 STD_NEW_HASH(ftstat_rpt_55, rpt55, 65536, ftchash_rec_prefix162, 10, 65536);
9780
9781 } /* ftstat_rpt_55_new */
9782
9783 /* function: ftstat_rpt_55_accum
9784 *
9785 * Accumulate counters for report by processing flow.
9786 *
9787 * returns 0: ok
9788 * !0: error
9789 */
ftstat_rpt_55_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9790 int ftstat_rpt_55_accum(struct ftstat_rpt *rpt, char *rec,
9791 struct fts3rec_offsets *fo)
9792 {
9793
9794 STD_ACCUM_HASH1(ftstat_rpt_55, rpt55, ftchash_rec_prefix162,
9795 ftch_recprefix162, ftch_prefix162p);
9796
9797 FT_RECGET_SRCPORT(cur,rec,*fo);
9798 FT_RECGET_DSTPORT(cur,rec,*fo);
9799 FT_RECGET_SRCADDR(cur,rec,*fo);
9800
9801 ftch_recprefix162.prefix = cur.srcaddr;
9802 ftch_recprefix162.c16a = cur.srcport;
9803 ftch_recprefix162.c16b = cur.dstport;
9804
9805 /* only use mask if option set */
9806 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
9807 FT_RECGET_SRC_MASK(cur,rec,*fo);
9808 ftch_recprefix162.mask = cur.src_mask;
9809 }
9810
9811 /* remove host bits */
9812 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
9813 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
9814
9815 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
9816 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
9817 (ftch_recprefix162.c16b);
9818
9819 STD_ACCUM_HASH2(rpt55, ftch_recprefix162, ftch_prefix162p);
9820
9821 return 0;
9822
9823 } /* ftstat_rpt_55_accum */
9824
9825 /* function: ftstat_rpt_55_calc
9826 *
9827 * Perform final calculations for rpt55
9828 *
9829 * returns allocated struct or 0L for error
9830 */
ftstat_rpt_55_calc(struct ftstat_rpt * rpt)9831 int ftstat_rpt_55_calc(struct ftstat_rpt *rpt)
9832 {
9833
9834 STD_CALC_HASH(ftstat_rpt_55, rpt55, ftchash_rec_prefix162,
9835 ftch_recprefix162);
9836
9837 } /* ftstat_rpt_55_calc */
9838
9839 /* function: ftstat_rpt_55_dump
9840 *
9841 * Dump data for report.
9842 *
9843 */
ftstat_rpt_55_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9844 int ftstat_rpt_55_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9845 {
9846
9847 STD_DUMP_HASH2P(ftstat_rpt_55, rpt55, chash_prefix162_dump,
9848 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
9849 FT_PATH_SYM_TCP_PORT, FT_PATH_SYM_TCP_PORT,
9850 "", "ip-source-address", "ip-source-port", "ip-destination-port", "", "",
9851 "");
9852
9853 } /* ftstat_rpt_55_dump */
9854
9855 /* function: ftstat_rpt_55_free
9856 *
9857 * Free data structures for report allocated by ftstat_rpt_55_new
9858 *
9859 */
ftstat_rpt_55_free(struct ftstat_rpt_55 * rpt55)9860 void ftstat_rpt_55_free(struct ftstat_rpt_55 *rpt55)
9861 {
9862
9863 STD_FREE_HASH(rpt55);
9864
9865 } /* ftstat_rpt_55_free */
9866
9867
9868 /* function: ftstat_rpt_56_new
9869 *
9870 * Allocate and initialize data structures for rpt 52.
9871 *
9872 * returns allocated struct or 0L for error
9873 */
ftstat_rpt_56_new(struct ftstat_rpt * rpt)9874 struct ftstat_rpt_56 *ftstat_rpt_56_new(struct ftstat_rpt *rpt)
9875 {
9876
9877 STD_NEW_HASH(ftstat_rpt_56, rpt56, 65536, ftchash_rec_prefix162, 10, 65536);
9878
9879 } /* ftstat_rpt_56_new */
9880
9881 /* function: ftstat_rpt_56_accum
9882 *
9883 * Accumulate counters for report by processing flow.
9884 *
9885 * returns 0: ok
9886 * !0: error
9887 */
ftstat_rpt_56_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9888 int ftstat_rpt_56_accum(struct ftstat_rpt *rpt, char *rec,
9889 struct fts3rec_offsets *fo)
9890 {
9891
9892 STD_ACCUM_HASH1(ftstat_rpt_56, rpt56, ftchash_rec_prefix162,
9893 ftch_recprefix162, ftch_prefix162p);
9894
9895 FT_RECGET_SRCPORT(cur,rec,*fo);
9896 FT_RECGET_DSTPORT(cur,rec,*fo);
9897 FT_RECGET_DSTADDR(cur,rec,*fo);
9898
9899 ftch_recprefix162.prefix = cur.dstaddr;
9900 ftch_recprefix162.c16a = cur.srcport;
9901 ftch_recprefix162.c16b = cur.dstport;
9902
9903 /* only use mask if option set */
9904 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
9905 FT_RECGET_DST_MASK(cur,rec,*fo);
9906 ftch_recprefix162.mask = cur.dst_mask;
9907 }
9908
9909 /* remove host bits */
9910 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
9911 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
9912
9913 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
9914 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
9915 (ftch_recprefix162.c16b);
9916
9917 STD_ACCUM_HASH2(rpt56, ftch_recprefix162, ftch_prefix162p);
9918
9919 return 0;
9920
9921 } /* ftstat_rpt_56_accum */
9922
9923 /* function: ftstat_rpt_56_calc
9924 *
9925 * Perform final calculations for rpt56
9926 *
9927 * returns allocated struct or 0L for error
9928 */
ftstat_rpt_56_calc(struct ftstat_rpt * rpt)9929 int ftstat_rpt_56_calc(struct ftstat_rpt *rpt)
9930 {
9931
9932 STD_CALC_HASH(ftstat_rpt_56, rpt56, ftchash_rec_prefix162,
9933 ftch_recprefix162);
9934
9935 } /* ftstat_rpt_56_calc */
9936
9937 /* function: ftstat_rpt_56_dump
9938 *
9939 * Dump data for report.
9940 *
9941 */
ftstat_rpt_56_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)9942 int ftstat_rpt_56_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
9943 {
9944
9945 STD_DUMP_HASH2P(ftstat_rpt_56, rpt56, chash_prefix162_dump,
9946 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
9947 FT_PATH_SYM_TCP_PORT, FT_PATH_SYM_TCP_PORT,
9948 "", "ip-destination-address", "ip-source-port", "ip-destination-port", "",
9949 "", "");
9950
9951 } /* ftstat_rpt_56_dump */
9952
9953 /* function: ftstat_rpt_56_free
9954 *
9955 * Free data structures for report allocated by ftstat_rpt_56_new
9956 *
9957 */
ftstat_rpt_56_free(struct ftstat_rpt_56 * rpt56)9958 void ftstat_rpt_56_free(struct ftstat_rpt_56 *rpt56)
9959 {
9960
9961 STD_FREE_HASH(rpt56);
9962
9963 } /* ftstat_rpt_56_free */
9964
9965
9966 /* function: ftstat_rpt_57_new
9967 *
9968 * Allocate and initialize data structures for rpt 52.
9969 *
9970 * returns allocated struct or 0L for error
9971 */
ftstat_rpt_57_new(struct ftstat_rpt * rpt)9972 struct ftstat_rpt_57 *ftstat_rpt_57_new(struct ftstat_rpt *rpt)
9973 {
9974
9975 STD_NEW_HASH(ftstat_rpt_57, rpt57, 65536, ftchash_rec_prefix216, 13, 65536);
9976
9977 } /* ftstat_rpt_57_new */
9978
9979 /* function: ftstat_rpt_57_accum
9980 *
9981 * Accumulate counters for report by processing flow.
9982 *
9983 * returns 0: ok
9984 * !0: error
9985 */
ftstat_rpt_57_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)9986 int ftstat_rpt_57_accum(struct ftstat_rpt *rpt, char *rec,
9987 struct fts3rec_offsets *fo)
9988 {
9989
9990 STD_ACCUM_HASH1(ftstat_rpt_57, rpt57, ftchash_rec_prefix216,
9991 ftch_recprefix216, ftch_recprefix216p);
9992
9993 FT_RECGET_SRCPORT(cur,rec,*fo);
9994 FT_RECGET_SRCADDR(cur,rec,*fo);
9995 FT_RECGET_DSTADDR(cur,rec,*fo);
9996
9997 ftch_recprefix216.src_prefix = cur.srcaddr;
9998 ftch_recprefix216.dst_prefix = cur.dstaddr;
9999 ftch_recprefix216.c16 = cur.srcport;
10000
10001 /* only use mask if option set */
10002 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10003 FT_RECGET_SRC_MASK(cur,rec,*fo);
10004 ftch_recprefix216.src_mask = cur.src_mask;
10005 }
10006
10007 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10008 FT_RECGET_DST_MASK(cur,rec,*fo);
10009 ftch_recprefix216.dst_mask = cur.dst_mask;
10010 }
10011
10012 /* remove host bits */
10013 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
10014 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
10015 }
10016
10017 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
10018 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
10019 }
10020
10021 hash = (ftch_recprefix216.src_prefix>>16)^
10022 (ftch_recprefix216.src_prefix & 0xFFFF)^
10023 (ftch_recprefix216.dst_prefix>>16)^
10024 (ftch_recprefix216.dst_prefix & 0xFFFF)^
10025 (ftch_recprefix216.c16)^
10026 (ftch_recprefix216.src_mask)^
10027 (uint32_t)(ftch_recprefix216.dst_mask<<8);
10028
10029 STD_ACCUM_HASH2(rpt57, ftch_recprefix216, ftch_recprefix216p);
10030
10031 return 0;
10032
10033 } /* ftstat_rpt_57_accum */
10034
10035 /* function: ftstat_rpt_57_calc
10036 *
10037 * Perform final calculations for rpt57
10038 *
10039 * returns allocated struct or 0L for error
10040 */
ftstat_rpt_57_calc(struct ftstat_rpt * rpt)10041 int ftstat_rpt_57_calc(struct ftstat_rpt *rpt)
10042 {
10043
10044 STD_CALC_HASH(ftstat_rpt_57, rpt57, ftchash_rec_prefix216,
10045 ftch_recprefix216);
10046
10047 } /* ftstat_rpt_57_calc */
10048
10049 /* function: ftstat_rpt_57_dump
10050 *
10051 * Dump data for report.
10052 *
10053 */
ftstat_rpt_57_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10054 int ftstat_rpt_57_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10055 {
10056
10057 STD_DUMP_HASH1(ftstat_rpt_57, rpt57, chash_prefix216_dump,
10058 FT_PATH_SYM_TCP_PORT,
10059 "", "ip-source-address", "ip-destination-address", "ip-source-port", "",
10060 "", "");
10061
10062 } /* ftstat_rpt_57_dump */
10063
10064 /* function: ftstat_rpt_57_free
10065 *
10066 * Free data structures for report allocated by ftstat_rpt_57_new
10067 *
10068 */
ftstat_rpt_57_free(struct ftstat_rpt_57 * rpt57)10069 void ftstat_rpt_57_free(struct ftstat_rpt_57 *rpt57)
10070 {
10071
10072 STD_FREE_HASH(rpt57);
10073
10074 } /* ftstat_rpt_57_free */
10075
10076 /* function: ftstat_rpt_58_new
10077 *
10078 * Allocate and initialize data structures for rpt 58.
10079 *
10080 * returns allocated struct or 0L for error
10081 */
ftstat_rpt_58_new(struct ftstat_rpt * rpt)10082 struct ftstat_rpt_58 *ftstat_rpt_58_new(struct ftstat_rpt *rpt)
10083 {
10084
10085 STD_NEW_HASH(ftstat_rpt_58, rpt58, 65536, ftchash_rec_prefix216, 13, 65536);
10086
10087 } /* ftstat_rpt_58_new */
10088
10089 /* function: ftstat_rpt_58_accum
10090 *
10091 * Accumulate counters for report by processing flow.
10092 *
10093 * returns 0: ok
10094 * !0: error
10095 */
ftstat_rpt_58_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10096 int ftstat_rpt_58_accum(struct ftstat_rpt *rpt, char *rec,
10097 struct fts3rec_offsets *fo)
10098 {
10099
10100 STD_ACCUM_HASH1(ftstat_rpt_58, rpt58, ftchash_rec_prefix216,
10101 ftch_recprefix216, ftch_recprefix216p);
10102
10103 FT_RECGET_DSTPORT(cur,rec,*fo);
10104 FT_RECGET_SRCADDR(cur,rec,*fo);
10105 FT_RECGET_DSTADDR(cur,rec,*fo);
10106
10107 ftch_recprefix216.src_prefix = cur.srcaddr;
10108 ftch_recprefix216.dst_prefix = cur.dstaddr;
10109 ftch_recprefix216.c16 = cur.dstport;
10110
10111 /* only use mask if option set */
10112 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10113 FT_RECGET_SRC_MASK(cur,rec,*fo);
10114 ftch_recprefix216.src_mask = cur.src_mask;
10115 }
10116
10117 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10118 FT_RECGET_DST_MASK(cur,rec,*fo);
10119 ftch_recprefix216.dst_mask = cur.dst_mask;
10120 }
10121
10122 /* remove host bits */
10123 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
10124 ftch_recprefix216.src_prefix &= ipv4_len2mask(ftch_recprefix216.src_mask);
10125 }
10126
10127 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
10128 ftch_recprefix216.dst_prefix &= ipv4_len2mask(ftch_recprefix216.dst_mask);
10129 }
10130
10131 hash = (ftch_recprefix216.src_prefix>>16)^
10132 (ftch_recprefix216.src_prefix & 0xFFFF)^
10133 (ftch_recprefix216.dst_prefix>>16)^
10134 (ftch_recprefix216.dst_prefix & 0xFFFF)^
10135 (ftch_recprefix216.c16)^
10136 (ftch_recprefix216.src_mask)^
10137 (uint32_t)(ftch_recprefix216.dst_mask<<8);
10138
10139 STD_ACCUM_HASH2(rpt58, ftch_recprefix216, ftch_recprefix216p);
10140
10141 return 0;
10142
10143 } /* ftstat_rpt_58_accum */
10144
10145 /* function: ftstat_rpt_58_calc
10146 *
10147 * Perform final calculations for rpt58
10148 *
10149 * returns allocated struct or 0L for error
10150 */
ftstat_rpt_58_calc(struct ftstat_rpt * rpt)10151 int ftstat_rpt_58_calc(struct ftstat_rpt *rpt)
10152 {
10153
10154 STD_CALC_HASH(ftstat_rpt_58, rpt58, ftchash_rec_prefix216,
10155 ftch_recprefix216);
10156
10157 } /* ftstat_rpt_58_calc */
10158
10159 /* function: ftstat_rpt_58_dump
10160 *
10161 * Dump data for report.
10162 *
10163 */
ftstat_rpt_58_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10164 int ftstat_rpt_58_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10165 {
10166
10167 STD_DUMP_HASH1(ftstat_rpt_58, rpt58, chash_prefix216_dump,
10168 FT_PATH_SYM_TCP_PORT,
10169 "", "ip-source-address", "ip-destination-address", "ip-destination-port",
10170 "", "", "");
10171
10172 } /* ftstat_rpt_58_dump */
10173
10174 /* function: ftstat_rpt_58_free
10175 *
10176 * Free data structures for report allocated by ftstat_rpt_58_new
10177 *
10178 */
ftstat_rpt_58_free(struct ftstat_rpt_58 * rpt58)10179 void ftstat_rpt_58_free(struct ftstat_rpt_58 *rpt58)
10180 {
10181
10182 STD_FREE_HASH(rpt58);
10183
10184 } /* ftstat_rpt_58_free */
10185
10186
10187
10188 /* function: ftstat_rpt_59_new
10189 *
10190 * Allocate and initialize data structures for rpt 52.
10191 *
10192 * returns allocated struct or 0L for error
10193 */
ftstat_rpt_59_new(struct ftstat_rpt * rpt)10194 struct ftstat_rpt_59 *ftstat_rpt_59_new(struct ftstat_rpt *rpt)
10195 {
10196
10197 STD_NEW_HASH(ftstat_rpt_59, rpt59, 65536, ftchash_rec_prefix2162, 16, 65536);
10198
10199 } /* ftstat_rpt_59_new */
10200
10201 /* function: ftstat_rpt_59_accum
10202 *
10203 * Accumulate counters for report by processing flow.
10204 *
10205 * returns 0: ok
10206 * !0: error
10207 */
ftstat_rpt_59_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10208 int ftstat_rpt_59_accum(struct ftstat_rpt *rpt, char *rec,
10209 struct fts3rec_offsets *fo)
10210 {
10211
10212 STD_ACCUM_HASH1(ftstat_rpt_59, rpt59, ftchash_rec_prefix2162,
10213 ftch_recprefix2162, ftch_recprefix2162p);
10214
10215 FT_RECGET_SRCPORT(cur,rec,*fo);
10216 FT_RECGET_DSTPORT(cur,rec,*fo);
10217 FT_RECGET_SRCADDR(cur,rec,*fo);
10218 FT_RECGET_DSTADDR(cur,rec,*fo);
10219
10220 ftch_recprefix2162.src_prefix = cur.srcaddr;
10221 ftch_recprefix2162.dst_prefix = cur.dstaddr;
10222 ftch_recprefix2162.c16a = cur.srcport;
10223 ftch_recprefix2162.c16b = cur.dstport;
10224
10225 /* only use mask if option set */
10226 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10227 FT_RECGET_SRC_MASK(cur,rec,*fo);
10228 ftch_recprefix2162.src_mask = cur.src_mask;
10229 }
10230
10231 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10232 FT_RECGET_DST_MASK(cur,rec,*fo);
10233 ftch_recprefix2162.dst_mask = cur.dst_mask;
10234 }
10235
10236 /* remove host bits */
10237 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
10238 ftch_recprefix2162.src_prefix &= ipv4_len2mask(ftch_recprefix2162.src_mask);
10239 }
10240
10241 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
10242 ftch_recprefix2162.dst_prefix &= ipv4_len2mask(ftch_recprefix2162.dst_mask);
10243 }
10244
10245 hash = (ftch_recprefix2162.src_prefix>>16)^
10246 (ftch_recprefix2162.src_prefix & 0xFFFF)^
10247 (ftch_recprefix2162.dst_prefix>>16)^
10248 (ftch_recprefix2162.dst_prefix & 0xFFFF)^
10249 (ftch_recprefix2162.c16b)^
10250 (ftch_recprefix2162.c16a)^
10251 (ftch_recprefix2162.src_mask)^
10252 (uint32_t)(ftch_recprefix2162.dst_mask<<8);
10253
10254 STD_ACCUM_HASH2(rpt59, ftch_recprefix2162, ftch_recprefix2162p);
10255
10256 return 0;
10257
10258 } /* ftstat_rpt_59_accum */
10259
10260 /* function: ftstat_rpt_59_calc
10261 *
10262 * Perform final calculations for rpt59
10263 *
10264 * returns allocated struct or 0L for error
10265 */
ftstat_rpt_59_calc(struct ftstat_rpt * rpt)10266 int ftstat_rpt_59_calc(struct ftstat_rpt *rpt)
10267 {
10268
10269 STD_CALC_HASH(ftstat_rpt_59, rpt59, ftchash_rec_prefix2162,
10270 ftch_recprefix2162);
10271
10272 } /* ftstat_rpt_59_calc */
10273
10274 /* function: ftstat_rpt_59_dump
10275 *
10276 * Dump data for report.
10277 *
10278 */
ftstat_rpt_59_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10279 int ftstat_rpt_59_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10280 {
10281
10282 STD_DUMP_HASH2(ftstat_rpt_31, rpt31, chash_prefix2162_dump,
10283 FT_PATH_SYM_TCP_PORT, FT_PATH_SYM_TCP_PORT,
10284 "", "ip-source-address", "ip-destination-address", "ip-source-port",
10285 "ip-destination-port", "", "");
10286
10287 } /* ftstat_rpt_59_dump */
10288
10289 /* function: ftstat_rpt_59_free
10290 *
10291 * Free data structures for report allocated by ftstat_rpt_59_new
10292 *
10293 */
ftstat_rpt_59_free(struct ftstat_rpt_59 * rpt59)10294 void ftstat_rpt_59_free(struct ftstat_rpt_59 *rpt59)
10295 {
10296
10297 STD_FREE_HASH(rpt59);
10298
10299 } /* ftstat_rpt_59_free */
10300
10301
10302 /* function: ftstat_rpt_60_new
10303 *
10304 * Allocate and initialize data structures for rpt 52.
10305 *
10306 * returns allocated struct or 0L for error
10307 */
ftstat_rpt_60_new(struct ftstat_rpt * rpt)10308 struct ftstat_rpt_60 *ftstat_rpt_60_new(struct ftstat_rpt *rpt)
10309 {
10310
10311 STD_NEW_HASH(ftstat_rpt_60, rpt60, 65536, ftchash_rec_prefix162, 10, 65536);
10312
10313 } /* ftstat_rpt_60_new */
10314
10315 /* function: ftstat_rpt_60_accum
10316 *
10317 * Accumulate counters for report by processing flow.
10318 *
10319 * returns 0: ok
10320 * !0: error
10321 */
ftstat_rpt_60_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10322 int ftstat_rpt_60_accum(struct ftstat_rpt *rpt, char *rec,
10323 struct fts3rec_offsets *fo)
10324 {
10325
10326 STD_ACCUM_HASH1(ftstat_rpt_60, rpt60, ftchash_rec_prefix162,
10327 ftch_recprefix162, ftch_prefix162p);
10328
10329 FT_RECGET_INPUT(cur,rec,*fo);
10330 FT_RECGET_OUTPUT(cur,rec,*fo);
10331 FT_RECGET_SRCADDR(cur,rec,*fo);
10332
10333 ftch_recprefix162.prefix = cur.srcaddr;
10334 ftch_recprefix162.c16a = cur.input;
10335 ftch_recprefix162.c16b = cur.output;
10336
10337 /* only use mask if option set */
10338 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10339 FT_RECGET_SRC_MASK(cur,rec,*fo);
10340 ftch_recprefix162.mask = cur.src_mask;
10341 }
10342
10343 /* remove host bits */
10344 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
10345 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
10346
10347 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
10348 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
10349 (ftch_recprefix162.c16b);
10350
10351 STD_ACCUM_HASH2(rpt60, ftch_recprefix162, ftch_prefix162p);
10352
10353 return 0;
10354
10355 } /* ftstat_rpt_60_accum */
10356
10357 /* function: ftstat_rpt_60_calc
10358 *
10359 * Perform final calculations for rpt60
10360 *
10361 * returns allocated struct or 0L for error
10362 */
ftstat_rpt_60_calc(struct ftstat_rpt * rpt)10363 int ftstat_rpt_60_calc(struct ftstat_rpt *rpt)
10364 {
10365
10366 STD_CALC_HASH(ftstat_rpt_60, rpt60, ftchash_rec_prefix162,
10367 ftch_recprefix162);
10368
10369 } /* ftstat_rpt_60_calc */
10370
10371 /* function: ftstat_rpt_60_dump
10372 *
10373 * Dump data for report.
10374 *
10375 */
ftstat_rpt_60_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10376 int ftstat_rpt_60_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10377 {
10378
10379 STD_DUMP_HASH2P(ftstat_rpt_60, rpt60, chash_prefix162_dump,
10380 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
10381 (char*)0L, (char*)0L,
10382 "", "ip-source-address", "input-interface", "output-interface", "", "",
10383 "");
10384
10385 } /* ftstat_rpt_60_dump */
10386
10387 /* function: ftstat_rpt_60_free
10388 *
10389 * Free data structures for report allocated by ftstat_rpt_60_new
10390 *
10391 */
ftstat_rpt_60_free(struct ftstat_rpt_60 * rpt60)10392 void ftstat_rpt_60_free(struct ftstat_rpt_60 *rpt60)
10393 {
10394
10395 STD_FREE_HASH(rpt60);
10396
10397 } /* ftstat_rpt_60_free */
10398
10399
10400 /* function: ftstat_rpt_61_new
10401 *
10402 * Allocate and initialize data structures for rpt 52.
10403 *
10404 * returns allocated struct or 0L for error
10405 */
ftstat_rpt_61_new(struct ftstat_rpt * rpt)10406 struct ftstat_rpt_61 *ftstat_rpt_61_new(struct ftstat_rpt *rpt)
10407 {
10408
10409 STD_NEW_HASH(ftstat_rpt_61, rpt61, 65536, ftchash_rec_prefix162, 10, 65536);
10410
10411 } /* ftstat_rpt_61_new */
10412
10413 /* function: ftstat_rpt_61_accum
10414 *
10415 * Accumulate counters for report by processing flow.
10416 *
10417 * returns 0: ok
10418 * !0: error
10419 */
ftstat_rpt_61_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10420 int ftstat_rpt_61_accum(struct ftstat_rpt *rpt, char *rec,
10421 struct fts3rec_offsets *fo)
10422 {
10423
10424 STD_ACCUM_HASH1(ftstat_rpt_61, rpt61, ftchash_rec_prefix162,
10425 ftch_recprefix162, ftch_prefix162p);
10426
10427 FT_RECGET_INPUT(cur,rec,*fo);
10428 FT_RECGET_OUTPUT(cur,rec,*fo);
10429 FT_RECGET_DSTADDR(cur,rec,*fo);
10430
10431 ftch_recprefix162.prefix = cur.dstaddr;
10432 ftch_recprefix162.c16a = cur.input;
10433 ftch_recprefix162.c16b = cur.output;
10434
10435 /* only use mask if option set */
10436 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10437 FT_RECGET_DST_MASK(cur,rec,*fo);
10438 ftch_recprefix162.mask = cur.dst_mask;
10439 }
10440
10441 /* remove host bits */
10442 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
10443 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
10444
10445 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
10446 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
10447 (ftch_recprefix162.c16b);
10448
10449 STD_ACCUM_HASH2(rpt61, ftch_recprefix162, ftch_prefix162p);
10450
10451 return 0;
10452
10453 } /* ftstat_rpt_61_accum */
10454
10455 /* function: ftstat_rpt_61_calc
10456 *
10457 * Perform final calculations for rpt61
10458 *
10459 * returns allocated struct or 0L for error
10460 */
ftstat_rpt_61_calc(struct ftstat_rpt * rpt)10461 int ftstat_rpt_61_calc(struct ftstat_rpt *rpt)
10462 {
10463
10464 STD_CALC_HASH(ftstat_rpt_61, rpt61, ftchash_rec_prefix162,
10465 ftch_recprefix162);
10466
10467 } /* ftstat_rpt_61_calc */
10468
10469 /* function: ftstat_rpt_61_dump
10470 *
10471 * Dump data for report.
10472 *
10473 */
ftstat_rpt_61_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10474 int ftstat_rpt_61_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10475 {
10476
10477 STD_DUMP_HASH2P(ftstat_rpt_61, rpt61, chash_prefix162_dump,
10478 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
10479 (char*)0L, (char*)0L,
10480 "", "ip-destination-address", "input-interface", "output-interface", "",
10481 "", "");
10482
10483 } /* ftstat_rpt_61_dump */
10484
10485 /* function: ftstat_rpt_61_free
10486 *
10487 * Free data structures for report allocated by ftstat_rpt_61_new
10488 *
10489 */
ftstat_rpt_61_free(struct ftstat_rpt_61 * rpt61)10490 void ftstat_rpt_61_free(struct ftstat_rpt_61 *rpt61)
10491 {
10492
10493 STD_FREE_HASH(rpt61);
10494
10495 } /* ftstat_rpt_61_free */
10496
10497
10498 /* function: ftstat_rpt_62_new
10499 *
10500 * Allocate and initialize data structures for rpt 52.
10501 *
10502 * returns allocated struct or 0L for error
10503 */
ftstat_rpt_62_new(struct ftstat_rpt * rpt)10504 struct ftstat_rpt_62 *ftstat_rpt_62_new(struct ftstat_rpt *rpt)
10505 {
10506
10507 STD_NEW_HASH(ftstat_rpt_62, rpt62, 65536, ftchash_rec_prefix162, 10, 65536);
10508
10509 } /* ftstat_rpt_62_new */
10510
10511 /* function: ftstat_rpt_62_accum
10512 *
10513 * Accumulate counters for report by processing flow.
10514 *
10515 * returns 0: ok
10516 * !0: error
10517 */
ftstat_rpt_62_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10518 int ftstat_rpt_62_accum(struct ftstat_rpt *rpt, char *rec,
10519 struct fts3rec_offsets *fo)
10520 {
10521
10522 STD_ACCUM_HASH1(ftstat_rpt_62, rpt62, ftchash_rec_prefix162,
10523 ftch_recprefix162, ftch_prefix162p);
10524
10525 FT_RECGET_SRC_AS(cur,rec,*fo);
10526 FT_RECGET_DST_AS(cur,rec,*fo);
10527 FT_RECGET_SRCADDR(cur,rec,*fo);
10528
10529 ftch_recprefix162.prefix = cur.srcaddr;
10530 ftch_recprefix162.c16a = cur.src_as;
10531 ftch_recprefix162.c16b = cur.dst_as;
10532
10533 /* only use mask if option set */
10534 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10535 FT_RECGET_SRC_MASK(cur,rec,*fo);
10536 ftch_recprefix162.mask = cur.src_mask;
10537 }
10538
10539 /* remove host bits */
10540 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
10541 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
10542
10543 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
10544 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
10545 (ftch_recprefix162.c16b);
10546
10547 STD_ACCUM_HASH2(rpt62, ftch_recprefix162, ftch_prefix162p);
10548
10549 return 0;
10550
10551 } /* ftstat_rpt_62_accum */
10552
10553 /* function: ftstat_rpt_62_calc
10554 *
10555 * Perform final calculations for rpt62
10556 *
10557 * returns allocated struct or 0L for error
10558 */
ftstat_rpt_62_calc(struct ftstat_rpt * rpt)10559 int ftstat_rpt_62_calc(struct ftstat_rpt *rpt)
10560 {
10561
10562 STD_CALC_HASH(ftstat_rpt_62, rpt55, ftchash_rec_prefix162,
10563 ftch_recprefix162);
10564
10565 } /* ftstat_rpt_62_calc */
10566
10567 /* function: ftstat_rpt_62_dump
10568 *
10569 * Dump data for report.
10570 *
10571 */
ftstat_rpt_62_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10572 int ftstat_rpt_62_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10573 {
10574
10575 STD_DUMP_HASH2P(ftstat_rpt_62, rpt62, chash_prefix162_dump,
10576 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
10577 FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
10578 "", "ip-source-address", "source-as", "destination-as", "", "", "");
10579
10580 } /* ftstat_rpt_62_dump */
10581
10582 /* function: ftstat_rpt_62_free
10583 *
10584 * Free data structures for report allocated by ftstat_rpt_62_new
10585 *
10586 */
ftstat_rpt_62_free(struct ftstat_rpt_62 * rpt62)10587 void ftstat_rpt_62_free(struct ftstat_rpt_62 *rpt62)
10588 {
10589
10590 STD_FREE_HASH(rpt62);
10591
10592 } /* ftstat_rpt_62_free */
10593
10594 /* function: ftstat_rpt_63_new
10595 *
10596 * Allocate and initialize data structures for rpt 63
10597 *
10598 * returns allocated struct or 0L for error
10599 */
ftstat_rpt_63_new(struct ftstat_rpt * rpt)10600 struct ftstat_rpt_63 *ftstat_rpt_63_new(struct ftstat_rpt *rpt)
10601 {
10602
10603 STD_NEW_HASH(ftstat_rpt_63, rpt63, 65536, ftchash_rec_prefix162, 10, 65536);
10604
10605 } /* ftstat_rpt_63_new */
10606
10607 /* function: ftstat_rpt_63_accum
10608 *
10609 * Accumulate counters for report by processing flow.
10610 *
10611 * returns 0: ok
10612 * !0: error
10613 */
ftstat_rpt_63_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10614 int ftstat_rpt_63_accum(struct ftstat_rpt *rpt, char *rec,
10615 struct fts3rec_offsets *fo)
10616 {
10617
10618 STD_ACCUM_HASH1(ftstat_rpt_63, rpt63, ftchash_rec_prefix162,
10619 ftch_recprefix162, ftch_prefix162p);
10620
10621 FT_RECGET_SRC_AS(cur,rec,*fo);
10622 FT_RECGET_DST_AS(cur,rec,*fo);
10623 FT_RECGET_DSTADDR(cur,rec,*fo);
10624
10625 ftch_recprefix162.prefix = cur.dstaddr;
10626 ftch_recprefix162.c16a = cur.src_as;
10627 ftch_recprefix162.c16b = cur.dst_as;
10628
10629 /* only use mask if option set */
10630 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10631 FT_RECGET_DST_MASK(cur,rec,*fo);
10632 ftch_recprefix162.mask = cur.dst_mask;
10633 }
10634
10635 /* remove host bits */
10636 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
10637 ftch_recprefix162.prefix &= ipv4_len2mask(ftch_recprefix162.mask);
10638
10639 hash = (ftch_recprefix162.prefix>>16) ^ (ftch_recprefix162.prefix & 0xFFFF) ^
10640 (ftch_recprefix162.mask) ^ (ftch_recprefix162.c16a) ^
10641 (ftch_recprefix162.c16b);
10642
10643 STD_ACCUM_HASH2(rpt63, ftch_recprefix162, ftch_prefix162p);
10644
10645 return 0;
10646
10647 } /* ftstat_rpt_63_accum */
10648
10649 /* function: ftstat_rpt_63_calc
10650 *
10651 * Perform final calculations for rpt63
10652 *
10653 * returns allocated struct or 0L for error
10654 */
ftstat_rpt_63_calc(struct ftstat_rpt * rpt)10655 int ftstat_rpt_63_calc(struct ftstat_rpt *rpt)
10656 {
10657
10658 STD_CALC_HASH(ftstat_rpt_63, rpt55, ftchash_rec_prefix162,
10659 ftch_recprefix162);
10660
10661 } /* ftstat_rpt_63_calc */
10662
10663 /* function: ftstat_rpt_63_dump
10664 *
10665 * Dump data for report.
10666 *
10667 */
ftstat_rpt_63_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10668 int ftstat_rpt_63_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10669 {
10670
10671 STD_DUMP_HASH2P(ftstat_rpt_63, rpt63, chash_prefix162_dump,
10672 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
10673 FT_PATH_SYM_ASN, FT_PATH_SYM_ASN,
10674 "", "ip-destination-address", "source-as", "destination-as", "", "", "");
10675
10676 } /* ftstat_rpt_63_dump */
10677
10678 /* function: ftstat_rpt_63_free
10679 *
10680 * Free data structures for report allocated by ftstat_rpt_62_new
10681 *
10682 */
ftstat_rpt_63_free(struct ftstat_rpt_63 * rpt63)10683 void ftstat_rpt_63_free(struct ftstat_rpt_63 *rpt63)
10684 {
10685
10686 STD_FREE_HASH(rpt63);
10687
10688 } /* ftstat_rpt_63_free */
10689
10690 /* function: ftstat_rpt_64_new
10691 *
10692 * Allocate and initialize data structures for rpt 15.
10693 *
10694 * returns allocated struct or 0L for error
10695 */
ftstat_rpt_64_new(struct ftstat_rpt * rpt)10696 struct ftstat_rpt_64 *ftstat_rpt_64_new(struct ftstat_rpt *rpt)
10697 {
10698
10699 STD_NEW_HASH(ftstat_rpt_64, rpt64, 65536, ftchash_rec_prefix, 5, 65536);
10700
10701 } /* ftstat_rpt_64_new */
10702
10703
10704 /* function: ftstat_rpt_64_accum
10705 *
10706 * Accumulate counters for report by processing flow.
10707 *
10708 * returns 0: ok
10709 * !0: error
10710 */
ftstat_rpt_64_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10711 int ftstat_rpt_64_accum(struct ftstat_rpt *rpt, char *rec,
10712 struct fts3rec_offsets *fo)
10713 {
10714
10715 STD_ACCUM_HASH1(ftstat_rpt_64, rpt64, ftchash_rec_prefix, ftch_recprefix,
10716 ftch_recprefixp);
10717
10718 FT_RECGET_SRCADDR(cur,rec,*fo);
10719
10720 ftch_recprefix.prefix = cur.srcaddr;
10721
10722 /* only use mask if option set */
10723 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10724 FT_RECGET_SRC_MASK(cur,rec,*fo);
10725 ftch_recprefix.mask = cur.src_mask;
10726 }
10727
10728 /* remove host bits */
10729 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
10730 ftch_recprefix.prefix &= ipv4_len2mask(ftch_recprefix.mask);
10731
10732 hash = (ftch_recprefix.prefix>>16) ^ (ftch_recprefix.prefix & 0xFFFF);
10733 hash = hash ^ (ftch_recprefix.mask);
10734
10735 STD_ACCUM_HASH2(rpt64, ftch_recprefix, ftch_recprefixp);
10736
10737 bzero(&ftch_recprefix, sizeof ftch_recprefix);
10738
10739 FT_RECGET_DSTADDR(cur,rec,*fo);
10740
10741 ftch_recprefix.prefix = cur.dstaddr;
10742
10743 /* only use mask if option set */
10744 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10745 FT_RECGET_DST_MASK(cur,rec,*fo);
10746 ftch_recprefix.mask = cur.dst_mask;
10747 }
10748
10749 /* remove host bits */
10750 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
10751 ftch_recprefix.prefix &= ipv4_len2mask(ftch_recprefix.mask);
10752
10753 hash = (ftch_recprefix.prefix>>16) ^ (ftch_recprefix.prefix & 0xFFFF);
10754 hash = hash ^ (ftch_recprefix.mask);
10755
10756 STD_ACCUM_HASH2(rpt64, ftch_recprefix, ftch_recprefixp);
10757
10758 return 0;
10759
10760 } /* ftstat_rpt_64_accum */
10761
10762 /* function: ftstat_rpt_64_calc
10763 *
10764 * Perform final calculations for rpt64
10765 *
10766 * returns allocated struct or 0L for error
10767 */
ftstat_rpt_64_calc(struct ftstat_rpt * rpt)10768 int ftstat_rpt_64_calc(struct ftstat_rpt *rpt)
10769 {
10770
10771 STD_CALC_HASH(ftstat_rpt_64, rpt64, ftchash_rec_prefix, ftch_recprefix);
10772
10773 } /* ftstat_rpt_64_calc */
10774
10775 /* function: ftstat_rpt_64_dump
10776 *
10777 * Dump data for report.
10778 *
10779 */
ftstat_rpt_64_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10780 int ftstat_rpt_64_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10781 {
10782
10783 STD_DUMP_HASH0P(ftstat_rpt_64, rpt64, chash_prefix_dump,
10784 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK|
10785 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
10786 "ip-address", "", "", "", "", "", "");
10787
10788 } /* ftstat_rpt_64_dump */
10789
10790
10791 /* function: ftstat_rpt_64_free
10792 *
10793 * Free data structures for report allocated by ftstat_rpt_64_new
10794 *
10795 */
ftstat_rpt_64_free(struct ftstat_rpt_64 * rpt64)10796 void ftstat_rpt_64_free(struct ftstat_rpt_64 *rpt64)
10797 {
10798
10799 STD_FREE_HASH(rpt64);
10800
10801 } /* ftstat_rpt_64_free */
10802
10803 /* function: ftstat_rpt_65_new
10804 *
10805 * Allocate and initialize data structures for rpt 6.
10806 *
10807 * returns allocated struct or 0L for error
10808 */
ftstat_rpt_65_new(struct ftstat_rpt * rpt)10809 struct ftstat_rpt_65 *ftstat_rpt_65_new(struct ftstat_rpt *rpt)
10810 {
10811
10812 STD_NEW_BUCKET(ftstat_rpt_65, rpt65, 65536, rpt);
10813
10814 } /* ftstat_rpt_65_new */
10815
10816
10817 /* function: ftstat_rpt_65_accum
10818 *
10819 * Accumulate counters for report by processing flow.
10820 *
10821 * returns 0: ok
10822 * !0: error
10823 */
ftstat_rpt_65_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10824 int ftstat_rpt_65_accum(struct ftstat_rpt *rpt, char *rec,
10825 struct fts3rec_offsets *fo)
10826 {
10827
10828 STD_ACCUM_BUCKET1(ftstat_rpt_65, rpt65);
10829
10830 FT_RECGET_SRCPORT(cur,rec,*fo);
10831
10832 STD_ACCUM_BUCKET2(rpt65->bucket, cur.srcport);
10833
10834 FT_RECGET_DSTPORT(cur,rec,*fo);
10835
10836 STD_ACCUM_BUCKET2(rpt65->bucket, cur.dstport);
10837
10838 return 0;
10839
10840 } /* ftstat_rpt_65_accum */
10841
10842 /* function: ftstat_rpt_65_calc
10843 *
10844 * Perform final calculations for rpt65
10845 *
10846 * returns allocated struct or 0L for error
10847 */
ftstat_rpt_65_calc(struct ftstat_rpt * rpt)10848 int ftstat_rpt_65_calc(struct ftstat_rpt *rpt)
10849 {
10850
10851 STD_CALC_BUCKET(ftstat_rpt_65, rpt65, 65536);
10852
10853 } /* ftstat_rpt_65_calc */
10854
10855 /* function: ftstat_rpt_65_dump
10856 *
10857 * Dump data for report.
10858 *
10859 */
ftstat_rpt_65_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)10860 int ftstat_rpt_65_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
10861 {
10862
10863 STD_DUMP_BUCKET(ftstat_rpt_65, rpt65, 65536, FT_PATH_SYM_TCP_PORT,
10864 "ip-port", "", "", "", "", "", "");
10865
10866 } /* ftstat_rpt_65_dump */
10867
10868
10869 /* function: ftstat_rpt_65_free
10870 *
10871 * Free data structures for report allocated by ftstat_rpt_65_new
10872 *
10873 */
ftstat_rpt_65_free(struct ftstat_rpt_65 * rpt65)10874 void ftstat_rpt_65_free(struct ftstat_rpt_65 *rpt65)
10875 {
10876
10877 STD_FREE_BUCKET(rpt65);
10878
10879 } /* ftstat_rpt_65_free */
10880
10881 /* function: ftstat_rpt_66_new
10882 *
10883 * Allocate and initialize data structures for rpt 15.
10884 *
10885 * returns allocated struct or 0L for error
10886 */
ftstat_rpt_66_new(struct ftstat_rpt * rpt)10887 struct ftstat_rpt_66 *ftstat_rpt_66_new(struct ftstat_rpt *rpt)
10888 {
10889
10890 STD_NEW_HASH(ftstat_rpt_66, rpt66, 65536, ftchash_rec_prefixh, 5, 65536);
10891
10892 } /* ftstat_rpt_66_new */
10893
10894
10895 /* function: ftstat_rpt_66_accum
10896 *
10897 * Accumulate counters for report by processing flow.
10898 *
10899 * returns 0: ok
10900 * !0: error
10901 */
ftstat_rpt_66_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)10902 int ftstat_rpt_66_accum(struct ftstat_rpt *rpt, char *rec,
10903 struct fts3rec_offsets *fo)
10904 {
10905 struct ftchash_rec_prefixs *ftch_recprefixsp, ftch_recprefixs;
10906
10907 STD_ACCUM_HASH1(ftstat_rpt_66, rpt66, ftchash_rec_prefixh, ftch_recprefixh,
10908 ftch_recprefixhp);
10909
10910 FT_RECGET_SRCADDR(cur,rec,*fo);
10911
10912 ftch_recprefixh.prefix = cur.srcaddr;
10913
10914 /* only use mask if option set */
10915 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
10916 FT_RECGET_SRC_MASK(cur,rec,*fo);
10917 ftch_recprefixh.mask = cur.src_mask;
10918 }
10919
10920 /* remove host bits */
10921 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
10922 ftch_recprefixh.prefix &= ipv4_len2mask(ftch_recprefixh.mask);
10923
10924 hash = (ftch_recprefixh.prefix>>16) ^ (ftch_recprefixh.prefix & 0xFFFF);
10925 hash = hash ^ (ftch_recprefixh.mask);
10926
10927 STD_ACCUM_HASH2(rpt66, ftch_recprefixh, ftch_recprefixhp);
10928
10929 /* new second hash */
10930 if (!ftch_recprefixhp->ftch) {
10931 if (!(ftch_recprefixhp->ftch = ftchash_new(256,
10932 sizeof (struct ftchash_rec_prefixs), 5, 64))) {
10933 fterr_warnx("ftchash_new(): failed");
10934 return -1;
10935 }
10936 }
10937
10938 FT_RECGET_DSTADDR(cur,rec,*fo);
10939
10940 bzero(&ftch_recprefixs, sizeof ftch_recprefixs);
10941
10942 ftch_recprefixs.prefix = cur.dstaddr;
10943
10944 /* only use mask if option set */
10945 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
10946 FT_RECGET_DST_MASK(cur,rec,*fo);
10947 ftch_recprefixs.mask = cur.dst_mask;
10948 }
10949
10950 /* remove host bits */
10951 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
10952 ftch_recprefixs.prefix &= ipv4_len2mask(ftch_recprefixs.mask);
10953
10954 hash = (ftch_recprefixs.prefix>>16) ^ (ftch_recprefixs.prefix & 0xFFFF);
10955 hash = hash ^ (ftch_recprefixs.mask);
10956 hash = (hash >> 8) ^ (hash & 0xFF);
10957
10958 if (!(ftch_recprefixsp = ftchash_update(ftch_recprefixhp->ftch,
10959 &ftch_recprefixs, hash))) {
10960 fterr_warnx("ftch_update(): failed");
10961 return -1;
10962 }
10963
10964 return 0;
10965
10966 } /* ftstat_rpt_66_accum */
10967
10968 /* function: ftstat_rpt_66_calc
10969 *
10970 * Perform final calculations for rpt66
10971 *
10972 * returns allocated struct or 0L for error
10973 */
ftstat_rpt_66_calc(struct ftstat_rpt * rpt)10974 int ftstat_rpt_66_calc(struct ftstat_rpt *rpt)
10975 {
10976 struct ftchash_rec_prefixh *ftch_recprefixh;
10977 struct ftstat_rpt_66 *rpt66;
10978
10979 rpt66 = rpt->data;
10980
10981 STD_CALC;
10982
10983 rpt->recs = rpt66->ftch->entries;
10984
10985 ftchash_first(rpt66->ftch);
10986
10987 while ((ftch_recprefixh = ftchash_foreach(rpt66->ftch))) {
10988
10989 if (ftch_recprefixh->etime) {
10990 if (rpt->all_fields & FT_STAT_FIELD_PS) {
10991 ftch_recprefixh->ps.avg_pps /= (double)ftch_recprefixh->nrecs;
10992 ftch_recprefixh->ps.avg_bps /= (double)ftch_recprefixh->nrecs;
10993 }
10994 }
10995
10996 ftch_recprefixh->nprefixes = ftch_recprefixh->ftch->entries;
10997 rpt->t_count += ftch_recprefixh->ftch->entries;
10998
10999 }
11000
11001 return 0;
11002
11003 } /* ftstat_rpt_66_calc */
11004
11005 /* function: ftstat_rpt_66_dump
11006 *
11007 * Dump data for report.
11008 *
11009 */
ftstat_rpt_66_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11010 int ftstat_rpt_66_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11011 {
11012
11013 STD_DUMP_HASH0P(ftstat_rpt_66, rpt66, chash_prefixh_dump,
11014 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
11015 "ip-source-address", "ip-destination-address-count", "", "", "", "", "");
11016
11017 } /* ftstat_rpt_66_dump */
11018
11019
11020 /* function: ftstat_rpt_66_free
11021 *
11022 * Free data structures for report allocated by ftstat_rpt_66_new
11023 *
11024 */
ftstat_rpt_66_free(struct ftstat_rpt_66 * rpt66)11025 void ftstat_rpt_66_free(struct ftstat_rpt_66 *rpt66)
11026 {
11027 struct ftchash_rec_prefixh *ftch_recprefixh;
11028
11029 if (rpt66) {
11030
11031 if (rpt66->ftch) {
11032
11033 ftchash_first(rpt66->ftch);
11034
11035 while ((ftch_recprefixh = ftchash_foreach(rpt66->ftch))) {
11036
11037 if (ftch_recprefixh->ftch)
11038 ftchash_free(ftch_recprefixh->ftch);
11039
11040 }
11041
11042 ftchash_free(rpt66->ftch);
11043
11044 }
11045
11046 free (rpt66);
11047
11048 }
11049
11050 } /* ftstat_rpt_66_free */
11051
11052 /* function: ftstat_rpt_67_new
11053 *
11054 * Allocate and initialize data structures for rpt 15.
11055 *
11056 * returns allocated struct or 0L for error
11057 */
ftstat_rpt_67_new(struct ftstat_rpt * rpt)11058 struct ftstat_rpt_67 *ftstat_rpt_67_new(struct ftstat_rpt *rpt)
11059 {
11060
11061 STD_NEW_HASH(ftstat_rpt_67, rpt67, 65536, ftchash_rec_prefixh, 5, 65536);
11062
11063 } /* ftstat_rpt_67_new */
11064
11065
11066 /* function: ftstat_rpt_67_accum
11067 *
11068 * Accumulate counters for report by processing flow.
11069 *
11070 * returns 0: ok
11071 * !0: error
11072 */
ftstat_rpt_67_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11073 int ftstat_rpt_67_accum(struct ftstat_rpt *rpt, char *rec,
11074 struct fts3rec_offsets *fo)
11075 {
11076 struct ftchash_rec_prefixs *ftch_recprefixsp, ftch_recprefixs;
11077
11078 STD_ACCUM_HASH1(ftstat_rpt_67, rpt67, ftchash_rec_prefixh, ftch_recprefixh,
11079 ftch_recprefixhp);
11080
11081 FT_RECGET_DSTADDR(cur,rec,*fo);
11082
11083 ftch_recprefixh.prefix = cur.dstaddr;
11084
11085 /* only use mask if option set */
11086 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11087 FT_RECGET_DST_MASK(cur,rec,*fo);
11088 ftch_recprefixh.mask = cur.dst_mask;
11089 }
11090
11091 /* remove host bits */
11092 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
11093 ftch_recprefixh.prefix &= ipv4_len2mask(ftch_recprefixh.mask);
11094
11095 hash = (ftch_recprefixh.prefix>>16) ^ (ftch_recprefixh.prefix & 0xFFFF);
11096 hash = hash ^ (ftch_recprefixh.mask);
11097
11098 STD_ACCUM_HASH2(rpt67, ftch_recprefixh, ftch_recprefixhp);
11099
11100 /* new second hash */
11101 if (!ftch_recprefixhp->ftch) {
11102 if (!(ftch_recprefixhp->ftch = ftchash_new(256,
11103 sizeof (struct ftchash_rec_prefixs), 5, 64))) {
11104 fterr_warnx("ftchash_new(): failed");
11105 return -1;
11106 }
11107 }
11108
11109 FT_RECGET_SRCADDR(cur,rec,*fo);
11110
11111 bzero(&ftch_recprefixs, sizeof ftch_recprefixs);
11112
11113 ftch_recprefixs.prefix = cur.srcaddr;
11114
11115 /* only use mask if option set */
11116 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11117 FT_RECGET_SRC_MASK(cur,rec,*fo);
11118 ftch_recprefixs.mask = cur.src_mask;
11119 }
11120
11121 /* remove host bits */
11122 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
11123 ftch_recprefixs.prefix &= ipv4_len2mask(ftch_recprefixs.mask);
11124
11125 hash = (ftch_recprefixs.prefix>>16) ^ (ftch_recprefixs.prefix & 0xFFFF);
11126 hash = hash ^ (ftch_recprefixs.mask);
11127 hash = (hash >> 8) ^ (hash & 0xFF);
11128
11129 if (!(ftch_recprefixsp = ftchash_update(ftch_recprefixhp->ftch,
11130 &ftch_recprefixs, hash))) {
11131 fterr_warnx("ftch_update(): failed");
11132 return -1;
11133 }
11134
11135 return 0;
11136
11137 } /* ftstat_rpt_67_accum */
11138
11139 /* function: ftstat_rpt_67_calc
11140 *
11141 * Perform final calculations for rpt67
11142 *
11143 * returns allocated struct or 0L for error
11144 */
ftstat_rpt_67_calc(struct ftstat_rpt * rpt)11145 int ftstat_rpt_67_calc(struct ftstat_rpt *rpt)
11146 {
11147 struct ftchash_rec_prefixh *ftch_recprefixh;
11148 struct ftstat_rpt_67 *rpt67;
11149
11150 rpt67 = rpt->data;
11151
11152 STD_CALC;
11153
11154 rpt->recs = rpt67->ftch->entries;
11155
11156 ftchash_first(rpt67->ftch);
11157
11158 while ((ftch_recprefixh = ftchash_foreach(rpt67->ftch))) {
11159
11160 if (ftch_recprefixh->etime) {
11161 if (rpt->all_fields & FT_STAT_FIELD_PS) {
11162 ftch_recprefixh->ps.avg_pps /= (double)ftch_recprefixh->nrecs;
11163 ftch_recprefixh->ps.avg_bps /= (double)ftch_recprefixh->nrecs;
11164 }
11165 }
11166
11167 ftch_recprefixh->nprefixes = ftch_recprefixh->ftch->entries;
11168 rpt->t_count += ftch_recprefixh->ftch->entries;
11169
11170 }
11171
11172 return 0;
11173
11174 } /* ftstat_rpt_67_calc */
11175
11176 /* function: ftstat_rpt_67_dump
11177 *
11178 * Dump data for report.
11179 *
11180 */
ftstat_rpt_67_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11181 int ftstat_rpt_67_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11182 {
11183
11184 STD_DUMP_HASH0P(ftstat_rpt_67, rpt67, chash_prefixh_dump,
11185 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
11186 "ip-destination-address", "ip-source-address-count", "", "", "", "", "");
11187
11188 } /* ftstat_rpt_67_dump */
11189
11190
11191 /* function: ftstat_rpt_67_free
11192 *
11193 * Free data structures for report allocated by ftstat_rpt_67_new
11194 *
11195 */
ftstat_rpt_67_free(struct ftstat_rpt_67 * rpt67)11196 void ftstat_rpt_67_free(struct ftstat_rpt_67 *rpt67)
11197 {
11198 struct ftchash_rec_prefixh *ftch_recprefixh;
11199
11200 if (rpt67) {
11201
11202 if (rpt67->ftch) {
11203
11204 ftchash_first(rpt67->ftch);
11205
11206 while ((ftch_recprefixh = ftchash_foreach(rpt67->ftch))) {
11207
11208 if (ftch_recprefixh->ftch)
11209 ftchash_free(ftch_recprefixh->ftch);
11210
11211 }
11212
11213 ftchash_free(rpt67->ftch);
11214
11215 }
11216
11217 free (rpt67);
11218
11219 }
11220
11221 } /* ftstat_rpt_67_free */
11222
11223
11224 /* function: ftstat_rpt_68_new
11225 *
11226 * Allocate and initialize data structures for rpt 68.
11227 *
11228 * returns allocated struct or 0L for error
11229 */
ftstat_rpt_68_new(struct ftstat_rpt * rpt)11230 struct ftstat_rpt_68 *ftstat_rpt_68_new(struct ftstat_rpt *rpt)
11231 {
11232
11233 STD_NEW_HASH(ftstat_rpt_68, rpt68, 65536, ftchash_rec_flow1, 16, 65536);
11234
11235 } /* ftstat_rpt_68_new */
11236
11237 /* function: ftstat_rpt_68_accum
11238 *
11239 * Accumulate counters for report by processing flow.
11240 *
11241 * returns 0: ok
11242 * !0: error
11243 */
ftstat_rpt_68_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11244 int ftstat_rpt_68_accum(struct ftstat_rpt *rpt, char *rec,
11245 struct fts3rec_offsets *fo)
11246 {
11247
11248 STD_ACCUM_HASH1(ftstat_rpt_68, rpt68, ftchash_rec_flow1,
11249 ftch_recflow1, ftch_recflow1p);
11250
11251 FT_RECGET_SRCPORT(cur,rec,*fo);
11252 FT_RECGET_DSTPORT(cur,rec,*fo);
11253 FT_RECGET_SRCADDR(cur,rec,*fo);
11254 FT_RECGET_DSTADDR(cur,rec,*fo);
11255 FT_RECGET_TOS(cur,rec,*fo);
11256 FT_RECGET_PROT(cur,rec,*fo);
11257
11258 ftch_recflow1.src_prefix = cur.srcaddr;
11259 ftch_recflow1.dst_prefix = cur.dstaddr;
11260 ftch_recflow1.src_port = cur.srcport;
11261 ftch_recflow1.dst_port = cur.dstport;
11262 ftch_recflow1.tos = cur.tos;
11263 ftch_recflow1.prot = cur.prot;
11264
11265 /* only use mask if option set */
11266 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11267 FT_RECGET_SRC_MASK(cur,rec,*fo);
11268 ftch_recflow1.src_mask = cur.src_mask;
11269 }
11270
11271 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11272 FT_RECGET_DST_MASK(cur,rec,*fo);
11273 ftch_recflow1.dst_mask = cur.dst_mask;
11274 }
11275
11276 /* remove host bits */
11277 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
11278 ftch_recflow1.src_prefix &= ipv4_len2mask(ftch_recflow1.src_mask);
11279 }
11280
11281 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
11282 ftch_recflow1.dst_prefix &= ipv4_len2mask(ftch_recflow1.dst_mask);
11283 }
11284
11285 hash = (ftch_recflow1.src_prefix>>16)^
11286 (ftch_recflow1.src_prefix & 0xFFFF)^
11287 (ftch_recflow1.dst_prefix>>16)^
11288 (ftch_recflow1.dst_prefix & 0xFFFF)^
11289 (ftch_recflow1.src_port)^
11290 (ftch_recflow1.dst_port)^
11291 (ftch_recflow1.src_mask)^
11292 (ftch_recflow1.tos)^
11293 (ftch_recflow1.prot)^
11294 (uint32_t)(ftch_recflow1.dst_mask<<8);
11295
11296 STD_ACCUM_HASH2(rpt68, ftch_recflow1, ftch_recflow1p);
11297
11298 return 0;
11299
11300 } /* ftstat_rpt_68_accum */
11301
11302 /* function: ftstat_rpt_68_calc
11303 *
11304 * Perform final calculations for rpt68
11305 *
11306 * returns allocated struct or 0L for error
11307 */
ftstat_rpt_68_calc(struct ftstat_rpt * rpt)11308 int ftstat_rpt_68_calc(struct ftstat_rpt *rpt)
11309 {
11310
11311 STD_CALC_HASH(ftstat_rpt_68, rpt68, ftchash_rec_flow1,
11312 ftch_recflow1);
11313
11314 } /* ftstat_rpt_68_calc */
11315
11316 /* function: ftstat_rpt_68_dump
11317 *
11318 * Dump data for report.
11319 *
11320 */
ftstat_rpt_68_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11321 int ftstat_rpt_68_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11322 {
11323
11324 STD_DUMP_HASH2(ftstat_rpt_68, rpt68, chash_flow1_dump,
11325 FT_PATH_SYM_TCP_PORT, FT_PATH_SYM_IP_PROT,
11326 "", "ip-source-address", "ip-destination-address", "ip-source-port",
11327 "ip-destination-port", "ip-protocol", "ip-tos");
11328
11329 } /* ftstat_rpt_68_dump */
11330
11331 /* function: ftstat_rpt_68_free
11332 *
11333 * Free data structures for report allocated by ftstat_rpt_68_new
11334 *
11335 */
ftstat_rpt_68_free(struct ftstat_rpt_68 * rpt68)11336 void ftstat_rpt_68_free(struct ftstat_rpt_68 *rpt68)
11337 {
11338
11339 STD_FREE_HASH(rpt68);
11340
11341 } /* ftstat_rpt_68_free */
11342
11343 /* function: ftstat_rpt_69_new
11344 *
11345 * Allocate and initialize data structures for rpt 69.
11346 *
11347 * returns allocated struct or 0L for error
11348 */
ftstat_rpt_69_new(struct ftstat_rpt * rpt)11349 struct ftstat_rpt_69 *ftstat_rpt_69_new(struct ftstat_rpt *rpt)
11350 {
11351
11352 STD_NEW_HASH(ftstat_rpt_69, rpt69, 65536, ftchash_rec_flow1, 16, 65536);
11353
11354 } /* ftstat_rpt_69_new */
11355
11356 /* function: ftstat_rpt_69_accum
11357 *
11358 * Accumulate counters for report by processing flow.
11359 *
11360 * returns 0: ok
11361 * !0: error
11362 */
ftstat_rpt_69_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11363 int ftstat_rpt_69_accum(struct ftstat_rpt *rpt, char *rec,
11364 struct fts3rec_offsets *fo)
11365 {
11366
11367 STD_ACCUM_HASH1(ftstat_rpt_69, rpt69, ftchash_rec_flow1,
11368 ftch_recflow1, ftch_recflow1p);
11369
11370 FT_RECGET_SRCADDR(cur,rec,*fo);
11371 FT_RECGET_DSTADDR(cur,rec,*fo);
11372 FT_RECGET_TOS(cur,rec,*fo);
11373 FT_RECGET_PROT(cur,rec,*fo);
11374
11375 ftch_recflow1.src_prefix = cur.srcaddr;
11376 ftch_recflow1.dst_prefix = cur.dstaddr;
11377 ftch_recflow1.tos = cur.tos;
11378 ftch_recflow1.prot = cur.prot;
11379
11380 /* only use mask if option set */
11381 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11382 FT_RECGET_SRC_MASK(cur,rec,*fo);
11383 ftch_recflow1.src_mask = cur.src_mask;
11384 }
11385
11386 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11387 FT_RECGET_DST_MASK(cur,rec,*fo);
11388 ftch_recflow1.dst_mask = cur.dst_mask;
11389 }
11390
11391 /* remove host bits */
11392 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK) {
11393 ftch_recflow1.src_prefix &= ipv4_len2mask(ftch_recflow1.src_mask);
11394 }
11395
11396 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK) {
11397 ftch_recflow1.dst_prefix &= ipv4_len2mask(ftch_recflow1.dst_mask);
11398 }
11399
11400 hash = (ftch_recflow1.src_prefix>>16)^
11401 (ftch_recflow1.src_prefix & 0xFFFF)^
11402 (ftch_recflow1.dst_prefix>>16)^
11403 (ftch_recflow1.dst_prefix & 0xFFFF)^
11404 (ftch_recflow1.src_mask)^
11405 (ftch_recflow1.tos)^
11406 (ftch_recflow1.prot)^
11407 (uint32_t)(ftch_recflow1.dst_mask<<8);
11408
11409 STD_ACCUM_HASH2(rpt69, ftch_recflow1, ftch_recflow1p);
11410
11411 return 0;
11412
11413 } /* ftstat_rpt_69_accum */
11414
11415 /* function: ftstat_rpt_69_calc
11416 *
11417 * Perform final calculations for rpt69
11418 *
11419 * returns allocated struct or 0L for error
11420 */
ftstat_rpt_69_calc(struct ftstat_rpt * rpt)11421 int ftstat_rpt_69_calc(struct ftstat_rpt *rpt)
11422 {
11423
11424 STD_CALC_HASH(ftstat_rpt_69, rpt69, ftchash_rec_flow1,
11425 ftch_recflow1);
11426
11427 } /* ftstat_rpt_69_calc */
11428
11429 /* function: ftstat_rpt_69_dump
11430 *
11431 * Dump data for report.
11432 *
11433 */
ftstat_rpt_69_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11434 int ftstat_rpt_69_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11435 {
11436
11437 STD_DUMP_HASH1(ftstat_rpt_69, rpt69, chash_flow12_dump,
11438 FT_PATH_SYM_IP_PROT,
11439 "", "ip-source-address", "ip-destination-address", "ip-protocol",
11440 "ip-tos", "", "");
11441
11442 } /* ftstat_rpt_69_dump */
11443
11444 /* function: ftstat_rpt_69_free
11445 *
11446 * Free data structures for report allocated by ftstat_rpt_69_new
11447 *
11448 */
ftstat_rpt_69_free(struct ftstat_rpt_69 * rpt69)11449 void ftstat_rpt_69_free(struct ftstat_rpt_69 *rpt69)
11450 {
11451
11452 STD_FREE_HASH(rpt69);
11453
11454 } /* ftstat_rpt_69_free */
11455
11456 /* function: ftstat_rpt_70_new
11457 *
11458 * Allocate and initialize data structures for rpt 70.
11459 *
11460 * returns allocated struct or 0L for error
11461 */
ftstat_rpt_70_new(struct ftstat_rpt * rpt)11462 struct ftstat_rpt_70 *ftstat_rpt_70_new(struct ftstat_rpt *rpt)
11463 {
11464
11465 STD_NEW_HASH(ftstat_rpt_70, rpt70, 65536, ftchash_rec_prefix_tag, 12, 65536);
11466
11467 } /* ftstat_rpt_70_new */
11468
11469
11470 /* function: ftstat_rpt_70_accum
11471 *
11472 * Accumulate counters for report by processing flow.
11473 *
11474 * returns 0: ok
11475 * !0: error
11476 */
ftstat_rpt_70_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11477 int ftstat_rpt_70_accum(struct ftstat_rpt *rpt, char *rec,
11478 struct fts3rec_offsets *fo)
11479 {
11480
11481 STD_ACCUM_HASH1(ftstat_rpt_70, rpt70, ftchash_rec_prefix_tag,
11482 ftch_recprefix_tag, ftch_recprefix_tagp);
11483
11484 FT_RECGET_SRCADDR(cur,rec,*fo);
11485 FT_RECGET_SRC_TAG(cur,rec,*fo);
11486
11487 ftch_recprefix_tag.prefix = cur.srcaddr;
11488 ftch_recprefix_tag.tag = cur.src_tag;
11489
11490 /* only use mask if option set */
11491 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11492 FT_RECGET_SRC_MASK(cur,rec,*fo);
11493 ftch_recprefix_tag.mask = cur.src_mask;
11494 }
11495
11496 /* remove host bits */
11497 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
11498 ftch_recprefix_tag.prefix &= ipv4_len2mask(ftch_recprefix_tag.mask);
11499
11500 hash = (ftch_recprefix_tag.tag>>16) ^ (ftch_recprefix_tag.tag & 0xFFFF) ^
11501 (ftch_recprefix_tag.prefix>>16) ^ (ftch_recprefix_tag.prefix & 0xFFFF) ^
11502 (ftch_recprefix_tag.mask);
11503
11504 STD_ACCUM_HASH2(rpt70, ftch_recprefix_tag, ftch_recprefix_tagp);
11505
11506 return 0;
11507
11508 } /* ftstat_rpt_70_accum */
11509
11510 /* function: ftstat_rpt_70_calc
11511 *
11512 * Perform final calculations for rpt70
11513 *
11514 * returns allocated struct or 0L for error
11515 */
ftstat_rpt_70_calc(struct ftstat_rpt * rpt)11516 int ftstat_rpt_70_calc(struct ftstat_rpt *rpt)
11517 {
11518
11519 STD_CALC_HASH(ftstat_rpt_70, rpt70, ftchash_rec_prefix_tag,
11520 ftch_recprefix_tag);
11521
11522 } /* ftstat_rpt_70_calc */
11523
11524 /* function: ftstat_rpt_70_dump
11525 *
11526 * Dump data for report.
11527 *
11528 */
ftstat_rpt_70_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11529 int ftstat_rpt_70_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11530 {
11531
11532 STD_DUMP_HASH1P(ftstat_rpt_70, rpt70, chash_prefix_tag_dump,
11533 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
11534 FT_PATH_SYM_TAG,
11535 "", "ip-source-address", "source-tag", "", "", "", "");
11536
11537 } /* ftstat_rpt_70_dump */
11538
11539
11540 /* function: ftstat_rpt_70_free
11541 *
11542 * Free data structures for report allocated by ftstat_rpt_70_new
11543 *
11544 */
ftstat_rpt_70_free(struct ftstat_rpt_70 * rpt70)11545 void ftstat_rpt_70_free(struct ftstat_rpt_70 *rpt70)
11546 {
11547
11548 STD_FREE_HASH(rpt70);
11549
11550 } /* ftstat_rpt_70_free */
11551
11552
11553 /* function: ftstat_rpt_71_new
11554 *
11555 * Allocate and initialize data structures for rpt 71.
11556 *
11557 * returns allocated struct or 0L for error
11558 */
ftstat_rpt_71_new(struct ftstat_rpt * rpt)11559 struct ftstat_rpt_71 *ftstat_rpt_71_new(struct ftstat_rpt *rpt)
11560 {
11561
11562 STD_NEW_HASH(ftstat_rpt_71, rpt71, 65536, ftchash_rec_prefix_tag, 12, 65536);
11563
11564 } /* ftstat_rpt_71_new */
11565
11566
11567 /* function: ftstat_rpt_71_accum
11568 *
11569 * Accumulate counters for report by processing flow.
11570 *
11571 * returns 0: ok
11572 * !0: error
11573 */
ftstat_rpt_71_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11574 int ftstat_rpt_71_accum(struct ftstat_rpt *rpt, char *rec,
11575 struct fts3rec_offsets *fo)
11576 {
11577
11578 STD_ACCUM_HASH1(ftstat_rpt_71, rpt71, ftchash_rec_prefix_tag,
11579 ftch_recprefix_tag, ftch_recprefix_tagp);
11580
11581 FT_RECGET_SRCADDR(cur,rec,*fo);
11582 FT_RECGET_DST_TAG(cur,rec,*fo);
11583
11584 ftch_recprefix_tag.prefix = cur.srcaddr;
11585 ftch_recprefix_tag.tag = cur.dst_tag;
11586
11587 /* only use mask if option set */
11588 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11589 FT_RECGET_SRC_MASK(cur,rec,*fo);
11590 ftch_recprefix_tag.mask = cur.src_mask;
11591 }
11592
11593 /* remove host bits */
11594 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
11595 ftch_recprefix_tag.prefix &= ipv4_len2mask(ftch_recprefix_tag.mask);
11596
11597 hash = (ftch_recprefix_tag.tag>>16) ^ (ftch_recprefix_tag.tag & 0xFFFF) ^
11598 (ftch_recprefix_tag.prefix>>16) ^ (ftch_recprefix_tag.prefix & 0xFFFF) ^
11599 (ftch_recprefix_tag.mask);
11600
11601 STD_ACCUM_HASH2(rpt71, ftch_recprefix_tag, ftch_recprefix_tagp);
11602
11603 return 0;
11604
11605 } /* ftstat_rpt_71_accum */
11606
11607 /* function: ftstat_rpt_71_calc
11608 *
11609 * Perform final calculations for rpt71
11610 *
11611 * returns allocated struct or 0L for error
11612 */
ftstat_rpt_71_calc(struct ftstat_rpt * rpt)11613 int ftstat_rpt_71_calc(struct ftstat_rpt *rpt)
11614 {
11615
11616 STD_CALC_HASH(ftstat_rpt_71, rpt71, ftchash_rec_prefix_tag,
11617 ftch_recprefix_tag);
11618
11619 } /* ftstat_rpt_71_calc */
11620
11621 /* function: ftstat_rpt_71_dump
11622 *
11623 * Dump data for report.
11624 *
11625 */
ftstat_rpt_71_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11626 int ftstat_rpt_71_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11627 {
11628
11629 STD_DUMP_HASH1P(ftstat_rpt_71, rpt71, chash_prefix_tag_dump,
11630 FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK,
11631 FT_PATH_SYM_TAG,
11632 "", "ip-source-address", "destination-tag", "", "", "", "");
11633
11634 } /* ftstat_rpt_71_dump */
11635
11636
11637 /* function: ftstat_rpt_71_free
11638 *
11639 * Free data structures for report allocated by ftstat_rpt_71_new
11640 *
11641 */
ftstat_rpt_71_free(struct ftstat_rpt_71 * rpt71)11642 void ftstat_rpt_71_free(struct ftstat_rpt_71 *rpt71)
11643 {
11644
11645 STD_FREE_HASH(rpt71);
11646
11647 } /* ftstat_rpt_71_free */
11648
11649 /* function: ftstat_rpt_72_new
11650 *
11651 * Allocate and initialize data structures for rpt 72.
11652 *
11653 * returns allocated struct or 0L for error
11654 */
ftstat_rpt_72_new(struct ftstat_rpt * rpt)11655 struct ftstat_rpt_72 *ftstat_rpt_72_new(struct ftstat_rpt *rpt)
11656 {
11657
11658 STD_NEW_HASH(ftstat_rpt_72, rpt72, 65536, ftchash_rec_prefix_tag, 12, 65536);
11659
11660 } /* ftstat_rpt_72_new */
11661
11662
11663 /* function: ftstat_rpt_72_accum
11664 *
11665 * Accumulate counters for report by processing flow.
11666 *
11667 * returns 0: ok
11668 * !0: error
11669 */
ftstat_rpt_72_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11670 int ftstat_rpt_72_accum(struct ftstat_rpt *rpt, char *rec,
11671 struct fts3rec_offsets *fo)
11672 {
11673
11674 STD_ACCUM_HASH1(ftstat_rpt_72, rpt72, ftchash_rec_prefix_tag,
11675 ftch_recprefix_tag, ftch_recprefix_tagp);
11676
11677 FT_RECGET_DSTADDR(cur,rec,*fo);
11678 FT_RECGET_SRC_TAG(cur,rec,*fo);
11679
11680 ftch_recprefix_tag.prefix = cur.dstaddr;
11681 ftch_recprefix_tag.tag = cur.src_tag;
11682
11683 /* only use mask if option set */
11684 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11685 FT_RECGET_DST_MASK(cur,rec,*fo);
11686 ftch_recprefix_tag.mask = cur.dst_mask;
11687 }
11688
11689 /* remove host bits */
11690 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
11691 ftch_recprefix_tag.prefix &= ipv4_len2mask(ftch_recprefix_tag.mask);
11692
11693 hash = (ftch_recprefix_tag.tag>>16) ^ (ftch_recprefix_tag.tag & 0xFFFF) ^
11694 (ftch_recprefix_tag.prefix>>16) ^ (ftch_recprefix_tag.prefix & 0xFFFF) ^
11695 (ftch_recprefix_tag.mask);
11696
11697 STD_ACCUM_HASH2(rpt72, ftch_recprefix_tag, ftch_recprefix_tagp);
11698
11699 return 0;
11700
11701 } /* ftstat_rpt_72_accum */
11702
11703 /* function: ftstat_rpt_72_calc
11704 *
11705 * Perform final calculations for rpt72
11706 *
11707 * returns allocated struct or 0L for error
11708 */
ftstat_rpt_72_calc(struct ftstat_rpt * rpt)11709 int ftstat_rpt_72_calc(struct ftstat_rpt *rpt)
11710 {
11711
11712 STD_CALC_HASH(ftstat_rpt_72, rpt72, ftchash_rec_prefix_tag,
11713 ftch_recprefix_tag);
11714
11715 } /* ftstat_rpt_72_calc */
11716
11717 /* function: ftstat_rpt_72_dump
11718 *
11719 * Dump data for report.
11720 *
11721 */
ftstat_rpt_72_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11722 int ftstat_rpt_72_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11723 {
11724
11725 STD_DUMP_HASH1P(ftstat_rpt_72, rpt72, chash_prefix_tag_dump,
11726 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
11727 FT_PATH_SYM_TAG,
11728 "", "ip-destination-address", "source-tag", "", "", "", "");
11729
11730 } /* ftstat_rpt_72_dump */
11731
11732
11733 /* function: ftstat_rpt_72_free
11734 *
11735 * Free data structures for report allocated by ftstat_rpt_72_new
11736 *
11737 */
ftstat_rpt_72_free(struct ftstat_rpt_72 * rpt72)11738 void ftstat_rpt_72_free(struct ftstat_rpt_72 *rpt72)
11739 {
11740
11741 STD_FREE_HASH(rpt72);
11742
11743 } /* ftstat_rpt_72_free */
11744
11745 /* function: ftstat_rpt_73_new
11746 *
11747 * Allocate and initialize data structures for rpt 73.
11748 *
11749 * returns allocated struct or 0L for error
11750 */
ftstat_rpt_73_new(struct ftstat_rpt * rpt)11751 struct ftstat_rpt_73 *ftstat_rpt_73_new(struct ftstat_rpt *rpt)
11752 {
11753
11754 STD_NEW_HASH(ftstat_rpt_73, rpt73, 65536, ftchash_rec_prefix_tag, 12, 65536);
11755
11756 } /* ftstat_rpt_73_new */
11757
11758
11759 /* function: ftstat_rpt_73_accum
11760 *
11761 * Accumulate counters for report by processing flow.
11762 *
11763 * returns 0: ok
11764 * !0: error
11765 */
ftstat_rpt_73_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11766 int ftstat_rpt_73_accum(struct ftstat_rpt *rpt, char *rec,
11767 struct fts3rec_offsets *fo)
11768 {
11769
11770 STD_ACCUM_HASH1(ftstat_rpt_73, rpt73, ftchash_rec_prefix_tag,
11771 ftch_recprefix_tag, ftch_recprefix_tagp);
11772
11773 FT_RECGET_DSTADDR(cur,rec,*fo);
11774 FT_RECGET_DST_TAG(cur,rec,*fo);
11775
11776 ftch_recprefix_tag.prefix = cur.dstaddr;
11777 ftch_recprefix_tag.tag = cur.dst_tag;
11778
11779 /* only use mask if option set */
11780 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11781 FT_RECGET_DST_MASK(cur,rec,*fo);
11782 ftch_recprefix_tag.mask = cur.dst_mask;
11783 }
11784
11785 /* remove host bits */
11786 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
11787 ftch_recprefix_tag.prefix &= ipv4_len2mask(ftch_recprefix_tag.mask);
11788
11789 hash = (ftch_recprefix_tag.tag>>16) ^ (ftch_recprefix_tag.tag & 0xFFFF) ^
11790 (ftch_recprefix_tag.prefix>>16) ^ (ftch_recprefix_tag.prefix & 0xFFFF) ^
11791 (ftch_recprefix_tag.mask);
11792
11793 STD_ACCUM_HASH2(rpt73, ftch_recprefix_tag, ftch_recprefix_tagp);
11794
11795 return 0;
11796
11797 } /* ftstat_rpt_73_accum */
11798
11799 /* function: ftstat_rpt_73_calc
11800 *
11801 * Perform final calculations for rpt73
11802 *
11803 * returns allocated struct or 0L for error
11804 */
ftstat_rpt_73_calc(struct ftstat_rpt * rpt)11805 int ftstat_rpt_73_calc(struct ftstat_rpt *rpt)
11806 {
11807
11808 STD_CALC_HASH(ftstat_rpt_73, rpt73, ftchash_rec_prefix_tag,
11809 ftch_recprefix_tag);
11810
11811 } /* ftstat_rpt_73_calc */
11812
11813 /* function: ftstat_rpt_73_dump
11814 *
11815 * Dump data for report.
11816 *
11817 */
ftstat_rpt_73_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11818 int ftstat_rpt_73_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11819 {
11820
11821 STD_DUMP_HASH1P(ftstat_rpt_73, rpt73, chash_prefix_tag_dump,
11822 FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK,
11823 FT_PATH_SYM_TAG,
11824 "", "ip-destination-address", "destination-tag", "", "", "", "");
11825
11826 } /* ftstat_rpt_73_dump */
11827
11828
11829 /* function: ftstat_rpt_73_free
11830 *
11831 * Free data structures for report allocated by ftstat_rpt_73_new
11832 *
11833 */
ftstat_rpt_73_free(struct ftstat_rpt_73 * rpt73)11834 void ftstat_rpt_73_free(struct ftstat_rpt_73 *rpt73)
11835 {
11836
11837 STD_FREE_HASH(rpt73);
11838
11839 } /* ftstat_rpt_73_free */
11840
11841 /* function: ftstat_rpt_74_new
11842 *
11843 * Allocate and initialize data structures for rpt 74.
11844 *
11845 * returns allocated struct or 0L for error
11846 */
ftstat_rpt_74_new(struct ftstat_rpt * rpt)11847 struct ftstat_rpt_74 *ftstat_rpt_74_new(struct ftstat_rpt *rpt)
11848 {
11849
11850 STD_NEW_HASH(ftstat_rpt_74, rpt74, 65536, ftchash_rec_prefix2tag2, 24, 65536);
11851
11852 } /* ftstat_rpt_74_new */
11853
11854
11855 /* function: ftstat_rpt_74_accum
11856 *
11857 * Accumulate counters for report by processing flow.
11858 *
11859 * returns 0: ok
11860 * !0: error
11861 */
ftstat_rpt_74_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11862 int ftstat_rpt_74_accum(struct ftstat_rpt *rpt, char *rec,
11863 struct fts3rec_offsets *fo)
11864 {
11865
11866 STD_ACCUM_HASH1(ftstat_rpt_74, rpt74, ftchash_rec_prefix2tag2,
11867 ftch_recprefix2tag2, ftch_recprefix2tag2p);
11868
11869 FT_RECGET_SRCADDR(cur,rec,*fo);
11870 FT_RECGET_DSTADDR(cur,rec,*fo);
11871 FT_RECGET_SRC_TAG(cur,rec,*fo);
11872 FT_RECGET_DST_TAG(cur,rec,*fo);
11873
11874 ftch_recprefix2tag2.src_prefix = cur.srcaddr;
11875 ftch_recprefix2tag2.src_tag = cur.src_tag;
11876 ftch_recprefix2tag2.dst_prefix = cur.dstaddr;
11877 ftch_recprefix2tag2.dst_tag = cur.dst_tag;
11878
11879 /* only use mask if option set */
11880 if (rpt->options & (FT_STAT_OPT_SRC_PREFIX_MASK|FT_STAT_OPT_SRC_PREFIX_LEN)) {
11881 FT_RECGET_SRC_MASK(cur,rec,*fo);
11882 ftch_recprefix2tag2.src_mask = cur.src_mask;
11883 }
11884
11885 /* only use mask if option set */
11886 if (rpt->options & (FT_STAT_OPT_DST_PREFIX_MASK|FT_STAT_OPT_DST_PREFIX_LEN)) {
11887 FT_RECGET_DST_MASK(cur,rec,*fo);
11888 ftch_recprefix2tag2.src_mask = cur.dst_mask;
11889 }
11890
11891 /* remove host bits */
11892 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
11893 ftch_recprefix2tag2.src_prefix &=
11894 ipv4_len2mask(ftch_recprefix2tag2.src_mask);
11895
11896 /* remove host bits */
11897 if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
11898 ftch_recprefix2tag2.dst_prefix
11899 &= ipv4_len2mask(ftch_recprefix2tag2.dst_mask);
11900
11901 hash = (ftch_recprefix2tag2.src_tag>>16) ^
11902 (ftch_recprefix2tag2.src_tag & 0xFFFF) ^
11903 (ftch_recprefix2tag2.dst_tag>>16) ^
11904 (ftch_recprefix2tag2.dst_tag & 0xFFFF) ^
11905 (ftch_recprefix2tag2.src_prefix>>16) ^
11906 (ftch_recprefix2tag2.src_prefix & 0xFFFF) ^
11907 (ftch_recprefix2tag2.dst_prefix>>16) ^
11908 (ftch_recprefix2tag2.dst_prefix & 0xFFFF) ^
11909 (ftch_recprefix2tag2.src_mask) ^
11910 (ftch_recprefix2tag2.dst_mask);
11911
11912 STD_ACCUM_HASH2(rpt74, ftch_recprefix2tag2, ftch_recprefix2tag2p);
11913
11914 return 0;
11915
11916 } /* ftstat_rpt_74_accum */
11917
11918 /* function: ftstat_rpt_74_calc
11919 *
11920 * Perform final calculations for rpt74
11921 *
11922 * returns allocated struct or 0L for error
11923 */
ftstat_rpt_74_calc(struct ftstat_rpt * rpt)11924 int ftstat_rpt_74_calc(struct ftstat_rpt *rpt)
11925 {
11926
11927 STD_CALC_HASH(ftstat_rpt_74, rpt74, ftchash_rec_prefix2tag2,
11928 ftch_recprefix2tag2);
11929
11930 } /* ftstat_rpt_74_calc */
11931
11932 /* function: ftstat_rpt_74_dump
11933 *
11934 * Dump data for report.
11935 *
11936 */
ftstat_rpt_74_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)11937 int ftstat_rpt_74_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
11938 {
11939
11940 STD_DUMP_HASH1(ftstat_rpt_74, rpt74, chash_prefix2tag2_dump,
11941 FT_PATH_SYM_TAG,
11942 "", "ip-source-address", "ip-destination-address", "source-tag",
11943 "destination-tag", "", "");
11944
11945 } /* ftstat_rpt_74_dump */
11946
11947
11948 /* function: ftstat_rpt_74_free
11949 *
11950 * Free data structures for report allocated by ftstat_rpt_74_new
11951 *
11952 */
ftstat_rpt_74_free(struct ftstat_rpt_74 * rpt74)11953 void ftstat_rpt_74_free(struct ftstat_rpt_74 *rpt74)
11954 {
11955
11956 STD_FREE_HASH(rpt74);
11957
11958 } /* ftstat_rpt_74_free */
11959
11960 /* function: ftstat_rpt_75_new
11961 *
11962 * Allocate and initialize data structures for rpt 75.
11963 *
11964 * returns allocated struct or 0L for error
11965 */
ftstat_rpt_75_new(struct ftstat_rpt * rpt)11966 struct ftstat_rpt_75 *ftstat_rpt_75_new(struct ftstat_rpt *rpt)
11967 {
11968
11969 STD_NEW_HASH(ftstat_rpt_75, rpt75, 65536, ftchash_rec_int, 4, 65536);
11970
11971 } /* ftstat_rpt_75_new */
11972
11973
11974 /* function: ftstat_rpt_75_accum
11975 *
11976 * Accumulate counters for report by processing flow.
11977 *
11978 * returns 0: ok
11979 * !0: error
11980 */
ftstat_rpt_75_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)11981 int ftstat_rpt_75_accum(struct ftstat_rpt *rpt, char *rec,
11982 struct fts3rec_offsets *fo)
11983 {
11984 struct fttime start, end;
11985 uint32_t i;
11986 double p_flows, p_octets, p_packets, d;
11987
11988 STD_ACCUM_HASH1(ftstat_rpt_75, rpt75, ftchash_rec_int,
11989 ftch_recint, ftch_recintp);
11990
11991 FT_RECGET_SYSUPTIME(cur,rec,*fo);
11992 FT_RECGET_UNIX_SECS(cur,rec,*fo);
11993 FT_RECGET_UNIX_NSECS(cur,rec,*fo);
11994 FT_RECGET_FIRST(cur,rec,*fo);
11995 FT_RECGET_LAST(cur,rec,*fo);
11996
11997 start = ftltime(cur.sysUpTime, cur.unix_secs, cur.unix_nsecs, cur.First);
11998 end = ftltime(cur.sysUpTime, cur.unix_secs, cur.unix_nsecs, cur.Last);
11999
12000 d = (end.secs - start.secs) + 1;
12001
12002 p_flows = (double)cur.dFlows64 / d;
12003 p_octets = (double)cur.dOctets64 / d;
12004 p_packets = (double)cur.dPkts64 / d;
12005
12006 for (i = start.secs; i <= end.secs; ++i) {
12007
12008 ftch_recint.time = i;
12009
12010 hash = (i>>16) ^ (i & 0xFFFF);
12011
12012 if (!(ftch_recintp = ftchash_update(rpt75->ftch, &ftch_recint, hash))) {
12013 fterr_warnx("ftch_update(): failed");
12014 return -1;
12015 }
12016
12017 ftch_recintp->nflows += p_flows;
12018 ftch_recintp->noctets += p_octets;
12019 ftch_recintp->npackets += p_packets;
12020
12021 }
12022
12023 return 0;
12024
12025 } /* ftstat_rpt_75_accum */
12026
12027 /* function: ftstat_rpt_75_calc
12028 *
12029 * Perform final calculations for rpt75
12030 *
12031 * returns allocated struct or 0L for error
12032 */
ftstat_rpt_75_calc(struct ftstat_rpt * rpt)12033 int ftstat_rpt_75_calc(struct ftstat_rpt *rpt)
12034 {
12035 struct ftstat_rpt_75 *rpt75;
12036
12037 rpt75 = rpt->data;
12038
12039 STD_CALC;
12040
12041 rpt->recs = rpt75->ftch->entries;
12042
12043 return 0;
12044
12045 } /* ftstat_rpt_75_calc */
12046
12047 /* function: ftstat_rpt_75_dump
12048 *
12049 * Dump data for report.
12050 *
12051 */
ftstat_rpt_75_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)12052 int ftstat_rpt_75_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
12053 {
12054
12055 STD_DUMP_HASH0(ftstat_rpt_75, rpt75, chash_int_dump,
12056 "unix-secs", "", "", "", "", "", "");
12057
12058 } /* ftstat_rpt_75_dump */
12059
12060
12061 /* function: ftstat_rpt_75_free
12062 *
12063 * Free data structures for report allocated by ftstat_rpt_75_new
12064 *
12065 */
ftstat_rpt_75_free(struct ftstat_rpt_75 * rpt75)12066 void ftstat_rpt_75_free(struct ftstat_rpt_75 *rpt75)
12067 {
12068
12069 STD_FREE_HASH(rpt75);
12070
12071 } /* ftstat_rpt_75_free */
12072
12073 /* function: ftstat_rpt_76_new
12074 *
12075 * Allocate and initialize data structures for rpt 76.
12076 *
12077 * returns allocated struct or 0L for error
12078 */
ftstat_rpt_76_new(struct ftstat_rpt * rpt)12079 struct ftstat_rpt_76 *ftstat_rpt_76_new(struct ftstat_rpt *rpt)
12080 {
12081
12082 STD_NEW_HASH(ftstat_rpt_76, rpt76, 65536, ftchash_rec_c32, 4, 65536);
12083
12084 } /* ftstat_rpt_76_new */
12085
12086
12087 /* function: ftstat_rpt_76_accum
12088 *
12089 * Accumulate counters for report by processing flow.
12090 *
12091 * returns 0: ok
12092 * !0: error
12093 */
ftstat_rpt_76_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)12094 int ftstat_rpt_76_accum(struct ftstat_rpt *rpt, char *rec,
12095 struct fts3rec_offsets *fo)
12096 {
12097
12098 STD_ACCUM_HASH1(ftstat_rpt_76, rpt76, ftchash_rec_c32,
12099 ftch_recc32, ftch_recc32p);
12100
12101 ftch_recc32.c32 = cur.First;
12102
12103 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
12104
12105 STD_ACCUM_HASH2(rpt76, ftch_recc32, ftch_recc32p);
12106
12107 return 0;
12108
12109 } /* ftstat_rpt_76_accum */
12110
12111 /* function: ftstat_rpt_76_calc
12112 *
12113 * Perform final calculations for rpt76
12114 *
12115 * returns allocated struct or 0L for error
12116 */
ftstat_rpt_76_calc(struct ftstat_rpt * rpt)12117 int ftstat_rpt_76_calc(struct ftstat_rpt *rpt)
12118 {
12119
12120 STD_CALC_HASH(ftstat_rpt_76, rpt76, ftchash_rec_c32, ftch_recc32);
12121
12122 } /* ftstat_rpt_76_calc */
12123
12124 /* function: ftstat_rpt_76_dump
12125 *
12126 * Dump data for report.
12127 *
12128 */
ftstat_rpt_76_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)12129 int ftstat_rpt_76_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
12130 {
12131
12132 STD_DUMP_HASH1(ftstat_rpt_76, rpt76, chash_c32_dump, (char*)0L,
12133 "First", "", "", "", "", "", "");
12134
12135 } /* ftstat_rpt_76_dump */
12136
12137
12138 /* function: ftstat_rpt_76_free
12139 *
12140 * Free data structures for report allocated by ftstat_rpt_76_new
12141 *
12142 */
ftstat_rpt_76_free(struct ftstat_rpt_76 * rpt76)12143 void ftstat_rpt_76_free(struct ftstat_rpt_76 *rpt76)
12144 {
12145
12146 STD_FREE_HASH(rpt76);
12147
12148 } /* ftstat_rpt_76_free */
12149
12150
12151 /* function: ftstat_rpt_77_new
12152 *
12153 * Allocate and initialize data structures for rpt 77.
12154 *
12155 * returns allocated struct or 0L for error
12156 */
ftstat_rpt_77_new(struct ftstat_rpt * rpt)12157 struct ftstat_rpt_77 *ftstat_rpt_77_new(struct ftstat_rpt *rpt)
12158 {
12159
12160 STD_NEW_HASH(ftstat_rpt_77, rpt77, 65536, ftchash_rec_c32, 4, 65536);
12161
12162 } /* ftstat_rpt_77_new */
12163
12164
12165 /* function: ftstat_rpt_77_accum
12166 *
12167 * Accumulate counters for report by processing flow.
12168 *
12169 * returns 0: ok
12170 * !0: error
12171 */
ftstat_rpt_77_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)12172 int ftstat_rpt_77_accum(struct ftstat_rpt *rpt, char *rec,
12173 struct fts3rec_offsets *fo)
12174 {
12175
12176 STD_ACCUM_HASH1(ftstat_rpt_77, rpt77, ftchash_rec_c32,
12177 ftch_recc32, ftch_recc32p);
12178
12179 ftch_recc32.c32 = cur.Last;
12180
12181 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
12182
12183 STD_ACCUM_HASH2(rpt77, ftch_recc32, ftch_recc32p);
12184
12185 return 0;
12186
12187 } /* ftstat_rpt_77_accum */
12188
12189 /* function: ftstat_rpt_77_calc
12190 *
12191 * Perform final calculations for rpt77
12192 *
12193 * returns allocated struct or 0L for error
12194 */
ftstat_rpt_77_calc(struct ftstat_rpt * rpt)12195 int ftstat_rpt_77_calc(struct ftstat_rpt *rpt)
12196 {
12197
12198 STD_CALC_HASH(ftstat_rpt_77, rpt77, ftchash_rec_c32, ftch_recc32);
12199
12200 } /* ftstat_rpt_77_calc */
12201
12202 /* function: ftstat_rpt_77_dump
12203 *
12204 * Dump data for report.
12205 *
12206 */
ftstat_rpt_77_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)12207 int ftstat_rpt_77_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
12208 {
12209
12210 STD_DUMP_HASH1(ftstat_rpt_77, rpt77, chash_c32_dump, (char*)0L,
12211 "Last", "", "", "", "", "", "");
12212
12213 } /* ftstat_rpt_77_dump */
12214
12215
12216 /* function: ftstat_rpt_77_free
12217 *
12218 * Free data structures for report allocated by ftstat_rpt_77_new
12219 *
12220 */
ftstat_rpt_77_free(struct ftstat_rpt_77 * rpt77)12221 void ftstat_rpt_77_free(struct ftstat_rpt_77 *rpt77)
12222 {
12223
12224 STD_FREE_HASH(rpt77);
12225
12226 } /* ftstat_rpt_77_free */
12227
12228
12229 /* function: ftstat_rpt_78_new
12230 *
12231 * Allocate and initialize data structures for rpt 78.
12232 *
12233 * returns allocated struct or 0L for error
12234 */
ftstat_rpt_78_new(struct ftstat_rpt * rpt)12235 struct ftstat_rpt_78 *ftstat_rpt_78_new(struct ftstat_rpt *rpt)
12236 {
12237
12238 STD_NEW_HASH(ftstat_rpt_78, rpt78, 65536, ftchash_rec_c32, 4, 65536);
12239
12240 } /* ftstat_rpt_78_new */
12241
12242
12243 /* function: ftstat_rpt_78_accum
12244 *
12245 * Accumulate counters for report by processing flow.
12246 *
12247 * returns 0: ok
12248 * !0: error
12249 */
ftstat_rpt_78_accum(struct ftstat_rpt * rpt,char * rec,struct fts3rec_offsets * fo)12250 int ftstat_rpt_78_accum(struct ftstat_rpt *rpt, char *rec,
12251 struct fts3rec_offsets *fo)
12252 {
12253
12254 STD_ACCUM_HASH1(ftstat_rpt_78, rpt78, ftchash_rec_c32,
12255 ftch_recc32, ftch_recc32p);
12256
12257 ftch_recc32.c32 = cur.Last - cur.First;
12258
12259 hash = (ftch_recc32.c32>>16) ^ (ftch_recc32.c32 & 0xFFFF);
12260
12261 STD_ACCUM_HASH2(rpt78, ftch_recc32, ftch_recc32p);
12262
12263 return 0;
12264
12265 } /* ftstat_rpt_78_accum */
12266
12267 /* function: ftstat_rpt_78_calc
12268 *
12269 * Perform final calculations for rpt78
12270 *
12271 * returns allocated struct or 0L for error
12272 */
ftstat_rpt_78_calc(struct ftstat_rpt * rpt)12273 int ftstat_rpt_78_calc(struct ftstat_rpt *rpt)
12274 {
12275
12276 STD_CALC_HASH(ftstat_rpt_78, rpt78, ftchash_rec_c32, ftch_recc32);
12277
12278 } /* ftstat_rpt_78_calc */
12279
12280 /* function: ftstat_rpt_78_dump
12281 *
12282 * Dump data for report.
12283 *
12284 */
ftstat_rpt_78_dump(FILE * fp,struct ftio * ftio,struct ftstat_rpt * rpt)12285 int ftstat_rpt_78_dump(FILE *fp, struct ftio *ftio, struct ftstat_rpt *rpt)
12286 {
12287
12288 STD_DUMP_HASH1(ftstat_rpt_78, rpt78, chash_c32_dump, (char*)0L,
12289 "Duration", "", "", "", "", "", "");
12290
12291 } /* ftstat_rpt_78_dump */
12292
12293
12294 /* function: ftstat_rpt_78_free
12295 *
12296 * Free data structures for report allocated by ftstat_rpt_78_new
12297 *
12298 */
ftstat_rpt_78_free(struct ftstat_rpt_78 * rpt78)12299 void ftstat_rpt_78_free(struct ftstat_rpt_78 *rpt78)
12300 {
12301
12302 STD_FREE_HASH(rpt78);
12303
12304 } /* ftstat_rpt_78_free */
12305
12306 /*
12307 * function: resolve_reports
12308 *
12309 * resolve the dangling pointers to rpts in definitions --
12310 * allows definitions to be defined before reports.
12311 *
12312 * _must_ be called after work done by parse_def_report
12313 *
12314 * returns: 0 ok
12315 * <0 fail
12316 */
resolve_reports(struct ftstat * ftstat)12317 static int resolve_reports(struct ftstat *ftstat)
12318 {
12319 struct ftstat_rpt_item *ftsrpti;
12320 struct ftstat_def *ftsd;
12321 struct ftstat_rpt *ftsrpt;
12322 int found;
12323
12324 /* foreach definition */
12325 FT_SLIST_FOREACH(ftsd, &ftstat->defs, chain) {
12326
12327 /* foreach report in the definition */
12328 FT_STAILQ_FOREACH(ftsrpti, &ftsd->items, chain) {
12329
12330 /* find the report */
12331 found = 0;
12332
12333 FT_SLIST_FOREACH(ftsrpt, &ftstat->rpts, chain) {
12334
12335 if (!strcasecmp(ftsrpti->tmp_report, ftsrpt->name)) {
12336
12337 found = 1;
12338 break;
12339
12340 } /* if */
12341
12342 } /* ftsrpt */
12343
12344 if (!found) {
12345 fterr_warnx(
12346 "Unable to resolve report \"%s\" in stat-definition \"%s\".",
12347 ftsrpti->tmp_report, ftsd->name);
12348 return -1;
12349 } /* !found */
12350
12351 /* report found */
12352 ftsrpti->rpt = ftsrpt;
12353 ftsd->xfields |= ftsrpt->xfields;
12354
12355 } /* ftsrpti */
12356
12357 } /* ftsd */
12358
12359 return 0;
12360
12361 } /* resolve_reports */
12362
dump_ascii_header(FILE * fp,struct ftio * ftio,struct ftstat_def * active_def,struct ftstat_rpt * rpt)12363 static int dump_ascii_header(FILE *fp, struct ftio *ftio,
12364 struct ftstat_def *active_def, struct ftstat_rpt *rpt)
12365 {
12366 int comma, sort_field;
12367 char *buf, fmt_buf[32];
12368 time_t now, time_flow;
12369
12370 /* shortcut */
12371 if (!(rpt->out->options & FT_STAT_OPT_HEADER))
12372 return 0;
12373
12374 if (!active_def->interval) {
12375
12376 fprintf(fp, "# --- ---- ---- Report Information --- --- ---\n");
12377 fprintf(fp, "# build-version: flow-tools %s\n", VERSION);
12378 fprintf(fp, "# name: %s\n", rpt->name);
12379 fprintf(fp, "# type: %s\n", rpt->format_name);
12380 if (rpt->scale)
12381 fprintf(fp, "# scale: %lu\n", (unsigned long)rpt->scale);
12382
12383 if (rpt->out->options) {
12384
12385 fprintf(fp, "# options: ");
12386
12387 comma = 0;
12388
12389 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
12390 fprintf(fp, "+percent-total");
12391 comma=1;
12392 }
12393
12394 if (rpt->out->options & FT_STAT_OPT_NAMES) {
12395 fprintf(fp, "%snames", comma ? ",+" : "+");
12396 comma=1;
12397 }
12398
12399 if (rpt->out->options & FT_STAT_OPT_HEADER) {
12400 fprintf(fp, "%sheader", comma ? ",+" : "+");
12401 comma=1;
12402 }
12403
12404 if (rpt->out->options & FT_STAT_OPT_XHEADER) {
12405 fprintf(fp, "%sxheader", comma ? ",+" : "+");
12406 comma=1;
12407 }
12408
12409 if (rpt->out->options & FT_STAT_OPT_TOTALS) {
12410 fprintf(fp, "%stotals", comma ? ",+" : "+");
12411 comma=1;
12412 }
12413
12414 fprintf(fp, "\n");
12415
12416 } /* options */
12417
12418 if (rpt->xfields & FT_XFIELD_SRCADDR) {
12419
12420 fprintf(fp, "# ip-src-addr-type: ");
12421
12422 if (rpt->options & FT_STAT_OPT_SRC_PREFIX_LEN)
12423 fprintf(fp, "prefix-len\n");
12424 else if (rpt->options & FT_STAT_OPT_SRC_PREFIX_MASK)
12425 fprintf(fp, "prefix-mask\n");
12426 else
12427 fprintf(fp, "address\n");
12428
12429 }
12430
12431 if (rpt->xfields & FT_XFIELD_DSTADDR) {
12432
12433 fprintf(fp, "# ip-dst-addr-type: ");
12434
12435 if (rpt->options & FT_STAT_OPT_DST_PREFIX_LEN)
12436 fprintf(fp, "prefix-len\n");
12437 else if (rpt->options & FT_STAT_OPT_DST_PREFIX_MASK)
12438 fprintf(fp, "prefix-mask\n");
12439 else
12440 fprintf(fp, "address\n");
12441
12442 }
12443
12444
12445 if (rpt->out->options & FT_STAT_OPT_SORT) {
12446
12447 sort_field = rpt->out->sort_field;
12448 if (sort_field < 0)
12449 sort_field *= -1;
12450
12451 if (sort_field & FT_STAT_FIELD_KEY)
12452 buf = "key";
12453 else if (sort_field & FT_STAT_FIELD_KEY1)
12454 buf = "key1";
12455 else if (sort_field & FT_STAT_FIELD_KEY2)
12456 buf = "key2";
12457 else if (sort_field & FT_STAT_FIELD_KEY3)
12458 buf = "key3";
12459 else if (sort_field & FT_STAT_FIELD_KEY4)
12460 buf = "key4";
12461 else if (sort_field & FT_STAT_FIELD_KEY5)
12462 buf = "key5";
12463 else if (sort_field & FT_STAT_FIELD_KEY6)
12464 buf = "key6";
12465 else if (sort_field & FT_STAT_FIELD_FLOWS)
12466 buf = "flows";
12467 else if (sort_field & FT_STAT_FIELD_OCTETS)
12468 buf = "octets";
12469 else if (sort_field & FT_STAT_FIELD_PACKETS)
12470 buf = "packets";
12471 else if (sort_field & FT_STAT_FIELD_DURATION)
12472 buf = "duration";
12473 else if (sort_field & FT_STAT_FIELD_AVG_PPS)
12474 buf = "avg-pps";
12475 else if (sort_field & FT_STAT_FIELD_MIN_PPS)
12476 buf = "min-pps";
12477 else if (sort_field & FT_STAT_FIELD_MAX_PPS)
12478 buf = "max-pps";
12479 else if (sort_field & FT_STAT_FIELD_AVG_BPS)
12480 buf = "avg-bps";
12481 else if (sort_field & FT_STAT_FIELD_MIN_BPS)
12482 buf = "min-bps";
12483 else if (sort_field & FT_STAT_FIELD_MAX_BPS)
12484 buf = "max-bps";
12485 else if (sort_field & FT_STAT_FIELD_OTHER)
12486 buf = "other";
12487 else if (sort_field & FT_STAT_FIELD_COUNT)
12488 buf = "count";
12489 else
12490 buf = "error";
12491
12492 fprintf(fp, "# sort_field: %c%s\n",
12493 (rpt->out->sort_field < 0) ? '-' : '+', buf);
12494
12495 } /* FT_STAT_OPT_SORT */
12496
12497 if (rpt->out->fields) {
12498
12499 fprintf(fp, "# fields: ");
12500
12501 comma = 0;
12502 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
12503 fprintf(fp, "+key");
12504 comma = 1;
12505 }
12506
12507 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
12508 fprintf(fp, "%skey1", comma ? ",+" : "+");
12509 comma = 1;
12510 }
12511
12512 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
12513 fprintf(fp, "%skey2", comma ? ",+" : "+");
12514 comma = 1;
12515 }
12516
12517 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
12518 fprintf(fp, "%skey3", comma ? ",+" : "+");
12519 comma = 1;
12520 }
12521
12522 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
12523 fprintf(fp, "%skey4", comma ? ",+" : "+");
12524 comma = 1;
12525 }
12526
12527 if (rpt->out->fields & FT_STAT_FIELD_KEY5) {
12528 fprintf(fp, "%skey5", comma ? ",+" : "+");
12529 comma = 1;
12530 }
12531
12532 if (rpt->out->fields & FT_STAT_FIELD_KEY6) {
12533 fprintf(fp, "%skey6", comma ? ",+" : "+");
12534 comma = 1;
12535 }
12536
12537 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {
12538 fprintf(fp, "%sflows", comma ? ",+" : "+");
12539 comma = 1;
12540 }
12541
12542 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {
12543 fprintf(fp, "%soctets", comma ? ",+" : "+");
12544 comma = 1;
12545 }
12546
12547 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {
12548 fprintf(fp, "%spackets", comma ? ",+" : "+");
12549 comma = 1;
12550 }
12551
12552 if (rpt->out->fields & FT_STAT_FIELD_DURATION) {
12553 fprintf(fp, "%sduration", comma ? ",+" : "+");
12554 comma = 1;
12555 }
12556
12557 if (rpt->out->fields & FT_STAT_FIELD_AVG_PPS) {
12558 fprintf(fp, "%savg-pps", comma ? ",+" : "+");
12559 comma = 1;
12560 }
12561
12562 if (rpt->out->fields & FT_STAT_FIELD_MIN_PPS) {
12563 fprintf(fp, "%smin-pps", comma ? ",+" : "+");
12564 comma = 1;
12565 }
12566
12567 if (rpt->out->fields & FT_STAT_FIELD_MAX_PPS) {
12568 fprintf(fp, "%smax-pps", comma ? ",+" : "+");
12569 comma = 1;
12570 }
12571
12572 if (rpt->out->fields & FT_STAT_FIELD_AVG_BPS) {
12573 fprintf(fp, "%savg-bps", comma ? ",+" : "+");
12574 comma = 1;
12575 }
12576
12577 if (rpt->out->fields & FT_STAT_FIELD_MIN_BPS) {
12578 fprintf(fp, "%smin-bps", comma ? ",+" : "+");
12579 comma = 1;
12580 }
12581
12582 if (rpt->out->fields & FT_STAT_FIELD_MAX_BPS) {
12583 fprintf(fp, "%smax-bps", comma ? ",+" : "+");
12584 comma = 1;
12585 }
12586
12587 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {
12588 fprintf(fp, "%sfrecs", comma ? ",+" : "+");
12589 comma = 1;
12590 }
12591
12592 if (rpt->out->fields & FT_STAT_FIELD_OTHER) {
12593 fprintf(fp, "%sother", comma ? ",+" : "+");
12594 comma = 1;
12595 }
12596
12597 fprintf(fp, "\n");
12598
12599 } /* rpt->out->fields */
12600
12601 if (rpt->out->options & FT_STAT_OPT_TALLY)
12602 fprintf(fp, "# tally: %lu\n",
12603 (unsigned long)rpt->out->tally);
12604
12605 if (active_def->ftd)
12606 fprintf(fp, "# tag: %s\n", active_def->ftd->name);
12607
12608 if (active_def->ftfd)
12609 fprintf(fp, "# pre-filter: %s\n", active_def->ftfd->name);
12610
12611 if (rpt->ftfd)
12612 fprintf(fp, "# filter: %s\n", rpt->ftfd->name);
12613
12614 } /* !active_def->interval */
12615
12616 fmt_uint64(fmt_buf, rpt->recs, FMT_JUST_LEFT);
12617 fprintf(fp, "# records: %s\n", fmt_buf);
12618
12619 if (rpt->out->records) {
12620 fmt_uint64(fmt_buf, rpt->out->records, FMT_JUST_LEFT);
12621 fprintf(fp, "# records_shown: %s\n", fmt_buf);
12622 }
12623
12624 time_flow = rpt->time_start;
12625 fprintf(fp, "# first-flow: %lu %s",
12626 (unsigned long)rpt->time_start, ctime(&time_flow));
12627
12628 time_flow = rpt->time_end;
12629 fprintf(fp, "# last-flow: %lu %s",
12630 (unsigned long)rpt->time_end, ctime(&time_flow));
12631
12632 now = time((time_t*)0L);
12633
12634 fprintf(fp, "# now: %lu %s", (unsigned long)now,
12635 ctime(&now));
12636
12637 if (active_def->max_time)
12638 fprintf(fp, "# time-series: %lu seconds / interval %lu\n",
12639 (unsigned long)active_def->max_time,
12640 (unsigned long)active_def->interval);
12641
12642 if (!active_def->interval) {
12643
12644 if (rpt->out->options & FT_STAT_OPT_XHEADER)
12645 ftio_header_print(ftio, fp, '#');
12646
12647 } /* !active_def->interval */
12648
12649 return 0;
12650
12651 } /* dump_ascii_header */
12652
chash_c32_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1)12653 static int chash_c32_dump(FILE *fp, struct ftstat_rpt *rpt,
12654 struct ftchash *ftch, const char *sym1)
12655 {
12656 struct ftsym *ftsym1;
12657
12658 CHASH_DUMP_INIT(ftchash_rec_c32, ftch_recc32);
12659
12660 ftsym1 = (struct ftsym*)0L;
12661
12662 if (rpt->out->options & FT_STAT_OPT_NAMES)
12663 ftsym1 = ftsym_new(sym1);
12664
12665 if (rpt->out->options & FT_STAT_OPT_SORT) {
12666
12667 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
12668 sort_flags = FT_CHASH_SORT_ASCENDING;
12669 else
12670 sort_flags = 0;
12671
12672 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
12673 sort_offset = offsetof(struct ftchash_rec_c32, c32);
12674 sort_flags |= FT_CHASH_SORT_32;
12675 } else
12676
12677 CHASH_DUMP_STD_SORT(ftchash_rec_c32);
12678
12679 ftchash_sort(ftch, sort_offset, sort_flags);
12680
12681 } /* FT_STAT_OPT_SORT */
12682
12683 ftchash_first(ftch);
12684
12685 while ((ftch_recc32 = ftchash_foreach(ftch))) {
12686
12687 len = comma = 0;
12688
12689 DUMP_STD_OUT();
12690
12691 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
12692 if (comma) fmt_buf[len++] = ',';
12693 len += fmt_uint32s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recc32->c32,
12694 FMT_JUST_LEFT);
12695 comma = 1;
12696 }
12697
12698 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
12699
12700 CHASH_STDP_OUT(ftch_recc32, comma);
12701
12702 } else {
12703
12704 CHASH_STD_OUT(ftch_recc32, comma);
12705
12706 }
12707
12708 }
12709
12710 if (ftsym1)
12711 ftsym_free(ftsym1);
12712
12713 return 0;
12714
12715 } /* chash_c32_dump */
12716
chash_c322_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2)12717 static int chash_c322_dump(FILE *fp, struct ftstat_rpt *rpt,
12718 struct ftchash *ftch, const char *sym1, const char *sym2)
12719 {
12720 struct ftsym *ftsym1, *ftsym2;
12721
12722 CHASH_DUMP_INIT(ftchash_rec_c322, ftch_recc322);
12723
12724 ftsym1 = ftsym2 = (struct ftsym*)0L;
12725
12726 if (rpt->out->options & FT_STAT_OPT_NAMES) {
12727 ftsym1 = ftsym_new(sym1);
12728 ftsym2 = ftsym_new(sym2);
12729 }
12730
12731 if (rpt->out->options & FT_STAT_OPT_SORT) {
12732
12733 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
12734 sort_flags = FT_CHASH_SORT_ASCENDING;
12735 else
12736 sort_flags = 0;
12737
12738 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
12739 sort_offset = offsetof(struct ftchash_rec_c322, c32a);
12740 sort_flags |= FT_CHASH_SORT_32;
12741 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
12742 sort_offset = offsetof(struct ftchash_rec_c322, c32b);
12743 sort_flags |= FT_CHASH_SORT_32;
12744 } else
12745
12746 CHASH_DUMP_STD_SORT(ftchash_rec_c322);
12747
12748 ftchash_sort(ftch, sort_offset, sort_flags);
12749
12750 } /* FT_STAT_OPT_SORT */
12751
12752 ftchash_first(ftch);
12753
12754 while ((ftch_recc322 = ftchash_foreach(ftch))) {
12755
12756 len = comma = 0;
12757
12758 DUMP_STD_OUT();
12759
12760 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
12761 if (comma) fmt_buf[len++] = ',';
12762 len += fmt_uint32s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recc322->c32a,
12763 FMT_JUST_LEFT);
12764 comma = 1;
12765 }
12766
12767 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
12768 if (comma) fmt_buf[len++] = ',';
12769 len += fmt_uint32s(ftsym2, FMT_SYM_LEN, fmt_buf+len, ftch_recc322->c32b,
12770 FMT_JUST_LEFT);
12771 comma = 1;
12772 }
12773
12774 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
12775
12776 CHASH_STDP_OUT(ftch_recc322, comma);
12777
12778 } else {
12779
12780 CHASH_STD_OUT(ftch_recc322, comma);
12781
12782 }
12783
12784 }
12785
12786 if (ftsym1)
12787 ftsym_free(ftsym1);
12788
12789 if (ftsym2)
12790 ftsym_free(ftsym2);
12791
12792 return 0;
12793
12794 } /* chash_c322_dump */
12795
chash_c162_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2)12796 static int chash_c162_dump(FILE *fp, struct ftstat_rpt *rpt,
12797 struct ftchash *ftch, const char *sym1, const char *sym2)
12798 {
12799 struct ftsym *ftsym1, *ftsym2;
12800
12801 CHASH_DUMP_INIT(ftchash_rec_c162, ftch_recc162);
12802
12803 ftsym1 = ftsym2 = (struct ftsym*)0L;
12804
12805 if (rpt->out->options & FT_STAT_OPT_NAMES) {
12806 ftsym1 = ftsym_new(sym1);
12807 ftsym2 = ftsym_new(sym2);
12808 }
12809
12810 if (rpt->out->options & FT_STAT_OPT_SORT) {
12811
12812 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
12813 sort_flags = FT_CHASH_SORT_ASCENDING;
12814 else
12815 sort_flags = 0;
12816
12817 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
12818 sort_offset = offsetof(struct ftchash_rec_c162, c16a);
12819 sort_flags |= FT_CHASH_SORT_16;
12820 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
12821 sort_offset = offsetof(struct ftchash_rec_c162, c16b);
12822 sort_flags |= FT_CHASH_SORT_16;
12823 } else
12824
12825 CHASH_DUMP_STD_SORT(ftchash_rec_c162);
12826
12827 ftchash_sort(ftch, sort_offset, sort_flags);
12828
12829 } /* FT_STAT_OPT_SORT */
12830
12831 ftchash_first(ftch);
12832
12833 while ((ftch_recc162 = ftchash_foreach(ftch))) {
12834
12835 len = comma = 0;
12836
12837 DUMP_STD_OUT()
12838
12839 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
12840 if (comma) fmt_buf[len++] = ',';
12841 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recc162->c16a,
12842 FMT_JUST_LEFT);
12843 comma = 1;
12844 }
12845
12846 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
12847 if (comma) fmt_buf[len++] = ',';
12848 len += fmt_uint16s(ftsym2, FMT_SYM_LEN, fmt_buf+len, ftch_recc162->c16b,
12849 FMT_JUST_LEFT);
12850 comma = 1;
12851 }
12852
12853 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
12854
12855 CHASH_STDP_OUT(ftch_recc162, comma);
12856
12857 } else {
12858
12859 CHASH_STD_OUT(ftch_recc162, comma);
12860
12861 }
12862
12863 }
12864
12865 if (ftsym1)
12866 ftsym_free(ftsym1);
12867
12868 if (ftsym2)
12869 ftsym_free(ftsym2);
12870
12871 return 0;
12872
12873 } /* chash_c162_dump */
12874
chash_c163_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2,const char * sym3)12875 static int chash_c163_dump(FILE *fp, struct ftstat_rpt *rpt,
12876 struct ftchash *ftch, const char *sym1, const char *sym2, const char *sym3)
12877 {
12878 struct ftsym *ftsym1, *ftsym2, *ftsym3;
12879
12880 CHASH_DUMP_INIT(ftchash_rec_c163, ftch_recc163);
12881
12882 ftsym1 = ftsym2 = ftsym3 = (struct ftsym*)0L;
12883
12884 if (rpt->out->options & FT_STAT_OPT_NAMES) {
12885 ftsym1 = ftsym_new(sym1);
12886 ftsym2 = ftsym_new(sym2);
12887 ftsym3 = ftsym_new(sym3);
12888 }
12889
12890 if (rpt->out->options & FT_STAT_OPT_SORT) {
12891
12892 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
12893 sort_flags = FT_CHASH_SORT_ASCENDING;
12894 else
12895 sort_flags = 0;
12896
12897 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
12898 sort_offset = offsetof(struct ftchash_rec_c163, c16a);
12899 sort_flags |= FT_CHASH_SORT_16;
12900 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
12901 sort_offset = offsetof(struct ftchash_rec_c163, c16b);
12902 sort_flags |= FT_CHASH_SORT_16;
12903 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
12904 sort_offset = offsetof(struct ftchash_rec_c163, c16c);
12905 sort_flags |= FT_CHASH_SORT_16;
12906 } else
12907
12908 CHASH_DUMP_STD_SORT(ftchash_rec_c163);
12909
12910 ftchash_sort(ftch, sort_offset, sort_flags);
12911
12912 } /* FT_STAT_OPT_SORT */
12913
12914 ftchash_first(ftch);
12915
12916 while ((ftch_recc163 = ftchash_foreach(ftch))) {
12917
12918 len = comma = 0;
12919
12920 DUMP_STD_OUT()
12921
12922 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
12923 if (comma) fmt_buf[len++] = ',';
12924 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recc163->c16a,
12925 FMT_JUST_LEFT);
12926 comma = 1;
12927 }
12928
12929 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
12930 if (comma) fmt_buf[len++] = ',';
12931 len += fmt_uint16s(ftsym2, FMT_SYM_LEN, fmt_buf+len, ftch_recc163->c16b,
12932 FMT_JUST_LEFT);
12933 comma = 1;
12934 }
12935
12936 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
12937 if (comma) fmt_buf[len++] = ',';
12938 len += fmt_uint16s(ftsym3, FMT_SYM_LEN, fmt_buf+len, ftch_recc163->c16c,
12939 FMT_JUST_LEFT);
12940 comma = 1;
12941 }
12942
12943 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
12944
12945 CHASH_STDP_OUT(ftch_recc163, comma);
12946
12947 } else {
12948
12949 CHASH_STD_OUT(ftch_recc163, comma);
12950
12951 }
12952
12953 }
12954
12955 if (ftsym1)
12956 ftsym_free(ftsym1);
12957
12958 if (ftsym2)
12959 ftsym_free(ftsym2);
12960
12961 if (ftsym3)
12962 ftsym_free(ftsym3);
12963
12964 return 0;
12965
12966 } /* chash_c163_dump */
12967
chash_c164_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2,const char * sym3,const char * sym4)12968 static int chash_c164_dump(FILE *fp, struct ftstat_rpt *rpt,
12969 struct ftchash *ftch, const char *sym1, const char *sym2, const char *sym3, const char *sym4)
12970 {
12971 struct ftsym *ftsym1, *ftsym2, *ftsym3, *ftsym4;
12972
12973 CHASH_DUMP_INIT(ftchash_rec_c164, ftch_recc164);
12974
12975 ftsym1 = ftsym2 = ftsym3 = ftsym4 = (struct ftsym*)0L;
12976
12977 if (rpt->out->options & FT_STAT_OPT_NAMES) {
12978 ftsym1 = ftsym_new(sym1);
12979 ftsym2 = ftsym_new(sym2);
12980 ftsym3 = ftsym_new(sym3);
12981 ftsym4 = ftsym_new(sym4);
12982 }
12983
12984 if (rpt->out->options & FT_STAT_OPT_SORT) {
12985
12986 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
12987 sort_flags = FT_CHASH_SORT_ASCENDING;
12988 else
12989 sort_flags = 0;
12990
12991 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
12992 sort_offset = offsetof(struct ftchash_rec_c164, c16a);
12993 sort_flags |= FT_CHASH_SORT_16;
12994 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
12995 sort_offset = offsetof(struct ftchash_rec_c164, c16b);
12996 sort_flags |= FT_CHASH_SORT_16;
12997 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
12998 sort_offset = offsetof(struct ftchash_rec_c164, c16c);
12999 sort_flags |= FT_CHASH_SORT_16;
13000 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY4) {
13001 sort_offset = offsetof(struct ftchash_rec_c164, c16d);
13002 sort_flags |= FT_CHASH_SORT_16;
13003 } else
13004
13005 CHASH_DUMP_STD_SORT(ftchash_rec_c164);
13006
13007 ftchash_sort(ftch, sort_offset, sort_flags);
13008
13009 } /* FT_STAT_OPT_SORT */
13010
13011 ftchash_first(ftch);
13012
13013 while ((ftch_recc164 = ftchash_foreach(ftch))) {
13014
13015 len = comma = 0;
13016
13017 DUMP_STD_OUT();
13018
13019 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13020 if (comma) fmt_buf[len++] = ',';
13021 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recc164->c16a,
13022 FMT_JUST_LEFT);
13023 comma = 1;
13024 }
13025
13026 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13027 if (comma) fmt_buf[len++] = ',';
13028 len += fmt_uint16s(ftsym2, FMT_SYM_LEN, fmt_buf+len, ftch_recc164->c16b,
13029 FMT_JUST_LEFT);
13030 comma = 1;
13031 }
13032
13033 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
13034 if (comma) fmt_buf[len++] = ',';
13035 len += fmt_uint16s(ftsym3, FMT_SYM_LEN, fmt_buf+len, ftch_recc164->c16c,
13036 FMT_JUST_LEFT);
13037 comma = 1;
13038 }
13039
13040 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
13041 if (comma) fmt_buf[len++] = ',';
13042 len += fmt_uint16s(ftsym4, FMT_SYM_LEN, fmt_buf+len, ftch_recc164->c16d,
13043 FMT_JUST_LEFT);
13044 comma = 1;
13045 }
13046
13047 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13048
13049 CHASH_STDP_OUT(ftch_recc164, comma);
13050
13051 } else {
13052
13053 CHASH_STD_OUT(ftch_recc164, comma);
13054
13055 }
13056
13057 }
13058
13059 if (ftsym1)
13060 ftsym_free(ftsym1);
13061
13062 if (ftsym2)
13063 ftsym_free(ftsym2);
13064
13065 if (ftsym3)
13066 ftsym_free(ftsym3);
13067
13068 if (ftsym4)
13069 ftsym_free(ftsym4);
13070
13071
13072 return 0;
13073
13074 } /* chash_c163_dump */
13075
13076
13077
chash_ip_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch)13078 static int chash_ip_dump(FILE *fp, struct ftstat_rpt *rpt,
13079 struct ftchash *ftch)
13080 {
13081
13082 CHASH_DUMP_INIT(ftchash_rec_c32, ftch_recc32);
13083
13084 if (rpt->out->options & FT_STAT_OPT_SORT) {
13085
13086 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13087 sort_flags = FT_CHASH_SORT_ASCENDING;
13088 else
13089 sort_flags = 0;
13090
13091 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
13092 sort_offset = offsetof(struct ftchash_rec_c32, c32);
13093 sort_flags |= FT_CHASH_SORT_32;
13094 } else
13095
13096 CHASH_DUMP_STD_SORT(ftchash_rec_c32);
13097
13098 ftchash_sort(ftch, sort_offset, sort_flags);
13099
13100 } /* FT_STAT_OPT_SORT */
13101
13102 ftchash_first(ftch);
13103
13104 while ((ftch_recc32 = ftchash_foreach(ftch))) {
13105
13106 len = comma = 0;
13107
13108 DUMP_STD_OUT();
13109
13110 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
13111 if (comma) fmt_buf[len++] = ',';
13112 len += fmt_ipv4s(fmt_buf+len, ftch_recc32->c32, 64, fmt);
13113 comma = 1;
13114 }
13115
13116 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13117
13118 CHASH_STDP_OUT(ftch_recc32, comma);
13119
13120 } else {
13121
13122 CHASH_STD_OUT(ftch_recc32, comma);
13123
13124 }
13125
13126 }
13127
13128 return 0;
13129
13130 } /* chash_ip_dump */
13131
chash_prefix_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,int f1)13132 static int chash_prefix_dump(FILE *fp, struct ftstat_rpt *rpt,
13133 struct ftchash *ftch, int f1)
13134 {
13135
13136 CHASH_DUMP_INIT(ftchash_rec_prefix, ftch_recprefix);
13137
13138 if (rpt->out->options & FT_STAT_OPT_SORT) {
13139
13140 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13141 sort_flags = FT_CHASH_SORT_ASCENDING;
13142 else
13143 sort_flags = 0;
13144
13145 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
13146 sort_offset = offsetof(struct ftchash_rec_prefix, prefix);
13147 sort_flags |= FT_CHASH_SORT_40;
13148 } else
13149
13150 CHASH_DUMP_STD_SORT(ftchash_rec_prefix);
13151
13152 ftchash_sort(ftch, sort_offset, sort_flags);
13153
13154 } /* FT_STAT_OPT_SORT */
13155
13156 ftchash_first(ftch);
13157
13158 while ((ftch_recprefix = ftchash_foreach(ftch))) {
13159
13160 len = comma = 0;
13161
13162 DUMP_STD_OUT();
13163
13164 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
13165 if (comma) fmt_buf[len++] = ',';
13166 if (rpt->options & f1)
13167 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix->prefix,
13168 ftch_recprefix->mask, 64, fmt);
13169 else
13170 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix->prefix, 64, fmt);
13171 comma = 1;
13172 }
13173
13174 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13175
13176 CHASH_STDP_OUT(ftch_recprefix, comma);
13177
13178 } else {
13179
13180 CHASH_STD_OUT(ftch_recprefix, comma);
13181
13182 }
13183
13184 }
13185
13186 return 0;
13187
13188 } /* chash_prefix_dump */
13189
chash_prefix_tag_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,int f1)13190 static int chash_prefix_tag_dump(FILE *fp, struct ftstat_rpt *rpt,
13191 struct ftchash *ftch, const char *sym1, int f1)
13192 {
13193 struct ftsym *ftsym1;
13194
13195 CHASH_DUMP_INIT(ftchash_rec_prefix_tag, ftch_recprefix_tag);
13196
13197 ftsym1 = (struct ftsym*)0L;
13198
13199 if (rpt->out->options & FT_STAT_OPT_NAMES)
13200 ftsym1 = ftsym_new(sym1);
13201
13202 if (rpt->out->options & FT_STAT_OPT_SORT) {
13203
13204 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13205 sort_flags = FT_CHASH_SORT_ASCENDING;
13206 else
13207 sort_flags = 0;
13208
13209 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13210 sort_offset = offsetof(struct ftchash_rec_prefix_tag, prefix);
13211 sort_flags |= FT_CHASH_SORT_40;
13212 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13213 sort_offset = offsetof(struct ftchash_rec_prefix_tag, tag);
13214 sort_flags |= FT_CHASH_SORT_32;
13215 } else
13216
13217 CHASH_DUMP_STD_SORT(ftchash_rec_prefix_tag);
13218
13219 ftchash_sort(ftch, sort_offset, sort_flags);
13220
13221 } /* FT_STAT_OPT_SORT */
13222
13223 ftchash_first(ftch);
13224
13225 while ((ftch_recprefix_tag = ftchash_foreach(ftch))) {
13226
13227 len = comma = 0;
13228
13229 DUMP_STD_OUT();
13230
13231 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13232 if (comma) fmt_buf[len++] = ',';
13233 if (rpt->options & f1)
13234 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix_tag->prefix,
13235 ftch_recprefix_tag->mask, 64, fmt);
13236 else
13237 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix_tag->prefix, 64, fmt);
13238 comma = 1;
13239 }
13240
13241 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13242 if (comma) fmt_buf[len++] = ',';
13243 len += fmt_uint32s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13244 ftch_recprefix_tag->tag, FMT_JUST_LEFT);
13245 comma = 1;
13246 }
13247
13248 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13249
13250 CHASH_STDP_OUT(ftch_recprefix_tag, comma);
13251
13252 } else {
13253
13254 CHASH_STD_OUT(ftch_recprefix_tag, comma);
13255
13256 }
13257
13258 }
13259
13260 if (ftsym1)
13261 ftsym_free(ftsym1);
13262
13263 return 0;
13264
13265 } /* chash_prefix_tag_dump */
13266
chash_prefix2tag2_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1)13267 static int chash_prefix2tag2_dump(FILE *fp, struct ftstat_rpt *rpt,
13268 struct ftchash *ftch, const char *sym1)
13269 {
13270 struct ftsym *ftsym1;
13271
13272 CHASH_DUMP_INIT(ftchash_rec_prefix2tag2, ftch_recprefix2tag2);
13273
13274 ftsym1 = (struct ftsym*)0L;
13275
13276 if (rpt->out->options & FT_STAT_OPT_NAMES)
13277 ftsym1 = ftsym_new(sym1);
13278
13279 if (rpt->out->options & FT_STAT_OPT_SORT) {
13280
13281 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13282 sort_flags = FT_CHASH_SORT_ASCENDING;
13283 else
13284 sort_flags = 0;
13285
13286 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13287 sort_offset = offsetof(struct ftchash_rec_prefix2tag2, src_prefix);
13288 sort_flags |= FT_CHASH_SORT_40;
13289 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13290 sort_offset = offsetof(struct ftchash_rec_prefix2tag2, dst_prefix);
13291 sort_flags |= FT_CHASH_SORT_40;
13292 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
13293 sort_offset = offsetof(struct ftchash_rec_prefix2tag2, src_tag);
13294 sort_flags |= FT_CHASH_SORT_32;
13295 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY4) {
13296 sort_offset = offsetof(struct ftchash_rec_prefix2tag2, dst_tag);
13297 sort_flags |= FT_CHASH_SORT_32;
13298 } else
13299
13300 CHASH_DUMP_STD_SORT(ftchash_rec_prefix2tag2);
13301
13302 ftchash_sort(ftch, sort_offset, sort_flags);
13303
13304 } /* FT_STAT_OPT_SORT */
13305
13306 ftchash_first(ftch);
13307
13308 while ((ftch_recprefix2tag2 = ftchash_foreach(ftch))) {
13309
13310 len = comma = 0;
13311
13312 DUMP_STD_OUT();
13313
13314 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13315 if (comma) fmt_buf[len++] = ',';
13316 if (rpt->options &
13317 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
13318 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2tag2->src_prefix,
13319 ftch_recprefix2tag2->src_mask, 64, fmt);
13320 else
13321 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2tag2->src_prefix,
13322 64, fmt);
13323 comma = 1;
13324 }
13325
13326 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13327 if (comma) fmt_buf[len++] = ',';
13328 if (rpt->options &
13329 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
13330 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2tag2->dst_prefix,
13331 ftch_recprefix2tag2->dst_mask, 64, fmt);
13332 else
13333 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2tag2->dst_prefix,
13334 64, fmt);
13335 comma = 1;
13336 }
13337
13338 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
13339 if (comma) fmt_buf[len++] = ',';
13340 len += fmt_uint32s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13341 ftch_recprefix2tag2->src_tag, FMT_JUST_LEFT);
13342 comma = 1;
13343 }
13344
13345 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
13346 if (comma) fmt_buf[len++] = ',';
13347 len += fmt_uint32s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13348 ftch_recprefix2tag2->dst_tag, FMT_JUST_LEFT);
13349 comma = 1;
13350 }
13351
13352 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13353
13354 CHASH_STDP_OUT(ftch_recprefix2tag2, comma);
13355
13356 } else {
13357
13358 CHASH_STD_OUT(ftch_recprefix2tag2, comma);
13359
13360 }
13361
13362 }
13363
13364 if (ftsym1)
13365 ftsym_free(ftsym1);
13366
13367 return 0;
13368
13369 } /* chash_prefix2tag2_dump */
13370
13371
13372
chash_prefixh_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,int f1)13373 static int chash_prefixh_dump(FILE *fp, struct ftstat_rpt *rpt,
13374 struct ftchash *ftch, int f1)
13375 {
13376
13377 CHASH_DUMP_INIT(ftchash_rec_prefixh, ftch_recprefixh);
13378
13379 if (rpt->out->options & FT_STAT_OPT_SORT) {
13380
13381 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13382 sort_flags = FT_CHASH_SORT_ASCENDING;
13383 else
13384 sort_flags = 0;
13385
13386 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
13387 sort_offset = offsetof(struct ftchash_rec_prefixh, prefix);
13388 sort_flags |= FT_CHASH_SORT_40;
13389 } else if (rpt->out->sort_field == FT_STAT_FIELD_COUNT) {
13390 sort_offset = offsetof(struct ftchash_rec_prefixh, nprefixes);
13391 sort_flags |= FT_CHASH_SORT_64;
13392 } else
13393
13394 CHASH_DUMP_STD_SORT(ftchash_rec_prefixh);
13395
13396 ftchash_sort(ftch, sort_offset, sort_flags);
13397
13398 } /* FT_STAT_OPT_SORT */
13399
13400 ftchash_first(ftch);
13401
13402 while ((ftch_recprefixh = ftchash_foreach(ftch))) {
13403
13404 len = comma = 0;
13405
13406 DUMP_STD_OUT();
13407
13408 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
13409 if (comma) fmt_buf[len++] = ',';
13410 if (rpt->options & f1)
13411 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefixh->prefix,
13412 ftch_recprefixh->mask, 64, fmt);
13413 else
13414 len += fmt_ipv4s(fmt_buf+len, ftch_recprefixh->prefix, 64, fmt);
13415 comma = 1;
13416 }
13417
13418 if (rpt->out->fields & FT_STAT_FIELD_COUNT) {
13419
13420 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13421
13422 if (comma) fmt_buf[len++] = ',';
13423 len += sprintf(fmt_buf+len, "%f",
13424 ((double)ftch_recprefixh->nprefixes / rpt->t_count)*100.0);
13425 comma = 1;
13426
13427 } else {
13428
13429 if (comma) fmt_buf[len++] = ',';
13430 len += fmt_uint64(fmt_buf+len, ftch_recprefixh->nprefixes,
13431 FMT_JUST_LEFT);
13432 comma = 1;
13433
13434 }
13435 }
13436
13437 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13438
13439 CHASH_STDP_OUT(ftch_recprefixh, comma);
13440
13441 } else {
13442
13443 CHASH_STD_OUT(ftch_recprefixh, comma);
13444
13445 }
13446
13447 }
13448
13449 return 0;
13450
13451 } /* chash_prefixh_dump */
13452
chash_prefix2_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch)13453 static int chash_prefix2_dump(FILE *fp, struct ftstat_rpt *rpt,
13454 struct ftchash *ftch)
13455 {
13456
13457 CHASH_DUMP_INIT(ftchash_rec_prefix2, ftch_recprefix2);
13458
13459 if (rpt->out->options & FT_STAT_OPT_SORT) {
13460
13461 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13462 sort_flags = FT_CHASH_SORT_ASCENDING;
13463 else
13464 sort_flags = 0;
13465
13466 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13467 sort_offset = offsetof(struct ftchash_rec_prefix2, src_prefix);
13468 sort_flags |= FT_CHASH_SORT_40;
13469 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13470 sort_offset = offsetof(struct ftchash_rec_prefix2, dst_prefix);
13471 sort_flags |= FT_CHASH_SORT_40;
13472 } else
13473
13474 CHASH_DUMP_STD_SORT(ftchash_rec_prefix2);
13475
13476 ftchash_sort(ftch, sort_offset, sort_flags);
13477
13478 } /* FT_STAT_OPT_SORT */
13479
13480 ftchash_first(ftch);
13481
13482 while ((ftch_recprefix2 = ftchash_foreach(ftch))) {
13483
13484 len = comma = 0;
13485
13486 DUMP_STD_OUT();
13487
13488 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13489 if (comma) fmt_buf[len++] = ',';
13490 if (rpt->options &
13491 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
13492 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2->src_prefix,
13493 ftch_recprefix2->src_mask, 64, fmt);
13494 else
13495 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2->src_prefix, 64, fmt);
13496 comma = 1;
13497 }
13498
13499 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13500 if (comma)
13501 fmt_buf[len++] = ',';
13502 if (rpt->options &
13503 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
13504 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2->dst_prefix,
13505 ftch_recprefix2->dst_mask, 64, fmt);
13506 else
13507 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2->dst_prefix, 64, fmt);
13508 comma = 1;
13509 }
13510
13511 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13512
13513 CHASH_STDP_OUT(ftch_recprefix2, comma);
13514
13515 } else {
13516
13517 CHASH_STD_OUT(ftch_recprefix2, comma);
13518
13519 }
13520
13521 }
13522
13523 return 0;
13524
13525 } /* chash_prefix2_dump */
13526
chash_prefix16_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,int f1)13527 static int chash_prefix16_dump(FILE *fp, struct ftstat_rpt *rpt,
13528 struct ftchash *ftch, const char *sym1, int f1)
13529 {
13530 struct ftsym *ftsym1;
13531
13532 CHASH_DUMP_INIT(ftchash_rec_prefix16, ftch_recprefix16);
13533
13534 ftsym1 = (struct ftsym*)0L;
13535
13536 if (rpt->out->options & FT_STAT_OPT_NAMES)
13537 ftsym1 = ftsym_new(sym1);
13538
13539 if (rpt->out->options & FT_STAT_OPT_SORT) {
13540
13541 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13542 sort_flags = FT_CHASH_SORT_ASCENDING;
13543 else
13544 sort_flags = 0;
13545
13546 if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13547 sort_offset = offsetof(struct ftchash_rec_prefix16, c16);
13548 sort_flags |= FT_CHASH_SORT_16;
13549 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13550 sort_offset = offsetof(struct ftchash_rec_prefix16, prefix);
13551 sort_flags |= FT_CHASH_SORT_40;
13552 } else
13553
13554 CHASH_DUMP_STD_SORT(ftchash_rec_prefix16);
13555
13556 ftchash_sort(ftch, sort_offset, sort_flags);
13557
13558 } /* FT_STAT_OPT_SORT */
13559
13560 ftchash_first(ftch);
13561
13562 while ((ftch_recprefix16 = ftchash_foreach(ftch))) {
13563
13564 len = comma = 0;
13565
13566 DUMP_STD_OUT();
13567
13568 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13569 if (comma) fmt_buf[len++] = ',';
13570 if (rpt->options & f1)
13571 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix16->prefix,
13572 ftch_recprefix16->mask, 64, fmt);
13573 else
13574 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix16->prefix, 64, fmt);
13575 comma = 1;
13576 }
13577
13578 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13579 if (comma) fmt_buf[len++] = ',';
13580 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13581 ftch_recprefix16->c16, FMT_JUST_LEFT);
13582 comma = 1;
13583 }
13584
13585 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13586
13587 CHASH_STDP_OUT(ftch_recprefix16, comma);
13588
13589 } else {
13590
13591 CHASH_STD_OUT(ftch_recprefix16, comma);
13592
13593 }
13594
13595 }
13596
13597 if (ftsym1)
13598 ftsym_free(ftsym1);
13599
13600 return 0;
13601
13602 } /* chash_prefix16_dump */
13603
chash_prefix162_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2,int f1)13604 static int chash_prefix162_dump(FILE *fp, struct ftstat_rpt *rpt,
13605 struct ftchash *ftch, const char *sym1, const char *sym2, int f1)
13606 {
13607 struct ftsym *ftsym1, *ftsym2;
13608
13609 CHASH_DUMP_INIT(ftchash_rec_prefix162, ftch_recprefix162);
13610
13611 ftsym1 = ftsym2 = (struct ftsym*)0L;
13612
13613 if (rpt->out->options & FT_STAT_OPT_NAMES) {
13614 ftsym1 = ftsym_new(sym1);
13615 ftsym2 = ftsym_new(sym2);
13616 }
13617
13618 if (rpt->out->options & FT_STAT_OPT_SORT) {
13619
13620 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13621 sort_flags = FT_CHASH_SORT_ASCENDING;
13622 else
13623 sort_flags = 0;
13624
13625 if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
13626 sort_offset = offsetof(struct ftchash_rec_prefix162, c16b);
13627 sort_flags |= FT_CHASH_SORT_16;
13628 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13629 sort_offset = offsetof(struct ftchash_rec_prefix162, c16a);
13630 sort_flags |= FT_CHASH_SORT_16;
13631 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13632 sort_offset = offsetof(struct ftchash_rec_prefix162, prefix);
13633 sort_flags |= FT_CHASH_SORT_40;
13634 } else
13635
13636 CHASH_DUMP_STD_SORT(ftchash_rec_prefix162);
13637
13638 ftchash_sort(ftch, sort_offset, sort_flags);
13639
13640 } /* FT_STAT_OPT_SORT */
13641
13642 ftchash_first(ftch);
13643
13644 while ((ftch_recprefix162 = ftchash_foreach(ftch))) {
13645
13646 len = comma = 0;
13647
13648 DUMP_STD_OUT();
13649
13650 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13651 if (comma) fmt_buf[len++] = ',';
13652 if (rpt->options & f1)
13653 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix162->prefix,
13654 ftch_recprefix162->mask, 64, fmt);
13655 else
13656 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix162->prefix, 64, fmt);
13657 comma = 1;
13658 }
13659
13660 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13661 if (comma) fmt_buf[len++] = ',';
13662 len += fmt_uint16s(ftsym2, FMT_SYM_LEN, fmt_buf+len,
13663 ftch_recprefix162->c16a, FMT_JUST_LEFT);
13664 comma = 1;
13665 }
13666
13667
13668 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
13669 if (comma) fmt_buf[len++] = ',';
13670 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13671 ftch_recprefix162->c16b, FMT_JUST_LEFT);
13672 comma = 1;
13673 }
13674
13675
13676 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13677
13678 CHASH_STDP_OUT(ftch_recprefix162, comma);
13679
13680 } else {
13681
13682 CHASH_STD_OUT(ftch_recprefix162, comma);
13683
13684 }
13685
13686 }
13687
13688 if (ftsym1)
13689 ftsym_free(ftsym1);
13690
13691 if (ftsym2)
13692 ftsym_free(ftsym2);
13693
13694 return 0;
13695
13696 } /* chash_prefix162_dump */
13697
13698
13699
chash_prefix216_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1)13700 static int chash_prefix216_dump(FILE *fp, struct ftstat_rpt *rpt,
13701 struct ftchash *ftch, const char *sym1)
13702 {
13703 struct ftsym *ftsym1;
13704
13705 CHASH_DUMP_INIT(ftchash_rec_prefix216, ftch_recprefix216);
13706
13707 ftsym1 = (struct ftsym*)0L;
13708
13709 if (rpt->out->options & FT_STAT_OPT_NAMES)
13710 ftsym1 = ftsym_new(sym1);
13711
13712 if (rpt->out->options & FT_STAT_OPT_SORT) {
13713
13714 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13715 sort_flags = FT_CHASH_SORT_ASCENDING;
13716 else
13717 sort_flags = 0;
13718
13719 if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
13720 sort_offset = offsetof(struct ftchash_rec_prefix216, c16);
13721 sort_flags |= FT_CHASH_SORT_16;
13722 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13723 sort_offset = offsetof(struct ftchash_rec_prefix216, src_prefix);
13724 sort_flags |= FT_CHASH_SORT_40;
13725 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13726 sort_offset = offsetof(struct ftchash_rec_prefix216, dst_prefix);
13727 sort_flags |= FT_CHASH_SORT_40;
13728 } else
13729
13730 CHASH_DUMP_STD_SORT(ftchash_rec_prefix216);
13731
13732 ftchash_sort(ftch, sort_offset, sort_flags);
13733
13734 } /* FT_STAT_OPT_SORT */
13735
13736 ftchash_first(ftch);
13737
13738 while ((ftch_recprefix216 = ftchash_foreach(ftch))) {
13739
13740 len = comma = 0;
13741
13742 DUMP_STD_OUT();
13743
13744 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13745 if (comma) fmt_buf[len++] = ',';
13746 if (rpt->options &
13747 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
13748 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix216->src_prefix,
13749 ftch_recprefix216->src_mask, 64, fmt);
13750 else
13751 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix216->src_prefix, 64, fmt);
13752 comma = 1;
13753 }
13754
13755 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13756 if (comma) fmt_buf[len++] = ',';
13757 if (rpt->options &
13758 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
13759 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix216->dst_prefix,
13760 ftch_recprefix216->dst_mask, 64, fmt);
13761 else
13762 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix216->dst_prefix,
13763 64, fmt);
13764 comma = 1;
13765 }
13766
13767 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
13768 if (comma) fmt_buf[len++] = ',';
13769 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13770 ftch_recprefix216->c16, FMT_JUST_LEFT);
13771 comma = 1;
13772 }
13773
13774 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13775
13776 CHASH_STDP_OUT(ftch_recprefix216, comma);
13777
13778 } else {
13779
13780 CHASH_STD_OUT(ftch_recprefix216, comma);
13781
13782 }
13783
13784 }
13785
13786 if (ftsym1)
13787 ftsym_free(ftsym1);
13788
13789 return 0;
13790
13791 } /* chash_prefix216_dump */
13792
chash_prefix2162_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2)13793 static int chash_prefix2162_dump(FILE *fp, struct ftstat_rpt *rpt,
13794 struct ftchash *ftch, const char *sym1, const char *sym2)
13795 {
13796 struct ftsym *ftsym1, *ftsym2;
13797
13798 CHASH_DUMP_INIT(ftchash_rec_prefix2162, ftch_recprefix2162);
13799
13800 ftsym1 = ftsym2 = (struct ftsym*)0L;
13801
13802 if (rpt->out->options & FT_STAT_OPT_NAMES) {
13803 ftsym1 = ftsym_new(sym1);
13804 ftsym2 = ftsym_new(sym2);
13805 }
13806
13807 if (rpt->out->options & FT_STAT_OPT_SORT) {
13808
13809 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13810 sort_flags = FT_CHASH_SORT_ASCENDING;
13811 else
13812 sort_flags = 0;
13813
13814 if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
13815 sort_offset = offsetof(struct ftchash_rec_prefix2162, c16a);
13816 sort_flags |= FT_CHASH_SORT_16;
13817 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY4) {
13818 sort_offset = offsetof(struct ftchash_rec_prefix2162, c16b);
13819 sort_flags |= FT_CHASH_SORT_16;
13820 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
13821 sort_offset = offsetof(struct ftchash_rec_prefix2162, src_prefix);
13822 sort_flags |= FT_CHASH_SORT_40;
13823 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
13824 sort_offset = offsetof(struct ftchash_rec_prefix2162, dst_prefix);
13825 sort_flags |= FT_CHASH_SORT_40;
13826 } else
13827
13828 CHASH_DUMP_STD_SORT(ftchash_rec_prefix2162);
13829
13830 ftchash_sort(ftch, sort_offset, sort_flags);
13831
13832 } /* FT_STAT_OPT_SORT */
13833
13834 ftchash_first(ftch);
13835
13836 while ((ftch_recprefix2162 = ftchash_foreach(ftch))) {
13837
13838 len = comma = 0;
13839
13840 DUMP_STD_OUT();
13841
13842 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
13843 if (comma) fmt_buf[len++] = ',';
13844 if (rpt->options &
13845 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
13846 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2162->src_prefix,
13847 ftch_recprefix2162->src_mask, 64, fmt);
13848 else
13849 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2162->src_prefix, 64, fmt);
13850 comma = 1;
13851 }
13852
13853 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
13854 if (comma) fmt_buf[len++] = ',';
13855 if (rpt->options &
13856 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
13857 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recprefix2162->dst_prefix,
13858 ftch_recprefix2162->dst_mask, 64, fmt);
13859 else
13860 len += fmt_ipv4s(fmt_buf+len, ftch_recprefix2162->dst_prefix, 64, fmt);
13861 comma = 1;
13862 }
13863
13864 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
13865 if (comma) fmt_buf[len++] = ',';
13866 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
13867 ftch_recprefix2162->c16a, FMT_JUST_LEFT);
13868 comma = 1;
13869 }
13870
13871 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
13872 if (comma) fmt_buf[len++] = ',';
13873 len += fmt_uint16s(ftsym2, FMT_SYM_LEN, fmt_buf+len,
13874 ftch_recprefix2162->c16b, FMT_JUST_LEFT);
13875 comma = 1;
13876 }
13877
13878 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13879
13880 CHASH_STDP_OUT(ftch_recprefix2162, comma);
13881
13882 } else {
13883
13884 CHASH_STD_OUT(ftch_recprefix2162, comma);
13885
13886 }
13887
13888 }
13889
13890 if (ftsym1)
13891 ftsym_free(ftsym1);
13892
13893 if (ftsym2)
13894 ftsym_free(ftsym2);
13895
13896 return 0;
13897
13898 } /* chash_prefix2162_dump */
13899
chash_c64_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch)13900 static int chash_c64_dump(FILE *fp, struct ftstat_rpt *rpt,
13901 struct ftchash *ftch)
13902 {
13903
13904 CHASH_DUMP_INIT(ftchash_rec_c64, ftch_recc64);
13905
13906 if (rpt->out->options & FT_STAT_OPT_SORT) {
13907
13908 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13909 sort_flags = FT_CHASH_SORT_ASCENDING;
13910 else
13911 sort_flags = 0;
13912
13913 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
13914 sort_offset = offsetof(struct ftchash_rec_c64, c64);
13915 sort_flags |= FT_CHASH_SORT_64;
13916 } else
13917
13918 CHASH_DUMP_STD_SORT(ftchash_rec_c64);
13919
13920 ftchash_sort(ftch, sort_offset, sort_flags);
13921
13922
13923 } /* FT_STAT_OPT_SORT */
13924
13925 ftchash_first(ftch);
13926
13927 while ((ftch_recc64 = ftchash_foreach(ftch))) {
13928
13929 len = comma = 0;
13930
13931 DUMP_STD_OUT();
13932
13933 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
13934 if (comma) fmt_buf[len++] = ',';
13935 len += fmt_uint64(fmt_buf+len, ftch_recc64->c64, FMT_JUST_LEFT);
13936 comma = 1;
13937 }
13938
13939 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
13940
13941 CHASH_STDP_OUT(ftch_recc64, comma);
13942
13943 } else {
13944
13945 CHASH_STD_OUT(ftch_recc64, comma);
13946
13947 }
13948
13949 }
13950
13951 return 0;
13952
13953 } /* chash_c64_dump */
13954
chash_int_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch)13955 static int chash_int_dump(FILE *fp, struct ftstat_rpt *rpt,
13956 struct ftchash *ftch)
13957 {
13958
13959 CHASH_DUMP_INIT(ftchash_rec_int, ftch_recint);
13960
13961 if (rpt->out->options & FT_STAT_OPT_SORT) {
13962
13963 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
13964 sort_flags = FT_CHASH_SORT_ASCENDING;
13965 else
13966 sort_flags = 0;
13967
13968 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
13969 sort_offset = offsetof(struct ftchash_rec_int, time);
13970 sort_flags |= FT_CHASH_SORT_32;
13971 } else if (rpt->out->sort_field == FT_STAT_FIELD_FLOWS) {\
13972 sort_offset = offsetof(struct ftchash_rec_int, nflows);\
13973 sort_flags |= FT_CHASH_SORT_DOUBLE;\
13974 } else if (rpt->out->sort_field == FT_STAT_FIELD_OCTETS) {\
13975 sort_offset = offsetof(struct ftchash_rec_int, noctets);\
13976 sort_flags |= FT_CHASH_SORT_DOUBLE;\
13977 } else if (rpt->out->sort_field == FT_STAT_FIELD_PACKETS) {\
13978 sort_offset = offsetof(struct ftchash_rec_int, npackets);\
13979 sort_flags |= FT_CHASH_SORT_DOUBLE;\
13980 }
13981
13982 ftchash_sort(ftch, sort_offset, sort_flags);
13983
13984
13985 } /* FT_STAT_OPT_SORT */
13986
13987 ftchash_first(ftch);
13988
13989 while ((ftch_recint = ftchash_foreach(ftch))) {
13990
13991 len = comma = 0;
13992
13993 DUMP_STD_OUT();
13994
13995 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
13996 if (comma) fmt_buf[len++] = ',';
13997 len += fmt_uint32(fmt_buf+len, ftch_recint->time, FMT_JUST_LEFT);
13998 comma = 1;
13999 }
14000
14001 /* XXX percent totals? */
14002
14003 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {
14004 if (comma) fmt_buf[len++] = ',';
14005 len += sprintf(fmt_buf+len, "%f", ftch_recint->nflows);\
14006 comma = 1;
14007 }
14008
14009 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {
14010 if (comma) fmt_buf[len++] = ',';
14011 len += sprintf(fmt_buf+len, "%f", ftch_recint->noctets);\
14012 comma = 1;
14013 }
14014
14015 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {
14016 if (comma) fmt_buf[len++] = ',';
14017 len += sprintf(fmt_buf+len, "%f", ftch_recint->npackets);\
14018 comma = 1;
14019 }
14020
14021 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {
14022 if (comma) fmt_buf[len++] = ',';
14023 len += fmt_uint64(fmt_buf+len, ftch_recint->nrecs, FMT_JUST_LEFT);
14024 comma = 1;\
14025 }
14026
14027 fmt_buf[len++] = '\n';
14028 fmt_buf[len] = 0;
14029
14030 fputs(fmt_buf, fp);
14031
14032 if (rpt->out->records && (tally.rt_recs == rpt->out->records)) {
14033 fprintf(fp, "# stop, hit record limit.\n");
14034 break;
14035 }
14036
14037 }
14038
14039 return 0;
14040
14041 } /* chash_int_dump */
14042
chash_flow1_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1,const char * sym2)14043 static int chash_flow1_dump(FILE *fp, struct ftstat_rpt *rpt,
14044 struct ftchash *ftch, const char *sym1, const char *sym2)
14045 {
14046 struct ftsym *ftsym1, *ftsym2;
14047
14048 CHASH_DUMP_INIT(ftchash_rec_flow1, ftch_recflow1);
14049
14050 ftsym1 = ftsym2 = (struct ftsym*)0L;
14051
14052 if (rpt->out->options & FT_STAT_OPT_NAMES) {
14053 ftsym1 = ftsym_new(sym1);
14054 ftsym2 = ftsym_new(sym2);
14055 }
14056
14057 if (rpt->out->options & FT_STAT_OPT_SORT) {
14058
14059 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
14060 sort_flags = FT_CHASH_SORT_ASCENDING;
14061 else
14062 sort_flags = 0;
14063
14064 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
14065 sort_offset = offsetof(struct ftchash_rec_flow1, src_prefix);
14066 sort_flags |= FT_CHASH_SORT_40;
14067 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
14068 sort_offset = offsetof(struct ftchash_rec_flow1, dst_prefix);
14069 sort_flags |= FT_CHASH_SORT_40;
14070 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
14071 sort_offset = offsetof(struct ftchash_rec_flow1, src_port);
14072 sort_flags |= FT_CHASH_SORT_16;
14073 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY4) {
14074 sort_offset = offsetof(struct ftchash_rec_flow1, dst_port);
14075 sort_flags |= FT_CHASH_SORT_16;
14076 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY5) {
14077 sort_offset = offsetof(struct ftchash_rec_flow1, prot);
14078 sort_flags |= FT_CHASH_SORT_8;
14079 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY6) {
14080 sort_offset = offsetof(struct ftchash_rec_flow1, tos);
14081 sort_flags |= FT_CHASH_SORT_8;
14082 } else
14083
14084 CHASH_DUMP_STD_SORT(ftchash_rec_flow1);
14085
14086 ftchash_sort(ftch, sort_offset, sort_flags);
14087
14088 } /* FT_STAT_OPT_SORT */
14089
14090 ftchash_first(ftch);
14091
14092 while ((ftch_recflow1 = ftchash_foreach(ftch))) {
14093
14094 len = comma = 0;
14095
14096 DUMP_STD_OUT();
14097
14098 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
14099 if (comma) fmt_buf[len++] = ',';
14100 if (rpt->options &
14101 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
14102 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recflow1->src_prefix,
14103 ftch_recflow1->src_mask, 64, fmt);
14104 else
14105 len += fmt_ipv4s(fmt_buf+len, ftch_recflow1->src_prefix, 64, fmt);
14106 comma = 1;
14107 }
14108
14109 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
14110 if (comma) fmt_buf[len++] = ',';
14111 if (rpt->options &
14112 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
14113 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recflow1->dst_prefix,
14114 ftch_recflow1->dst_mask, 64, fmt);
14115 else
14116 len += fmt_ipv4s(fmt_buf+len, ftch_recflow1->dst_prefix, 64, fmt);
14117 comma = 1;
14118 }
14119
14120 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
14121 if (comma) fmt_buf[len++] = ',';
14122 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
14123 ftch_recflow1->src_port, FMT_JUST_LEFT);
14124 comma = 1;
14125 }
14126
14127 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
14128 if (comma) fmt_buf[len++] = ',';
14129 len += fmt_uint16s(ftsym1, FMT_SYM_LEN, fmt_buf+len,
14130 ftch_recflow1->dst_port, FMT_JUST_LEFT);
14131 comma = 1;
14132 }
14133
14134 if (rpt->out->fields & FT_STAT_FIELD_KEY5) {
14135 if (comma) fmt_buf[len++] = ',';
14136 len += fmt_uint8s(ftsym2, FMT_SYM_LEN, fmt_buf+len, ftch_recflow1->prot,
14137 FMT_JUST_LEFT);
14138 comma = 1;
14139 }
14140
14141 if (rpt->out->fields & FT_STAT_FIELD_KEY6) {
14142 if (comma) fmt_buf[len++] = ',';
14143 len += fmt_uint8(fmt_buf+len, ftch_recflow1->tos,
14144 FMT_JUST_LEFT);
14145 comma = 1;
14146 }
14147
14148 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
14149
14150 CHASH_STDP_OUT(ftch_recflow1, comma);
14151
14152 } else {
14153
14154 CHASH_STD_OUT(ftch_recflow1, comma);
14155
14156 }
14157
14158 }
14159
14160 if (ftsym1)
14161 ftsym_free(ftsym1);
14162
14163 if (ftsym2)
14164 ftsym_free(ftsym2);
14165
14166 return 0;
14167
14168 } /* chash_flow1_dump */
14169
chash_flow12_dump(FILE * fp,struct ftstat_rpt * rpt,struct ftchash * ftch,const char * sym1)14170 static int chash_flow12_dump(FILE *fp, struct ftstat_rpt *rpt,
14171 struct ftchash *ftch, const char *sym1)
14172 {
14173 struct ftsym *ftsym1;
14174
14175 CHASH_DUMP_INIT(ftchash_rec_flow1, ftch_recflow1);
14176
14177 ftsym1 = (struct ftsym*)0L;
14178
14179 if (rpt->out->options & FT_STAT_OPT_NAMES) {
14180 ftsym1 = ftsym_new(sym1);
14181 }
14182
14183 if (rpt->out->options & FT_STAT_OPT_SORT) {
14184
14185 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
14186 sort_flags = FT_CHASH_SORT_ASCENDING;
14187 else
14188 sort_flags = 0;
14189
14190 if (rpt->out->sort_field == FT_STAT_FIELD_KEY1) {
14191 sort_offset = offsetof(struct ftchash_rec_flow1, src_prefix);
14192 sort_flags |= FT_CHASH_SORT_40;
14193 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY2) {
14194 sort_offset = offsetof(struct ftchash_rec_flow1, dst_prefix);
14195 sort_flags |= FT_CHASH_SORT_40;
14196 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY3) {
14197 sort_offset = offsetof(struct ftchash_rec_flow1, prot);
14198 sort_flags |= FT_CHASH_SORT_8;
14199 } else if (rpt->out->sort_field == FT_STAT_FIELD_KEY4) {
14200 sort_offset = offsetof(struct ftchash_rec_flow1, tos);
14201 sort_flags |= FT_CHASH_SORT_8;
14202 } else
14203
14204 CHASH_DUMP_STD_SORT(ftchash_rec_flow1);
14205
14206 ftchash_sort(ftch, sort_offset, sort_flags);
14207
14208 } /* FT_STAT_OPT_SORT */
14209
14210 ftchash_first(ftch);
14211
14212 while ((ftch_recflow1 = ftchash_foreach(ftch))) {
14213
14214 len = comma = 0;
14215
14216 DUMP_STD_OUT();
14217
14218 if (rpt->out->fields & FT_STAT_FIELD_KEY1) {
14219 if (comma) fmt_buf[len++] = ',';
14220 if (rpt->options &
14221 (FT_STAT_OPT_SRC_PREFIX_LEN|FT_STAT_OPT_SRC_PREFIX_MASK))
14222 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recflow1->src_prefix,
14223 ftch_recflow1->src_mask, 64, fmt);
14224 else
14225 len += fmt_ipv4s(fmt_buf+len, ftch_recflow1->src_prefix,
14226 64, fmt);
14227 comma = 1;
14228 }
14229
14230 if (rpt->out->fields & FT_STAT_FIELD_KEY2) {
14231 if (comma) fmt_buf[len++] = ',';
14232 if (rpt->options &
14233 (FT_STAT_OPT_DST_PREFIX_LEN|FT_STAT_OPT_DST_PREFIX_MASK))
14234 len += fmt_ipv4prefixs(fmt_buf+len, ftch_recflow1->dst_prefix,
14235 ftch_recflow1->dst_mask, 64, fmt);
14236 else
14237 len += fmt_ipv4s(fmt_buf+len, ftch_recflow1->dst_prefix, 64, fmt);
14238 comma = 1;
14239 }
14240
14241 if (rpt->out->fields & FT_STAT_FIELD_KEY3) {
14242 if (comma) fmt_buf[len++] = ',';
14243 len += fmt_uint8s(ftsym1, FMT_SYM_LEN, fmt_buf+len, ftch_recflow1->prot,
14244 FMT_JUST_LEFT);
14245 comma = 1;
14246 }
14247
14248 if (rpt->out->fields & FT_STAT_FIELD_KEY4) {
14249 if (comma) fmt_buf[len++] = ',';
14250 len += fmt_uint8(fmt_buf+len, ftch_recflow1->tos,
14251 FMT_JUST_LEFT);
14252 comma = 1;
14253 }
14254
14255 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
14256
14257 CHASH_STDP_OUT(ftch_recflow1, comma);
14258
14259 } else {
14260
14261 CHASH_STD_OUT(ftch_recflow1, comma);
14262
14263 }
14264
14265 }
14266
14267 if (ftsym1)
14268 ftsym_free(ftsym1);
14269
14270 return 0;
14271
14272 } /* chash_flow12_dump */
14273
14274
bucket_dump1(FILE * fp,struct ftstat_rpt * rpt,struct flow_bucket * b,uint32_t nindex,const char * symfile)14275 static int bucket_dump1(FILE *fp, struct ftstat_rpt *rpt, struct flow_bucket *b,
14276 uint32_t nindex, const char *symfile)
14277 {
14278 struct ftsym *ftsym;
14279 struct tally tally;
14280 char fmt_buf1[32], fmt_buf[1024];
14281 int len, comma;
14282 int32_t i, start, end, increment;
14283 uint32_t *index;
14284
14285 ftsym = (struct ftsym*)0L;
14286 fmt_buf1[0] = fmt_buf[0] = 0;
14287 index = b->index;
14288 bzero(&tally, sizeof tally);
14289
14290 if (rpt->out->options & FT_STAT_OPT_NAMES)
14291 ftsym = ftsym_new(symfile);
14292
14293 start = 0; end = nindex, increment = 1;
14294
14295 if (rpt->out->options & FT_STAT_OPT_SORT) {
14296
14297 if (rpt->out->sort_order & FT_STAT_SORT_ASCEND)
14298 start = nindex - 1, end = -1, increment = -1;
14299
14300 if (rpt->out->sort_field == FT_STAT_FIELD_KEY) {
14301 ; /* sorted by default */
14302 } else if (rpt->out->sort_field == FT_STAT_FIELD_FLOWS) {
14303 sort_i64 = b->flows;
14304 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp64);
14305 } else if (rpt->out->sort_field == FT_STAT_FIELD_OCTETS) {
14306 sort_i64 = b->octets;
14307 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp64);
14308 } else if (rpt->out->sort_field == FT_STAT_FIELD_PACKETS) {
14309 sort_i64 = b->packets;
14310 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp64);
14311 } else if (rpt->out->sort_field == FT_STAT_FIELD_DURATION) {
14312 sort_i64 = b->duration;
14313 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp64);
14314 } else if (rpt->out->sort_field == FT_STAT_FIELD_AVG_PPS) {
14315 sort_idouble = b->avg_pps;
14316 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14317 } else if (rpt->out->sort_field == FT_STAT_FIELD_MIN_PPS) {
14318 sort_idouble = b->min_pps;
14319 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14320 } else if (rpt->out->sort_field == FT_STAT_FIELD_MAX_PPS) {
14321 sort_idouble = b->max_pps;
14322 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14323 } else if (rpt->out->sort_field == FT_STAT_FIELD_AVG_BPS) {
14324 sort_idouble = b->avg_bps;
14325 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14326 } else if (rpt->out->sort_field == FT_STAT_FIELD_MIN_BPS) {
14327 sort_idouble = b->min_bps;
14328 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14329 } else if (rpt->out->sort_field == FT_STAT_FIELD_MAX_BPS) {
14330 sort_idouble = b->max_bps;
14331 qsort(b->index, nindex, sizeof (uint32_t), sort_cmp_double);
14332 } else {
14333 fterr_errx(1,"bucket_dump1(): internal error");
14334 }
14335
14336 } /* FT_STAT_OPT_SORT */
14337
14338 /* need to know the total number of records first */
14339 if (rpt->out->options & FT_STAT_OPT_TALLY) {
14340
14341 for (i = start; i != end; i += increment) {
14342
14343 if (!b->flows[index[i]])
14344 continue;
14345
14346 ++tally.t_recs;
14347
14348 }
14349
14350 }
14351
14352 if (rpt->out->options & FT_STAT_OPT_PERCENT) {
14353
14354 for (i = start; i != end; i += increment) {
14355
14356 if (!b->flows[index[i]])
14357 continue;
14358
14359 if ((rpt->out->options & FT_STAT_OPT_TALLY) && tally.rt_recs &&
14360 (!(tally.rt_recs % rpt->out->tally))) {
14361
14362 if (rpt->all_fields & FT_STAT_FIELD_PS)
14363 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f %%avg-bps=%3.3f %%avg-pps=%3.3f\n",
14364 ((double)tally.rt_recs/(double)tally.t_recs)*100,
14365 ((double)tally.rt_flows/(double)rpt->t_flows)*100,
14366 ((double)tally.rt_octets/(double)rpt->t_octets)*100,
14367 ((double)tally.rt_packets/(double)rpt->t_packets)*100,
14368 (((double)tally.ravg_bps/(double)tally.rt_frecs)/
14369 (double)rpt->avg_bps)*100,
14370 (((double)tally.ravg_pps/(double)tally.rt_frecs)/
14371 (double)rpt->avg_pps)*100);
14372 else
14373 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f\n",
14374 ((double)tally.rt_recs/(double)tally.t_recs)*100,
14375 ((double)tally.rt_flows/(double)rpt->t_flows)*100,
14376 ((double)tally.rt_octets/(double)rpt->t_octets)*100,
14377 ((double)tally.rt_packets/(double)rpt->t_packets)*100);
14378
14379 } /* tally */
14380
14381 tally.rt_flows += b->flows[index[i]];
14382 tally.rt_octets += b->octets[index[i]];
14383 tally.rt_packets += b->packets[index[i]];
14384 tally.rt_frecs += b->recs[index[i]];
14385 tally.rt_recs ++;
14386 if (rpt->all_fields & FT_STAT_FIELD_PS) {
14387 tally.ravg_bps += b->avg_bps[index[i]] * b->recs[index[i]];
14388 tally.ravg_pps += b->avg_pps[index[i]] * b->recs[index[i]];
14389 }
14390
14391 len = comma = 0;
14392
14393 DUMP_STD_OUT();
14394
14395 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
14396 if (comma) fmt_buf[len++] = ',';
14397 len += fmt_uint32s(ftsym, FMT_SYM_LEN, fmt_buf+len, b->index[i],
14398 FMT_JUST_LEFT);
14399 comma = 1;
14400 }
14401
14402 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {
14403 if (comma) fmt_buf[len++] = ',';
14404 len += sprintf(fmt_buf+len, "%f",
14405 ((double)b->flows[index[i]] / (double)rpt->t_flows)*100.0);
14406 comma = 1;
14407 }
14408
14409 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {
14410 if (comma) fmt_buf[len++] = ',';
14411 len += sprintf(fmt_buf+len, "%f",
14412 ((double)b->octets[index[i]] / (double)rpt->t_octets)*100.0);
14413 comma = 1;
14414 }
14415
14416 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {
14417 if (comma) fmt_buf[len++] = ',';
14418 len += sprintf(fmt_buf+len, "%f",
14419 ((double)b->packets[index[i]] / (double)rpt->t_packets)*100.0);
14420 comma = 1;
14421 }
14422
14423
14424 if (rpt->out->fields & FT_STAT_FIELD_DURATION) {
14425 if (comma) fmt_buf[len++] = ',';
14426 len += sprintf(fmt_buf+len, "%f",
14427 ((double)b->duration[index[i]] / (double)rpt->t_duration)*100.0);
14428 comma = 1;
14429 }
14430
14431 if (rpt->out->fields & FT_STAT_FIELD_AVG_BPS) {
14432 if (comma) fmt_buf[len++] = ',';
14433 len += sprintf(fmt_buf+len, "%f",
14434 ((double)b->avg_bps[index[i]] / (double)rpt->avg_bps)*100.0);
14435 comma = 1;
14436 }
14437
14438 if (rpt->out->fields & FT_STAT_FIELD_MIN_BPS) {
14439 if (comma) fmt_buf[len++] = ',';
14440 len += sprintf(fmt_buf+len, "%f",
14441 ((double)b->min_bps[index[i]] / (double)rpt->min_bps)*100.0);
14442 comma = 1;
14443 }
14444
14445 if (rpt->out->fields & FT_STAT_FIELD_MAX_BPS) {
14446 if (comma) fmt_buf[len++] = ',';
14447 len += sprintf(fmt_buf+len, "%f",
14448 ((double)b->max_bps[index[i]] / (double)rpt->max_bps)*100.0);
14449 comma = 1;
14450 }
14451
14452 if (rpt->out->fields & FT_STAT_FIELD_AVG_PPS) {
14453 if (comma) fmt_buf[len++] = ',';
14454 len += sprintf(fmt_buf+len, "%f",
14455 ((double)b->avg_pps[index[i]] / (double)rpt->avg_pps)*100.0);
14456 comma = 1;
14457 }
14458
14459 if (rpt->out->fields & FT_STAT_FIELD_MIN_PPS) {
14460 if (comma) fmt_buf[len++] = ',';
14461 len += sprintf(fmt_buf+len, "%f",
14462 ((double)b->min_pps[index[i]] / (double)rpt->min_pps)*100.0);
14463 comma = 1;
14464 }
14465
14466 if (rpt->out->fields & FT_STAT_FIELD_MAX_PPS) {
14467 if (comma) fmt_buf[len++] = ',';
14468 len += sprintf(fmt_buf+len, "%f",
14469 ((double)b->max_pps[index[i]] / (double)rpt->max_pps)*100.0);
14470 comma = 1;
14471 }
14472
14473 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {
14474 if (comma) fmt_buf[len++] = ',';
14475 len += fmt_uint64(fmt_buf+len, b->recs[index[i]], FMT_JUST_LEFT);\
14476 comma = 1;
14477 }
14478
14479 fmt_buf[len++] = '\n';
14480 fmt_buf[len] = 0;
14481
14482 fputs(fmt_buf, fp);
14483
14484 if (rpt->out->records && (tally.rt_recs == rpt->out->records)) {
14485 fprintf(fp, "# stop, hit record limit.\n");
14486 break;
14487 }
14488
14489 }
14490
14491 } else {
14492
14493 for (i = start; i != end; i += increment) {
14494
14495 if (!b->flows[index[i]])
14496 continue;
14497
14498 if ((rpt->out->options & FT_STAT_OPT_TALLY) && tally.rt_recs &&
14499 (!(tally.rt_recs % rpt->out->tally))) {
14500
14501 if (rpt->all_fields & FT_STAT_FIELD_PS)
14502 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f %%avg-bps=%3.3f %%avg-pps=%3.3f\n",
14503 ((double)tally.rt_recs/(double)tally.t_recs)*100,
14504 ((double)tally.rt_flows/(double)rpt->t_flows)*100,
14505 ((double)tally.rt_octets/(double)rpt->t_octets)*100,
14506 ((double)tally.rt_packets/(double)rpt->t_packets)*100,
14507 (((double)tally.ravg_bps/(double)tally.rt_frecs)/
14508 (double)rpt->avg_bps)*100,
14509 (((double)tally.ravg_pps/(double)tally.rt_frecs)/
14510 (double)rpt->avg_pps)*100);
14511 else
14512 fprintf(fp, "#TALLY %%recs=%3.3f %%flows=%3.3f %%octets=%3.3f %%packets=%3.3f\n",
14513 ((double)tally.rt_recs/(double)tally.t_recs)*100,
14514 ((double)tally.rt_flows/(double)rpt->t_flows)*100,
14515 ((double)tally.rt_octets/(double)rpt->t_octets)*100,
14516 ((double)tally.rt_packets/(double)rpt->t_packets)*100);
14517
14518 } /* tally */
14519
14520 tally.rt_flows += b->flows[index[i]];
14521 tally.rt_octets += b->octets[index[i]];
14522 tally.rt_packets += b->packets[index[i]];
14523 tally.rt_recs ++;
14524 tally.rt_frecs += b->recs[index[i]];
14525 if (rpt->all_fields & FT_STAT_FIELD_PS) {
14526 tally.ravg_bps += b->avg_bps[index[i]] * b->recs[index[i]];
14527 tally.ravg_pps += b->avg_pps[index[i]] * b->recs[index[i]];
14528 }
14529
14530 len = comma = 0;
14531
14532 DUMP_STD_OUT();
14533
14534 if (rpt->out->fields & FT_STAT_FIELD_KEY) {
14535 if (comma) fmt_buf[len++] = ',';
14536 len += fmt_uint32s(ftsym, FMT_SYM_LEN, fmt_buf+len, b->index[i],
14537 FMT_JUST_LEFT);
14538 comma = 1;
14539 }
14540
14541 if (rpt->out->fields & FT_STAT_FIELD_FLOWS) {
14542 if (comma) fmt_buf[len++] = ',';
14543 len += fmt_uint64(fmt_buf+len, b->flows[index[i]], FMT_JUST_LEFT);
14544 comma = 1;
14545 }
14546
14547 if (rpt->out->fields & FT_STAT_FIELD_OCTETS) {
14548 if (comma) fmt_buf[len++] = ',';
14549 len += fmt_uint64(fmt_buf+len, b->octets[index[i]], FMT_JUST_LEFT);
14550 comma = 1;
14551 }
14552
14553 if (rpt->out->fields & FT_STAT_FIELD_PACKETS) {
14554 if (comma) fmt_buf[len++] = ',';
14555 len += fmt_uint64(fmt_buf+len, b->packets[index[i]], FMT_JUST_LEFT);
14556 comma = 1;
14557 }
14558
14559 if (rpt->out->fields & FT_STAT_FIELD_DURATION) {
14560 if (comma) fmt_buf[len++] = ',';
14561 len += fmt_uint64(fmt_buf+len, b->duration[index[i]], FMT_JUST_LEFT);
14562 comma = 1;
14563 }
14564
14565 if (rpt->out->fields & FT_STAT_FIELD_AVG_BPS) {
14566 if (comma) fmt_buf[len++] = ',';
14567 len += sprintf(fmt_buf+len, "%f", b->avg_bps[index[i]]);
14568 comma = 1;
14569 }
14570
14571 if (rpt->out->fields & FT_STAT_FIELD_MIN_BPS) {
14572 if (comma) fmt_buf[len++] = ',';
14573 len += sprintf(fmt_buf+len, "%f", b->min_bps[index[i]]);
14574 comma = 1;
14575 }
14576
14577 if (rpt->out->fields & FT_STAT_FIELD_MAX_BPS) {
14578 if (comma) fmt_buf[len++] = ',';
14579 len += sprintf(fmt_buf+len, "%f", b->max_bps[index[i]]);
14580 comma = 1;
14581 }
14582
14583 if (rpt->out->fields & FT_STAT_FIELD_AVG_PPS) {
14584 if (comma) fmt_buf[len++] = ',';
14585 len += sprintf(fmt_buf+len, "%f", b->avg_pps[index[i]]);
14586 comma = 1;
14587 }
14588
14589 if (rpt->out->fields & FT_STAT_FIELD_MIN_PPS) {
14590 if (comma) fmt_buf[len++] = ',';
14591 len += sprintf(fmt_buf+len, "%f", b->min_pps[index[i]]);
14592 comma = 1;
14593 }
14594
14595 if (rpt->out->fields & FT_STAT_FIELD_MAX_PPS) {
14596 if (comma) fmt_buf[len++] = ',';
14597 len += sprintf(fmt_buf+len, "%f", b->max_pps[index[i]]);
14598 comma = 1;
14599 }
14600
14601 if (rpt->out->fields & FT_STAT_FIELD_FRECS) {
14602 if (comma) fmt_buf[len++] = ',';
14603 len += fmt_uint64(fmt_buf+len, b->recs[index[i]], FMT_JUST_LEFT);\
14604 comma = 1;
14605 }
14606
14607 fmt_buf[len++] = '\n';
14608 fmt_buf[len] = 0;
14609
14610 fputs(fmt_buf, fp);
14611
14612 if (rpt->out->records && (tally.rt_recs == rpt->out->records)) {
14613 fprintf(fp, "# stop, hit record limit.\n");
14614 break;
14615 }
14616
14617 } /* foreach record */
14618
14619 } /* totals */
14620
14621 if (ftsym)
14622 ftsym_free(ftsym);
14623
14624 return 0;
14625
14626 } /* bucket_dump1 */
14627
recn_dump(FILE * fp,int fields,char * key,char * key1,char * key2,char * key3,char * key4,char * key5,char * key6)14628 static int recn_dump(FILE *fp, int fields, char *key, char *key1,
14629 char *key2, char *key3, char *key4, char *key5, char *key6)
14630 {
14631 int comma;
14632
14633 fprintf(fp, "# recn: ");
14634 comma = 0;
14635
14636 if (fields & FT_STAT_FIELD_INDEX) {
14637 fprintf(fp, "%sindex", comma ? "," : "");
14638 comma = 1;
14639 }
14640
14641 if (fields & FT_STAT_FIELD_FIRST) {
14642 fprintf(fp, "%sfirst", comma ? "," : "");
14643 comma = 1;
14644 }
14645
14646 if (fields & FT_STAT_FIELD_LAST) {
14647 fprintf(fp, "%slast", comma ? "," : "");
14648 comma = 1;
14649 }
14650
14651 if (fields & FT_STAT_FIELD_KEY) {
14652 fprintf(fp, "%s%s*", comma ? "," : "", key);
14653 comma = 1;
14654 }
14655
14656 if (fields & FT_STAT_FIELD_KEY1) {
14657 fprintf(fp, "%s%s*", comma ? "," : "", key1);
14658 comma = 1;
14659 }
14660
14661 if (fields & FT_STAT_FIELD_KEY2) {
14662 fprintf(fp, "%s%s*", comma ? "," : "", key2);
14663 comma = 1;
14664 }
14665
14666 if (fields & FT_STAT_FIELD_KEY3) {
14667 fprintf(fp, "%s%s*", comma ? "," : "", key3);
14668 comma = 1;
14669 }
14670
14671 if (fields & FT_STAT_FIELD_KEY4) {
14672 fprintf(fp, "%s%s*", comma ? "," : "", key4);
14673 comma = 1;
14674 }
14675
14676 if (fields & FT_STAT_FIELD_KEY5) {
14677 fprintf(fp, "%s%s*", comma ? "," : "", key5);
14678 comma = 1;
14679 }
14680
14681 if (fields & FT_STAT_FIELD_KEY6) {
14682 fprintf(fp, "%s%s*", comma ? "," : "", key6);
14683 comma = 1;
14684 }
14685
14686 if (fields & FT_STAT_FIELD_COUNT) {
14687 fprintf(fp, "%s%s", comma ? "," : "", key1);
14688 comma = 1;
14689 }
14690
14691 if (fields & FT_STAT_FIELD_FLOWS) {
14692 fprintf(fp, "%sflows", comma ? "," : "");
14693 comma = 1;
14694 }
14695
14696 if (fields & FT_STAT_FIELD_OCTETS) {
14697 fprintf(fp, "%soctets", comma ? "," : "");
14698 comma = 1;
14699 }
14700
14701 if (fields & FT_STAT_FIELD_PACKETS) {
14702 fprintf(fp, "%spackets", comma ? "," : "");
14703 comma = 1;
14704 }
14705
14706 if (fields & FT_STAT_FIELD_DURATION) {
14707 fprintf(fp, "%sduration", comma ? "," : "");
14708 comma = 1;
14709 }
14710
14711 if (fields & FT_STAT_FIELD_AVG_BPS) {
14712 fprintf(fp, "%savg-bps", comma ? "," : "");
14713 comma = 1;
14714 }
14715
14716 if (fields & FT_STAT_FIELD_MIN_BPS) {
14717 fprintf(fp, "%smin-bps", comma ? "," : "");
14718 comma = 1;
14719 }
14720
14721 if (fields & FT_STAT_FIELD_MAX_BPS) {
14722 fprintf(fp, "%smax-bps", comma ? "," : "");
14723 comma = 1;
14724 }
14725
14726 if (fields & FT_STAT_FIELD_AVG_PPS) {
14727 fprintf(fp, "%savg-pps", comma ? "," : "");
14728 comma = 1;
14729 }
14730
14731 if (fields & FT_STAT_FIELD_MIN_PPS) {
14732 fprintf(fp, "%smin-pps", comma ? "," : "");
14733 comma = 1;
14734 }
14735
14736 if (fields & FT_STAT_FIELD_MAX_PPS) {
14737 fprintf(fp, "%smax-pps", comma ? "," : "");
14738 comma = 1;
14739 }
14740
14741 if (fields & FT_STAT_FIELD_FRECS) {
14742 fprintf(fp, "%sfrecs", comma ? "," : "");
14743 comma = 1;
14744 }
14745
14746 fprintf(fp, "\n");
14747
14748 return 0;
14749
14750 } /* recn_dump */
14751
bucket_alloc(struct flow_bucket * b,uint32_t n,struct ftstat_rpt * rpt)14752 int bucket_alloc(struct flow_bucket *b, uint32_t n, struct ftstat_rpt *rpt)
14753 {
14754 register int i;
14755
14756 bzero(b, sizeof (*b));
14757
14758 if (!(b->recs = (uint64_t*)malloc(n*sizeof(uint64_t)))) {
14759 fterr_warn("malloc(b->recs):");
14760 return -1;
14761 }
14762
14763 if (!(b->flows = (uint64_t*)malloc(n*sizeof(uint64_t)))) {
14764 fterr_warn("malloc(b->flows):");
14765 return -1;
14766 }
14767
14768 if (!(b->octets = (uint64_t*)malloc(n*sizeof(uint64_t)))) {
14769 fterr_warn("malloc(fopdi):");
14770 bucket_free(b);
14771 return -1;
14772 }
14773
14774 if (!(b->packets = (uint64_t*)malloc(n*sizeof(uint64_t)))) {
14775 fterr_warn("malloc(b->packets):");
14776 bucket_free(b);
14777 return -1;
14778 }
14779
14780 if (!(b->duration = (uint64_t*)malloc(n*sizeof(uint64_t)))) {
14781 fterr_warn("malloc(b->duration):");
14782 bucket_free(b);
14783 return -1;
14784 }
14785
14786 if (!(b->index = (uint32_t*)malloc(n*sizeof(uint32_t)))) {
14787 fterr_warn("malloc(b->index):");
14788 bucket_free(b);
14789 return -1;
14790 }
14791
14792 if (rpt->all_fields & FT_STAT_FIELD_PS) {
14793
14794 if (!(b->avg_pps = (double*)malloc(n*sizeof(double)))) {
14795 fterr_warn("malloc(b->avg_pps):");
14796 bucket_free(b);
14797 return -1;
14798 }
14799
14800 if (!(b->min_pps = (double*)malloc(n*sizeof(double)))) {
14801 fterr_warn("malloc(b->min_pps):");
14802 bucket_free(b);
14803 return -1;
14804 }
14805
14806 if (!(b->max_pps = (double*)malloc(n*sizeof(double)))) {
14807 fterr_warn("malloc(b->max_pps):");
14808 bucket_free(b);
14809 return -1;
14810 }
14811
14812 if (!(b->avg_bps = (double*)malloc(n*sizeof(double)))) {
14813 fterr_warn("malloc(b->avg_bps):");
14814 bucket_free(b);
14815 return -1;
14816 }
14817
14818 if (!(b->min_bps = (double*)malloc(n*sizeof(double)))) {
14819 fterr_warn("malloc(b->min_bps):");
14820 bucket_free(b);
14821 return -1;
14822 }
14823
14824 if (!(b->max_bps = (double*)malloc(n*sizeof(double)))) {
14825 fterr_warn("malloc(b->max_bps):");
14826 bucket_free(b);
14827 return -1;
14828 }
14829
14830 bzero(b->avg_pps, n*sizeof(double));
14831 bzero(b->min_pps, n*sizeof(double));
14832 bzero(b->max_pps, n*sizeof(double));
14833 bzero(b->avg_bps, n*sizeof(double));
14834 bzero(b->min_bps, n*sizeof(double));
14835 bzero(b->max_bps, n*sizeof(double));
14836
14837 }
14838
14839 bzero(b->recs, n*sizeof(uint64_t));
14840 bzero(b->flows, n*sizeof(uint64_t));
14841 bzero(b->octets, n*sizeof(uint64_t));
14842 bzero(b->packets, n*sizeof(uint64_t));
14843 bzero(b->duration, n*sizeof(uint64_t));
14844
14845 for (i = 0; i < n; ++i)
14846 b->index[i] = i;
14847
14848 return 0;
14849
14850 } /* bucket_alloc */
14851
bucket_free(struct flow_bucket * b)14852 void bucket_free(struct flow_bucket *b)
14853 {
14854 if (b->recs)
14855 free(b->recs);
14856 if (b->flows)
14857 free(b->flows);
14858 if (b->octets)
14859 free(b->octets);
14860 if (b->packets)
14861 free(b->packets);
14862 if (b->duration)
14863 free(b->duration);
14864 if (b->avg_pps)
14865 free(b->avg_pps);
14866 if (b->min_pps)
14867 free(b->min_pps);
14868 if (b->max_pps)
14869 free(b->max_pps);
14870 if (b->avg_bps)
14871 free(b->avg_bps);
14872 if (b->min_bps)
14873 free(b->min_bps);
14874 if (b->max_bps)
14875 free(b->max_bps);
14876 if (b->index)
14877 free(b->index);
14878
14879 bzero(b, sizeof (*b));
14880
14881 } /* bucket_free */
14882
sort_cmp64(const void * a,const void * b)14883 static int sort_cmp64(const void *a, const void *b)
14884 {
14885 uint32_t l, r;
14886
14887 l = *(uint32_t*)a;
14888 r = *(uint32_t*)b;
14889
14890 if (sort_i64[l] < sort_i64[r])
14891 return -1;
14892 if (sort_i64[l] > sort_i64[r])
14893 return 1;
14894 return 0;
14895
14896 } /* sort_cmp64 */
14897
sort_cmp_double(const void * a,const void * b)14898 static int sort_cmp_double(const void *a, const void *b)
14899 {
14900 uint32_t l, r;
14901
14902 l = *(uint32_t*)a;
14903 r = *(uint32_t*)b;
14904
14905 if (sort_idouble[l] < sort_idouble[r])
14906 return -1;
14907 if (sort_idouble[l] > sort_idouble[r])
14908 return 1;
14909 return 0;
14910
14911 } /* sort_cmp_double */
14912
14913 /*
14914 * function: load_tags
14915 *
14916 * load the filter definitions if they have not been loaded
14917 *
14918 * return value of fttag_load()
14919 *
14920 */
load_tags(struct ftstat * ftstat)14921 static int load_tags(struct ftstat *ftstat)
14922 {
14923 struct ftver ftv;
14924
14925 /* work to do? */
14926 if (ftstat->fttag_init)
14927 return 0;
14928
14929 if (fttag_load(&ftstat->fttag, ftstat->ftvar, (ftstat->tag_fname) ?
14930 ftstat->tag_fname : FT_PATH_CFG_TAG)) {
14931 return 1;
14932 }
14933
14934 /* required later by accum when tags are enabled */
14935 ftv.d_version = 1005;
14936 fts3rec_compute_offsets(&nfo, &ftv);
14937
14938 ftstat->fttag_init = 1;
14939 return 0;
14940
14941 } /* load_tags */
14942
14943 /*
14944 * function: load_masks
14945 *
14946 * load the mask definitions if they have not been loaded
14947 *
14948 * return value of ftmask_load()
14949 *
14950 */
load_masks(struct ftstat * ftstat)14951 static int load_masks(struct ftstat *ftstat)
14952 {
14953
14954 /* work to do? */
14955 if (ftstat->ftmask_init)
14956 return 0;
14957
14958 if (ftmask_load(&ftstat->ftmask, (ftstat->mask_fname) ?
14959 ftstat->mask_fname : FT_PATH_CFG_MASK)) {
14960 return 1;
14961 }
14962
14963 ftstat->ftmask_init = 1;
14964 return 0;
14965
14966 } /* load_masks */
14967
14968 /*
14969 * function: load_filters
14970 *
14971 * load the filter definitions if they have not been loaded
14972 *
14973 * return value of ftfil_load()
14974 *
14975 */
14976
load_filters(struct ftstat * ftstat)14977 static int load_filters(struct ftstat *ftstat)
14978 {
14979
14980 /* work to do? */
14981 if (ftstat->ftfil_init)
14982 return 0;
14983
14984 if (ftfil_load(&ftstat->ftfil, ftstat->ftvar, (ftstat->filter_fname) ?
14985 ftstat->filter_fname : FT_PATH_CFG_FILTER)) {
14986 return 1;
14987 }
14988
14989 ftstat->ftfil_init = 1;
14990 return 0;
14991
14992 } /* load_filters */
14993
14994