diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-09-25 00:38:19 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-09-25 00:38:19 +0200 |
commit | 9eeec649fb91784d26cbfcad876cff1d6b950408 (patch) | |
tree | 198c7c885566b57a70990429fef7fea5a92f903f /ffd/ffd.c | |
parent | e16168401d61c20bf4d66d5636c30ad10874fc52 (diff) | |
download | ffd-9eeec649fb91784d26cbfcad876cff1d6b950408.tar ffd-9eeec649fb91784d26cbfcad876cff1d6b950408.zip |
Send hello packets
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r-- | ffd/ffd.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -27,6 +27,8 @@ #include "ffd.h" #include "netif.h" #include "packet.h" +#include "tlv.h" +#include "tlv_types.h" #include <errno.h> #include <poll.h> @@ -46,6 +48,7 @@ static const eth_addr_t ffd_addr = {{0x03, 0x00, 0x00, 0x00, 0x0f, 0xfd}}; #define HELLO_INTERVAL 10 +#define PACKET_MAX 1000 static char *mesh = "bat0"; @@ -161,19 +164,28 @@ static void send_hello(const char *ifname, unsigned ifindex, void *arg) { ffd_packet_t *packet = arg; - if (!send_eth(&ffd_addr, ifindex, packet, sizeof(ffd_packet_t)+packet->len)) + if (!send_eth(&ffd_addr, ifindex, packet, sizeof(ffd_packet_t)+ntohs(packet->len))) fprintf(stderr, "send_eth: %m\n"); } static void send_hellos() { /*if (!orig_data) return;*/ + static uint16_t seqno = 0; - ffd_packet_t *packet = alloca(sizeof(ffd_packet_t)+1000); + ffd_packet_t *packet = alloca(sizeof(ffd_packet_t)+PACKET_MAX); packet->version_magic = htons(FFD_VERSION_MAGIC); packet->len = 0; + ffd_tlv_hello_t *hello = ffd_tlv_add(packet, PACKET_MAX, TLV_HELLO, sizeof(ffd_tlv_hello_t)); + if (!hello) + return; + + memset(hello, 0, sizeof(ffd_tlv_hello_t)); + hello->seqno = htons(seqno++); + hello->interval = htons(HELLO_INTERVAL*100); + netif_foreach(send_hello, packet); } |