lib: put route_types.txt to real use

this replaces most occurences of routing protocol lists by preprocessor
defines from route_types.h. the latter is autogenerated from
route_types.txt by a perl script (previously awk). adding a routing
protocol now is mostly a matter of changing route_types.txt and log.c.

Conflicts:

	lib/route_types.awk
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index 59f5fb6..c928e81 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -93,29 +93,6 @@
 
 
 static int
-str2distribute_source (const char *str, int *source)
-{
-  /* Sanity check. */
-  if (str == NULL)
-    return 0;
-
-  if (strncmp (str, "k", 1) == 0)
-    *source = ZEBRA_ROUTE_KERNEL;
-  else if (strncmp (str, "c", 1) == 0)
-    *source = ZEBRA_ROUTE_CONNECT;
-  else if (strncmp (str, "s", 1) == 0)
-    *source = ZEBRA_ROUTE_STATIC;
-  else if (strncmp (str, "r", 1) == 0)
-    *source = ZEBRA_ROUTE_RIP;
-  else if (strncmp (str, "b", 1) == 0)
-    *source = ZEBRA_ROUTE_BGP;
-  else
-    return 0;
-
-  return 1;
-}
-
-static int
 str2metric (const char *str, int *metric)
 {
   /* Sanity check. */
@@ -5825,7 +5802,8 @@
   int metric = -1;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   /* Get metric value. */
@@ -5886,7 +5864,8 @@
   int metric = -1;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   /* Get metric value. */
@@ -5950,7 +5929,8 @@
   int metric = -1;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   /* Get metric value. */
@@ -5983,7 +5963,8 @@
   int type = -1;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   /* Get metric value. */
@@ -6011,7 +5992,8 @@
   int source;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   if (argc == 2)
@@ -6032,7 +6014,8 @@
   struct ospf *ospf = vty->index;
   int source;
 
-  if (!str2distribute_source (argv[0], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   ospf_routemap_unset (ospf, source);
@@ -6051,7 +6034,8 @@
   int source;
 
   /* Get distribute source. */
-  if (!str2distribute_source (argv[1], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   return ospf_distribute_list_out_set (ospf, source, argv[0]);
@@ -6069,7 +6053,8 @@
   struct ospf *ospf = vty->index;
   int source;
 
-  if (!str2distribute_source (argv[1], &source))
+  source = proto_redistnum(AFI_IP, argv[0]);
+  if (source < 0 || source == ZEBRA_ROUTE_OSPF)
     return CMD_WARNING;
 
   return ospf_distribute_list_out_unset (ospf, source, argv[0]);