FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
ipfix_packet.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Cisco and/or its affiliates.
3
* Licensed under the Apache License, Version 2.0 (the "License");
4
* you may not use this file except in compliance with the License.
5
* You may obtain a copy of the License at:
6
*
7
* http://www.apache.org/licenses/LICENSE-2.0
8
*
9
* Unless required by applicable law or agreed to in writing, software
10
* distributed under the License is distributed on an "AS IS" BASIS,
11
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
* See the License for the specific language governing permissions and
13
* limitations under the License.
14
*/
15
#ifndef __included_ipfix_packet_h__
16
#define __included_ipfix_packet_h__
17
18
#include <
vnet/ipfix-export/ipfix_info_elements.h
>
19
20
/* From RFC-7011:
21
* https://tools.ietf.org/html/rfc7011
22
*/
23
24
typedef
struct
25
{
26
u32
version_length
;
27
u32
export_time
;
28
u32
sequence_number
;
29
u32
domain_id
;
30
}
ipfix_message_header_t
;
31
32
static
inline
u32
33
version_length
(
u16
length
)
34
{
35
return
clib_host_to_net_u32 (0x000a0000 |
length
);
36
}
37
38
39
/*
40
* The Field Specifier format is shown in Figure G.
41
*
42
* 0 1 2 3
43
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
44
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45
* |E| Information Element ident. | Field Length |
46
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47
* | Enterprise Number |
48
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49
*
50
* Figure G: Field Specifier Format
51
*
52
* Where:
53
*
54
* E
55
*
56
* Enterprise bit. This is the first bit of the Field Specifier. If
57
* this bit is zero, the Information Element identifier identifies an
58
* Information Element in [IANA-IPFIX], and the four-octet Enterprise
59
* Number field MUST NOT be present. If this bit is one, the
60
* Information Element identifier identifies an enterprise-specific
61
* Information Element, and the Enterprise Number field MUST be
62
* present.
63
*/
64
65
typedef
struct
66
{
67
u32
e_id_length
;
68
u32
enterprise
;
69
}
ipfix_enterprise_field_specifier_t
;
70
71
typedef
struct
72
{
73
u32
e_id_length
;
74
}
ipfix_field_specifier_t
;
75
76
static
inline
u32
77
ipfix_e_id_length
(
int
e,
u16
id
,
u16
length
)
78
{
79
u32
value
;
80
value
= (e << 31) | ((
id
& 0x7FFF) << 16) |
length
;
81
return
clib_host_to_net_u32 (
value
);
82
}
83
84
/*
85
* Every Set contains a common header. This header is defined in
86
* Figure I.
87
*
88
* 0 1 2 3
89
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
90
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91
* | Set ID | Length |
92
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93
*
94
* Figure I: Set Header Format
95
*
96
* Each Set Header field is exported in network format. The fields are
97
* defined as follows:
98
*
99
* Set ID
100
*
101
* Identifies the Set. A value of 2 is reserved for Template Sets.
102
* A value of 3 is reserved for Options Template Sets. Values from 4
103
* to 255 are reserved for future use. Values 256 and above are used
104
* for Data Sets. The Set ID values of 0 and 1 are not used, for
105
* historical reasons [RFC3954].
106
*
107
* Length
108
*
109
* Total length of the Set, in octets, including the Set Header, all
110
* records, and the optional padding. Because an individual Set MAY
111
* contain multiple records, the Length value MUST be used to
112
* determine the position of the next Set.
113
*/
114
115
typedef
struct
116
{
117
u32
set_id_length
;
118
}
ipfix_set_header_t
;
119
120
static
inline
u32
121
ipfix_set_id_length
(
u16
set_id,
u16
length
)
122
{
123
return
clib_host_to_net_u32 ((set_id << 16) |
length
);
124
}
125
126
/*
127
* The format of the Template Record is shown in Figure J. It consists
128
* of a Template Record Header and one or more Field Specifiers. Field
129
* Specifiers are defined in Figure G above.
130
*
131
* +--------------------------------------------------+
132
* | Template Record Header |
133
* +--------------------------------------------------+
134
* | Field Specifier |
135
* +--------------------------------------------------+
136
* | Field Specifier |
137
* +--------------------------------------------------+
138
* ...
139
* +--------------------------------------------------+
140
* | Field Specifier |
141
* +--------------------------------------------------+
142
*
143
* Figure J: Template Record Format
144
*
145
* The format of the Template Record Header is shown in Figure K.
146
*
147
* 0 1 2 3
148
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
149
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150
* | Template ID (> 255) | Field Count |
151
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152
*
153
* Figure K: Template Record Header Format
154
*
155
* The Template Record Header Field definitions are as follows:
156
*
157
* Template ID
158
*
159
* Each Template Record is given a unique Template ID in the range
160
* 256 to 65535. This uniqueness is local to the Transport Session
161
* and Observation Domain that generated the Template ID. Since
162
* Template IDs are used as Set IDs in the Sets they describe (see
163
* Section 3.4.3), values 0-255 are reserved for special Set types
164
* (e.g., Template Sets themselves), and Templates and Options
165
* Templates (see Section 3.4.2) cannot share Template IDs within a
166
* Transport Session and Observation Domain. There are no
167
* constraints regarding the order of the Template ID allocation. As
168
* Exporting Processes are free to allocate Template IDs as they see
169
* fit, Collecting Processes MUST NOT assume incremental Template
170
* IDs, or anything about the contents of a Template based on its
171
* Template ID alone.
172
*
173
* Field Count
174
*
175
* Number of fields in this Template Record.
176
*/
177
178
typedef
struct
179
{
180
u32
id_count
;
181
}
ipfix_template_header_t
;
182
183
static
inline
u32
184
ipfix_id_count
(
u16
id
,
u16
count
)
185
{
186
return
clib_host_to_net_u32 ((
id
<< 16) |
count
);
187
}
188
189
/* Template packet */
190
typedef
struct
191
{
192
ipfix_message_header_t
h
;
193
ipfix_set_header_t
s
;
194
ipfix_template_header_t
t
;
195
ipfix_field_specifier_t
fields[0];
196
}
ipfix_template_packet_t
;
197
198
#endif
/* __included_ipfix_packet_h__ */
199
200
/*
201
* fd.io coding-style-patch-verification: ON
202
*
203
* Local Variables:
204
* eval: (c-set-style "gnu")
205
* End:
206
*/
ipfix_template_packet_t::t
ipfix_template_header_t t
Definition:
ipfix_packet.h:194
ipfix_e_id_length
static u32 ipfix_e_id_length(int e, u16 id, u16 length)
Definition:
ipfix_packet.h:77
ipfix_set_header_t
Definition:
ipfix_packet.h:115
u16
unsigned short u16
Definition:
types.h:57
ipfix_field_specifier_t::e_id_length
u32 e_id_length
Definition:
ipfix_packet.h:73
ipfix_message_header_t::sequence_number
u32 sequence_number
Definition:
ipfix_packet.h:28
ipfix_message_header_t::domain_id
u32 domain_id
Definition:
ipfix_packet.h:29
ipfix_template_packet_t::h
ipfix_message_header_t h
Definition:
ipfix_packet.h:192
count
u8 count
Definition:
dhcp.api:208
ipfix_enterprise_field_specifier_t::e_id_length
u32 e_id_length
Definition:
ipfix_packet.h:67
ipfix_message_header_t::export_time
u32 export_time
Definition:
ipfix_packet.h:27
ipfix_message_header_t::version_length
u32 version_length
Definition:
ipfix_packet.h:26
version_length
static u32 version_length(u16 length)
Definition:
ipfix_packet.h:33
ipfix_message_header_t
Definition:
ipfix_packet.h:24
ipfix_enterprise_field_specifier_t::enterprise
u32 enterprise
Definition:
ipfix_packet.h:68
ipfix_info_elements.h
ipfix_id_count
static u32 ipfix_id_count(u16 id, u16 count)
Definition:
ipfix_packet.h:184
ipfix_template_packet_t
Definition:
ipfix_packet.h:190
u32
unsigned int u32
Definition:
types.h:88
value
u8 value
Definition:
qos.api:54
ipfix_template_header_t
Definition:
ipfix_packet.h:178
length
char const int length
Definition:
cJSON.h:163
ipfix_field_specifier_t
Definition:
ipfix_packet.h:71
ipfix_set_id_length
static u32 ipfix_set_id_length(u16 set_id, u16 length)
Definition:
ipfix_packet.h:121
ipfix_set_header_t::set_id_length
u32 set_id_length
Definition:
ipfix_packet.h:117
ipfix_template_packet_t::s
ipfix_set_header_t s
Definition:
ipfix_packet.h:193
ipfix_enterprise_field_specifier_t
Definition:
ipfix_packet.h:65
ipfix_template_header_t::id_count
u32 id_count
Definition:
ipfix_packet.h:180
src
vnet
ipfix-export
ipfix_packet.h
Generated on Sat Jan 8 2022 10:36:42 for FD.io VPP by
1.8.17