]>
Commit | Line | Data |
---|---|---|
064af421 | 1 | /* |
54e05b5f | 2 | * Copyright (c) 2008, 2009, 2010 Nicira Networks. |
064af421 | 3 | * |
a14bc59f BP |
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: | |
064af421 | 7 | * |
a14bc59f BP |
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. | |
064af421 BP |
15 | */ |
16 | ||
17 | #ifndef NETFLOW_H | |
18 | #define NETFLOW_H 1 | |
19 | ||
54e05b5f | 20 | #include <stdint.h> |
064af421 | 21 | #include "flow.h" |
0193b2af | 22 | #include "svec.h" |
064af421 | 23 | |
137fea8d BP |
24 | /* Default active timeout interval, in seconds. |
25 | * | |
26 | * (The active timeout interval is the interval at which NetFlow records are | |
27 | * sent for flows that do not expire, so that such flows are still | |
28 | * accounted.) */ | |
29 | #define NF_ACTIVE_TIMEOUT_DEFAULT 600 | |
e9e2856e | 30 | |
064af421 | 31 | struct ofexpired; |
0193b2af JG |
32 | |
33 | struct netflow_options { | |
34 | struct svec collectors; | |
35 | uint8_t engine_type; | |
36 | uint8_t engine_id; | |
37 | int active_timeout; | |
38 | bool add_id_to_iface; | |
39 | }; | |
064af421 | 40 | |
6a07af36 JG |
41 | enum netflow_output_ports { |
42 | NF_OUT_FLOOD = UINT16_MAX, | |
43 | NF_OUT_MULTI = UINT16_MAX - 1, | |
44 | NF_OUT_DROP = UINT16_MAX - 2 | |
45 | }; | |
46 | ||
0193b2af JG |
47 | struct netflow_flow { |
48 | long long int last_expired; /* Time this flow last timed out. */ | |
49 | long long int created; /* Time flow was created since time out. */ | |
50 | ||
51 | uint64_t packet_count_off; /* Packet count at last time out. */ | |
52 | uint64_t byte_count_off; /* Byte count at last time out. */ | |
53 | ||
54 | uint16_t output_iface; /* Output interface index. */ | |
0193b2af JG |
55 | uint8_t tcp_flags; /* Bitwise-OR of all TCP flags seen. */ |
56 | }; | |
57 | ||
064af421 BP |
58 | struct netflow *netflow_create(void); |
59 | void netflow_destroy(struct netflow *); | |
0193b2af JG |
60 | int netflow_set_options(struct netflow *, const struct netflow_options *); |
61 | void netflow_expire(struct netflow *, struct netflow_flow *, | |
62 | struct ofexpired *); | |
064af421 BP |
63 | void netflow_run(struct netflow *); |
64 | ||
d6de72a1 | 65 | void netflow_flow_init(struct netflow_flow *); |
0193b2af JG |
66 | void netflow_flow_clear(struct netflow_flow *); |
67 | void netflow_flow_update_time(struct netflow *, struct netflow_flow *, | |
68 | long long int used); | |
abfec865 | 69 | void netflow_flow_update_flags(struct netflow_flow *, uint8_t tcp_flags); |
0193b2af JG |
70 | bool netflow_active_timeout_expired(struct netflow *, struct netflow_flow *); |
71 | ||
064af421 | 72 | #endif /* netflow.h */ |