Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 189 lines (162 sloc) 6.082 kb
36b02c7d » rmustacc
2011-08-09 HVM-588 Make sure copyright is updated in kvm-cmd
1 /*
2 * Copyright 2011 QEMU contributors
3 * Portions Copyright 2011 Joyent, Inc.
4 */
68396ea9 » rmustacc
2011-06-24 Initial commit of d32e8d0 from qemu-kvm
5 #ifndef QEMU_NET_H
6 #define QEMU_NET_H
7
8 #include "qemu-queue.h"
9 #include "qemu-common.h"
10 #include "qdict.h"
11 #include "qemu-option.h"
12 #include "net/queue.h"
13
14 struct MACAddr {
15 uint8_t a[6];
16 };
17
18 /* qdev nic properties */
19
20 typedef struct NICConf {
21 MACAddr macaddr;
22 VLANState *vlan;
23 VLANClientState *peer;
24 int32_t bootindex;
25 } NICConf;
26
27 #define DEFINE_NIC_PROPERTIES(_state, _conf) \
28 DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \
29 DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \
30 DEFINE_PROP_NETDEV("netdev", _state, _conf.peer), \
31 DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
32
33 /* VLANs support */
34
35 typedef enum {
36 NET_CLIENT_TYPE_NONE,
37 NET_CLIENT_TYPE_NIC,
38 NET_CLIENT_TYPE_SLIRP,
39 NET_CLIENT_TYPE_TAP,
40 NET_CLIENT_TYPE_SOCKET,
41 NET_CLIENT_TYPE_VDE,
fa9a2364 » rmustacc
2011-06-24 HVM-388 Run native kvm with qemu-v0.14.x
42 NET_CLIENT_TYPE_DUMP,
43 NET_CLIENT_TYPE_VNIC
68396ea9 » rmustacc
2011-06-24 Initial commit of d32e8d0 from qemu-kvm
44 } net_client_type;
45
46 typedef void (NetPoll)(VLANClientState *, bool enable);
47 typedef int (NetCanReceive)(VLANClientState *);
48 typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
49 typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
50 typedef void (NetCleanup) (VLANClientState *);
51 typedef void (LinkStatusChanged)(VLANClientState *);
52
53 typedef struct NetClientInfo {
54 net_client_type type;
55 size_t size;
56 NetReceive *receive;
57 NetReceive *receive_raw;
58 NetReceiveIOV *receive_iov;
59 NetCanReceive *can_receive;
60 NetCleanup *cleanup;
61 LinkStatusChanged *link_status_changed;
62 NetPoll *poll;
63 } NetClientInfo;
64
65 struct VLANClientState {
66 NetClientInfo *info;
67 int link_down;
68 QTAILQ_ENTRY(VLANClientState) next;
69 struct VLANState *vlan;
70 VLANClientState *peer;
71 NetQueue *send_queue;
72 char *model;
73 char *name;
74 char info_str[256];
75 unsigned receive_disabled : 1;
76 };
77
78 typedef struct NICState {
79 VLANClientState nc;
80 NICConf *conf;
81 void *opaque;
82 bool peer_deleted;
83 } NICState;
84
85 struct VLANState {
86 int id;
87 QTAILQ_HEAD(, VLANClientState) clients;
88 QTAILQ_ENTRY(VLANState) next;
89 NetQueue *send_queue;
90 };
91
92 VLANState *qemu_find_vlan(int id, int allocate);
93 VLANClientState *qemu_find_netdev(const char *id);
94 VLANClientState *qemu_new_net_client(NetClientInfo *info,
95 VLANState *vlan,
96 VLANClientState *peer,
97 const char *model,
98 const char *name);
99 NICState *qemu_new_nic(NetClientInfo *info,
100 NICConf *conf,
101 const char *model,
102 const char *name,
103 void *opaque);
104 void qemu_del_vlan_client(VLANClientState *vc);
105 VLANClientState *qemu_find_vlan_client_by_name(Monitor *mon, int vlan_id,
106 const char *client_str);
107 typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque);
108 void qemu_foreach_nic(qemu_nic_foreach func, void *opaque);
109 int qemu_can_send_packet(VLANClientState *vc);
110 ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
111 int iovcnt);
112 ssize_t qemu_sendv_packet_async(VLANClientState *vc, const struct iovec *iov,
113 int iovcnt, NetPacketSent *sent_cb);
114 void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
115 ssize_t qemu_send_packet_raw(VLANClientState *vc, const uint8_t *buf, int size);
116 ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
117 int size, NetPacketSent *sent_cb);
118 void qemu_purge_queued_packets(VLANClientState *vc);
119 void qemu_flush_queued_packets(VLANClientState *vc);
120 void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]);
121 void qemu_macaddr_default_if_unset(MACAddr *macaddr);
122 int qemu_show_nic_models(const char *arg, const char *const *models);
123 void qemu_check_nic_model(NICInfo *nd, const char *model);
124 int qemu_find_nic_model(NICInfo *nd, const char * const *models,
125 const char *default_model);
126
127 void do_info_network(Monitor *mon);
128 int do_set_link(Monitor *mon, const QDict *qdict, QObject **ret_data);
129
130 /* NIC info */
131
132 #define MAX_NICS 8
133
134 struct NICInfo {
135 uint8_t macaddr[6];
136 char *model;
137 char *name;
138 char *devaddr;
139 VLANState *vlan;
140 VLANClientState *netdev;
141 int used;
142 int nvectors;
143 };
144
145 extern int nb_nics;
146 extern NICInfo nd_table[MAX_NICS];
147 extern int default_net;
148
149 /* BT HCI info */
150
151 struct HCIInfo {
152 int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
153 void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
154 void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
155 void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
156 void *opaque;
157 void (*evt_recv)(void *opaque, const uint8_t *data, int len);
158 void (*acl_recv)(void *opaque, const uint8_t *data, int len);
159 };
160
161 struct HCIInfo *qemu_next_hci(void);
162
163 /* from net.c */
164 extern const char *legacy_tftp_prefix;
165 extern const char *legacy_bootp_filename;
166
167 int net_client_init(Monitor *mon, QemuOpts *opts, int is_netdev);
168 int net_client_parse(QemuOptsList *opts_list, const char *str);
169 int net_init_clients(void);
170 void net_check_clients(void);
171 void net_cleanup(void);
172 void net_host_device_add(Monitor *mon, const QDict *qdict);
173 void net_host_device_remove(Monitor *mon, const QDict *qdict);
174 int do_netdev_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
175 int do_netdev_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
176
177 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
178 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
179 #ifdef __sun__
180 #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
181 #else
182 #define SMBD_COMMAND "/usr/sbin/smbd"
183 #endif
184
185 void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd);
186
187 int net_handle_fd_param(Monitor *mon, const char *param);
188
189 #endif
Something went wrong with that request. Please try again.