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.
9 #ifndef QEMU_NET_FILTER_H
10 #define QEMU_NET_FILTER_H
12 #include "qapi/qapi-types-net.h"
13 #include "qemu/queue.h"
14 #include "qom/object.h"
15 #include "net/queue.h"
17 #define TYPE_NETFILTER "netfilter"
18 OBJECT_DECLARE_TYPE(NetFilterState
, NetFilterClass
, NETFILTER
)
20 typedef void (FilterSetup
) (NetFilterState
*nf
, Error
**errp
);
21 typedef void (FilterCleanup
) (NetFilterState
*nf
);
24 * 0: finished handling the packet, we should continue
25 * size: filter stolen this packet, we stop pass this packet further
27 typedef ssize_t (FilterReceiveIOV
)(NetFilterState
*nc
,
28 NetClientState
*sender
,
30 const struct iovec
*iov
,
32 NetPacketSent
*sent_cb
);
34 typedef void (FilterStatusChanged
) (NetFilterState
*nf
, Error
**errp
);
36 typedef void (FilterHandleEvent
) (NetFilterState
*nf
, int event
, Error
**errp
);
38 struct NetFilterClass
{
39 ObjectClass parent_class
;
43 FilterCleanup
*cleanup
;
44 FilterStatusChanged
*status_changed
;
45 FilterHandleEvent
*handle_event
;
47 FilterReceiveIOV
*receive_iov
;
51 struct NetFilterState
{
57 NetClientState
*netdev
;
58 NetFilterDirection direction
;
61 bool insert_before_flag
;
62 QTAILQ_ENTRY(NetFilterState
) next
;
65 ssize_t
qemu_netfilter_receive(NetFilterState
*nf
,
66 NetFilterDirection direction
,
67 NetClientState
*sender
,
69 const struct iovec
*iov
,
71 NetPacketSent
*sent_cb
);
73 /* pass the packet to the next filter */
74 ssize_t
qemu_netfilter_pass_to_next(NetClientState
*sender
,
76 const struct iovec
*iov
,
80 void colo_notify_filters_event(int event
, Error
**errp
);
82 #endif /* QEMU_NET_FILTER_H */