From 2d369f16e420f01f0fc5cbc168ccc662d3328a43 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 21 Mar 2013 03:07:51 +0100 Subject: Implement ACK request handling --- src/tlv_types.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/tlv_types.c') diff --git a/src/tlv_types.c b/src/tlv_types.c index a3f1fbb..9c485f2 100644 --- a/src/tlv_types.c +++ b/src/tlv_types.c @@ -43,6 +43,24 @@ static inline gp_babel_neigh_t* get_tlv_neigh(handle_tlv_arg_t *arg) { return gp_babel_neigh_get(arg->iface, arg->source); } +static void handle_tlv_ack_req(gmrf_t *gmrf, gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t *tlv_req, size_t len, handle_tlv_arg_t *arg) { + if (len < sizeof(gp_babel_tlv_ack_req_t)) { + gmrf_logf(gmrf, LOG_WARNING, "received short acknowledement request TLV."); + return; + } + + gp_babel_send_ack(gmrf, ctx, get_tlv_neigh(arg), ntohs(tlv_req->nonce)); +} + +static void handle_tlv_ack(gmrf_t *gmrf, gmrf_context_t *ctx, const gp_babel_tlv_ack_t *tlv_ack, size_t len, handle_tlv_arg_t *arg) { + if (len < sizeof(gp_babel_tlv_ack_t)) { + gmrf_logf(gmrf, LOG_WARNING, "received short acknowledement TLV."); + return; + } + + //gp_babel_ack_handle(ntohs(tlv_ack->nonce)); +} + static void handle_tlv_hello(gmrf_t *gmrf, gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tlv_hello, size_t len, handle_tlv_arg_t *arg) { if (len < sizeof(gp_babel_tlv_hello_t)) { gmrf_logf(gmrf, LOG_WARNING, "received short hello TLV."); @@ -122,6 +140,14 @@ static void handle_tlv(gmrf_t *gmrf, gmrf_context_t *ctx, gp_babel_tlv_type_t ty handle_tlv_arg_t *tlv_arg = arg; switch (type) { + case TLV_ACK_REQ: + handle_tlv_ack_req(gmrf, ctx, data, len, tlv_arg); + return; + + case TLV_ACK: + handle_tlv_ack(gmrf, ctx, data, len, tlv_arg); + return; + case TLV_HELLO: handle_tlv_hello(gmrf, ctx, data, len, tlv_arg); return; -- cgit v1.2.3