Skip to content
Snippets Groups Projects
Commit 67abf81a authored by Oleg Hahm's avatar Oleg Hahm
Browse files

Merge pull request #2576 from fnack/nhdp_ext_seqno

sys/nhdp: Add interface-specific sequence number to created RFC5444 packets
parents 0144bb58 133aeede
No related branches found
No related tags found
No related merge requests found
...@@ -170,6 +170,8 @@ int nhdp_register_if(kernel_pid_t if_pid, uint8_t *addr, size_t addr_size, uint8 ...@@ -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; if_entry->validity_time.microseconds = MS_IN_USEC * val_time_ms;
timex_normalize(&if_entry->hello_interval); timex_normalize(&if_entry->hello_interval);
timex_normalize(&if_entry->validity_time); timex_normalize(&if_entry->validity_time);
/* Reset sequence number */
if_entry->seq_no = 0;
/* Everything went well */ /* Everything went well */
nhdp_decrement_addr_usage(nhdp_addr); nhdp_decrement_addr_usage(nhdp_addr);
......
...@@ -92,6 +92,7 @@ typedef struct nhdp_if_entry_t { ...@@ -92,6 +92,7 @@ typedef struct nhdp_if_entry_t {
vtimer_t if_timer; /**< Vtimer used for the periodic signaling */ vtimer_t if_timer; /**< Vtimer used for the periodic signaling */
timex_t hello_interval; /**< Interval time for periodic HELLOs */ timex_t hello_interval; /**< Interval time for periodic HELLOs */
timex_t validity_time; /**< Validity time for propagated information */ 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 */ struct rfc5444_writer_target wr_target; /**< Interface specific writer target */
} nhdp_if_entry_t; } nhdp_if_entry_t;
......
...@@ -46,6 +46,8 @@ static void _nhdp_add_hello_msg_header_cb(struct rfc5444_writer *wr, ...@@ -46,6 +46,8 @@ static void _nhdp_add_hello_msg_header_cb(struct rfc5444_writer *wr,
struct rfc5444_writer_message *msg); struct rfc5444_writer_message *msg);
static void _nhdp_add_message_tlvs_cb(struct rfc5444_writer *wr); 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_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); static void netaddr_from_nhdp_address(struct netaddr *target, nhdp_addr_t *n_addr);
/* Array containing the known Address TLVs */ /* Array containing the known Address TLVs */
...@@ -108,6 +110,8 @@ void nhdp_writer_register_if(struct rfc5444_writer_target *new_if) ...@@ -108,6 +110,8 @@ void nhdp_writer_register_if(struct rfc5444_writer_target *new_if)
{ {
mutex_lock(&mtx_packet_write); 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 */ /* Register target interface in writer */
rfc5444_writer_register_target(&nhdp_writer, new_if); rfc5444_writer_register_target(&nhdp_writer, new_if);
...@@ -212,6 +216,17 @@ static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr) ...@@ -212,6 +216,17 @@ static void _nhdp_add_addresses_cb(struct rfc5444_writer *wr)
nhdp_reset_addresses_tmp_usg(); 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 * Construct a netaddr from a given NHDP address
*/ */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment