This will have its first user in an upcoming commit.

Signed-off-by: Ben Pfaff <[email protected]>
---
 lib/flow.c | 15 ++++++++++++++-
 lib/flow.h |  4 +++-
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/flow.c b/lib/flow.c
index 5f9c3d0e3a88..7552cd72a173 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -1000,7 +1000,8 @@ flow_get_metadata(const struct flow *flow, struct match 
*flow_metadata)
     }
 }
 
-const char *ct_state_to_string(uint32_t state)
+const char *
+ct_state_to_string(uint32_t state)
 {
     switch (state) {
 #define CS_STATE(ENUM, INDEX, NAME) case CS_##ENUM: return NAME;
@@ -1011,6 +1012,18 @@ const char *ct_state_to_string(uint32_t state)
     }
 }
 
+uint32_t
+ct_state_from_string(const char *s)
+{
+#define CS_STATE(ENUM, INDEX, NAME) \
+    if (!strcmp(s, NAME)) {         \
+        return CS_##ENUM;           \
+    }
+    CS_STATES
+#undef CS_STATE
+    return 0;
+}
+
 char *
 flow_to_string(const struct flow *flow)
 {
diff --git a/lib/flow.h b/lib/flow.h
index 86b52584b1de..9d4ae49ccfbd 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Nicira, 
Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 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.
@@ -73,6 +73,8 @@ void flow_unwildcard_tp_ports(const struct flow *, struct 
flow_wildcards *);
 void flow_get_metadata(const struct flow *, struct match *flow_metadata);
 
 const char *ct_state_to_string(uint32_t state);
+uint32_t ct_state_from_string(const char *);
+
 char *flow_to_string(const struct flow *);
 void format_flags(struct ds *ds, const char *(*bit_to_string)(uint32_t),
                   uint32_t flags, char del);
-- 
2.10.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to