Skip to content

Commit

Permalink
Fixed circular buffer of packets waiting for ND
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniele Lacamera committed Mar 24, 2015
1 parent 9e64285 commit 0643265
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/pico_icmp6.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#define PICO_PING6_ERR_PENDING 0xFFFF

/* ND configuration */
#define PICO_ND_MAX_FRAMES_QUEUED 3 /* max frames queued while awaiting address resolution */
#define PICO_ND_MAX_FRAMES_QUEUED 4 /* max frames queued while awaiting address resolution */

/* ND RFC constants */
#define PICO_ND_MAX_SOLICIT 3
Expand Down
8 changes: 7 additions & 1 deletion modules/pico_ipv6_nd.c
Original file line number Diff line number Diff line change
Expand Up @@ -774,14 +774,20 @@ struct pico_eth *pico_ipv6_get_neighbor(struct pico_frame *f)
void pico_ipv6_nd_postpone(struct pico_frame *f)
{
int i;
static int last_enq = -1;
for (i = 0; i < PICO_ND_MAX_FRAMES_QUEUED; i++)
{
if (!frames_queued_v6[i]) {
frames_queued_v6[i] = pico_frame_copy(f);
last_enq = i;
return;
}
}
/* Not possible to enqueue: caller will discard */
/* Overwrite the oldest frame in the buffer */
if (++last_enq >= PICO_ND_MAX_FRAMES_QUEUED) {
last_enq = 0;
}
frames_queued_v6[last_enq] = pico_frame_copy(f);
}


Expand Down

0 comments on commit 0643265

Please sign in to comment.