Skip to content

Commit

Permalink
gnrc_sixlowpan_frag_fb: introduce function to get entry by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Oct 28, 2019
1 parent 9d09e09 commit d270331
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sys/include/net/gnrc/sixlowpan/frag/fb.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ void gnrc_sixlowpan_frag_fb_reset(void);
*/
gnrc_sixlowpan_frag_fb_t *gnrc_sixlowpan_frag_fb_get(void);

/**
* @brief Get an existing fragmentation buffer entry by a given tag
*
* @param[in] tag Tag to search for.
*
* @return a fragmentation buffer entry if one with @p tag exists.
* @return NULL, if no fragmentation buffer entry can be found.
*/
gnrc_sixlowpan_frag_fb_t *gnrc_sixlowpan_frag_fb_get_by_tag(uint16_t tag);

/**
* @brief Generate a new datagram tag for sending
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ gnrc_sixlowpan_frag_fb_t *gnrc_sixlowpan_frag_fb_get(void)
return NULL;
}

gnrc_sixlowpan_frag_fb_t *gnrc_sixlowpan_frag_fb_get_by_tag(uint16_t tag)
{
for (unsigned i = 0; i < GNRC_SIXLOWPAN_FRAG_FB_SIZE; i++) {
if ((_fbs[i].pkt != NULL) && (_fbs[i].tag == tag)) {
return &_fbs[i];
}
}
return NULL;
}

uint16_t gnrc_sixlowpan_frag_fb_next_tag(void)
{
return (++_current_tag);
Expand Down

0 comments on commit d270331

Please # to comment.