]> git.proxmox.com Git - ovs.git/blame - lib/ct-dpif.h
lib: Indicate if netlink message had labels.
[ovs.git] / lib / ct-dpif.h
CommitLineData
3948eb54
DDP
1/*
2 * Copyright (c) 2015 Nicira, Inc.
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 CT_DPIF_H
18#define CT_DPIF_H
19
20#include "openvswitch/types.h"
21#include "packets.h"
22
23union ct_dpif_inet_addr {
24 ovs_be32 ip;
25 ovs_be32 ip6[4];
26 struct in_addr in;
27 struct in6_addr in6;
28};
29
30struct ct_dpif_tuple {
31 uint16_t l3_type; /* Address family. */
32 uint8_t ip_proto;
33 union ct_dpif_inet_addr src;
34 union ct_dpif_inet_addr dst;
35 union {
36 ovs_be16 src_port;
37 ovs_be16 icmp_id;
38 };
39 union {
40 ovs_be16 dst_port;
41 struct {
42 uint8_t icmp_type;
43 uint8_t icmp_code;
44 };
45 };
46};
47BUILD_ASSERT_DECL(sizeof(struct ct_dpif_tuple) % 8 == 0);
48
49struct ct_dpif_counters {
50 uint64_t packets;
51 uint64_t bytes;
52};
53
54/* Nanoseconds from January 1, 1970 */
55struct ct_dpif_timestamp {
56 /* When the entry was created */
57 uint64_t start;
58 /* When the entry was deleted */
59 uint64_t stop;
60};
61
62#define CT_DPIF_TCP_STATES \
63 CT_DPIF_TCP_STATE(CLOSED) \
64 CT_DPIF_TCP_STATE(LISTEN) \
65 CT_DPIF_TCP_STATE(SYN_SENT) \
66 CT_DPIF_TCP_STATE(SYN_RECV) \
67 CT_DPIF_TCP_STATE(ESTABLISHED) \
68 CT_DPIF_TCP_STATE(CLOSE_WAIT) \
69 CT_DPIF_TCP_STATE(FIN_WAIT_1) \
70 CT_DPIF_TCP_STATE(CLOSING) \
71 CT_DPIF_TCP_STATE(LAST_ACK) \
72 CT_DPIF_TCP_STATE(FIN_WAIT_2) \
73 CT_DPIF_TCP_STATE(TIME_WAIT)
74
75enum ct_dpif_tcp_state {
76#define CT_DPIF_TCP_STATE(STATE) CT_DPIF_TCPS_##STATE,
77 CT_DPIF_TCP_STATES
78#undef CT_DPIF_TCP_STATE
79};
80
81extern const char *ct_dpif_tcp_state_string[];
82
83#define CT_DPIF_TCP_FLAGS \
84 CT_DPIF_TCP_FLAG(WINDOW_SCALE) \
85 CT_DPIF_TCP_FLAG(SACK_PERM) \
86 CT_DPIF_TCP_FLAG(CLOSE_INIT) \
87 CT_DPIF_TCP_FLAG(BE_LIBERAL) \
88 CT_DPIF_TCP_FLAG(DATA_UNACKNOWLEDGED) \
89 CT_DPIF_TCP_FLAG(MAXACK_SET) \
90
91enum ct_dpif_tcp_flags_count_ {
92#define CT_DPIF_TCP_FLAG(FLAG) FLAG##_COUNT_,
93 CT_DPIF_TCP_FLAGS
94#undef CT_DPIF_TCP_FLAG
95};
96
97enum ct_dpif_tcp_flags {
98#define CT_DPIF_TCP_FLAG(FLAG) CT_DPIF_TCPF_##FLAG = (1 << FLAG##_COUNT_),
99 CT_DPIF_TCP_FLAGS
100#undef CT_DPIF_TCP_FLAG
101};
102
103struct ct_dpif_protoinfo {
104 uint16_t proto; /* IPPROTO_* */
105 union {
106 struct {
107 uint8_t state_orig;
108 uint8_t state_reply;
109 uint8_t wscale_orig;
110 uint8_t wscale_reply;
111 uint8_t flags_orig;
112 uint8_t flags_reply;
113 } tcp;
114 };
115};
116
117struct ct_dpif_helper {
118 char *name;
119};
120
121#define CT_DPIF_STATUS_FLAGS \
122 CT_DPIF_STATUS_FLAG(EXPECTED) \
123 CT_DPIF_STATUS_FLAG(SEEN_REPLY) \
124 CT_DPIF_STATUS_FLAG(ASSURED) \
125 CT_DPIF_STATUS_FLAG(CONFIRMED) \
126 CT_DPIF_STATUS_FLAG(SRC_NAT) \
127 CT_DPIF_STATUS_FLAG(DST_NAT) \
128 CT_DPIF_STATUS_FLAG(SEQ_ADJUST) \
129 CT_DPIF_STATUS_FLAG(SRC_NAT_DONE) \
130 CT_DPIF_STATUS_FLAG(DST_NAT_DONE) \
131 CT_DPIF_STATUS_FLAG(DYING) \
132 CT_DPIF_STATUS_FLAG(FIXED_TIMEOUT) \
133 CT_DPIF_STATUS_FLAG(TEMPLATE) \
134 CT_DPIF_STATUS_FLAG(UNTRACKED) \
135
136enum ct_dpif_status_flags_count_ {
137#define CT_DPIF_STATUS_FLAG(FLAG) FLAG##_COUNT_,
138 CT_DPIF_STATUS_FLAGS
139#undef CT_DPIF_STATUS_FLAG
140};
141
142enum ct_dpif_status_flags {
143#define CT_DPIF_STATUS_FLAG(FLAG) CT_DPIF_STATUS_##FLAG = (1 << FLAG##_COUNT_),
144 CT_DPIF_STATUS_FLAGS
145#undef CT_DPIF_STATUS_FLAG
146};
147
148struct ct_dpif_entry {
149 /* Const members. */
150 struct ct_dpif_tuple tuple_orig;
151 struct ct_dpif_tuple tuple_reply;
152 struct ct_dpif_tuple tuple_master;
153 struct ct_dpif_helper helper;
154 uint32_t id;
155 uint16_t zone;
156
157 /* Modifiable members. */
158
159 struct ct_dpif_counters counters_orig;
160 struct ct_dpif_counters counters_reply;
161
162 struct ct_dpif_timestamp timestamp;
163 struct ct_dpif_protoinfo protoinfo;
164
165 ovs_u128 labels;
e7237700 166 bool have_labels;
3948eb54
DDP
167 uint32_t status;
168 /* Timeout for this entry in seconds */
169 uint32_t timeout;
170 uint32_t mark;
171};
172
b77d9629
DDP
173struct dpif;
174
175struct ct_dpif_dump_state {
176 struct dpif *dpif;
177};
178
179int ct_dpif_dump_start(struct dpif *, struct ct_dpif_dump_state **,
180 const uint16_t *zone);
181int ct_dpif_dump_next(struct ct_dpif_dump_state *, struct ct_dpif_entry *);
182int ct_dpif_dump_done(struct ct_dpif_dump_state *);
a0f7b6d5 183int ct_dpif_flush(struct dpif *, const uint16_t *zone);
3948eb54
DDP
184void ct_dpif_entry_uninit(struct ct_dpif_entry *);
185void ct_dpif_format_entry(const struct ct_dpif_entry *, struct ds *,
186 bool verbose, bool print_stats);
b269a122 187void ct_dpif_format_tuple(struct ds *, const struct ct_dpif_tuple *);
3948eb54
DDP
188
189#endif /* CT_DPIF_H */