In the future, if CT ever has to be abstracted out this will make it easier.
Signed-off-by: Aaron Conole <[email protected]> --- lib/automake.mk | 1 + lib/ct-state.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ lib/flow.h | 1 + lib/packets.h | 31 ------------------------------ 4 files changed, 52 insertions(+), 31 deletions(-) create mode 100644 lib/ct-state.h diff --git a/lib/automake.mk b/lib/automake.mk index 51aa99118f..879300b4a2 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -99,6 +99,7 @@ lib_libopenvswitch_la_SOURCES = \ lib/cooperative-multitasking-private.h \ lib/coverage.c \ lib/coverage.h \ + lib/ct-state.h \ lib/cpu.c \ lib/cpu.h \ lib/crc32c.c \ diff --git a/lib/ct-state.h b/lib/ct-state.h new file mode 100644 index 0000000000..7033744e0a --- /dev/null +++ b/lib/ct-state.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, 2017 Nicira, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef CT_STATE_H +#define CT_STATE_H 1 + +/* Connection states. + * + * Names like CS_RELATED are bit values, e.g. 1 << 2. + * Names like CS_RELATED_BIT are bit indexes, e.g. 2. */ +#define CS_STATES \ + CS_STATE(NEW, 0, "new") \ + CS_STATE(ESTABLISHED, 1, "est") \ + CS_STATE(RELATED, 2, "rel") \ + CS_STATE(REPLY_DIR, 3, "rpl") \ + CS_STATE(INVALID, 4, "inv") \ + CS_STATE(TRACKED, 5, "trk") \ + CS_STATE(SRC_NAT, 6, "snat") \ + CS_STATE(DST_NAT, 7, "dnat") + +enum { +#define CS_STATE(ENUM, INDEX, NAME) \ + CS_##ENUM = 1 << INDEX, \ + CS_##ENUM##_BIT = INDEX, + CS_STATES +#undef CS_STATE +}; + +/* Undefined connection state bits. */ +enum { +#define CS_STATE(ENUM, INDEX, NAME) +CS_##ENUM + CS_SUPPORTED_MASK = CS_STATES +#undef CS_STATE +}; +#define CS_UNSUPPORTED_MASK (~(uint32_t)CS_SUPPORTED_MASK) + +#endif /* ct-state.h */ diff --git a/lib/flow.h b/lib/flow.h index 0b67438487..bf0656cacd 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -25,6 +25,7 @@ #include "bitmap.h" #include "byte-order.h" #include "openvswitch/compiler.h" +#include "ct-state.h" #include "openflow/nicira-ext.h" #include "openflow/openflow.h" #include "openvswitch/flow.h" diff --git a/lib/packets.h b/lib/packets.h index ad12272244..e85a99d07f 100644 --- a/lib/packets.h +++ b/lib/packets.h @@ -220,37 +220,6 @@ void pop_eth(struct dp_packet *packet); void push_nsh(struct dp_packet *packet, const struct nsh_hdr *nsh_hdr_src); bool pop_nsh(struct dp_packet *packet); -/* Connection states. - * - * Names like CS_RELATED are bit values, e.g. 1 << 2. - * Names like CS_RELATED_BIT are bit indexes, e.g. 2. */ -#define CS_STATES \ - CS_STATE(NEW, 0, "new") \ - CS_STATE(ESTABLISHED, 1, "est") \ - CS_STATE(RELATED, 2, "rel") \ - CS_STATE(REPLY_DIR, 3, "rpl") \ - CS_STATE(INVALID, 4, "inv") \ - CS_STATE(TRACKED, 5, "trk") \ - CS_STATE(SRC_NAT, 6, "snat") \ - CS_STATE(DST_NAT, 7, "dnat") - -enum { -#define CS_STATE(ENUM, INDEX, NAME) \ - CS_##ENUM = 1 << INDEX, \ - CS_##ENUM##_BIT = INDEX, - CS_STATES -#undef CS_STATE -}; - -/* Undefined connection state bits. */ -enum { -#define CS_STATE(ENUM, INDEX, NAME) +CS_##ENUM - CS_SUPPORTED_MASK = CS_STATES -#undef CS_STATE -}; -#define CS_UNSUPPORTED_MASK (~(uint32_t)CS_SUPPORTED_MASK) - - void *eth_compose(struct dp_packet *, const struct eth_addr eth_dst, const struct eth_addr eth_src, uint16_t eth_type, size_t size); -- 2.51.0 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
