Use value_string for ctrl_type

Use value_string for enum ctrl_type instead of custom code. Add
corresponding unit tests.

Related: OS#1615
Change-Id: Icd4e96dd9f00876cb70b43cfcf42ab4f10311b28
diff --git a/include/osmocom/ctrl/control_cmd.h b/include/osmocom/ctrl/control_cmd.h
index a63557d..d82c9af 100644
--- a/include/osmocom/ctrl/control_cmd.h
+++ b/include/osmocom/ctrl/control_cmd.h
@@ -4,7 +4,7 @@
 #include <osmocom/core/talloc.h>
 #include <osmocom/core/write_queue.h>
 #include <osmocom/core/logging.h>
-
+#include <osmocom/core/utils.h>
 #include <osmocom/vty/vector.h>
 
 #define CTRL_CMD_ERROR		-1
@@ -22,7 +22,7 @@
 };
 
 enum ctrl_type {
-	CTRL_TYPE_UNKNOWN,
+	CTRL_TYPE_UNKNOWN = 0,
 	CTRL_TYPE_GET,
 	CTRL_TYPE_SET,
 	CTRL_TYPE_GET_REPLY,
@@ -31,6 +31,8 @@
 	CTRL_TYPE_ERROR
 };
 
+extern const struct value_string ctrl_type_vals[];
+
 struct ctrl_connection {
 	struct llist_head list_entry;