4 #include "qemu-queue.h"
5 #include "qemu-common.h"
7 #include "qemu-option.h"
16 typedef int (NetCanReceive
)(VLANClientState
*);
17 typedef ssize_t (NetReceive
)(VLANClientState
*, const uint8_t *, size_t);
18 typedef ssize_t (NetReceiveIOV
)(VLANClientState
*, const struct iovec
*, int);
19 typedef void (NetCleanup
) (VLANClientState
*);
20 typedef void (LinkStatusChanged
)(VLANClientState
*);
22 struct VLANClientState
{
24 NetReceiveIOV
*receive_iov
;
25 /* Packets may still be sent if this returns zero. It's used to
26 rate-limit the slirp code. */
27 NetCanReceive
*can_receive
;
29 LinkStatusChanged
*link_status_changed
;
32 QTAILQ_ENTRY(VLANClientState
) next
;
33 struct VLANState
*vlan
;
34 VLANClientState
*peer
;
43 QTAILQ_HEAD(, VLANClientState
) clients
;
44 QTAILQ_ENTRY(VLANState
) next
;
45 unsigned int nb_guest_devs
, nb_host_devs
;
49 VLANState
*qemu_find_vlan(int id
, int allocate
);
50 VLANClientState
*qemu_find_netdev(const char *id
);
51 VLANClientState
*qemu_new_vlan_client(VLANState
*vlan
,
52 VLANClientState
*peer
,
55 NetCanReceive
*can_receive
,
57 NetReceiveIOV
*receive_iov
,
60 void qemu_del_vlan_client(VLANClientState
*vc
);
61 VLANClientState
*qemu_find_vlan_client(VLANState
*vlan
, void *opaque
);
62 int qemu_can_send_packet(VLANClientState
*vc
);
63 ssize_t
qemu_sendv_packet(VLANClientState
*vc
, const struct iovec
*iov
,
65 ssize_t
qemu_sendv_packet_async(VLANClientState
*vc
, const struct iovec
*iov
,
66 int iovcnt
, NetPacketSent
*sent_cb
);
67 void qemu_send_packet(VLANClientState
*vc
, const uint8_t *buf
, int size
);
68 ssize_t
qemu_send_packet_async(VLANClientState
*vc
, const uint8_t *buf
,
69 int size
, NetPacketSent
*sent_cb
);
70 void qemu_purge_queued_packets(VLANClientState
*vc
);
71 void qemu_flush_queued_packets(VLANClientState
*vc
);
72 void qemu_format_nic_info_str(VLANClientState
*vc
, uint8_t macaddr
[6]);
73 void qemu_macaddr_default_if_unset(MACAddr
*macaddr
);
74 int qemu_show_nic_models(const char *arg
, const char *const *models
);
75 void qemu_check_nic_model(NICInfo
*nd
, const char *model
);
76 int qemu_find_nic_model(NICInfo
*nd
, const char * const *models
,
77 const char *default_model
);
79 void do_info_network(Monitor
*mon
);
80 void do_set_link(Monitor
*mon
, const QDict
*qdict
);
82 void do_info_usernet(Monitor
*mon
);
88 NIC_NVECTORS_UNSPECIFIED
= -1
97 VLANClientState
*netdev
;
106 extern NICInfo nd_table
[MAX_NICS
];
111 int (*bdaddr_set
)(struct HCIInfo
*hci
, const uint8_t *bd_addr
);
112 void (*cmd_send
)(struct HCIInfo
*hci
, const uint8_t *data
, int len
);
113 void (*sco_send
)(struct HCIInfo
*hci
, const uint8_t *data
, int len
);
114 void (*acl_send
)(struct HCIInfo
*hci
, const uint8_t *data
, int len
);
116 void (*evt_recv
)(void *opaque
, const uint8_t *data
, int len
);
117 void (*acl_recv
)(void *opaque
, const uint8_t *data
, int len
);
120 struct HCIInfo
*qemu_next_hci(void);
122 /* checksumming functions (net-checksum.c) */
123 uint32_t net_checksum_add(int len
, uint8_t *buf
);
124 uint16_t net_checksum_finish(uint32_t sum
);
125 uint16_t net_checksum_tcpudp(uint16_t length
, uint16_t proto
,
126 uint8_t *addrs
, uint8_t *buf
);
127 void net_checksum_calculate(uint8_t *data
, int length
);
130 extern const char *legacy_tftp_prefix
;
131 extern const char *legacy_bootp_filename
;
133 int net_client_init(Monitor
*mon
, QemuOpts
*opts
, int is_netdev
);
134 void net_client_uninit(NICInfo
*nd
);
135 int net_client_parse(QemuOptsList
*opts_list
, const char *str
);
136 int net_init_clients(void);
137 int net_slirp_smb(const char *exported_dir
);
138 void net_slirp_hostfwd_add(Monitor
*mon
, const QDict
*qdict
);
139 void net_slirp_hostfwd_remove(Monitor
*mon
, const QDict
*qdict
);
140 int net_slirp_redir(const char *redir_str
);
141 void net_cleanup(void);
142 void net_set_boot_mask(int boot_mask
);
143 void net_host_device_add(Monitor
*mon
, const QDict
*qdict
);
144 void net_host_device_remove(Monitor
*mon
, const QDict
*qdict
);
146 #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
147 #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
149 #define SMBD_COMMAND "/usr/sfw/sbin/smbd"
151 #define SMBD_COMMAND "/usr/sbin/smbd"
154 void qdev_get_macaddr(DeviceState
*dev
, uint8_t *macaddr
);
155 VLANClientState
*qdev_get_vlan_client(DeviceState
*dev
,
156 NetCanReceive
*can_receive
,
158 NetReceiveIOV
*receive_iov
,