[ovs-dev] [PATCH ovn pipeline 3/6] lex: New function lex_format_to_string().
Ben Pfaff
blp at nicira.com
Sat Apr 18 17:04:35 UTC 2015
First used in an upcoming commit.
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
ovn/lib/lex.c | 22 +++++++++++++++++++++-
ovn/lib/lex.h | 1 +
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/ovn/lib/lex.c b/ovn/lib/lex.c
index 8fe0508..73f0ca3 100644
--- a/ovn/lib/lex.c
+++ b/ovn/lib/lex.c
@@ -22,7 +22,27 @@
#include "dynamic-string.h"
#include "json.h"
#include "util.h"
-
+
+/* Returns a string that represents 'format'. */
+const char *
+lex_format_to_string(enum lex_format format)
+{
+ switch (format) {
+ case LEX_F_DECIMAL:
+ return "decimal";
+ case LEX_F_HEXADECIMAL:
+ return "hexadecimal";
+ case LEX_F_IPV4:
+ return "IPv4";
+ case LEX_F_IPV6:
+ return "IPv6";
+ case LEX_F_ETHERNET:
+ return "Ethernet";
+ default:
+ abort();
+ }
+}
+
/* Initializes 'token'. */
void
lex_token_init(struct lex_token *token)
diff --git a/ovn/lib/lex.h b/ovn/lib/lex.h
index 5d391ea..29e922c 100644
--- a/ovn/lib/lex.h
+++ b/ovn/lib/lex.h
@@ -73,6 +73,7 @@ enum lex_format {
LEX_F_IPV6,
LEX_F_ETHERNET,
};
+const char *lex_format_to_string(enum lex_format);
/* A token.
*
--
2.1.3
More information about the dev
mailing list