diff --git a/babeld/kernel_zebra.c b/babeld/kernel_zebra.c
new file mode 100644
index 0000000..0fecb52
--- /dev/null
+++ b/babeld/kernel_zebra.c
@@ -0,0 +1,461 @@
+/*  
+ *  This file is free software: you may copy, redistribute and/or modify it  
+ *  under the terms of the GNU General Public License as published by the  
+ *  Free Software Foundation, either version 2 of the License, or (at your  
+ *  option) any later version.  
+ *  
+ *  This file is distributed in the hope that it will be useful, but  
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of  
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  
+ *  General Public License for more details.  
+ *  
+ *  You should have received a copy of the GNU General Public License  
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  
+ *  
+ * This file incorporates work covered by the following copyright and  
+ * permission notice:  
+ *  
+Copyright 2011 by Matthieu Boutier and Juliusz Chroboczek
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+
+#include <zebra.h>
+#include "prefix.h"
+#include "zclient.h"
+#include "kernel.h"
+#include "privs.h"
+#include "command.h"
+#include "vty.h"
+#include "memory.h"
+#include "thread.h"
+
+#include "util.h"
+#include "babel_interface.h"
+#include "babel_zebra.h"
+
+
+static int
+kernel_route_add_v4(const unsigned char *pref, unsigned short plen,
+                    const unsigned char *gate, int ifindex, unsigned int metric,
+                    const unsigned char *newgate, int newifindex,
+                    unsigned int newmetric);
+static int
+kernel_route_add_v6(const unsigned char *pref, unsigned short plen,
+                    const unsigned char *gate, int ifindex, unsigned int metric,
+                    const unsigned char *newgate, int newifindex,
+                    unsigned int newmetric);
+static int
+kernel_route_delete_v4(const unsigned char *pref, unsigned short plen,
+                       const unsigned char *gate, int ifindex,
+                       unsigned int metric,
+                       const unsigned char *newgate, int newifindex,
+                       unsigned int newmetric);
+static int
+kernel_route_delete_v6(const unsigned char *pref, unsigned short plen,
+                       const unsigned char *gate, int ifindex,
+                       unsigned int metric,
+                       const unsigned char *newgate, int newifindex,
+                       unsigned int newmetric);
+
+
+int export_table = -1, import_table = -1; /* just for compatibility */
+
+int
+kernel_setup(int setup)
+{
+    return 0;
+}
+
+/* get a connection with zebra client, at all costs */
+int
+kernel_setup_socket(int setup)
+{
+    return -1;
+}
+
+int
+kernel_setup_interface(int setup, struct interface *interface)
+{
+    return 1;
+}
+
+int
+kernel_interface_operational(struct interface *interface)
+{
+    return if_is_operative(interface);
+}
+
+int
+kernel_interface_ipv4(struct interface *interface, unsigned char *addr_r)
+{
+    assert(0); /* function not used */
+    return -1;
+}
+
+int
+kernel_interface_mtu(struct interface *interface)
+{
+    return MIN(interface->mtu, interface->mtu6);
+}
+
+int
+kernel_interface_wireless(struct interface *interface)
+{
+    return 0;
+}
+
+extern int
+zapi_ipv6_route (u_char cmd, struct zclient *zclient,
+                 struct prefix_ipv6 *p, struct zapi_ipv6 *api);
+
+int
+kernel_route(int operation, const unsigned char *pref, unsigned short plen,
+             const unsigned char *gate, int ifindex, unsigned int metric,
+             const unsigned char *newgate, int newifindex,
+             unsigned int newmetric)
+{
+    int rc;
+    int added;
+    int ipv4;
+
+    /* Check that the protocol family is consistent. */
+    if(plen >= 96 && v4mapped(pref)) {
+        if(!v4mapped(gate)) {
+            errno = EINVAL;
+            return -1;
+        }
+        ipv4 = 1;
+    } else {
+        if(v4mapped(gate)) {
+            errno = EINVAL;
+            return -1;
+        }
+        ipv4 = 0;
+    }
+
+    switch (operation) {
+        case ROUTE_ADD:
+            return ipv4 ?
+                   kernel_route_add_v4(pref, plen, gate, ifindex, metric,
+                                       newgate, newifindex, newmetric):
+                   kernel_route_add_v6(pref, plen, gate, ifindex, metric,
+                                       newgate, newifindex, newmetric);
+            break;
+        case ROUTE_FLUSH:
+            return ipv4 ?
+                   kernel_route_delete_v4(pref, plen, gate, ifindex, metric,
+                                          newgate, newifindex, newmetric):
+                   kernel_route_delete_v6(pref, plen, gate, ifindex, metric,
+                                          newgate, newifindex, newmetric);
+            break;
+        case ROUTE_MODIFY:
+            if(newmetric == metric && memcmp(newgate, gate, 16) == 0 &&
+               newifindex == ifindex)
+                return 0;
+            /* It is better to add the new route before removing the old
+             one, to avoid losing packets.  However, if the old and new
+             priorities are equal, this only works if the kernel supports
+             ECMP.  So we first try the "right" order, and fall back on
+             the "wrong" order if it fails with EEXIST. */
+            rc = ipv4 ?
+                 kernel_route_add_v4(pref, plen,
+                                     newgate, newifindex, newmetric,
+                                     NULL, 0, 0):
+                 kernel_route_add_v6(pref, plen,
+                                     newgate, newifindex, newmetric,
+                                     NULL, 0, 0);
+            if(rc < 0) {
+                if(errno != EEXIST)
+                    return rc;
+                added = 0;
+            } else {
+                added = 1;
+            }
+
+            if (ipv4) {
+                kernel_route_delete_v4(pref, plen,
+                                       gate, ifindex, metric,
+                                       NULL, 0, 0);
+            } else {
+                kernel_route_delete_v6(pref, plen,
+                                       gate, ifindex, metric,
+                                       NULL, 0, 0);
+            }
+
+            if(!added) {
+                rc = ipv4 ?
+                     kernel_route_add_v4(pref, plen,
+                                         newgate, newifindex, newmetric,
+                                         NULL, 0, 0):
+                     kernel_route_add_v6(pref, plen,
+                                         newgate, newifindex, newmetric,
+                                         NULL, 0, 0);
+                if(rc < 0) {
+                    if(errno == EEXIST)
+                        rc = 1;
+                    /* In principle, we should try to re-install the flushed
+                     route on failure to preserve.  However, this should
+                     hopefully not matter much in practice. */
+                }
+            }
+
+            return rc;
+            break;
+        default:
+            zlog_err("this should never appens (false value - kernel_route)");
+            assert(0);
+            exit(1);
+            break;
+    }
+}
+
+static int
+kernel_route_add_v4(const unsigned char *pref, unsigned short plen,
+                    const unsigned char *gate, int ifindex, unsigned int metric,
+                    const unsigned char *newgate, int newifindex,
+                    unsigned int newmetric)
+{
+    unsigned int tmp_ifindex = ifindex; /* (for typing) */
+    struct zapi_ipv4 api;               /* quagga's communication system */
+    struct prefix_ipv4 quagga_prefix;   /* quagga's prefix */
+    struct in_addr babel_prefix_addr;   /* babeld's prefix addr */
+    struct in_addr nexthop;             /* next router to go */
+    struct in_addr *nexthop_pointer = &nexthop; /* it's an array! */
+
+    /* convert to be comprehensive by quagga */
+    /* convert given addresses */
+    uchar_to_inaddr(&babel_prefix_addr, pref);
+    uchar_to_inaddr(&nexthop, gate);
+
+    /* make prefix structure */
+    memset (&quagga_prefix, 0, sizeof(quagga_prefix));
+    quagga_prefix.family = AF_INET;
+    IPV4_ADDR_COPY (&quagga_prefix.prefix, &babel_prefix_addr);
+    quagga_prefix.prefixlen = plen - 96; /* our plen is for v4mapped's addr */
+    apply_mask_ipv4(&quagga_prefix);
+
+    api.type  = ZEBRA_ROUTE_BABEL;
+    api.flags = 0;
+    api.message = 0;
+    SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+    api.nexthop_num = 1;
+    api.nexthop = &nexthop_pointer;
+    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+    api.ifindex_num = 1;
+    api.ifindex = &tmp_ifindex;
+    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+    api.metric = metric;
+
+    debugf(BABEL_DEBUG_ROUTE, "adding route (ipv4) to zebra");
+    return zapi_ipv4_route (ZEBRA_IPV4_ROUTE_ADD, zclient,
+                            &quagga_prefix, &api);
+}
+
+static int
+kernel_route_add_v6(const unsigned char *pref, unsigned short plen,
+                    const unsigned char *gate, int ifindex, unsigned int metric,
+                    const unsigned char *newgate, int newifindex,
+                    unsigned int newmetric)
+{
+    unsigned int tmp_ifindex = ifindex; /* (for typing) */
+    struct zapi_ipv6 api;               /* quagga's communication system */
+    struct prefix_ipv6 quagga_prefix;   /* quagga's prefix */
+    struct in6_addr babel_prefix_addr;  /* babeld's prefix addr */
+    struct in6_addr nexthop;            /* next router to go */
+    struct in6_addr *nexthop_pointer = &nexthop;
+
+    /* convert to be comprehensive by quagga */
+    /* convert given addresses */
+    uchar_to_in6addr(&babel_prefix_addr, pref);
+    uchar_to_in6addr(&nexthop, gate);
+
+    /* make prefix structure */
+    memset (&quagga_prefix, 0, sizeof(quagga_prefix));
+    quagga_prefix.family = AF_INET6;
+    IPV6_ADDR_COPY (&quagga_prefix.prefix, &babel_prefix_addr);
+    quagga_prefix.prefixlen = plen;
+    apply_mask_ipv6(&quagga_prefix);
+
+    api.type  = ZEBRA_ROUTE_BABEL;
+    api.flags = 0;
+    api.message = 0;
+    SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+    api.nexthop_num = 1;
+    api.nexthop = &nexthop_pointer;
+    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+    api.ifindex_num = 1;
+    api.ifindex = &tmp_ifindex;
+    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+    api.metric = metric;
+
+    debugf(BABEL_DEBUG_ROUTE, "adding route (ipv6) to zebra");
+    return zapi_ipv6_route (ZEBRA_IPV6_ROUTE_ADD, zclient,
+                            &quagga_prefix, &api);
+}
+
+static int
+kernel_route_delete_v4(const unsigned char *pref, unsigned short plen,
+                       const unsigned char *gate, int ifindex,
+                       unsigned int metric,
+                       const unsigned char *newgate, int newifindex,
+                       unsigned int newmetric)
+{
+    unsigned int tmp_ifindex = ifindex; /* (for typing) */
+    struct zapi_ipv4 api;               /* quagga's communication system */
+    struct prefix_ipv4 quagga_prefix;   /* quagga's prefix */
+    struct in_addr babel_prefix_addr;   /* babeld's prefix addr */
+    struct in_addr nexthop;             /* next router to go */
+    struct in_addr *nexthop_pointer = &nexthop; /* it's an array! */
+
+    /* convert to be comprehensive by quagga */
+    /* convert given addresses */
+    uchar_to_inaddr(&babel_prefix_addr, pref);
+    uchar_to_inaddr(&nexthop, gate);
+
+    /* make prefix structure */
+    memset (&quagga_prefix, 0, sizeof(quagga_prefix));
+    quagga_prefix.family = AF_INET;
+    IPV4_ADDR_COPY (&quagga_prefix.prefix, &babel_prefix_addr);
+    quagga_prefix.prefixlen = plen - 96;
+    apply_mask_ipv4(&quagga_prefix);
+
+    api.type  = ZEBRA_ROUTE_BABEL;
+    api.flags = 0;
+    api.message = 0;
+    SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+    api.nexthop_num = 1;
+    api.nexthop = &nexthop_pointer;
+    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+    api.ifindex_num = 1;
+    api.ifindex = &tmp_ifindex;
+    SET_FLAG(api.message, ZAPI_MESSAGE_METRIC);
+    api.metric = metric;
+
+    debugf(BABEL_DEBUG_ROUTE, "removing route (ipv4) to zebra");
+    return zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient,
+                            &quagga_prefix, &api);
+}
+
+static int
+kernel_route_delete_v6(const unsigned char *pref, unsigned short plen,
+                       const unsigned char *gate, int ifindex,
+                       unsigned int metric,
+                       const unsigned char *newgate, int newifindex,
+                       unsigned int newmetric)
+{
+    unsigned int tmp_ifindex = ifindex; /* (for typing) */
+    struct zapi_ipv6 api;               /* quagga's communication system */
+    struct prefix_ipv6 quagga_prefix;   /* quagga's prefix */
+    struct in6_addr babel_prefix_addr;  /* babeld's prefix addr */
+    struct in6_addr nexthop;            /* next router to go */
+    struct in6_addr *nexthop_pointer = &nexthop;
+
+    /* convert to be comprehensive by quagga */
+    /* convert given addresses */
+    uchar_to_in6addr(&babel_prefix_addr, pref);
+    uchar_to_in6addr(&nexthop, gate);
+
+    /* make prefix structure */
+    memset (&quagga_prefix, 0, sizeof(quagga_prefix));
+    quagga_prefix.family = AF_INET6;
+    IPV6_ADDR_COPY (&quagga_prefix.prefix, &babel_prefix_addr);
+    quagga_prefix.prefixlen = plen;
+    apply_mask_ipv6(&quagga_prefix);
+
+    api.type  = ZEBRA_ROUTE_BABEL;
+    api.flags = 0;
+    api.message = 0;
+    SET_FLAG(api.message, ZAPI_MESSAGE_NEXTHOP);
+    api.nexthop_num = 1;
+    api.nexthop = &nexthop_pointer;
+    SET_FLAG(api.message, ZAPI_MESSAGE_IFINDEX);
+    api.ifindex_num = 1;
+    api.ifindex = &tmp_ifindex;
+
+    debugf(BABEL_DEBUG_ROUTE, "removing route (ipv6) to zebra");
+    return zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient,
+                            &quagga_prefix, &api);
+}
+
+int
+kernel_routes(struct kernel_route *routes, int maxroutes)
+{
+    fprintf(stderr, "\tkernel_routes  --- not implemented\n");
+    return 0;
+}
+
+int
+kernel_callback(int (*fn)(int, void*), void *closure)
+{
+    struct thread thread;
+    fprintf(stderr, "\tkernel_callback\n");
+    /* do a little work on threads */
+    if (thread_fetch(master, &thread) != NULL) {
+        thread_call (&thread);
+    }
+    return 0;
+}
+
+int
+kernel_addresses(struct interface *interface, int ll,
+                 struct kernel_route *routes, int maxroutes)
+{
+    fprintf(stderr, "\tkernel_addresses  --- not implemented\n");
+    return 0;
+}
+
+int
+if_eui64(char *ifname, int ifindex, unsigned char *eui)
+{
+    struct interface *ifp = if_lookup_by_index(ifindex);
+    if (ifp == NULL) {
+        return -1;
+    }
+#ifdef HAVE_STRUCT_SOCKADDR_DL
+    u_char len = ifp->sdl.sdl_alen;
+    char *tmp = ifp->sdl.sdl_data + ifp->sdl.sdl_nlen;
+#else
+    u_char len = (u_char) ifp->hw_addr_len;
+    char *tmp = (void*) ifp->hw_addr;
+#endif
+    if (len == 8) {
+        memcpy(eui, tmp, 8);
+        eui[0] ^= 2;
+    } else if (len == 6) {
+        memcpy(eui,   tmp,   3);
+        eui[3] = 0xFF;
+        eui[4] = 0xFE;
+        memcpy(eui+5, tmp+3, 3);
+    } else if (len > 8) {
+        memcpy(eui, tmp, 8);
+    } else if (len > 0){
+        memset(eui, 0, 8 - len);
+        memcpy(eui + 8 - len, tmp, len);
+    } else {
+        return -1;
+    }
+    return 0;
+}
