Statistics
| Branch: | Revision:

root / net.h @ 7cb7434b

History | View | Annotate | Download (2.9 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 bf38c1a0 aliguori
    char *model;
22 676cff29 aliguori
    char *name;
23 87ecb68b pbrook
    char info_str[256];
24 87ecb68b pbrook
};
25 87ecb68b pbrook
26 87ecb68b pbrook
struct VLANState {
27 87ecb68b pbrook
    int id;
28 87ecb68b pbrook
    VLANClientState *first_client;
29 87ecb68b pbrook
    struct VLANState *next;
30 87ecb68b pbrook
    unsigned int nb_guest_devs, nb_host_devs;
31 87ecb68b pbrook
};
32 87ecb68b pbrook
33 87ecb68b pbrook
VLANState *qemu_find_vlan(int id);
34 87ecb68b pbrook
VLANClientState *qemu_new_vlan_client(VLANState *vlan,
35 bf38c1a0 aliguori
                                      const char *model,
36 87ecb68b pbrook
                                      IOReadHandler *fd_read,
37 87ecb68b pbrook
                                      IOCanRWHandler *fd_can_read,
38 87ecb68b pbrook
                                      void *opaque);
39 dcf414d6 balrog
void qemu_del_vlan_client(VLANClientState *vc);
40 87ecb68b pbrook
int qemu_can_send_packet(VLANClientState *vc);
41 fbe78f4f aliguori
ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
42 fbe78f4f aliguori
                          int iovcnt);
43 87ecb68b pbrook
void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
44 7cb7434b aliguori
void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
45 87ecb68b pbrook
void qemu_handler_true(void *opaque);
46 87ecb68b pbrook
47 87ecb68b pbrook
void do_info_network(void);
48 87ecb68b pbrook
49 87ecb68b pbrook
/* NIC info */
50 87ecb68b pbrook
51 87ecb68b pbrook
#define MAX_NICS 8
52 87ecb68b pbrook
53 87ecb68b pbrook
struct NICInfo {
54 87ecb68b pbrook
    uint8_t macaddr[6];
55 87ecb68b pbrook
    const char *model;
56 87ecb68b pbrook
    VLANState *vlan;
57 87ecb68b pbrook
};
58 87ecb68b pbrook
59 87ecb68b pbrook
extern int nb_nics;
60 87ecb68b pbrook
extern NICInfo nd_table[MAX_NICS];
61 87ecb68b pbrook
62 1ae26a18 balrog
/* BT HCI info */
63 1ae26a18 balrog
64 1ae26a18 balrog
struct HCIInfo {
65 1ae26a18 balrog
    int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
66 1ae26a18 balrog
    void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
67 1ae26a18 balrog
    void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
68 1ae26a18 balrog
    void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
69 1ae26a18 balrog
    void *opaque;
70 1ae26a18 balrog
    void (*evt_recv)(void *opaque, const uint8_t *data, int len);
71 1ae26a18 balrog
    void (*acl_recv)(void *opaque, const uint8_t *data, int len);
72 1ae26a18 balrog
};
73 1ae26a18 balrog
74 1ae26a18 balrog
struct HCIInfo *qemu_next_hci(void);
75 1ae26a18 balrog
76 48c64363 aliguori
/* checksumming functions (net-checksum.c) */
77 48c64363 aliguori
uint32_t net_checksum_add(int len, uint8_t *buf);
78 48c64363 aliguori
uint16_t net_checksum_finish(uint32_t sum);
79 48c64363 aliguori
uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
80 48c64363 aliguori
                             uint8_t *addrs, uint8_t *buf);
81 48c64363 aliguori
void net_checksum_calculate(uint8_t *data, int length);
82 48c64363 aliguori
83 63a01ef8 aliguori
/* from net.c */
84 63a01ef8 aliguori
int net_client_init(const char *device, const char *p);
85 63a01ef8 aliguori
int net_client_parse(const char *str);
86 63a01ef8 aliguori
void net_slirp_smb(const char *exported_dir);
87 63a01ef8 aliguori
void net_slirp_redir(const char *redir_str);
88 63a01ef8 aliguori
void net_cleanup(void);
89 63a01ef8 aliguori
int slirp_is_inited(void);
90 63a01ef8 aliguori
void net_client_check(void);
91 63a01ef8 aliguori
92 f54825cc aurel32
#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
93 f54825cc aurel32
#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
94 f54825cc aurel32
#ifdef __sun__
95 f54825cc aurel32
#define SMBD_COMMAND "/usr/sfw/sbin/smbd"
96 f54825cc aurel32
#else
97 f54825cc aurel32
#define SMBD_COMMAND "/usr/sbin/smbd"
98 f54825cc aurel32
#endif
99 f54825cc aurel32
100 87ecb68b pbrook
#endif