summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index ce71d4b..fcf41e3 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -42,11 +42,10 @@
#define FFD_PROTO 0xffd
-#define FFD_VERSION 0
static const eth_addr_t ffd_addr = {{0x03, 0x00, 0x00, 0x00, 0x0f, 0xfd}};
-#define ANNOUNCE_INTERVAL 10
+#define HELLO_INTERVAL 10
static char *mesh = "bat0";
@@ -60,7 +59,7 @@ static ffd_orig_t own_data;
/* neighs and origs that have been changed must be moved to front */
//static ffd_neigh_t *neigh_data = NULL;
-static ffd_orig_t *orig_data = NULL;
+//static ffd_orig_t *orig_data = NULL;
static inline bool use_netif(const char *ifname) {
@@ -156,33 +155,26 @@ static bool send_eth(const eth_addr_t *addr, unsigned ifindex, void *buf, size_t
return true;
}
-static void send_announce(const char *ifname, unsigned ifindex, void *arg) {
+static void send_hello(const char *ifname, unsigned ifindex, void *arg) {
if (!use_netif(ifname))
return;
- ffd_packet_announce_t *announce = arg;
+ ffd_packet_t *packet = arg;
- if (!send_eth(&ffd_addr, ifindex, announce, PACKET_ANNOUNCE_SIZE(announce->n_origs)))
+ if (!send_eth(&ffd_addr, ifindex, packet, sizeof(ffd_packet_t)+packet->len))
fprintf(stderr, "send_eth: %m\n");
}
-static void send_announces() {
- if (!orig_data)
- return;
-
- ffd_packet_announce_t *announce = alloca(PACKET_ANNOUNCE_SIZE(PACKET_ANNOUNCE_MAX_ORIGS));
-
- memset(announce, 0, PACKET_ANNOUNCE_SIZE(PACKET_ANNOUNCE_MAX_ORIGS));
+static void send_hellos() {
+ /*if (!orig_data)
+ return;*/
- announce->version = FFD_VERSION;
- announce->type = PACKET_ANNOUNCE;
- announce->self_rev = self.rev;
+ ffd_packet_t *packet = alloca(sizeof(ffd_packet_t)+1000);
- ffd_orig_t *orig;
- for (orig = orig_data; orig && (announce->n_origs < PACKET_ANNOUNCE_MAX_ORIGS); orig = orig->next)
- announce->origs[announce->n_origs++] = orig->rev;
+ packet->version_magic = htons(FFD_VERSION_MAGIC);
+ packet->len = 0;
- netif_foreach(send_announce, announce);
+ netif_foreach(send_hello, packet);
}
static void receive_packet() {
@@ -212,17 +204,17 @@ int main() {
update_time();
- struct timespec next_announce = now;
+ struct timespec next_hello = now;
while (true) {
netif_foreach(join_mcast, NULL);
- int timeout = timespec_diff(&next_announce, &now);
+ int timeout = timespec_diff(&next_hello, &now);
if (timeout <= 0) {
- send_announces();
+ send_hellos();
- next_announce.tv_sec += ANNOUNCE_INTERVAL;
+ next_hello.tv_sec += HELLO_INTERVAL;
continue;
}