diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-21 04:44:20 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2012-10-21 04:53:17 +0200 |
commit | aa15b96d39dd0242c33b7a11c7c02ebdba50f150 (patch) | |
tree | aa28611f444abae67869b1d33b7d3a063629615c /ffd/ffd.c | |
parent | a45854b5d8dc699e68c5b538e299d5ef8fda59f3 (diff) | |
download | ffd-aa15b96d39dd0242c33b7a11c7c02ebdba50f150.tar ffd-aa15b96d39dd0242c33b7a11c7c02ebdba50f150.zip |
Add infrastructure for ack handling
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r-- | ffd/ffd.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -203,6 +203,15 @@ static void handle_tlv_ack_req(const ffd_tlv_ack_req_t *tlv_req, size_t len, han ffd_send_ack(neigh, ntohs(tlv_req->nonce)); } +static void handle_tlv_ack(const ffd_tlv_ack_t *tlv_ack, size_t len, handle_tlv_arg_t *arg) { + if (len < sizeof(ffd_tlv_ack_t)) { + fprintf(stderr, "warn: received short acknowledement TLV.\n"); + return; + } + + ffd_ack_handle(ntohs(tlv_ack->nonce)); +} + static void handle_tlv_hello(const ffd_tlv_hello_t *tlv_hello, size_t len, handle_tlv_arg_t *arg) { if (len < sizeof(ffd_tlv_hello_t)) { fprintf(stderr, "warn: received short hello TLV.\n"); @@ -425,7 +434,7 @@ static void handle_tlv(ffd_tlv_type_t type, const void *data, size_t len, void * return; case TLV_ACK: - /* we don't send ack reqs */ + handle_tlv_ack(data, len, arg); return; case TLV_HELLO: @@ -617,10 +626,11 @@ int main() { while (true) { ffd_queue_run(&tasks); ffd_update_run(); + ffd_ack_run(); struct pollfd fds[1]; - int timeout = 10*timeout_min(ffd_queue_timeout(&tasks), ffd_update_timeout()); + int timeout = 10*timeout_min(timeout_min(ffd_queue_timeout(&tasks), ffd_update_timeout()), ffd_ack_timeout()); if (timeout < 0) timeout = -1; |