Update VERSION for v7.2.0-rc3
[qemu.git] / include / net / filter.h
1 /*
2 * Copyright (c) 2015 FUJITSU LIMITED
3 * Author: Yang Hongyang <yanghy@cn.fujitsu.com>
4 *
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 */
8
9 #ifndef QEMU_NET_FILTER_H
10 #define QEMU_NET_FILTER_H
11
12 #include "qapi/qapi-types-net.h"
13 #include "qemu/queue.h"
14 #include "qom/object.h"
15 #include "net/queue.h"
16
17 #define TYPE_NETFILTER "netfilter"
18 OBJECT_DECLARE_TYPE(NetFilterState, NetFilterClass, NETFILTER)
19
20 typedef void (FilterSetup) (NetFilterState *nf, Error **errp);
21 typedef void (FilterCleanup) (NetFilterState *nf);
22 /*
23 * Return:
24 * 0: finished handling the packet, we should continue
25 * size: filter stolen this packet, we stop pass this packet further
26 */
27 typedef ssize_t (FilterReceiveIOV)(NetFilterState *nc,
28 NetClientState *sender,
29 unsigned flags,
30 const struct iovec *iov,
31 int iovcnt,
32 NetPacketSent *sent_cb);
33
34 typedef void (FilterStatusChanged) (NetFilterState *nf, Error **errp);
35
36 typedef void (FilterHandleEvent) (NetFilterState *nf, int event, Error **errp);
37
38 struct NetFilterClass {
39 ObjectClass parent_class;
40
41 /* optional */
42 FilterSetup *setup;
43 FilterCleanup *cleanup;
44 FilterStatusChanged *status_changed;
45 FilterHandleEvent *handle_event;
46 /* mandatory */
47 FilterReceiveIOV *receive_iov;
48 };
49
50
51 struct NetFilterState {
52 /* private */
53 Object parent;
54
55 /* protected */
56 char *netdev_id;
57 NetClientState *netdev;
58 NetFilterDirection direction;
59 bool on;
60 char *position;
61 bool insert_before_flag;
62 QTAILQ_ENTRY(NetFilterState) next;
63 };
64
65 ssize_t qemu_netfilter_receive(NetFilterState *nf,
66 NetFilterDirection direction,
67 NetClientState *sender,
68 unsigned flags,
69 const struct iovec *iov,
70 int iovcnt,
71 NetPacketSent *sent_cb);
72
73 /* pass the packet to the next filter */
74 ssize_t qemu_netfilter_pass_to_next(NetClientState *sender,
75 unsigned flags,
76 const struct iovec *iov,
77 int iovcnt,
78 void *opaque);
79
80 void colo_notify_filters_event(int event, Error **errp);
81
82 #endif /* QEMU_NET_FILTER_H */