yaftab.h
Go to the documentation of this file.
1/*
2 * Copyright 2006-2024 Carnegie Mellon University
3 * See license information in LICENSE.txt.
4 */
5/*
6 * yaftab.h
7 * YAF Active Flow Table
8 *
9 * ------------------------------------------------------------------------
10 * Authors: Brian Trammell
11 * ------------------------------------------------------------------------
12 * @DISTRIBUTION_STATEMENT_BEGIN@
13 * YAF 2.16
14 *
15 * Copyright 2024 Carnegie Mellon University.
16 *
17 * NO WARRANTY. THIS CARNEGIE MELLON UNIVERSITY AND SOFTWARE ENGINEERING
18 * INSTITUTE MATERIAL IS FURNISHED ON AN "AS-IS" BASIS. CARNEGIE MELLON
19 * UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
20 * AS TO ANY MATTER INCLUDING, BUT NOT LIMITED TO, WARRANTY OF FITNESS FOR
21 * PURPOSE OR MERCHANTABILITY, EXCLUSIVITY, OR RESULTS OBTAINED FROM USE OF
22 * THE MATERIAL. CARNEGIE MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF
23 * ANY KIND WITH RESPECT TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT
24 * INFRINGEMENT.
25 *
26 * Licensed under a GNU GPL 2.0-style license, please see LICENSE.txt or
27 * contact permission@sei.cmu.edu for full terms.
28 *
29 * [DISTRIBUTION STATEMENT A] This material has been approved for public
30 * release and unlimited distribution. Please see Copyright notice for
31 * non-US Government use and distribution.
32 *
33 * This Software includes and/or makes use of Third-Party Software each
34 * subject to its own license.
35 *
36 * DM24-1063
37 * @DISTRIBUTION_STATEMENT_END@
38 * ------------------------------------------------------------------------
39 */
40
41/*
42 * This is the documentation for the _old_ yaftab.h; it is no longer current,
43 * and should not be read by anyone.
44 *
45 * Flow generation interface for YAF. This facility works by maintaining a
46 * current flow table. Packets may be added to the active flows within this
47 * table using the yfFlowPkt() call. Completed flows may be written to an
48 * IPFIX message buffer using yfFlowFlush().
49 *
50 * The flow table is configured by a number of global variables.
51 *
52 * <tt>yaf_idle</tt> sets
53 * the idle timeout in seconds. A flow that receives no packets for the idle
54 * timeout is assumed to be complete. The idle timeout is set to 300 seconds
55 * (five minutes) by default.
56 *
57 * <tt>yaf_active</tt> sets the active timeout in seconds.
58 * The maximum duration of a flow is the active timeout; additional packets
59 * for the same flow will be counted as part of a new flow. The active timeout
60 * is set to 1800 seconds (half an hour) by default.
61 *
62 * <tt>yaf_flowlim</tt> sets the maximum size of the flow table; flows
63 * exceeding
64 * this limit will be expired in least-recent order, as if they were idle. The
65 * flow limit defaults to zero, for no limit. Use this global to limit resource
66 * usage by the flow table.
67 *
68 * <tt>yaf_paylen</tt> sets the number of bytes of payload to capture from the
69 * start of each flow. The payload length defaults to zero, which disables
70 * payload capture.
71 *
72 * <tt>yaf_uniflow</tt>, if TRUE, exports flows in uniflow mode, using the
73 * record adjacency export method described in section 3 of
74 * draft-ietf-ipfix-biflow. Defaults to FALSE.
75 *
76 * <tt>yaf_macmode</tt>, if TRUE, exports layer 2 information with each flow;
77 * presently this is limited to VLAN tags but may be expanded to include the
78 * MPLS stack and MAC addresses in the future. Defaults to FALSE.
79 *
80 * <tt>yaf_silkmode</tt>, if TRUE, enables SiLK compatibility mode. In this
81 * mode, totalOctetCount and reverseTotalOctetCount are clamped to 32 bits.
82 * Any packet that would cause either of these counters to overflow 32 bits
83 * will force an active timeout. The high-order bit of the flowEndReason IE
84 * is set on any flow created on a counter overflow, as above, or on an active
85 * timeout. Defaults to FALSE.
86 *
87 * <tt>yaf_reqtype</tt> limits the flow table to collecting IPv4 or IPv6 flows
88 * only. Set to YF_TYPE_IPv4 for IPv4 flows only, YF_TYPE_IPv6 for IPv6 flows
89 * only, or YF_TYPE_IPANY (the default) to collect both IPv4 and IPv6 flows.
90 *
91 * This facility is used by YAF to assemble packets into flows.
92 */
93
102#ifndef _YAF_TAB_H_
103#define _YAF_TAB_H_
104
105#include <yaf/autoinc.h>
106#include <yaf/yafcore.h>
107#include <yaf/decode.h>
108
109
114typedef struct yfFlowTab_st yfFlowTab_t;
115
120typedef struct yfFlowTabConfig_st {
126 int32_t active_sec;
131 int32_t idle_sec;
138 uint32_t max_flows;
145 uint32_t max_payload;
146
151 const char *ndpi_proto_file;
152
156 const char *pcap_dir;
160 const char *pcap_meta_file;
164 uint64_t pcap_max;
172 const char *pcap_search_stime;
173
179
192 gboolean entropy_mode;
211 gboolean mac_mode;
215 gboolean ndpi;
225 gboolean p0f_mode;
230 gboolean pcap_index;
242 gboolean silk_mode;
254 gboolean uniflow_mode;
255
257
271 const yfFlowTabConfig_t *ftconfig,
272 void **hfctx);
273
281void
283 yfFlowTab_t *flowtab);
284
285
292void
294 yfFlowTab_t *flowtab,
295 char *new_file_name);
296
308void
310 yfFlowTab_t *flowtab,
311 uint64_t *packets,
312 uint64_t *flows,
313 uint64_t *rej_pkts,
314 uint32_t *peak,
315 uint32_t *flush);
316
328void
330 yfFlowTab_t *flowtab,
331 size_t pbuflen,
332 yfPBuf_t *pbuf);
333
347gboolean
349 void *yfContext,
350 gboolean close,
351 GError **err);
352
359void
361 const yfFlowTab_t *flowtab,
362 yfTime_t *yftime);
363
372uint64_t
374 yfFlowTab_t *flowtab,
375 GTimer *timer);
376
377#endif /* ifndef _YAF_TAB_H_ */
Configuration settings used to initalize the flow table in yfFlowTabAlloc().
Definition yaftab.h:120
gboolean pcap_index
If TRUE, print one line per packet we export.
Definition yaftab.h:230
gboolean flowstats_mode
If TRUE, then YAF will do some extra calculations on flows.
Definition yaftab.h:196
uint32_t max_payload
Maximum octets of payload to capture per flow direction.
Definition yaftab.h:145
gboolean silk_mode
If TRUE, clamp totalOctetCount and maxTotalOctetCount to 32 bits and force active timeout on overflow...
Definition yaftab.h:242
gboolean entropy_mode
If TRUE, then a Shannon Entropy measurement is made over the captured payload (as limited by max_payl...
Definition yaftab.h:192
const char * pcap_meta_file
File for pcap meta output.
Definition yaftab.h:160
gboolean ndpi
If TRUE, enable nDPI application labeling with standard protocols.
Definition yaftab.h:215
const char * ndpi_proto_file
If not NULL, and ndpi is TRUE, use the provided protocol file to expand the sub-protocols list and po...
Definition yaftab.h:151
gboolean p0f_mode
If TRUE, then this will enable passive OS finger printing using the p0f engine based mostly on TCP ne...
Definition yaftab.h:225
gboolean fpexport_mode
If TRUE, then this will enable exporting of full packet banners of the TCP negotiations for the first...
Definition yaftab.h:207
gboolean uniflow_mode
If TRUE, export biflows using record adjacency (two uniflows exported back-to-back.
Definition yaftab.h:254
const char * pcap_dir
Directory to put pcap-per-flow files.
Definition yaftab.h:156
gboolean no_vlan_in_key
If TRUE, this will remove the vlan in the calculation of the flow key hash.
Definition yaftab.h:220
gboolean applabel_mode
If TRUE, then the payload, (as limited by max_payload,) is sent through various plugins and code in o...
Definition yaftab.h:186
uint16_t udp_uniflow_port
If not 0, then this will enable exporting a single UDP packet with this src/dst port as a flow.
Definition yaftab.h:178
gboolean pcap_per_flow
If TRUE, then pcap_dir will be set to the directory to place pcap-per-flow files.
Definition yaftab.h:235
uint32_t max_flows
Maximum number of active flows.
Definition yaftab.h:138
gboolean mac_mode
If TRUE, collect and export source and destination Mac Addresses.
Definition yaftab.h:211
int32_t idle_sec
Idle timeout in seconds.
Definition yaftab.h:131
uint32_t pcap_search_flowkey
The flow key hash to create a PCAP for.
Definition yaftab.h:168
int32_t active_sec
Active timeout in seconds.
Definition yaftab.h:126
uint64_t pcap_max
Maximum size [in bytes] of a pcap file before rotating.
Definition yaftab.h:164
gboolean udp_multipkt_payload
If TRUE, then this will enable capturing payload for all UDP packets in a flow (instead of just the f...
Definition yaftab.h:248
gboolean force_read_all
If TRUE, then yaf will process files that are out of sequence.
Definition yaftab.h:201
const char * pcap_search_stime
The start time to create a PCAP for.
Definition yaftab.h:172
Full packet information structure.
Definition decode.h:133
YAF timestamp: represents a moment in time.
Definition yaftime.h:47
YAF Core Library.
void yfUpdateRollingPcapFile(yfFlowTab_t *flowtab, char *new_file_name)
Update the Pcap Filename in the Flowtab for pcap meta data output.
void yfFlowTabCurrentTime(const yfFlowTab_t *flowtab, yfTime_t *yftime)
Get the current packet clock from a flow table.
void yfFlowTabFree(yfFlowTab_t *flowtab)
Free a previously allocated flow table.
gboolean yfFlowTabFlush(void *yfContext, gboolean close, GError **err)
Flush closed flows in the given flow table to the given IPFIX Message Buffer.
struct yfFlowTabConfig_st yfFlowTabConfig_t
Configuration settings used to initalize the flow table in yfFlowTabAlloc().
void yfGetFlowTabStats(yfFlowTab_t *flowtab, uint64_t *packets, uint64_t *flows, uint64_t *rej_pkts, uint32_t *peak, uint32_t *flush)
yfGetFlowTabStats Get Flow Table Stats for Export
void yfFlowPBuf(yfFlowTab_t *flowtab, size_t pbuflen, yfPBuf_t *pbuf)
Add a decoded packet buffer to a given flow table.
uint64_t yfFlowDumpStats(yfFlowTab_t *flowtab, GTimer *timer)
Print flow table statistics to the log.
struct yfFlowTab_st yfFlowTab_t
A flow table.
Definition yaftab.h:114
yfFlowTab_t * yfFlowTabAlloc(const yfFlowTabConfig_t *ftconfig, void **hfctx)
yfFlowTabAlloc