2 * Copyright (c) 2015 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 #include "openvswitch/types.h"
23 union ct_dpif_inet_addr
{
30 struct ct_dpif_tuple
{
31 uint16_t l3_type
; /* Address family. */
33 union ct_dpif_inet_addr src
;
34 union ct_dpif_inet_addr dst
;
47 BUILD_ASSERT_DECL(sizeof(struct ct_dpif_tuple
) % 8 == 0);
49 struct ct_dpif_counters
{
54 /* Nanoseconds from January 1, 1970 */
55 struct ct_dpif_timestamp
{
56 /* When the entry was created */
58 /* When the entry was deleted */
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 CT_DPIF_TCP_STATE(MAX_NUM)
76 enum ct_dpif_tcp_state
{
77 #define CT_DPIF_TCP_STATE(STATE) CT_DPIF_TCPS_##STATE,
79 #undef CT_DPIF_TCP_STATE
82 extern const char *ct_dpif_tcp_state_string
[];
84 #define CT_DPIF_TCP_FLAGS \
85 CT_DPIF_TCP_FLAG(WINDOW_SCALE) \
86 CT_DPIF_TCP_FLAG(SACK_PERM) \
87 CT_DPIF_TCP_FLAG(CLOSE_INIT) \
88 CT_DPIF_TCP_FLAG(BE_LIBERAL) \
89 CT_DPIF_TCP_FLAG(DATA_UNACKNOWLEDGED) \
90 CT_DPIF_TCP_FLAG(MAXACK_SET) \
92 enum ct_dpif_tcp_flags_count_ {
93 #define CT_DPIF_TCP_FLAG(FLAG) FLAG##_COUNT_,
95 #undef CT_DPIF_TCP_FLAG
98 enum ct_dpif_tcp_flags
{
99 #define CT_DPIF_TCP_FLAG(FLAG) CT_DPIF_TCPF_##FLAG = (1 << FLAG##_COUNT_),
101 #undef CT_DPIF_TCP_FLAG
104 struct ct_dpif_protoinfo
{
105 uint16_t proto
; /* IPPROTO_* */
111 uint8_t wscale_reply
;
118 struct ct_dpif_helper
{
122 #define CT_DPIF_STATUS_FLAGS \
123 CT_DPIF_STATUS_FLAG(EXPECTED) \
124 CT_DPIF_STATUS_FLAG(SEEN_REPLY) \
125 CT_DPIF_STATUS_FLAG(ASSURED) \
126 CT_DPIF_STATUS_FLAG(CONFIRMED) \
127 CT_DPIF_STATUS_FLAG(SRC_NAT) \
128 CT_DPIF_STATUS_FLAG(DST_NAT) \
129 CT_DPIF_STATUS_FLAG(SEQ_ADJUST) \
130 CT_DPIF_STATUS_FLAG(SRC_NAT_DONE) \
131 CT_DPIF_STATUS_FLAG(DST_NAT_DONE) \
132 CT_DPIF_STATUS_FLAG(DYING) \
133 CT_DPIF_STATUS_FLAG(FIXED_TIMEOUT) \
134 CT_DPIF_STATUS_FLAG(TEMPLATE) \
135 CT_DPIF_STATUS_FLAG(UNTRACKED) \
137 enum ct_dpif_status_flags_count_ {
138 #define CT_DPIF_STATUS_FLAG(FLAG) FLAG##_COUNT_,
140 #undef CT_DPIF_STATUS_FLAG
143 enum ct_dpif_status_flags
{
144 #define CT_DPIF_STATUS_FLAG(FLAG) CT_DPIF_STATUS_##FLAG = (1 << FLAG##_COUNT_),
146 #undef CT_DPIF_STATUS_FLAG
149 struct ct_dpif_entry
{
151 struct ct_dpif_tuple tuple_orig
;
152 struct ct_dpif_tuple tuple_reply
;
153 struct ct_dpif_tuple tuple_master
;
154 struct ct_dpif_helper helper
;
158 /* Modifiable members. */
160 struct ct_dpif_counters counters_orig
;
161 struct ct_dpif_counters counters_reply
;
163 struct ct_dpif_timestamp timestamp
;
164 struct ct_dpif_protoinfo protoinfo
;
169 /* Timeout for this entry in seconds */
172 uint32_t bkt
; /* CT bucket number. */
190 struct ct_dpif_dump_state
{
194 int ct_dpif_dump_start(struct dpif
*, struct ct_dpif_dump_state
**,
195 const uint16_t *zone
, int *);
196 int ct_dpif_dump_next(struct ct_dpif_dump_state
*, struct ct_dpif_entry
*);
197 int ct_dpif_dump_done(struct ct_dpif_dump_state
*);
198 int ct_dpif_flush(struct dpif
*, const uint16_t *zone
,
199 const struct ct_dpif_tuple
*);
200 int ct_dpif_set_maxconns(struct dpif
*dpif
, uint32_t maxconns
);
201 int ct_dpif_get_maxconns(struct dpif
*dpif
, uint32_t *maxconns
);
202 int ct_dpif_get_nconns(struct dpif
*dpif
, uint32_t *nconns
);
203 void ct_dpif_entry_uninit(struct ct_dpif_entry
*);
204 void ct_dpif_format_entry(const struct ct_dpif_entry
*, struct ds
*,
205 bool verbose
, bool print_stats
);
206 void ct_dpif_format_tuple(struct ds
*, const struct ct_dpif_tuple
*);
207 uint8_t ct_dpif_coalesce_tcp_state(uint8_t state
);
208 void ct_dpif_format_tcp_stat(struct ds
*, int, int);
209 bool ct_dpif_parse_tuple(struct ct_dpif_tuple
*, const char *s
, struct ds
*);
211 #endif /* CT_DPIF_H */