skbuff.h
来自「ARM Linux Tool 各种代码包括MTD」· C头文件 代码 · 共 1,172 行 · 第 1/3 页
H
1,172 行
* be careful with this one. A peek leaves the buffer on the * list and someone else may run off with it. You must hold * the appropriate locks or have a private queue to do this. * * Returns %NULL for an empty list or a pointer to the head element. * The reference count is not incremented and the reference is therefore * volatile. Use with caution. */ static inline struct sk_buff *skb_peek(struct sk_buff_head *list_){ struct sk_buff *list = ((struct sk_buff *)list_)->next; if (list == (struct sk_buff *)list_) list = NULL; return list;}/** * skb_peek_tail * @list_: list to peek at * * Peek an &sk_buff. Unlike most other operations you _MUST_ * be careful with this one. A peek leaves the buffer on the * list and someone else may run off with it. You must hold * the appropriate locks or have a private queue to do this. * * Returns %NULL for an empty list or a pointer to the tail element. * The reference count is not incremented and the reference is therefore * volatile. Use with caution. */static inline struct sk_buff *skb_peek_tail(struct sk_buff_head *list_){ struct sk_buff *list = ((struct sk_buff *)list_)->prev; if (list == (struct sk_buff *)list_) list = NULL; return list;}/** * skb_queue_len - get queue length * @list_: list to measure * * Return the length of an &sk_buff queue. */ static inline __u32 skb_queue_len(struct sk_buff_head *list_){ return(list_->qlen);}static inline void skb_queue_head_init(struct sk_buff_head *list){ spin_lock_init(&list->lock); list->prev = (struct sk_buff *)list; list->next = (struct sk_buff *)list; list->qlen = 0;}/* * Insert an sk_buff at the start of a list. * * The "__skb_xxxx()" functions are the non-atomic ones that * can only be called with interrupts disabled. *//** * __skb_queue_head - queue a buffer at the list head * @list: list to use * @newsk: buffer to queue * * Queue a buffer at the start of a list. This function takes no locks * and you must therefore hold required locks before calling it. * * A buffer cannot be placed on two lists at the same time. */ static inline void __skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk){ struct sk_buff *prev, *next; newsk->list = list; list->qlen++; prev = (struct sk_buff *)list; next = prev->next; newsk->next = next; newsk->prev = prev; next->prev = newsk; prev->next = newsk;}/** * skb_queue_head - queue a buffer at the list head * @list: list to use * @newsk: buffer to queue * * Queue a buffer at the start of the list. This function takes the * list lock and can be used safely with other locking &sk_buff functions * safely. * * A buffer cannot be placed on two lists at the same time. */ static inline void skb_queue_head(struct sk_buff_head *list, struct sk_buff *newsk){ unsigned long flags; spin_lock_irqsave(&list->lock, flags); __skb_queue_head(list, newsk); spin_unlock_irqrestore(&list->lock, flags);}/** * __skb_queue_tail - queue a buffer at the list tail * @list: list to use * @newsk: buffer to queue * * Queue a buffer at the end of a list. This function takes no locks * and you must therefore hold required locks before calling it. * * A buffer cannot be placed on two lists at the same time. */ static inline void __skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk){ struct sk_buff *prev, *next; newsk->list = list; list->qlen++; next = (struct sk_buff *)list; prev = next->prev; newsk->next = next; newsk->prev = prev; next->prev = newsk; prev->next = newsk;}/** * skb_queue_tail - queue a buffer at the list tail * @list: list to use * @newsk: buffer to queue * * Queue a buffer at the tail of the list. This function takes the * list lock and can be used safely with other locking &sk_buff functions * safely. * * A buffer cannot be placed on two lists at the same time. */ static inline void skb_queue_tail(struct sk_buff_head *list, struct sk_buff *newsk){ unsigned long flags; spin_lock_irqsave(&list->lock, flags); __skb_queue_tail(list, newsk); spin_unlock_irqrestore(&list->lock, flags);}/** * __skb_dequeue - remove from the head of the queue * @list: list to dequeue from * * Remove the head of the list. This function does not take any locks * so must be used with appropriate locks held only. The head item is * returned or %NULL if the list is empty. */static inline struct sk_buff *__skb_dequeue(struct sk_buff_head *list){ struct sk_buff *next, *prev, *result; prev = (struct sk_buff *) list; next = prev->next; result = NULL; if (next != prev) { result = next; next = next->next; list->qlen--; next->prev = prev; prev->next = next; result->next = NULL; result->prev = NULL; result->list = NULL; } return result;}/** * skb_dequeue - remove from the head of the queue * @list: list to dequeue from * * Remove the head of the list. The list lock is taken so the function * may be used safely with other locking list functions. The head item is * returned or %NULL if the list is empty. */static inline struct sk_buff *skb_dequeue(struct sk_buff_head *list){ unsigned long flags; struct sk_buff *result; spin_lock_irqsave(&list->lock, flags); result = __skb_dequeue(list); spin_unlock_irqrestore(&list->lock, flags); return result;}/* * Insert a packet on a list. */static inline void __skb_insert(struct sk_buff *newsk, struct sk_buff * prev, struct sk_buff *next, struct sk_buff_head * list){ newsk->next = next; newsk->prev = prev; next->prev = newsk; prev->next = newsk; newsk->list = list; list->qlen++;}/** * skb_insert - insert a buffer * @old: buffer to insert before * @newsk: buffer to insert * * Place a packet before a given packet in a list. The list locks are taken * and this function is atomic with respect to other list locked calls * A buffer cannot be placed on two lists at the same time. */static inline void skb_insert(struct sk_buff *old, struct sk_buff *newsk){ unsigned long flags; spin_lock_irqsave(&old->list->lock, flags); __skb_insert(newsk, old->prev, old, old->list); spin_unlock_irqrestore(&old->list->lock, flags);}/* * Place a packet after a given packet in a list. */static inline void __skb_append(struct sk_buff *old, struct sk_buff *newsk){ __skb_insert(newsk, old, old->next, old->list);}/** * skb_append - append a buffer * @old: buffer to insert after * @newsk: buffer to insert * * Place a packet after a given packet in a list. The list locks are taken * and this function is atomic with respect to other list locked calls. * A buffer cannot be placed on two lists at the same time. */static inline void skb_append(struct sk_buff *old, struct sk_buff *newsk){ unsigned long flags; spin_lock_irqsave(&old->list->lock, flags); __skb_append(old, newsk); spin_unlock_irqrestore(&old->list->lock, flags);}/* * remove sk_buff from list. _Must_ be called atomically, and with * the list known.. */ static inline void __skb_unlink(struct sk_buff *skb, struct sk_buff_head *list){ struct sk_buff * next, * prev; list->qlen--; next = skb->next; prev = skb->prev; skb->next = NULL; skb->prev = NULL; skb->list = NULL; next->prev = prev; prev->next = next;}/** * skb_unlink - remove a buffer from a list * @skb: buffer to remove * * Place a packet after a given packet in a list. The list locks are taken * and this function is atomic with respect to other list locked calls * * Works even without knowing the list it is sitting on, which can be * handy at times. It also means that THE LIST MUST EXIST when you * unlink. Thus a list must have its contents unlinked before it is * destroyed. */static inline void skb_unlink(struct sk_buff *skb){ struct sk_buff_head *list = skb->list; if(list) { unsigned long flags; spin_lock_irqsave(&list->lock, flags); if(skb->list == list) __skb_unlink(skb, skb->list); spin_unlock_irqrestore(&list->lock, flags); }}/* XXX: more streamlined implementation *//** * __skb_dequeue_tail - remove from the tail of the queue * @list: list to dequeue from * * Remove the tail of the list. This function does not take any locks * so must be used with appropriate locks held only. The tail item is * returned or %NULL if the list is empty. */static inline struct sk_buff *__skb_dequeue_tail(struct sk_buff_head *list){ struct sk_buff *skb = skb_peek_tail(list); if (skb) __skb_unlink(skb, list); return skb;}/** * skb_dequeue - remove from the head of the queue * @list: list to dequeue from * * Remove the head of the list. The list lock is taken so the function * may be used safely with other locking list functions. The tail item is * returned or %NULL if the list is empty. */static inline struct sk_buff *skb_dequeue_tail(struct sk_buff_head *list){ unsigned long flags; struct sk_buff *result; spin_lock_irqsave(&list->lock, flags); result = __skb_dequeue_tail(list); spin_unlock_irqrestore(&list->lock, flags); return result;}static inline int skb_is_nonlinear(const struct sk_buff *skb){ return skb->data_len;}static inline int skb_headlen(const struct sk_buff *skb){ return skb->len - skb->data_len;}#define SKB_PAGE_ASSERT(skb) do { if (skb_shinfo(skb)->nr_frags) out_of_line_bug(); } while (0)#define SKB_FRAG_ASSERT(skb) do { if (skb_shinfo(skb)->frag_list) out_of_line_bug(); } while (0)#define SKB_LINEAR_ASSERT(skb) do { if (skb_is_nonlinear(skb)) out_of_line_bug(); } while (0)/* * Add data to an sk_buff */ static inline unsigned char *__skb_put(struct sk_buff *skb, unsigned int len){ unsigned char *tmp=skb->tail; SKB_LINEAR_ASSERT(skb); skb->tail+=len; skb->len+=len; return tmp;}/** * skb_put - add data to a buffer * @skb: buffer to use * @len: amount of data to add * * This function extends the used data area of the buffer. If this would
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?