diff options
Diffstat (limited to 'ffd/send.c')
-rw-r--r-- | ffd/send.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -188,6 +188,18 @@ void ffd_send_hellos(void) { } } +static bool add_ack_request(ffd_packet_t *packet, uint16_t nonce) { + ffd_tlv_ack_req_t *tlv = ffd_tlv_add(packet, FFD_PACKET_MAX, TLV_ACK_REQ, sizeof(ffd_tlv_ack_req_t)); + if (!tlv) + return false; + + tlv->reserved = 0; + tlv->nonce = htons(nonce); + tlv->interval = htons(FFD_ACK_INTERVAL); + + return true; +} + static bool add_node_id(ffd_packet_t *packet, size_t max_len, ffd_node_id_t node_id) { ffd_tlv_node_id_t *tlv = ffd_tlv_add(packet, FFD_PACKET_MAX, TLV_NODE_ID, sizeof(ffd_tlv_node_id_t)); if (!tlv) @@ -329,7 +341,7 @@ void ffd_send_retract(ffd_neigh_t *neigh, ffd_node_id_t node, uint16_t type, uin send_neigh(neigh, packet); } -ffd_update_t* ffd_send_update_new(ffd_iface_t *iface, ffd_neigh_t *neigh) { +ffd_update_t* ffd_send_update_new(ffd_iface_t *iface, ffd_neigh_t *neigh, const uint16_t *nonce) { unsigned max_updates = (FFD_PACKET_MAX+sizeof(ffd_tlv_update_t)+1)/(sizeof(ffd_tlv_update_t)+2); ffd_update_t *update = calloc(1, sizeof(ffd_update_t) + max_updates*sizeof(announce_info_t)); update->iface = iface; @@ -340,6 +352,9 @@ ffd_update_t* ffd_send_update_new(ffd_iface_t *iface, ffd_neigh_t *neigh) { update->packet->version_magic = htons(FFD_VERSION_MAGIC); update->packet->len = 0; + if (nonce) + add_ack_request(update->packet, *nonce); + return update; } |