diff --git a/sys/net/routing/nhdp/nhdp.c b/sys/net/routing/nhdp/nhdp.c index c9d1fe1efd..086454550c 100644 --- a/sys/net/routing/nhdp/nhdp.c +++ b/sys/net/routing/nhdp/nhdp.c @@ -170,6 +170,8 @@ int nhdp_register_if(kernel_pid_t if_pid, uint8_t *addr, size_t addr_size, uint8 if_entry->validity_time.microseconds = MS_IN_USEC * val_time_ms; timex_normalize(&if_entry->hello_interval); timex_normalize(&if_entry->validity_time); + /* Reset sequence number */ + if_entry->seq_no = 0; /* Everything went well */ nhdp_decrement_addr_usage(nhdp_addr); diff --git a/sys/net/routing/nhdp/nhdp.h b/sys/net/routing/nhdp/nhdp.h index b44f98252a..46fd04e051 100644 --- a/sys/net/routing/nhdp/nhdp.h +++ b/sys/net/routing/nhdp/nhdp.h @@ -92,6 +92,7 @@ typedef struct nhdp_if_entry_t { vtimer_t if_timer; /**< Vtimer used for the periodic signaling */ timex_t hello_interval; /**< Interval time for periodic HELLOs */ timex_t validity_time; /**< Validity time for propagated information */ + uint16_t seq_no; /**< Sequence number of last send RFC5444 packet */ struct rfc5444_writer_target wr_target; /**< Interface specific writer target */ } nhdp_if_entry_t; diff --git a/sys/net/routing/nhdp/nhdp_writer.c b/sys/net/routing/nhdp/nhdp_writer.c index 4e5653b4ae..cf14cd7978 100644 --- a/sys/net/routing/nhdp/nhdp_writer.c +++ b/sys/net/routing/nhdp/nhdp_writer.c @@ -46,6 +46,8 @@ static void _nhdp_add_hello_msg_header_cb(struct rfc5444_writer *wr, struct rfc5444_writer_message *msg); static void _nhdp_add_message_tlvs_cb(struct rfc5444_writer *wr); static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr); +static void _nhdp_add_packet_header_cb(struct rfc5444_writer *writer, + struct rfc5444_writer_target *rfc5444_target); static void netaddr_from_nhdp_address(struct netaddr *target, nhdp_addr_t *n_addr); /* Array containing the known Address TLVs */ @@ -108,6 +110,8 @@ void nhdp_writer_register_if(struct rfc5444_writer_target *new_if) { mutex_lock(&mtx_packet_write); + /* Add packet header callback to writer target of the interface */ + new_if->addPacketHeader = _nhdp_add_packet_header_cb; /* Register target interface in writer */ rfc5444_writer_register_target(&nhdp_writer, new_if); @@ -212,6 +216,17 @@ static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr) nhdp_reset_addresses_tmp_usg(); } +/** + * Add packet header with sequence number to current packet + * Called by oonf_api during packet creation + */ +static void _nhdp_add_packet_header_cb(struct rfc5444_writer *writer, + struct rfc5444_writer_target *rfc5444_target) +{ + rfc5444_writer_set_pkt_header(writer, rfc5444_target, true); + rfc5444_writer_set_pkt_seqno(writer, rfc5444_target, ++nhdp_wr_curr_if_entry->seq_no); +} + /** * Construct a netaddr from a given NHDP address */