Skip to content

Commit

Permalink
Merge pull request #2576 from fnack/nhdp_ext_seqno
Browse files Browse the repository at this point in the history
sys/nhdp: Add interface-specific sequence number to created RFC5444 packets
  • Loading branch information
OlegHahm committed Mar 13, 2015
2 parents 0144bb5 + 133aeed commit 67abf81
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/net/routing/nhdp/nhdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions sys/net/routing/nhdp/nhdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
15 changes: 15 additions & 0 deletions sys/net/routing/nhdp/nhdp_writer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
*/
Expand Down

0 comments on commit 67abf81

Please sign in to comment.