An upcoming commit will make use of this.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
if re.match('enum ofptype', line):
break
+ all_types = []
while True:
get_line()
if re.match(r'\s*/?\*', line) or line.isspace():
% (raw, all_raws[raw]["ofptype"]))
all_raws[raw]["ofptype"] = ofptype
+ all_types.append(all_raws[raws[0]]["human_name"])
+
input_file.close()
if n_errors:
% r["human_name"])
output.append("};")
+ output.append("");
+ output.append("static const char *type_names[] = {");
+ for t in all_types:
+ output.append(" \"%s\"," % t)
+ output.append("};")
+
if n_errors:
sys.exit(1)
/*
- * Copyright (c) 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
return raw_info_get(raw)->type;
}
+
+const char *
+ofptype_get_name(enum ofptype type)
+{
+ ovs_assert(type < ARRAY_SIZE(type_names));
+ return type_names[type];
+}
\f
/* Updates the 'length' field of the OpenFlow message in 'buf' to
* 'buf->size'. */
/*
- * Copyright (c) 2012, 2013, 2014 Nicira, Inc.
+ * Copyright (c) 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
enum ofperr ofptype_decode(enum ofptype *, const struct ofp_header *);
enum ofperr ofptype_pull(enum ofptype *, struct ofpbuf *);
enum ofptype ofptype_from_ofpraw(enum ofpraw);
+
+/* Information about OFTYPE_* values. */
+const char *ofptype_get_name(enum ofptype);
\f
/* OpenFlow message properties. */
void ofpmsg_update_length(struct ofpbuf *);