babeld: Initial import, for Babel routing protocol.

* Initial import of the Babel routing protocol, ported to Quagga.
* LICENCE: Update the original LICENCE file to include all known potentially
  applicable copyright claims.  Ask that any future contributors to babeld/
  grant MIT/X11 licence to their work.
* *.{c,h}: Add GPL headers, in according with the SFLC guidance on
  dealing with potentially mixed GPL/other licensed work, at:

  https://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html
diff --git a/lib/command.c b/lib/command.c
index 4f6d184..e62a7a7 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2400,6 +2400,7 @@
     case BGP_NODE:
     case RIP_NODE:
     case RIPNG_NODE:
+    case BABEL_NODE:
     case OSPF_NODE:
     case OSPF6_NODE:
     case ISIS_NODE:
@@ -2449,6 +2450,7 @@
     case ZEBRA_NODE:
     case RIP_NODE:
     case RIPNG_NODE:
+    case BABEL_NODE:
     case BGP_NODE:
     case BGP_VPNV4_NODE:
     case BGP_IPV4_NODE:
diff --git a/lib/command.h b/lib/command.h
index 1275efe..2d708d8 100644
--- a/lib/command.h
+++ b/lib/command.h
@@ -78,6 +78,7 @@
   TABLE_NODE,			/* rtm_table selection node. */
   RIP_NODE,			/* RIP protocol mode node. */ 
   RIPNG_NODE,			/* RIPng protocol mode node. */
+  BABEL_NODE,			/* Babel protocol mode node. */
   BGP_NODE,			/* BGP protocol mode which includes BGP4+ */
   BGP_VPNV4_NODE,		/* BGP MPLS-VPN PE exchange. */
   BGP_IPV4_NODE,		/* BGP IPv4 unicast address family.  */
diff --git a/lib/distribute.c b/lib/distribute.c
index 0488903..8d6f637 100644
--- a/lib/distribute.c
+++ b/lib/distribute.c
@@ -758,22 +758,25 @@
                           (int (*) (const void *, const void *)) distribute_cmp);
 
   if(node==RIP_NODE) {
-    install_element (RIP_NODE, &distribute_list_all_cmd);
-    install_element (RIP_NODE, &no_distribute_list_all_cmd);
-    install_element (RIP_NODE, &distribute_list_cmd);
-    install_element (RIP_NODE, &no_distribute_list_cmd);
-    install_element (RIP_NODE, &distribute_list_prefix_all_cmd);
-    install_element (RIP_NODE, &no_distribute_list_prefix_all_cmd);
-    install_element (RIP_NODE, &distribute_list_prefix_cmd);
-    install_element (RIP_NODE, &no_distribute_list_prefix_cmd);
-  } else {
-    install_element (RIPNG_NODE, &ipv6_distribute_list_all_cmd);
-    install_element (RIPNG_NODE, &no_ipv6_distribute_list_all_cmd);
-    install_element (RIPNG_NODE, &ipv6_distribute_list_cmd);
-    install_element (RIPNG_NODE, &no_ipv6_distribute_list_cmd);
-    install_element (RIPNG_NODE, &ipv6_distribute_list_prefix_all_cmd);
-    install_element (RIPNG_NODE, &no_ipv6_distribute_list_prefix_all_cmd);
-    install_element (RIPNG_NODE, &ipv6_distribute_list_prefix_cmd);
-    install_element (RIPNG_NODE, &no_ipv6_distribute_list_prefix_cmd);
+    install_element (node, &distribute_list_all_cmd);
+    install_element (node, &no_distribute_list_all_cmd);
+    install_element (node, &distribute_list_cmd);
+    install_element (node, &no_distribute_list_cmd);
+    install_element (node, &distribute_list_prefix_all_cmd);
+    install_element (node, &no_distribute_list_prefix_all_cmd);
+    install_element (node, &distribute_list_prefix_cmd);
+    install_element (node, &no_distribute_list_prefix_cmd);
+  } else if (node == RIPNG_NODE || node == BABEL_NODE) {
+    /* WARNING: two identical commands installed do a crash, so be worry with
+     aliases. For this reason, and because all these commands are aliases, Babel
+     is not set with RIP. */
+    install_element (node, &ipv6_distribute_list_all_cmd);
+    install_element (node, &no_ipv6_distribute_list_all_cmd);
+    install_element (node, &ipv6_distribute_list_cmd);
+    install_element (node, &no_ipv6_distribute_list_cmd);
+    install_element (node, &ipv6_distribute_list_prefix_all_cmd);
+    install_element (node, &no_ipv6_distribute_list_prefix_all_cmd);
+    install_element (node, &ipv6_distribute_list_prefix_cmd);
+    install_element (node, &no_ipv6_distribute_list_prefix_cmd);
   }
 }
diff --git a/lib/distribute.h b/lib/distribute.h
index a1bec03..5072016 100644
--- a/lib/distribute.h
+++ b/lib/distribute.h
@@ -22,6 +22,9 @@
 #ifndef _ZEBRA_DISTRIBUTE_H
 #define _ZEBRA_DISTRIBUTE_H
 
+#include <zebra.h>
+#include "if.h"
+
 /* Disctirubte list types. */
 enum distribute_type
 {
diff --git a/lib/log.c b/lib/log.c
index 3d905f4..91efe57 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -48,6 +48,7 @@
   "BGP",
   "OSPF",
   "RIPNG",
+  "BABEL",
   "OSPF6",
   "ISIS",
   "MASC",
diff --git a/lib/log.h b/lib/log.h
index ee34a4a..27f21b3 100644
--- a/lib/log.h
+++ b/lib/log.h
@@ -49,7 +49,8 @@
   ZLOG_RIP,
   ZLOG_BGP,
   ZLOG_OSPF,
-  ZLOG_RIPNG,  
+  ZLOG_RIPNG,
+  ZLOG_BABEL,
   ZLOG_OSPF6,
   ZLOG_ISIS,
   ZLOG_MASC
diff --git a/lib/memory.c b/lib/memory.c
index 4090fd9..63ec6b5 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -466,6 +466,17 @@
   return CMD_SUCCESS;
 }
 
+DEFUN (show_memory_babel,
+       show_memory_babel_cmd,
+       "show memory babel",
+       SHOW_STR
+       "Memory statistics\n"
+       "Babel memory\n")
+{
+  show_memory_vty (vty, memory_list_babel);
+  return CMD_SUCCESS;
+}
+
 DEFUN (show_memory_bgp,
        show_memory_bgp_cmd,
        "show memory bgp",
diff --git a/lib/memtypes.c b/lib/memtypes.c
index d2bc1c6..cd39c99 100644
--- a/lib/memtypes.c
+++ b/lib/memtypes.c
@@ -174,6 +174,13 @@
   { -1, NULL }
 };
 
+struct memory_list memory_list_babel[] =
+{
+  { MTYPE_BABEL,              "Babel structure"			},
+  { MTYPE_BABEL_IF,           "Babel interface"			},
+  { -1, NULL }
+};
+
 struct memory_list memory_list_ospf[] =
 {
   { MTYPE_OSPF_TOP,           "OSPF top"			},
diff --git a/lib/route_types.txt b/lib/route_types.txt
index fde0bc8..cebf01f 100644
--- a/lib/route_types.txt
+++ b/lib/route_types.txt
@@ -58,6 +58,7 @@
 # possible).
 ZEBRA_ROUTE_HSLS,       hsls,      hslsd,  'H', 0, 0, "HSLS"
 ZEBRA_ROUTE_OLSR,       olsr,      olsrd,  'o', 0, 0, "OLSR"
+ZEBRA_ROUTE_BABEL,      babel,     babeld, 'A', 1, 1, "Babel"
 
 ## help strings
 ZEBRA_ROUTE_SYSTEM, "Reserved route type, for internal use only"
@@ -72,3 +73,4 @@
 ZEBRA_ROUTE_BGP,    "Border Gateway Protocol (BGP)"
 ZEBRA_ROUTE_HSLS,   "Hazy-Sighted Link State Protocol (HSLS)"
 ZEBRA_ROUTE_OLSR,   "Optimised Link State Routing (OLSR)"
+ZEBRA_ROUTE_BABEL,  "Babel routing protocol (Babel)"
diff --git a/lib/routemap.h b/lib/routemap.h
index 1402f5c..ba64553 100644
--- a/lib/routemap.h
+++ b/lib/routemap.h
@@ -43,6 +43,7 @@
 {
   RMAP_RIP,
   RMAP_RIPNG,
+  RMAP_BABEL,
   RMAP_OSPF,
   RMAP_OSPF6,
   RMAP_BGP,
diff --git a/lib/thread.h b/lib/thread.h
index 69bb8d6..dfc51e2 100644
--- a/lib/thread.h
+++ b/lib/thread.h
@@ -23,6 +23,8 @@
 #ifndef _ZEBRA_THREAD_H
 #define _ZEBRA_THREAD_H
 
+#include <zebra.h>
+
 struct rusage_t
 {
 #ifdef HAVE_RUSAGE
diff --git a/lib/vty.c b/lib/vty.c
index 83bd678..9a4efe6 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -699,6 +699,7 @@
     case ZEBRA_NODE:
     case RIP_NODE:
     case RIPNG_NODE:
+    case BABEL_NODE:
     case BGP_NODE:
     case BGP_VPNV4_NODE:
     case BGP_IPV4_NODE:
@@ -1107,6 +1108,7 @@
     case ZEBRA_NODE:
     case RIP_NODE:
     case RIPNG_NODE:
+    case BABEL_NODE:
     case BGP_NODE:
     case RMAP_NODE:
     case OSPF_NODE:
diff --git a/lib/zclient.h b/lib/zclient.h
index 73389ec..a7d7b54 100644
--- a/lib/zclient.h
+++ b/lib/zclient.h
@@ -22,6 +22,9 @@
 #ifndef _ZEBRA_ZCLIENT_H
 #define _ZEBRA_ZCLIENT_H
 
+/* For struct zapi_ipv{4,6}. */
+#include "prefix.h"
+
 /* For struct interface and struct connected. */
 #include "if.h"