2 * Copyright (c) 2008, 2009, 2010, 2011 Nicira, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 /* NetFlow v5 protocol definitions. */
23 #include "openvswitch/types.h"
26 #define NETFLOW_V5_VERSION 5
28 /* Every NetFlow v5 message contains the header that follows. This is
29 * followed by up to thirty records that describe a terminating flow.
30 * We only send a single record per NetFlow message.
32 struct netflow_v5_header {
33 ovs_be16 version; /* NetFlow version is 5. */
34 ovs_be16 count; /* Number of records in this message. */
35 ovs_be32 sysuptime; /* System uptime in milliseconds. */
36 ovs_be32 unix_secs; /* Number of seconds since Unix epoch. */
37 ovs_be32 unix_nsecs; /* Number of residual nanoseconds
38 after epoch seconds. */
39 ovs_be32 flow_seq; /* Number of flows since sending
41 uint8_t engine_type; /* Engine type. */
42 uint8_t engine_id; /* Engine id. */
43 ovs_be16 sampling_interval; /* Set to zero. */
45 BUILD_ASSERT_DECL(sizeof(struct netflow_v5_header) == 24);
47 /* A NetFlow v5 description of a terminating flow. It is preceded by a
50 struct netflow_v5_record {
51 ovs_be32 src_addr; /* Source IP address. */
52 ovs_be32 dst_addr; /* Destination IP address. */
53 ovs_be32 nexthop; /* IP address of next hop. Set to 0. */
54 ovs_be16 input; /* Input interface index. */
55 ovs_be16 output; /* Output interface index. */
56 ovs_be32 packet_count; /* Number of packets. */
57 ovs_be32 byte_count; /* Number of bytes. */
58 ovs_be32 init_time; /* Value of sysuptime on first packet. */
59 ovs_be32 used_time; /* Value of sysuptime on last packet. */
61 /* The 'src_port' and 'dst_port' identify the source and destination
62 * port, respectively, for TCP and UDP. For ICMP, the high-order
63 * byte identifies the type and low-order byte identifies the code
64 * in the 'dst_port' field. */
69 uint8_t tcp_flags; /* Union of seen TCP flags. */
70 uint8_t ip_proto; /* IP protocol. */
71 uint8_t ip_tos; /* IP TOS value. */
72 ovs_be16 src_as; /* Source AS ID. Set to 0. */
73 ovs_be16 dst_as; /* Destination AS ID. Set to 0. */
74 uint8_t src_mask; /* Source mask bits. Set to 0. */
75 uint8_t dst_mask; /* Destination mask bits. Set to 0. */
78 BUILD_ASSERT_DECL(sizeof(struct netflow_v5_record) == 48);
80 #endif /* lib/netflow.h */