summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index fcf41e3..27e5c29 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -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);
}