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:
parent
3be898757f
commit
bbe4f3074b
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "kernel_types.h"
|
#include "kernel_types.h"
|
||||||
#include "net/gnrc/nettype.h"
|
#include "net/gnrc/nettype.h"
|
||||||
#include "utlist.h"
|
#include "list.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -135,9 +135,10 @@ typedef struct gnrc_pktsnip {
|
|||||||
static inline gnrc_pktsnip_t *gnrc_pkt_prev_snip(gnrc_pktsnip_t *pkt,
|
static inline gnrc_pktsnip_t *gnrc_pkt_prev_snip(gnrc_pktsnip_t *pkt,
|
||||||
gnrc_pktsnip_t *snip)
|
gnrc_pktsnip_t *snip)
|
||||||
{
|
{
|
||||||
gnrc_pktsnip_t *prev;
|
while ((pkt != NULL) && (pkt->next != snip)) {
|
||||||
LL_SEARCH_SCALAR(pkt, prev, next, snip);
|
pkt = pkt->next;
|
||||||
return prev;
|
}
|
||||||
|
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,
|
static inline gnrc_pktsnip_t *gnrc_pkt_append(gnrc_pktsnip_t *pkt,
|
||||||
gnrc_pktsnip_t *snip)
|
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;
|
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,
|
static inline gnrc_pktsnip_t *gnrc_pkt_prepend(gnrc_pktsnip_t *pkt,
|
||||||
gnrc_pktsnip_t *snip)
|
gnrc_pktsnip_t *snip)
|
||||||
{
|
{
|
||||||
LL_PREPEND(pkt, snip);
|
snip->next = pkt;
|
||||||
return 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,
|
static inline gnrc_pktsnip_t *gnrc_pkt_delete(gnrc_pktsnip_t *pkt,
|
||||||
gnrc_pktsnip_t *snip)
|
gnrc_pktsnip_t *snip)
|
||||||
{
|
{
|
||||||
LL_DELETE(pkt, snip);
|
list_node_t list = { .next = (list_node_t *)pkt };
|
||||||
return pkt;
|
|
||||||
|
list_remove(&list, (list_node_t *)snip);
|
||||||
|
return (gnrc_pktsnip_t *)list.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user