root / net.h @ bc578fe0
History | View | Annotate | Download (5.5 kB)
1 | 87ecb68b | pbrook | #ifndef QEMU_NET_H
|
---|---|---|---|
2 | 87ecb68b | pbrook | #define QEMU_NET_H
|
3 | 87ecb68b | pbrook | |
4 | 72cf2d4f | Blue Swirl | #include "qemu-queue.h" |
5 | fbe78f4f | aliguori | #include "qemu-common.h" |
6 | f18c16de | Luiz Capitulino | #include "qdict.h" |
7 | 13cf8f21 | Mark McLoughlin | #include "qemu-option.h" |
8 | fbe78f4f | aliguori | |
9 | 87ecb68b | pbrook | /* VLANs support */
|
10 | 87ecb68b | pbrook | |
11 | 87ecb68b | pbrook | typedef struct VLANClientState VLANClientState; |
12 | 87ecb68b | pbrook | |
13 | e3f5ec2b | Mark McLoughlin | typedef int (NetCanReceive)(VLANClientState *); |
14 | 4f1c942b | Mark McLoughlin | typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); |
15 | e3f5ec2b | Mark McLoughlin | typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); |
16 | b946a153 | aliguori | typedef void (NetCleanup) (VLANClientState *); |
17 | 34b25ca7 | aliguori | typedef void (LinkStatusChanged)(VLANClientState *); |
18 | 34b25ca7 | aliguori | |
19 | 87ecb68b | pbrook | struct VLANClientState {
|
20 | cda9046b | Mark McLoughlin | NetReceive *receive; |
21 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov; |
22 | 87ecb68b | pbrook | /* Packets may still be sent if this returns zero. It's used to
|
23 | 87ecb68b | pbrook | rate-limit the slirp code. */
|
24 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive; |
25 | b946a153 | aliguori | NetCleanup *cleanup; |
26 | 34b25ca7 | aliguori | LinkStatusChanged *link_status_changed; |
27 | 436e5e53 | aliguori | int link_down;
|
28 | 87ecb68b | pbrook | void *opaque;
|
29 | 87ecb68b | pbrook | struct VLANClientState *next;
|
30 | 87ecb68b | pbrook | struct VLANState *vlan;
|
31 | bf38c1a0 | aliguori | char *model;
|
32 | 676cff29 | aliguori | char *name;
|
33 | 87ecb68b | pbrook | char info_str[256]; |
34 | 87ecb68b | pbrook | }; |
35 | 87ecb68b | pbrook | |
36 | 764a4d1d | aliguori | typedef struct VLANPacket VLANPacket; |
37 | 764a4d1d | aliguori | |
38 | 783527a9 | Mark McLoughlin | typedef void (NetPacketSent) (VLANClientState *, ssize_t); |
39 | f3b6c7fc | Mark McLoughlin | |
40 | 764a4d1d | aliguori | struct VLANPacket {
|
41 | 72cf2d4f | Blue Swirl | QTAILQ_ENTRY(VLANPacket) entry; |
42 | 764a4d1d | aliguori | VLANClientState *sender; |
43 | 764a4d1d | aliguori | int size;
|
44 | f3b6c7fc | Mark McLoughlin | NetPacketSent *sent_cb; |
45 | 764a4d1d | aliguori | uint8_t data[0];
|
46 | 764a4d1d | aliguori | }; |
47 | 764a4d1d | aliguori | |
48 | 87ecb68b | pbrook | struct VLANState {
|
49 | 87ecb68b | pbrook | int id;
|
50 | 87ecb68b | pbrook | VLANClientState *first_client; |
51 | 87ecb68b | pbrook | struct VLANState *next;
|
52 | 87ecb68b | pbrook | unsigned int nb_guest_devs, nb_host_devs; |
53 | 72cf2d4f | Blue Swirl | QTAILQ_HEAD(send_queue, VLANPacket) send_queue; |
54 | 764a4d1d | aliguori | int delivering;
|
55 | 87ecb68b | pbrook | }; |
56 | 87ecb68b | pbrook | |
57 | 1a609520 | Jan Kiszka | VLANState *qemu_find_vlan(int id, int allocate); |
58 | 87ecb68b | pbrook | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
59 | bf38c1a0 | aliguori | const char *model, |
60 | 7a9f6e4a | aliguori | const char *name, |
61 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive, |
62 | cda9046b | Mark McLoughlin | NetReceive *receive, |
63 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov, |
64 | b946a153 | aliguori | NetCleanup *cleanup, |
65 | 87ecb68b | pbrook | void *opaque);
|
66 | dcf414d6 | balrog | void qemu_del_vlan_client(VLANClientState *vc);
|
67 | 8b13c4a7 | aliguori | VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque);
|
68 | 87ecb68b | pbrook | int qemu_can_send_packet(VLANClientState *vc);
|
69 | fbe78f4f | aliguori | ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, |
70 | fbe78f4f | aliguori | int iovcnt);
|
71 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_sendv_packet_async(VLANClientState *vc, const struct iovec *iov, |
72 | f3b6c7fc | Mark McLoughlin | int iovcnt, NetPacketSent *sent_cb);
|
73 | 87ecb68b | pbrook | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
74 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
|
75 | f3b6c7fc | Mark McLoughlin | int size, NetPacketSent *sent_cb);
|
76 | 8cad5516 | Mark McLoughlin | void qemu_purge_queued_packets(VLANClientState *vc);
|
77 | f3b6c7fc | Mark McLoughlin | void qemu_flush_queued_packets(VLANClientState *vc);
|
78 | 7cb7434b | aliguori | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); |
79 | 07caea31 | Markus Armbruster | int qemu_show_nic_models(const char *arg, const char *const *models); |
80 | d07f22c5 | aliguori | void qemu_check_nic_model(NICInfo *nd, const char *model); |
81 | 07caea31 | Markus Armbruster | int qemu_find_nic_model(NICInfo *nd, const char * const *models, |
82 | 07caea31 | Markus Armbruster | const char *default_model); |
83 | 87ecb68b | pbrook | void qemu_handler_true(void *opaque); |
84 | 87ecb68b | pbrook | |
85 | 376253ec | aliguori | void do_info_network(Monitor *mon);
|
86 | f18c16de | Luiz Capitulino | void do_set_link(Monitor *mon, const QDict *qdict); |
87 | 87ecb68b | pbrook | |
88 | 6dbe553f | Jan Kiszka | void do_info_usernet(Monitor *mon);
|
89 | 6dbe553f | Jan Kiszka | |
90 | 87ecb68b | pbrook | /* NIC info */
|
91 | 87ecb68b | pbrook | |
92 | 87ecb68b | pbrook | #define MAX_NICS 8 |
93 | ffe6370c | Michael S. Tsirkin | enum {
|
94 | ffe6370c | Michael S. Tsirkin | NIC_NVECTORS_UNSPECIFIED = -1
|
95 | ffe6370c | Michael S. Tsirkin | }; |
96 | 87ecb68b | pbrook | |
97 | 87ecb68b | pbrook | struct NICInfo {
|
98 | 87ecb68b | pbrook | uint8_t macaddr[6];
|
99 | 9203f520 | Mark McLoughlin | char *model;
|
100 | 9203f520 | Mark McLoughlin | char *name;
|
101 | 9203f520 | Mark McLoughlin | char *devaddr;
|
102 | 9203f520 | Mark McLoughlin | char *id;
|
103 | 87ecb68b | pbrook | VLANState *vlan; |
104 | ae50b274 | Mark McLoughlin | VLANClientState *vc; |
105 | 72da4208 | aliguori | void *private;
|
106 | 7697079b | aliguori | int used;
|
107 | 406c8df3 | Glauber Costa | int bootable;
|
108 | ffe6370c | Michael S. Tsirkin | int nvectors;
|
109 | 87ecb68b | pbrook | }; |
110 | 87ecb68b | pbrook | |
111 | 87ecb68b | pbrook | extern int nb_nics; |
112 | 87ecb68b | pbrook | extern NICInfo nd_table[MAX_NICS];
|
113 | 87ecb68b | pbrook | |
114 | 1ae26a18 | balrog | /* BT HCI info */
|
115 | 1ae26a18 | balrog | |
116 | 1ae26a18 | balrog | struct HCIInfo {
|
117 | 1ae26a18 | balrog | int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); |
118 | 1ae26a18 | balrog | void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
119 | 1ae26a18 | balrog | void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
120 | 1ae26a18 | balrog | void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
121 | 1ae26a18 | balrog | void *opaque;
|
122 | 1ae26a18 | balrog | void (*evt_recv)(void *opaque, const uint8_t *data, int len); |
123 | 1ae26a18 | balrog | void (*acl_recv)(void *opaque, const uint8_t *data, int len); |
124 | 1ae26a18 | balrog | }; |
125 | 1ae26a18 | balrog | |
126 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void); |
127 | 1ae26a18 | balrog | |
128 | 48c64363 | aliguori | /* checksumming functions (net-checksum.c) */
|
129 | 48c64363 | aliguori | uint32_t net_checksum_add(int len, uint8_t *buf);
|
130 | 48c64363 | aliguori | uint16_t net_checksum_finish(uint32_t sum); |
131 | 48c64363 | aliguori | uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, |
132 | 48c64363 | aliguori | uint8_t *addrs, uint8_t *buf); |
133 | 48c64363 | aliguori | void net_checksum_calculate(uint8_t *data, int length); |
134 | 48c64363 | aliguori | |
135 | 63a01ef8 | aliguori | /* from net.c */
|
136 | ad196a9d | Jan Kiszka | extern const char *legacy_tftp_prefix; |
137 | ad196a9d | Jan Kiszka | extern const char *legacy_bootp_filename; |
138 | ad196a9d | Jan Kiszka | |
139 | dc1c9fe8 | Mark McLoughlin | int net_client_init(Monitor *mon, QemuOpts *opts);
|
140 | 8b13c4a7 | aliguori | void net_client_uninit(NICInfo *nd);
|
141 | 63a01ef8 | aliguori | int net_client_parse(const char *str); |
142 | dc1c9fe8 | Mark McLoughlin | int net_init_clients(void); |
143 | 0752706d | Markus Armbruster | int net_slirp_smb(const char *exported_dir); |
144 | 1d4daa91 | Luiz Capitulino | void net_slirp_hostfwd_add(Monitor *mon, const QDict *qdict); |
145 | 1d4daa91 | Luiz Capitulino | void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict); |
146 | 0752706d | Markus Armbruster | int net_slirp_redir(const char *redir_str); |
147 | 63a01ef8 | aliguori | void net_cleanup(void); |
148 | 406c8df3 | Glauber Costa | void net_set_boot_mask(int boot_mask); |
149 | f18c16de | Luiz Capitulino | void net_host_device_add(Monitor *mon, const QDict *qdict); |
150 | f18c16de | Luiz Capitulino | void net_host_device_remove(Monitor *mon, const QDict *qdict); |
151 | 63a01ef8 | aliguori | |
152 | f54825cc | aurel32 | #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" |
153 | f54825cc | aurel32 | #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" |
154 | f54825cc | aurel32 | #ifdef __sun__
|
155 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sfw/sbin/smbd" |
156 | f54825cc | aurel32 | #else
|
157 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sbin/smbd" |
158 | f54825cc | aurel32 | #endif
|
159 | f54825cc | aurel32 | |
160 | 9d07d757 | Paul Brook | void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
|
161 | 9d07d757 | Paul Brook | VLANClientState *qdev_get_vlan_client(DeviceState *dev, |
162 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive, |
163 | cda9046b | Mark McLoughlin | NetReceive *receive, |
164 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov, |
165 | 9d07d757 | Paul Brook | NetCleanup *cleanup, |
166 | 9d07d757 | Paul Brook | void *opaque);
|
167 | 9d07d757 | Paul Brook | |
168 | 87ecb68b | pbrook | #endif |