netflow: Correctly set active timeout value.
[sliver-openvswitch.git] / ofproto / netflow.h
1 /*
2  * Copyright (c) 2008, 2009 Nicira Networks.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef NETFLOW_H
18 #define NETFLOW_H 1
19
20 #include "flow.h"
21 #include "svec.h"
22
23 static const int NF_ACTIVE_TIMEOUT_DEFAULT = 600;
24
25 struct ofexpired;
26
27 struct netflow_options {
28     struct svec collectors;
29     uint8_t engine_type;
30     uint8_t engine_id;
31     int active_timeout;
32     bool add_id_to_iface;
33 };
34
35 enum netflow_output_ports {
36     NF_OUT_FLOOD = UINT16_MAX,
37     NF_OUT_MULTI = UINT16_MAX - 1,
38     NF_OUT_DROP = UINT16_MAX - 2
39 };
40
41 struct netflow_flow {
42     long long int last_expired;   /* Time this flow last timed out. */
43     long long int created;        /* Time flow was created since time out. */
44
45     uint64_t packet_count_off;    /* Packet count at last time out. */
46     uint64_t byte_count_off;      /* Byte count at last time out. */
47
48     uint16_t output_iface;        /* Output interface index. */
49     uint8_t ip_tos;               /* Last-seen IP type-of-service. */
50     uint8_t tcp_flags;            /* Bitwise-OR of all TCP flags seen. */
51 };
52
53 struct netflow *netflow_create(void);
54 void netflow_destroy(struct netflow *);
55 int netflow_set_options(struct netflow *, const struct netflow_options *);
56 void netflow_expire(struct netflow *, struct netflow_flow *,
57                     struct ofexpired *);
58 void netflow_run(struct netflow *);
59
60 void netflow_flow_clear(struct netflow_flow *);
61 void netflow_flow_update_time(struct netflow *, struct netflow_flow *,
62                               long long int used);
63 void netflow_flow_update_flags(struct netflow_flow *, uint8_t ip_tos,
64                                uint8_t tcp_flags);
65 bool netflow_active_timeout_expired(struct netflow *, struct netflow_flow *);
66
67 #endif /* netflow.h */