flowmon-export-ipfix
1.2.1
FlowMon IPFIX Export Plugin
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
flowmon-export-ipfix.h
Go to the documentation of this file.
1
39
#include <time.h>
40
#include <netdb.h>
41
42
#ifdef DEBUG
43
#define MSG(format, ...) fprintf(stderr, format, ## __VA_ARGS__)
44
#else
45
#define MSG(format, ...) {}
46
#endif
47
48
#define DEFAULT_TEMPLATE_FILE "/etc/flowmon/ipfix-template-file.txt"
49
#define FIRST_TEMPLATE_ID 258
50
#define IPFIX_VERISON 10
51
#define TEMPLATE_SET_ID 2
52
#define PACKET_DATA_SIZE 1458
/* ethernet 14, ip 20, udp 8 */
53
/* Template buffer cannot be filled more than to packet data size */
54
#define TEMPLATE_BUFFER_SIZE (PACKET_DATA_SIZE - IPFIX_HEADER_SIZE)
55
#define IPFIX_HEADER_SIZE 16
56
#define IPFIX_SET_HEADER_SIZE 4
57
#define RECONNECT_TIMEOUT 60
58
64
typedef
struct
{
65
char
*
getterName
;
66
uint16_t
enterpriseNumber
;
67
uint16_t
elementID
;
68
int32_t
length
;
69
}
template_file_record_t
;
70
71
75
typedef
struct
template_t
{
76
uint16_t
id
;
77
uint8_t
templateRecord
[1024];
79
uint16_t
templateSize
;
80
uint8_t
buffer
[
TEMPLATE_BUFFER_SIZE
];
81
uint16_t
bufferSize
;
82
uint16_t
recordCount
;
83
uint16_t
fieldCount
;
84
uint64_t
mask
;
85
flow_record_getter_t *
templateGetters
;
86
template_file_record_t
**
templateFileRecords
;
87
uint8_t
exported
;
88
time_t
exportTime
;
89
uint64_t
exportPacket
;
90
struct
template_t
*
next
;
91
}
template_t
;
92
93
97
typedef
struct
{
98
/* General */
99
flow_record_getter_t *
getters
;
100
uint32_t
sequenceNum
;
101
uint64_t
counter
;
102
uint64_t
exportedPackets
;
103
int
socket
;
104
struct
addrinfo *
addrinfo
;
106
/* Parameters */
107
char
*
host
;
108
char
*
templateFile
;
109
char
*
port
;
110
int
protocol
;
111
int
ip
;
112
int
flags
;
113
uint32_t
reconnectTimeout
;
114
time_t
lastReconnect
;
115
uint32_t
odid
;
116
uint32_t
templateRefreshTime
;
117
uint32_t
templateRefreshPackets
;
119
/* Templates */
120
template_file_record_t
*
templateFileRecords
;
121
template_t
*
templates
;
122
uint16_t
templatesDataSize
;
123
}
plugin_private_t
;
124
125
129
typedef
struct
{
130
char
*
data
;
131
uint16_t
length
;
132
uint16_t
flows
;
133
}
ipfix_packet_t
;
134
135
152
typedef
struct
ipfix_header
{
158
uint16_t
version
;
159
164
uint16_t
length
;
165
170
uint32_t
exportTime
;
171
181
uint32_t
sequenceNumber
;
182
196
uint32_t
observationDomainId
;
197
}
ipfix_header_t
;
198
209
typedef
struct
ipfix_template_set_header
{
217
uint16_t
id
;
218
225
uint16_t
length
;
226
227
}
ipfix_template_set_header_t
;
228
232
static
plugin_desc_t plugin_desc = {
233
"ipfixx"
,
234
"Plugin that exports data using IPFIX protocol\n"
235
"Parameters are (delimited by ','):\n"
236
" host=hostname (default = localhost)\n"
237
" port=port (default = 4739)\n"
238
" ip=ip IP version used to connect to collector (4,6,64 or default).\n"
239
" 64 uses IPv6 and then IPv4 mapped addresses, default takes priorities from the system.\n"
240
" protocol=proto Protocol used to connect to collector - udp(default),tcp,sctp.\n"
241
" reconnect-timeout=seconds Timeout in seconds between reconnect attempts.\n"
242
" odid=id Observation Domain ID (default = 0).\n"
243
" template-file=filename File with template parameters. (default = /etc/flowmon/ipfix-template-file.txt).\n"
244
" template-refresh-time=time Send templates to collector each 'time' seconds. UDP only (default = 600).\n"
245
" template-refresh-packets=num Send templates to collector each 'num' packets. UDP only.\n"
,
246
0,
247
0
248
};
© 2012 Masaryk University - Institute of Computer Science - visit
http://www.muni.cz/ics/