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