scripts/gdb: Fix a python exception in mtree.py
[qemu/ar7.git] / include / net / filter.h
blob2deda362a6900486318142fd91b74ed71f749678
1 /*
2 * Copyright (c) 2015 FUJITSU LIMITED
3 * Author: Yang Hongyang <yanghy@cn.fujitsu.com>
5 * This work is licensed under the terms of the GNU GPL, version 2 or
6 * later. See the COPYING file in the top-level directory.
7 */
9 #ifndef QEMU_NET_FILTER_H
10 #define QEMU_NET_FILTER_H
12 #include "qom/object.h"
13 #include "qemu-common.h"
14 #include "qemu/typedefs.h"
15 #include "net/queue.h"
17 #define TYPE_NETFILTER "netfilter"
18 #define NETFILTER(obj) \
19 OBJECT_CHECK(NetFilterState, (obj), TYPE_NETFILTER)
20 #define NETFILTER_GET_CLASS(obj) \
21 OBJECT_GET_CLASS(NetFilterClass, (obj), TYPE_NETFILTER)
22 #define NETFILTER_CLASS(klass) \
23 OBJECT_CLASS_CHECK(NetFilterClass, (klass), TYPE_NETFILTER)
25 typedef void (FilterSetup) (NetFilterState *nf, Error **errp);
26 typedef void (FilterCleanup) (NetFilterState *nf);
28 * Return:
29 * 0: finished handling the packet, we should continue
30 * size: filter stolen this packet, we stop pass this packet further
32 typedef ssize_t (FilterReceiveIOV)(NetFilterState *nc,
33 NetClientState *sender,
34 unsigned flags,
35 const struct iovec *iov,
36 int iovcnt,
37 NetPacketSent *sent_cb);
39 typedef struct NetFilterClass {
40 ObjectClass parent_class;
42 /* optional */
43 FilterSetup *setup;
44 FilterCleanup *cleanup;
45 /* mandatory */
46 FilterReceiveIOV *receive_iov;
47 } NetFilterClass;
50 struct NetFilterState {
51 /* private */
52 Object parent;
54 /* protected */
55 char *netdev_id;
56 NetClientState *netdev;
57 NetFilterDirection direction;
58 char info_str[256];
59 QTAILQ_ENTRY(NetFilterState) next;
62 ssize_t qemu_netfilter_receive(NetFilterState *nf,
63 NetFilterDirection direction,
64 NetClientState *sender,
65 unsigned flags,
66 const struct iovec *iov,
67 int iovcnt,
68 NetPacketSent *sent_cb);
70 /* pass the packet to the next filter */
71 ssize_t qemu_netfilter_pass_to_next(NetClientState *sender,
72 unsigned flags,
73 const struct iovec *iov,
74 int iovcnt,
75 void *opaque);
77 #endif /* QEMU_NET_FILTER_H */