Beispiel #1
0
static unsigned int nf_ip_post_routing_hook(unsigned int hooknum,
		struct sk_buff *skb, const struct net_device *in,
		const struct net_device *out, int(*okfn)(struct sk_buff*)) {
	filter_chain c = get_chain(POST_ROUTING_CHAIN);
	klist_iterator* it;
	filter* f;
	unsigned int retval;

	if (c.len == 0)
		return NF_ACCEPT;

	it = make_klist_iterator(c.filters);
	while (klist_iterator_has_next(it)) {
		f = (filter*) (klist_iterator_next(it))->data;
		if (match_filter(f, skb)) {
			retval = apply_filter(f, hooknum, skb, in, out, okfn);
			if (retval != NF_ACCEPT) {
				free_klist_iterator(it);
				return retval;
			}
		}
	}
	free_klist_iterator(it);

	return NF_ACCEPT;
}
static int usb_host_auto_del(const char *spec)
{
    struct USBAutoFilter *pf = usb_auto_filter;
    struct USBAutoFilter **prev = &usb_auto_filter;
    struct USBAutoFilter filter;

    if (parse_filter(spec, &filter) < 0)
        return -1;

    while (pf) {
        if (match_filter(pf, &filter)) {
            dprintf("husb: removed auto filter: bus_num %d addr %d vid %d pid %d\n",
	             pf->bus_num, pf->addr, pf->vendor_id, pf->product_id);

            *prev = pf->next;

	    if (!usb_auto_filter) {
                /* No more filters. Stop scanning. */
                qemu_del_timer(usb_auto_timer);
                qemu_free_timer(usb_auto_timer);
            }

            return 0;
        }

        prev = &pf->next;
        pf   = pf->next;
    }

    return -1;
}