root / net.h @ 6fb6d245
History | View | Annotate | Download (5.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 | e1144d00 | 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 | bb6e6364 | Mark McLoughlin | typedef enum { |
30 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_NONE, |
31 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_NIC, |
32 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_SLIRP, |
33 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_TAP, |
34 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_SOCKET, |
35 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_VDE, |
36 | bb6e6364 | Mark McLoughlin | NET_CLIENT_TYPE_DUMP |
37 | bb6e6364 | Mark McLoughlin | } net_client_type; |
38 | bb6e6364 | Mark McLoughlin | |
39 | e3f5ec2b | Mark McLoughlin | typedef int (NetCanReceive)(VLANClientState *); |
40 | 4f1c942b | Mark McLoughlin | typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); |
41 | e3f5ec2b | Mark McLoughlin | typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); |
42 | b946a153 | aliguori | typedef void (NetCleanup) (VLANClientState *); |
43 | 34b25ca7 | aliguori | typedef void (LinkStatusChanged)(VLANClientState *); |
44 | 34b25ca7 | aliguori | |
45 | 3ed79cc9 | Mark McLoughlin | typedef struct NetClientInfo { |
46 | 3ed79cc9 | Mark McLoughlin | net_client_type type; |
47 | 3ed79cc9 | Mark McLoughlin | size_t size; |
48 | 3ed79cc9 | Mark McLoughlin | NetReceive *receive; |
49 | 3ed79cc9 | Mark McLoughlin | NetReceive *receive_raw; |
50 | 3ed79cc9 | Mark McLoughlin | NetReceiveIOV *receive_iov; |
51 | 3ed79cc9 | Mark McLoughlin | NetCanReceive *can_receive; |
52 | 3ed79cc9 | Mark McLoughlin | NetCleanup *cleanup; |
53 | 3ed79cc9 | Mark McLoughlin | LinkStatusChanged *link_status_changed; |
54 | 3ed79cc9 | Mark McLoughlin | } NetClientInfo; |
55 | 3ed79cc9 | Mark McLoughlin | |
56 | 87ecb68b | pbrook | struct VLANClientState {
|
57 | 665a3b07 | Mark McLoughlin | NetClientInfo *info; |
58 | 436e5e53 | aliguori | int link_down;
|
59 | 5610c3aa | Mark McLoughlin | QTAILQ_ENTRY(VLANClientState) next; |
60 | 87ecb68b | pbrook | struct VLANState *vlan;
|
61 | 283c7c63 | Mark McLoughlin | VLANClientState *peer; |
62 | 9a6ecb30 | Mark McLoughlin | NetQueue *send_queue; |
63 | bf38c1a0 | aliguori | char *model;
|
64 | 676cff29 | aliguori | char *name;
|
65 | 87ecb68b | pbrook | char info_str[256]; |
66 | 893379ef | Mark McLoughlin | unsigned receive_disabled : 1; |
67 | 87ecb68b | pbrook | }; |
68 | 87ecb68b | pbrook | |
69 | ebef2c09 | Mark McLoughlin | typedef struct NICState { |
70 | ebef2c09 | Mark McLoughlin | VLANClientState nc; |
71 | ebef2c09 | Mark McLoughlin | NICConf *conf; |
72 | ebef2c09 | Mark McLoughlin | void *opaque;
|
73 | ebef2c09 | Mark McLoughlin | } NICState; |
74 | ebef2c09 | Mark McLoughlin | |
75 | 87ecb68b | pbrook | struct VLANState {
|
76 | 87ecb68b | pbrook | int id;
|
77 | 5610c3aa | Mark McLoughlin | QTAILQ_HEAD(, VLANClientState) clients; |
78 | 5610c3aa | Mark McLoughlin | QTAILQ_ENTRY(VLANState) next; |
79 | 87ecb68b | pbrook | unsigned int nb_guest_devs, nb_host_devs; |
80 | f7105843 | Mark McLoughlin | NetQueue *send_queue; |
81 | 87ecb68b | pbrook | }; |
82 | 87ecb68b | pbrook | |
83 | 1a609520 | Jan Kiszka | VLANState *qemu_find_vlan(int id, int allocate); |
84 | 2ef924b4 | Gerd Hoffmann | VLANClientState *qemu_find_netdev(const char *id); |
85 | 45460d1a | Mark McLoughlin | VLANClientState *qemu_new_net_client(NetClientInfo *info, |
86 | 45460d1a | Mark McLoughlin | VLANState *vlan, |
87 | 45460d1a | Mark McLoughlin | VLANClientState *peer, |
88 | 45460d1a | Mark McLoughlin | const char *model, |
89 | 45460d1a | Mark McLoughlin | const char *name); |
90 | ebef2c09 | Mark McLoughlin | NICState *qemu_new_nic(NetClientInfo *info, |
91 | ebef2c09 | Mark McLoughlin | NICConf *conf, |
92 | ebef2c09 | Mark McLoughlin | const char *model, |
93 | ebef2c09 | Mark McLoughlin | const char *name, |
94 | ebef2c09 | Mark McLoughlin | void *opaque);
|
95 | dcf414d6 | balrog | void qemu_del_vlan_client(VLANClientState *vc);
|
96 | 68ac40d2 | Mark McLoughlin | VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
|
97 | 68ac40d2 | Mark McLoughlin | const char *client_str); |
98 | 57f9ef17 | Mark McLoughlin | typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); |
99 | 57f9ef17 | Mark McLoughlin | void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); |
100 | 87ecb68b | pbrook | int qemu_can_send_packet(VLANClientState *vc);
|
101 | fbe78f4f | aliguori | ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, |
102 | fbe78f4f | aliguori | int iovcnt);
|
103 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_sendv_packet_async(VLANClientState *vc, const struct iovec *iov, |
104 | f3b6c7fc | Mark McLoughlin | int iovcnt, NetPacketSent *sent_cb);
|
105 | 87ecb68b | pbrook | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
106 | ca77d175 | Mark McLoughlin | ssize_t qemu_send_packet_raw(VLANClientState *vc, const uint8_t *buf, int size); |
107 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
|
108 | f3b6c7fc | Mark McLoughlin | int size, NetPacketSent *sent_cb);
|
109 | 8cad5516 | Mark McLoughlin | void qemu_purge_queued_packets(VLANClientState *vc);
|
110 | f3b6c7fc | Mark McLoughlin | void qemu_flush_queued_packets(VLANClientState *vc);
|
111 | 7cb7434b | aliguori | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); |
112 | 76d32cba | Gerd Hoffmann | void qemu_macaddr_default_if_unset(MACAddr *macaddr);
|
113 | 07caea31 | Markus Armbruster | int qemu_show_nic_models(const char *arg, const char *const *models); |
114 | d07f22c5 | aliguori | void qemu_check_nic_model(NICInfo *nd, const char *model); |
115 | 07caea31 | Markus Armbruster | int qemu_find_nic_model(NICInfo *nd, const char * const *models, |
116 | 07caea31 | Markus Armbruster | const char *default_model); |
117 | 87ecb68b | pbrook | |
118 | 376253ec | aliguori | void do_info_network(Monitor *mon);
|
119 | f18c16de | Luiz Capitulino | void do_set_link(Monitor *mon, const QDict *qdict); |
120 | 87ecb68b | pbrook | |
121 | 87ecb68b | pbrook | /* NIC info */
|
122 | 87ecb68b | pbrook | |
123 | 87ecb68b | pbrook | #define MAX_NICS 8 |
124 | ffe6370c | Michael S. Tsirkin | enum {
|
125 | ffe6370c | Michael S. Tsirkin | NIC_NVECTORS_UNSPECIFIED = -1
|
126 | ffe6370c | Michael S. Tsirkin | }; |
127 | 87ecb68b | pbrook | |
128 | 87ecb68b | pbrook | struct NICInfo {
|
129 | 87ecb68b | pbrook | uint8_t macaddr[6];
|
130 | 9203f520 | Mark McLoughlin | char *model;
|
131 | 9203f520 | Mark McLoughlin | char *name;
|
132 | 9203f520 | Mark McLoughlin | char *devaddr;
|
133 | 87ecb68b | pbrook | VLANState *vlan; |
134 | 5869c4d5 | Mark McLoughlin | VLANClientState *netdev; |
135 | 7697079b | aliguori | int used;
|
136 | 406c8df3 | Glauber Costa | int bootable;
|
137 | ffe6370c | Michael S. Tsirkin | int nvectors;
|
138 | 87ecb68b | pbrook | }; |
139 | 87ecb68b | pbrook | |
140 | 87ecb68b | pbrook | extern int nb_nics; |
141 | 87ecb68b | pbrook | extern NICInfo nd_table[MAX_NICS];
|
142 | 87ecb68b | pbrook | |
143 | 1ae26a18 | balrog | /* BT HCI info */
|
144 | 1ae26a18 | balrog | |
145 | 1ae26a18 | balrog | struct HCIInfo {
|
146 | 1ae26a18 | balrog | int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); |
147 | 1ae26a18 | balrog | void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
148 | 1ae26a18 | balrog | void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
149 | 1ae26a18 | balrog | void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
150 | 1ae26a18 | balrog | void *opaque;
|
151 | 1ae26a18 | balrog | void (*evt_recv)(void *opaque, const uint8_t *data, int len); |
152 | 1ae26a18 | balrog | void (*acl_recv)(void *opaque, const uint8_t *data, int len); |
153 | 1ae26a18 | balrog | }; |
154 | 1ae26a18 | balrog | |
155 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void); |
156 | 1ae26a18 | balrog | |
157 | 63a01ef8 | aliguori | /* from net.c */
|
158 | ad196a9d | Jan Kiszka | extern const char *legacy_tftp_prefix; |
159 | ad196a9d | Jan Kiszka | extern const char *legacy_bootp_filename; |
160 | ad196a9d | Jan Kiszka | |
161 | f6b134ac | Mark McLoughlin | int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev); |
162 | 8b13c4a7 | aliguori | void net_client_uninit(NICInfo *nd);
|
163 | 7f161aae | Mark McLoughlin | int net_client_parse(QemuOptsList *opts_list, const char *str); |
164 | dc1c9fe8 | Mark McLoughlin | int net_init_clients(void); |
165 | 63a01ef8 | aliguori | void net_cleanup(void); |
166 | 406c8df3 | Glauber Costa | void net_set_boot_mask(int boot_mask); |
167 | f18c16de | Luiz Capitulino | void net_host_device_add(Monitor *mon, const QDict *qdict); |
168 | f18c16de | Luiz Capitulino | void net_host_device_remove(Monitor *mon, const QDict *qdict); |
169 | 63a01ef8 | aliguori | |
170 | f54825cc | aurel32 | #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" |
171 | f54825cc | aurel32 | #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" |
172 | f54825cc | aurel32 | #ifdef __sun__
|
173 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sfw/sbin/smbd" |
174 | f54825cc | aurel32 | #else
|
175 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sbin/smbd" |
176 | f54825cc | aurel32 | #endif
|
177 | f54825cc | aurel32 | |
178 | ed16ab5a | Gerd Hoffmann | void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
|
179 | 9d07d757 | Paul Brook | |
180 | 5281d757 | Mark McLoughlin | int net_handle_fd_param(Monitor *mon, const char *param); |
181 | 5281d757 | Mark McLoughlin | |
182 | 87ecb68b | pbrook | #endif |