diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-20 00:36:31 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2013-03-20 00:36:31 +0100 |
commit | de428f0b8f3a959038d06d00fcf2fb4d2ce156d2 (patch) | |
tree | bada4b9fa624dcf123da30fa37032e8f794a2610 /src/babel.c | |
parent | b7ad864ec8b5f26b02dc0b34208c27d504077c2e (diff) | |
download | babel-de428f0b8f3a959038d06d00fcf2fb4d2ce156d2.tar babel-de428f0b8f3a959038d06d00fcf2fb4d2ce156d2.zip |
Move send functions to a new source file
Diffstat (limited to 'src/babel.c')
-rw-r--r-- | src/babel.c | 45 |
1 files changed, 1 insertions, 44 deletions
diff --git a/src/babel.c b/src/babel.c index 91cd97b..9ae6ff7 100644 --- a/src/babel.c +++ b/src/babel.c @@ -27,8 +27,6 @@ #include "babel.h" #include "neigh.h" #include "packet.h" -#include "tlv.h" -#include "tlv_types.h" #include <stdlib.h> @@ -37,51 +35,10 @@ const char *gmrf_protocol_name = "babel"; const char *gmrf_protocol_version = "experimental"; -static void add_ihus(gmrf_t *gmrf, gp_babel_packet_t *packet, size_t max_len, const gp_babel_iface_t *iface) { - const gp_babel_neigh_t *neigh; - - for (neigh = iface->neighbours; neigh; neigh = neigh->next) { - gp_babel_tlv_ihu_t *ihu = gp_babel_tlv_add(packet, GP_BABEL_PACKET_MAX, TLV_IHU, sizeof(gp_babel_tlv_ihu_t)+sizeof(gmrf_addr_t)); - if (!ihu) - return; - - ihu->ae = ADDR_ENC_GMRF; - ihu->reserved = 0; - ihu->rxcost = htons(gp_babel_neigh_get_rxcost(gmrf, neigh)); - ihu->interval = htons(GP_BABEL_IHU_INTERVAL); - memcpy(ihu->address, &neigh->addr, sizeof(gmrf_addr_t)); - } -} - static void send_hellos(gmrf_t *gmrf, gmrf_context_t *ctx, void *arg) { gmrf_schedule(gmrf, send_hellos, NULL, GP_BABEL_HELLO_INTERVAL*10); - gmrf_logf(gmrf, LOG_DEBUG, "sending hellos..."); - - gp_babel_packet_t *packet = alloca(sizeof(gp_babel_packet_t)+GP_BABEL_PACKET_MAX); - - packet->version = htons(GP_BABEL_VERSION); - packet->len = 0; - - gp_babel_tlv_hello_t *hello = gp_babel_tlv_add(packet, GP_BABEL_PACKET_MAX, TLV_HELLO, sizeof(gp_babel_tlv_hello_t)); - if (!hello) - return; - - hello->reserved = 0; - hello->interval = htons(GP_BABEL_HELLO_INTERVAL); - - uint16_t len = packet->len; - - gp_babel_iface_t *iface; - for (iface = ctx->interfaces; iface; iface = iface->next) { - hello->seqno = htons(iface->seqno++); - - packet->len = len; - - add_ihus(gmrf, packet, GP_BABEL_PACKET_MAX, iface); - - gmrf_iface_send_bc(gmrf, iface->gmrf_iface, packet, gp_babel_packet_size(packet)); - } + gp_babel_send_hellos(gmrf, ctx); } static void maintenance(gmrf_t *gmrf, gmrf_context_t *ctx, void *arg) { |