Statistics
| Branch: | Revision:

root / net / queue.h @ 54cdaa1b

History | View | Annotate | Download (2.9 kB)

1 f7105843 Mark McLoughlin
/*
2 f7105843 Mark McLoughlin
 * Copyright (c) 2003-2008 Fabrice Bellard
3 f7105843 Mark McLoughlin
 * Copyright (c) 2009 Red Hat, Inc.
4 f7105843 Mark McLoughlin
 *
5 f7105843 Mark McLoughlin
 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 f7105843 Mark McLoughlin
 * of this software and associated documentation files (the "Software"), to deal
7 f7105843 Mark McLoughlin
 * in the Software without restriction, including without limitation the rights
8 f7105843 Mark McLoughlin
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 f7105843 Mark McLoughlin
 * copies of the Software, and to permit persons to whom the Software is
10 f7105843 Mark McLoughlin
 * furnished to do so, subject to the following conditions:
11 f7105843 Mark McLoughlin
 *
12 f7105843 Mark McLoughlin
 * The above copyright notice and this permission notice shall be included in
13 f7105843 Mark McLoughlin
 * all copies or substantial portions of the Software.
14 f7105843 Mark McLoughlin
 *
15 f7105843 Mark McLoughlin
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 f7105843 Mark McLoughlin
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 f7105843 Mark McLoughlin
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 f7105843 Mark McLoughlin
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 f7105843 Mark McLoughlin
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 f7105843 Mark McLoughlin
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 f7105843 Mark McLoughlin
 * THE SOFTWARE.
22 f7105843 Mark McLoughlin
 */
23 f7105843 Mark McLoughlin
24 f7105843 Mark McLoughlin
#ifndef QEMU_NET_QUEUE_H
25 f7105843 Mark McLoughlin
#define QEMU_NET_QUEUE_H
26 f7105843 Mark McLoughlin
27 f7105843 Mark McLoughlin
#include "qemu-common.h"
28 f7105843 Mark McLoughlin
29 f7105843 Mark McLoughlin
typedef struct NetPacket NetPacket;
30 f7105843 Mark McLoughlin
typedef struct NetQueue NetQueue;
31 f7105843 Mark McLoughlin
32 f7105843 Mark McLoughlin
typedef void (NetPacketSent) (VLANClientState *sender, ssize_t ret);
33 f7105843 Mark McLoughlin
34 f7105843 Mark McLoughlin
typedef ssize_t (NetPacketDeliver) (VLANClientState *sender,
35 c0b8e49c Mark McLoughlin
                                    unsigned flags,
36 f7105843 Mark McLoughlin
                                    const uint8_t *buf,
37 f7105843 Mark McLoughlin
                                    size_t size,
38 f7105843 Mark McLoughlin
                                    void *opaque);
39 f7105843 Mark McLoughlin
40 f7105843 Mark McLoughlin
typedef ssize_t (NetPacketDeliverIOV) (VLANClientState *sender,
41 c0b8e49c Mark McLoughlin
                                       unsigned flags,
42 f7105843 Mark McLoughlin
                                       const struct iovec *iov,
43 f7105843 Mark McLoughlin
                                       int iovcnt,
44 f7105843 Mark McLoughlin
                                       void *opaque);
45 f7105843 Mark McLoughlin
46 c0b8e49c Mark McLoughlin
#define QEMU_NET_PACKET_FLAG_NONE  0
47 ca77d175 Mark McLoughlin
#define QEMU_NET_PACKET_FLAG_RAW  (1<<0)
48 c0b8e49c Mark McLoughlin
49 f7105843 Mark McLoughlin
NetQueue *qemu_new_net_queue(NetPacketDeliver *deliver,
50 f7105843 Mark McLoughlin
                             NetPacketDeliverIOV *deliver_iov,
51 f7105843 Mark McLoughlin
                             void *opaque);
52 f7105843 Mark McLoughlin
void qemu_del_net_queue(NetQueue *queue);
53 f7105843 Mark McLoughlin
54 f7105843 Mark McLoughlin
ssize_t qemu_net_queue_send(NetQueue *queue,
55 f7105843 Mark McLoughlin
                            VLANClientState *sender,
56 c0b8e49c Mark McLoughlin
                            unsigned flags,
57 f7105843 Mark McLoughlin
                            const uint8_t *data,
58 f7105843 Mark McLoughlin
                            size_t size,
59 f7105843 Mark McLoughlin
                            NetPacketSent *sent_cb);
60 f7105843 Mark McLoughlin
61 f7105843 Mark McLoughlin
ssize_t qemu_net_queue_send_iov(NetQueue *queue,
62 f7105843 Mark McLoughlin
                                VLANClientState *sender,
63 c0b8e49c Mark McLoughlin
                                unsigned flags,
64 f7105843 Mark McLoughlin
                                const struct iovec *iov,
65 f7105843 Mark McLoughlin
                                int iovcnt,
66 f7105843 Mark McLoughlin
                                NetPacketSent *sent_cb);
67 f7105843 Mark McLoughlin
68 f7105843 Mark McLoughlin
void qemu_net_queue_purge(NetQueue *queue, VLANClientState *from);
69 f7105843 Mark McLoughlin
void qemu_net_queue_flush(NetQueue *queue);
70 f7105843 Mark McLoughlin
71 f7105843 Mark McLoughlin
#endif /* QEMU_NET_QUEUE_H */