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