qcow2: make qcow2_encrypt_sectors encrypt in place
[qemu/ar7.git] / include / net / filter.h
blob0c4a2ea6c90f4a1676d0e7c27ae408ed85514489
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 "net/queue.h"
16 #define TYPE_NETFILTER "netfilter"
17 #define NETFILTER(obj) \
18 OBJECT_CHECK(NetFilterState, (obj), TYPE_NETFILTER)
19 #define NETFILTER_GET_CLASS(obj) \
20 OBJECT_GET_CLASS(NetFilterClass, (obj), TYPE_NETFILTER)
21 #define NETFILTER_CLASS(klass) \
22 OBJECT_CLASS_CHECK(NetFilterClass, (klass), TYPE_NETFILTER)
24 typedef void (FilterSetup) (NetFilterState *nf, Error **errp);
25 typedef void (FilterCleanup) (NetFilterState *nf);
27 * Return:
28 * 0: finished handling the packet, we should continue
29 * size: filter stolen this packet, we stop pass this packet further
31 typedef ssize_t (FilterReceiveIOV)(NetFilterState *nc,
32 NetClientState *sender,
33 unsigned flags,
34 const struct iovec *iov,
35 int iovcnt,
36 NetPacketSent *sent_cb);
38 typedef void (FilterStatusChanged) (NetFilterState *nf, Error **errp);
40 typedef struct NetFilterClass {
41 ObjectClass parent_class;
43 /* optional */
44 FilterSetup *setup;
45 FilterCleanup *cleanup;
46 FilterStatusChanged *status_changed;
47 /* mandatory */
48 FilterReceiveIOV *receive_iov;
49 } NetFilterClass;
52 struct NetFilterState {
53 /* private */
54 Object parent;
56 /* protected */
57 char *netdev_id;
58 NetClientState *netdev;
59 NetFilterDirection direction;
60 bool on;
61 QTAILQ_ENTRY(NetFilterState) next;
64 ssize_t qemu_netfilter_receive(NetFilterState *nf,
65 NetFilterDirection direction,
66 NetClientState *sender,
67 unsigned flags,
68 const struct iovec *iov,
69 int iovcnt,
70 NetPacketSent *sent_cb);
72 /* pass the packet to the next filter */
73 ssize_t qemu_netfilter_pass_to_next(NetClientState *sender,
74 unsigned flags,
75 const struct iovec *iov,
76 int iovcnt,
77 void *opaque);
79 #endif /* QEMU_NET_FILTER_H */