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