]> git.proxmox.com Git - mirror_qemu.git/blame - include/net/filter.h
Include qemu-common.h exactly where needed
[mirror_qemu.git] / include / net / filter.h
CommitLineData
fdccce45
YH
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
9af23989 12#include "qapi/qapi-types-net.h"
fdccce45 13#include "qom/object.h"
fdccce45
YH
14#include "net/queue.h"
15
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)
23
24typedef void (FilterSetup) (NetFilterState *nf, Error **errp);
25typedef void (FilterCleanup) (NetFilterState *nf);
26/*
27 * Return:
28 * 0: finished handling the packet, we should continue
29 * size: filter stolen this packet, we stop pass this packet further
30 */
31typedef ssize_t (FilterReceiveIOV)(NetFilterState *nc,
32 NetClientState *sender,
33 unsigned flags,
34 const struct iovec *iov,
35 int iovcnt,
36 NetPacketSent *sent_cb);
37
338d3f41
HZ
38typedef void (FilterStatusChanged) (NetFilterState *nf, Error **errp);
39
5fbba3d6
ZC
40typedef void (FilterHandleEvent) (NetFilterState *nf, int event, Error **errp);
41
fdccce45
YH
42typedef struct NetFilterClass {
43 ObjectClass parent_class;
44
45 /* optional */
46 FilterSetup *setup;
47 FilterCleanup *cleanup;
338d3f41 48 FilterStatusChanged *status_changed;
5fbba3d6 49 FilterHandleEvent *handle_event;
fdccce45
YH
50 /* mandatory */
51 FilterReceiveIOV *receive_iov;
52} NetFilterClass;
53
54
55struct NetFilterState {
56 /* private */
57 Object parent;
58
59 /* protected */
60 char *netdev_id;
61 NetClientState *netdev;
62 NetFilterDirection direction;
338d3f41 63 bool on;
fdccce45
YH
64 QTAILQ_ENTRY(NetFilterState) next;
65};
66
e64c770d
YH
67ssize_t qemu_netfilter_receive(NetFilterState *nf,
68 NetFilterDirection direction,
69 NetClientState *sender,
70 unsigned flags,
71 const struct iovec *iov,
72 int iovcnt,
73 NetPacketSent *sent_cb);
74
7ef7bc85
YH
75/* pass the packet to the next filter */
76ssize_t qemu_netfilter_pass_to_next(NetClientState *sender,
77 unsigned flags,
78 const struct iovec *iov,
79 int iovcnt,
80 void *opaque);
81
5fbba3d6
ZC
82void colo_notify_filters_event(int event, Error **errp);
83
fdccce45 84#endif /* QEMU_NET_FILTER_H */