kernels/linux-2.4.0/net/ipv4/netfilter/ip_queue.c
/* Dequeue a packet if matched by cmp, or the next available if cmp is NULL */
Dequeue a packet if matched by cmp, or the next available if cmp is NULL
Dequeue a packet if matched by cmp or the next available if cmp is NULL
static ipq_queue_element_t *
ipq_dequeue(ipq_queue_t *q,
            int (*cmp)(ipq_queue_element_t *, unsigned long),
            unsigned long data)
{
	struct list_head *i;
	spin_lock_bh(&q->lock);
	for (i = q->list.prev; i != &q->list; i = i->prev) {
		ipq_queue_element_t *e = (ipq_queue_element_t *)i;
		if (!cmp || cmp(e, data)) {
			list_del(&e->list);
			q->len--;
			spin_unlock_bh(&q->lock);
			return e;
		}
	}
	spin_unlock_bh(&q->lock);
	return NULL;
}
static ipq_queue_element_t * ipq_dequeue ( ipq_queue_t * q , int ( * cmp ) ( ipq_queue_element_t * , unsigned long ) , unsigned long data ) { struct list_head * i ; spin_lock_bh ( & q -> lock ) ; for ( i = q -> list . prev ; i != & q -> list ; i = i -> prev ) { ipq_queue_element_t * e = ( ipq_queue_element_t * ) i ; if ( ! cmp || cmp ( e , data ) ) { list_del ( & e -> list ) ; q -> len -- ; spin_unlock_bh ( & q -> lock ) ; return e ; } } spin_unlock_bh ( & q -> lock ) ; return NULL ; }
Dequeue a packet if matched by cmp, or the next available if cmp is NULL
Dequeue a packet if matched by cmp or the next available if cmp is NULL