aboutsummaryrefslogtreecommitdiff
path: root/net/vmnet_int.h
blob: adf6e8c20d5d7780be0e5b7bcba34ecde08731fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * vmnet_int.h
 *
 * Copyright(c) 2022 Vladislav Yaroshchuk <vladislav.yaroshchuk@jetbrains.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 *
 */
#ifndef VMNET_INT_H
#define VMNET_INT_H

#include "qemu/osdep.h"
#include "vmnet_int.h"
#include "clients.h"

#include <vmnet/vmnet.h>
#include <dispatch/dispatch.h>

/**
 *  From vmnet.framework documentation
 *
 *  Each read/write call allows up to 200 packets to be
 *  read or written for a maximum of 256KB.
 *
 *  Each packet written should be a complete
 *  ethernet frame.
 *
 *  https://developer.apple.com/documentation/vmnet
 */
#define VMNET_PACKETS_LIMIT 200

typedef struct VmnetState {
    NetClientState nc;
    interface_ref vmnet_if;

    uint64_t mtu;
    uint64_t max_packet_size;

    dispatch_queue_t if_queue;

    QEMUBH *send_bh;

    struct vmpktdesc packets_buf[VMNET_PACKETS_LIMIT];
    int packets_send_current_pos;
    int packets_send_end_pos;

    struct iovec iov_buf[VMNET_PACKETS_LIMIT];
} VmnetState;

const char *vmnet_status_map_str(vmnet_return_t status);

int vmnet_if_create(NetClientState *nc,
                    xpc_object_t if_desc,
                    Error **errp);

ssize_t vmnet_receive_common(NetClientState *nc,
                             const uint8_t *buf,
                             size_t size);

void vmnet_cleanup_common(NetClientState *nc);

#endif /* VMNET_INT_H */