1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gnrc_pkt: port to list.h

This commit is contained in:
Martine Lenders 2020-10-15 17:07:59 +02:00
parent 3be898757f
commit bbe4f3074b
No known key found for this signature in database
GPG Key ID: CCD317364F63286F

View File

@ -27,7 +27,7 @@
#include "kernel_types.h"
#include "net/gnrc/nettype.h"
#include "utlist.h"
#include "list.h"
#ifdef __cplusplus
extern "C" {
@ -135,9 +135,10 @@ typedef struct gnrc_pktsnip {
static inline gnrc_pktsnip_t *gnrc_pkt_prev_snip(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
gnrc_pktsnip_t *prev;
LL_SEARCH_SCALAR(pkt, prev, next, snip);
return prev;
while ((pkt != NULL) && (pkt->next != snip)) {
pkt = pkt->next;
}
return pkt;
}
/**
@ -170,7 +171,16 @@ static inline size_t gnrc_pkt_len(const gnrc_pktsnip_t *pkt)
static inline gnrc_pktsnip_t *gnrc_pkt_append(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
LL_APPEND(pkt, snip);
/* find last snip in pkt */
gnrc_pktsnip_t *last = gnrc_pkt_prev_snip(pkt, NULL);
if (last != NULL) {
last->next = snip;
}
else {
/* last == NULL means snip */
pkt = snip;
}
return pkt;
}
@ -185,8 +195,8 @@ static inline gnrc_pktsnip_t *gnrc_pkt_append(gnrc_pktsnip_t *pkt,
static inline gnrc_pktsnip_t *gnrc_pkt_prepend(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
LL_PREPEND(pkt, snip);
return pkt;
snip->next = pkt;
return snip;
}
/**
@ -200,8 +210,10 @@ static inline gnrc_pktsnip_t *gnrc_pkt_prepend(gnrc_pktsnip_t *pkt,
static inline gnrc_pktsnip_t *gnrc_pkt_delete(gnrc_pktsnip_t *pkt,
gnrc_pktsnip_t *snip)
{
LL_DELETE(pkt, snip);
return pkt;
list_node_t list = { .next = (list_node_t *)pkt };
list_remove(&list, (list_node_t *)snip);
return (gnrc_pktsnip_t *)list.next;
}