summaryrefslogtreecommitdiffstats
path: root/src/send.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-03-21 03:07:51 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-03-21 03:07:51 +0100
commit2d369f16e420f01f0fc5cbc168ccc662d3328a43 (patch)
tree03d083055370a031bebd23ec9d0fd37488445eb9 /src/send.c
parente099bddc24fad6c628e29284a585bd50404768b6 (diff)
downloadbabel-2d369f16e420f01f0fc5cbc168ccc662d3328a43.tar
babel-2d369f16e420f01f0fc5cbc168ccc662d3328a43.zip
Implement ACK request handling
Diffstat (limited to 'src/send.c')
-rw-r--r--src/send.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/send.c b/src/send.c
index 7fc9453..fd3f9d7 100644
--- a/src/send.c
+++ b/src/send.c
@@ -31,6 +31,30 @@
#include "tlv_types.h"
+static inline bool send_neigh(gmrf_t *gmrf, const gp_babel_neigh_t *neigh, const gp_babel_packet_t *packet) {
+ if (!neigh->iface)
+ return false;
+
+ if (!gmrf_iface_send(gmrf, neigh->iface->gmrf_iface, packet, gp_babel_packet_size(packet), &neigh->addr)) {
+ gmrf_logf(gmrf, LOG_WARNING, "gmrf_iface_send: %m");
+ return false;
+ }
+
+ return true;
+}
+
+void gp_babel_send_ack(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_neigh_t *neigh, uint16_t nonce) {
+ gp_babel_packet_t *packet = alloca_packet(GP_BABEL_PACKET_MAX);
+
+ gp_babel_tlv_ack_t *ack = gp_babel_tlv_add(packet, GP_BABEL_PACKET_MAX, TLV_ACK, sizeof(gp_babel_tlv_ack_t));
+ if (!ack)
+ return;
+
+ ack->nonce = htons(nonce);
+
+ send_neigh(gmrf, neigh, packet);
+}
+
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;