From 990cee37446caf65eef89109a0f2c5df2574e1ab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 1 Jul 2009 14:43:02 -0700 Subject: [PATCH] Backport skb_queue_is_first(), skb_queue_prev(), skb_queue_is_last() and skb_queue_next() These are needed by p54. Signed-off-by: Luis R. Rodriguez --- compat/compat.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/compat/compat.h b/compat/compat.h index 964a51281f74..f76f0f278e8d 100644 --- a/compat/compat.h +++ b/compat/compat.h @@ -4,6 +4,7 @@ #include #include #include +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) #include @@ -81,6 +82,68 @@ static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) +/** + * skb_queue_is_first - check if skb is the first entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the first buffer on the list. + */ +static inline bool skb_queue_is_first(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->prev == (struct sk_buff *) list); +} + +/** + * skb_queue_prev - return the prev packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the prev packet in @list before @skb. It is only valid to + * call this if skb_queue_is_first() evaluates to false. + */ +static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_first(list, skb)); + return skb->prev; +} + +/** + * skb_queue_is_last - check if skb is the last entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the last buffer on the list. + */ +static inline bool skb_queue_is_last(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->next == (struct sk_buff *) list); +} + +/** + * skb_queue_next - return the next packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the next packet in @list after @skb. It is only valid to + * call this if skb_queue_is_last() evaluates to false. + */ +static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_last(list, skb)); + return skb->next; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) -- 2.30.2