Statistics
| Branch: | Revision:

root / net.h @ 8098ed41

History | View | Annotate | Download (2.5 kB)

1 87ecb68b pbrook
#ifndef QEMU_NET_H
2 87ecb68b pbrook
#define QEMU_NET_H
3 87ecb68b pbrook
4 fbe78f4f aliguori
#include "qemu-common.h"
5 fbe78f4f aliguori
6 87ecb68b pbrook
/* VLANs support */
7 87ecb68b pbrook
8 fbe78f4f aliguori
typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
9 fbe78f4f aliguori
10 87ecb68b pbrook
typedef struct VLANClientState VLANClientState;
11 87ecb68b pbrook
12 87ecb68b pbrook
struct VLANClientState {
13 87ecb68b pbrook
    IOReadHandler *fd_read;
14 fbe78f4f aliguori
    IOReadvHandler *fd_readv;
15 87ecb68b pbrook
    /* Packets may still be sent if this returns zero.  It's used to
16 87ecb68b pbrook
       rate-limit the slirp code.  */
17 87ecb68b pbrook
    IOCanRWHandler *fd_can_read;
18 87ecb68b pbrook
    void *opaque;
19 87ecb68b pbrook
    struct VLANClientState *next;
20 87ecb68b pbrook
    struct VLANState *vlan;
21 87ecb68b pbrook
    char info_str[256];
22 87ecb68b pbrook
};
23 87ecb68b pbrook
24 87ecb68b pbrook
struct VLANState {
25 87ecb68b pbrook
    int id;
26 87ecb68b pbrook
    VLANClientState *first_client;
27 87ecb68b pbrook
    struct VLANState *next;
28 87ecb68b pbrook
    unsigned int nb_guest_devs, nb_host_devs;
29 87ecb68b pbrook
};
30 87ecb68b pbrook
31 87ecb68b pbrook
VLANState *qemu_find_vlan(int id);
32 87ecb68b pbrook
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
33 87ecb68b pbrook
                                      IOReadHandler *fd_read,
34 87ecb68b pbrook
                                      IOCanRWHandler *fd_can_read,
35 87ecb68b pbrook
                                      void *opaque);
36 dcf414d6 balrog
void qemu_del_vlan_client(VLANClientState *vc);
37 87ecb68b pbrook
int qemu_can_send_packet(VLANClientState *vc);
38 fbe78f4f aliguori
ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
39 fbe78f4f aliguori
                          int iovcnt);
40 87ecb68b pbrook
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
41 87ecb68b pbrook
void qemu_handler_true(void *opaque);
42 87ecb68b pbrook
43 87ecb68b pbrook
void do_info_network(void);
44 87ecb68b pbrook
45 87ecb68b pbrook
/* NIC info */
46 87ecb68b pbrook
47 87ecb68b pbrook
#define MAX_NICS 8
48 87ecb68b pbrook
49 87ecb68b pbrook
struct NICInfo {
50 87ecb68b pbrook
    uint8_t macaddr[6];
51 87ecb68b pbrook
    const char *model;
52 87ecb68b pbrook
    VLANState *vlan;
53 87ecb68b pbrook
};
54 87ecb68b pbrook
55 87ecb68b pbrook
extern int nb_nics;
56 87ecb68b pbrook
extern NICInfo nd_table[MAX_NICS];
57 87ecb68b pbrook
58 1ae26a18 balrog
/* BT HCI info */
59 1ae26a18 balrog
60 1ae26a18 balrog
struct HCIInfo {
61 1ae26a18 balrog
    int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
62 1ae26a18 balrog
    void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
63 1ae26a18 balrog
    void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
64 1ae26a18 balrog
    void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
65 1ae26a18 balrog
    void *opaque;
66 1ae26a18 balrog
    void (*evt_recv)(void *opaque, const uint8_t *data, int len);
67 1ae26a18 balrog
    void (*acl_recv)(void *opaque, const uint8_t *data, int len);
68 1ae26a18 balrog
};
69 1ae26a18 balrog
70 1ae26a18 balrog
struct HCIInfo *qemu_next_hci(void);
71 1ae26a18 balrog
72 48c64363 aliguori
/* checksumming functions (net-checksum.c) */
73 48c64363 aliguori
uint32_t net_checksum_add(int len, uint8_t *buf);
74 48c64363 aliguori
uint16_t net_checksum_finish(uint32_t sum);
75 48c64363 aliguori
uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
76 48c64363 aliguori
                             uint8_t *addrs, uint8_t *buf);
77 48c64363 aliguori
void net_checksum_calculate(uint8_t *data, int length);
78 48c64363 aliguori
79 63a01ef8 aliguori
/* from net.c */
80 63a01ef8 aliguori
int net_client_init(const char *device, const char *p);
81 63a01ef8 aliguori
int net_client_parse(const char *str);
82 63a01ef8 aliguori
void net_slirp_smb(const char *exported_dir);
83 63a01ef8 aliguori
void net_slirp_redir(const char *redir_str);
84 63a01ef8 aliguori
void net_cleanup(void);
85 63a01ef8 aliguori
int slirp_is_inited(void);
86 63a01ef8 aliguori
void net_client_check(void);
87 63a01ef8 aliguori
88 87ecb68b pbrook
#endif