root / net.h @ 6dbe553f
History | View | Annotate | Download (5.4 kB)
1 | 87ecb68b | pbrook | #ifndef QEMU_NET_H
|
---|---|---|---|
2 | 87ecb68b | pbrook | #define QEMU_NET_H
|
3 | 87ecb68b | pbrook | |
4 | fbe78f4f | aliguori | #include "qemu-common.h" |
5 | fbe78f4f | aliguori | |
6 | 87ecb68b | pbrook | /* VLANs support */
|
7 | 87ecb68b | pbrook | |
8 | 87ecb68b | pbrook | typedef struct VLANClientState VLANClientState; |
9 | 87ecb68b | pbrook | |
10 | e3f5ec2b | Mark McLoughlin | typedef int (NetCanReceive)(VLANClientState *); |
11 | 4f1c942b | Mark McLoughlin | typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t); |
12 | e3f5ec2b | Mark McLoughlin | typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int); |
13 | b946a153 | aliguori | typedef void (NetCleanup) (VLANClientState *); |
14 | 34b25ca7 | aliguori | typedef void (LinkStatusChanged)(VLANClientState *); |
15 | 34b25ca7 | aliguori | |
16 | 87ecb68b | pbrook | struct VLANClientState {
|
17 | cda9046b | Mark McLoughlin | NetReceive *receive; |
18 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov; |
19 | 87ecb68b | pbrook | /* Packets may still be sent if this returns zero. It's used to
|
20 | 87ecb68b | pbrook | rate-limit the slirp code. */
|
21 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive; |
22 | b946a153 | aliguori | NetCleanup *cleanup; |
23 | 34b25ca7 | aliguori | LinkStatusChanged *link_status_changed; |
24 | 436e5e53 | aliguori | int link_down;
|
25 | 87ecb68b | pbrook | void *opaque;
|
26 | 87ecb68b | pbrook | struct VLANClientState *next;
|
27 | 87ecb68b | pbrook | struct VLANState *vlan;
|
28 | bf38c1a0 | aliguori | char *model;
|
29 | 676cff29 | aliguori | char *name;
|
30 | 87ecb68b | pbrook | char info_str[256]; |
31 | 87ecb68b | pbrook | }; |
32 | 87ecb68b | pbrook | |
33 | 764a4d1d | aliguori | typedef struct VLANPacket VLANPacket; |
34 | 764a4d1d | aliguori | |
35 | 783527a9 | Mark McLoughlin | typedef void (NetPacketSent) (VLANClientState *, ssize_t); |
36 | f3b6c7fc | Mark McLoughlin | |
37 | 764a4d1d | aliguori | struct VLANPacket {
|
38 | 764a4d1d | aliguori | struct VLANPacket *next;
|
39 | 764a4d1d | aliguori | VLANClientState *sender; |
40 | 764a4d1d | aliguori | int size;
|
41 | f3b6c7fc | Mark McLoughlin | NetPacketSent *sent_cb; |
42 | 764a4d1d | aliguori | uint8_t data[0];
|
43 | 764a4d1d | aliguori | }; |
44 | 764a4d1d | aliguori | |
45 | 87ecb68b | pbrook | struct VLANState {
|
46 | 87ecb68b | pbrook | int id;
|
47 | 87ecb68b | pbrook | VLANClientState *first_client; |
48 | 87ecb68b | pbrook | struct VLANState *next;
|
49 | 87ecb68b | pbrook | unsigned int nb_guest_devs, nb_host_devs; |
50 | 764a4d1d | aliguori | VLANPacket *send_queue; |
51 | 764a4d1d | aliguori | int delivering;
|
52 | 87ecb68b | pbrook | }; |
53 | 87ecb68b | pbrook | |
54 | 87ecb68b | pbrook | VLANState *qemu_find_vlan(int id);
|
55 | 87ecb68b | pbrook | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
56 | bf38c1a0 | aliguori | const char *model, |
57 | 7a9f6e4a | aliguori | const char *name, |
58 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive, |
59 | cda9046b | Mark McLoughlin | NetReceive *receive, |
60 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov, |
61 | b946a153 | aliguori | NetCleanup *cleanup, |
62 | 87ecb68b | pbrook | void *opaque);
|
63 | dcf414d6 | balrog | void qemu_del_vlan_client(VLANClientState *vc);
|
64 | 8b13c4a7 | aliguori | VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque);
|
65 | 87ecb68b | pbrook | int qemu_can_send_packet(VLANClientState *vc);
|
66 | fbe78f4f | aliguori | ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, |
67 | fbe78f4f | aliguori | int iovcnt);
|
68 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_sendv_packet_async(VLANClientState *vc, const struct iovec *iov, |
69 | f3b6c7fc | Mark McLoughlin | int iovcnt, NetPacketSent *sent_cb);
|
70 | 87ecb68b | pbrook | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
71 | f3b6c7fc | Mark McLoughlin | ssize_t qemu_send_packet_async(VLANClientState *vc, const uint8_t *buf,
|
72 | f3b6c7fc | Mark McLoughlin | int size, NetPacketSent *sent_cb);
|
73 | 8cad5516 | Mark McLoughlin | void qemu_purge_queued_packets(VLANClientState *vc);
|
74 | f3b6c7fc | Mark McLoughlin | void qemu_flush_queued_packets(VLANClientState *vc);
|
75 | 7cb7434b | aliguori | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); |
76 | d07f22c5 | aliguori | void qemu_check_nic_model(NICInfo *nd, const char *model); |
77 | d07f22c5 | aliguori | void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, |
78 | d07f22c5 | aliguori | const char *default_model); |
79 | 87ecb68b | pbrook | void qemu_handler_true(void *opaque); |
80 | 87ecb68b | pbrook | |
81 | 376253ec | aliguori | void do_info_network(Monitor *mon);
|
82 | 376253ec | aliguori | int do_set_link(Monitor *mon, const char *name, const char *up_or_down); |
83 | 87ecb68b | pbrook | |
84 | 6dbe553f | Jan Kiszka | void do_info_usernet(Monitor *mon);
|
85 | 6dbe553f | Jan Kiszka | |
86 | 87ecb68b | pbrook | /* NIC info */
|
87 | 87ecb68b | pbrook | |
88 | 87ecb68b | pbrook | #define MAX_NICS 8 |
89 | ffe6370c | Michael S. Tsirkin | enum {
|
90 | ffe6370c | Michael S. Tsirkin | NIC_NVECTORS_UNSPECIFIED = -1
|
91 | ffe6370c | Michael S. Tsirkin | }; |
92 | 87ecb68b | pbrook | |
93 | 87ecb68b | pbrook | struct NICInfo {
|
94 | 87ecb68b | pbrook | uint8_t macaddr[6];
|
95 | 87ecb68b | pbrook | const char *model; |
96 | 7a9f6e4a | aliguori | const char *name; |
97 | 5607c388 | Markus Armbruster | const char *devaddr; |
98 | 87ecb68b | pbrook | VLANState *vlan; |
99 | 72da4208 | aliguori | void *private;
|
100 | 7697079b | aliguori | int used;
|
101 | 406c8df3 | Glauber Costa | int bootable;
|
102 | ffe6370c | Michael S. Tsirkin | int nvectors;
|
103 | 87ecb68b | pbrook | }; |
104 | 87ecb68b | pbrook | |
105 | 87ecb68b | pbrook | extern int nb_nics; |
106 | 87ecb68b | pbrook | extern NICInfo nd_table[MAX_NICS];
|
107 | 87ecb68b | pbrook | |
108 | 1ae26a18 | balrog | /* BT HCI info */
|
109 | 1ae26a18 | balrog | |
110 | 1ae26a18 | balrog | struct HCIInfo {
|
111 | 1ae26a18 | balrog | int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); |
112 | 1ae26a18 | balrog | void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
113 | 1ae26a18 | balrog | void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
114 | 1ae26a18 | balrog | void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
115 | 1ae26a18 | balrog | void *opaque;
|
116 | 1ae26a18 | balrog | void (*evt_recv)(void *opaque, const uint8_t *data, int len); |
117 | 1ae26a18 | balrog | void (*acl_recv)(void *opaque, const uint8_t *data, int len); |
118 | 1ae26a18 | balrog | }; |
119 | 1ae26a18 | balrog | |
120 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void); |
121 | 1ae26a18 | balrog | |
122 | 48c64363 | aliguori | /* checksumming functions (net-checksum.c) */
|
123 | 48c64363 | aliguori | uint32_t net_checksum_add(int len, uint8_t *buf);
|
124 | 48c64363 | aliguori | uint16_t net_checksum_finish(uint32_t sum); |
125 | 48c64363 | aliguori | uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, |
126 | 48c64363 | aliguori | uint8_t *addrs, uint8_t *buf); |
127 | 48c64363 | aliguori | void net_checksum_calculate(uint8_t *data, int length); |
128 | 48c64363 | aliguori | |
129 | 63a01ef8 | aliguori | /* from net.c */
|
130 | ad196a9d | Jan Kiszka | extern const char *legacy_tftp_prefix; |
131 | ad196a9d | Jan Kiszka | extern const char *legacy_bootp_filename; |
132 | ad196a9d | Jan Kiszka | |
133 | 10ae5a7a | Jan Kiszka | int net_client_init(Monitor *mon, const char *device, const char *p); |
134 | 8b13c4a7 | aliguori | void net_client_uninit(NICInfo *nd);
|
135 | 63a01ef8 | aliguori | int net_client_parse(const char *str); |
136 | 63a01ef8 | aliguori | void net_slirp_smb(const char *exported_dir); |
137 | f3546deb | Jan Kiszka | void net_slirp_hostfwd_add(Monitor *mon, const char *redir_str); |
138 | 3c6a0580 | Jan Kiszka | void net_slirp_hostfwd_remove(Monitor *mon, const char *src_str); |
139 | f3546deb | Jan Kiszka | void net_slirp_redir(const char *redir_str); |
140 | 63a01ef8 | aliguori | void net_cleanup(void); |
141 | 63a01ef8 | aliguori | int slirp_is_inited(void); |
142 | 63a01ef8 | aliguori | void net_client_check(void); |
143 | 406c8df3 | Glauber Costa | void net_set_boot_mask(int boot_mask); |
144 | 376253ec | aliguori | void net_host_device_add(Monitor *mon, const char *device, const char *opts); |
145 | 376253ec | aliguori | void net_host_device_remove(Monitor *mon, int vlan_id, const char *device); |
146 | 63a01ef8 | aliguori | |
147 | f54825cc | aurel32 | #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" |
148 | f54825cc | aurel32 | #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" |
149 | f54825cc | aurel32 | #ifdef __sun__
|
150 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sfw/sbin/smbd" |
151 | f54825cc | aurel32 | #else
|
152 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sbin/smbd" |
153 | f54825cc | aurel32 | #endif
|
154 | f54825cc | aurel32 | |
155 | 9d07d757 | Paul Brook | void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr);
|
156 | 9d07d757 | Paul Brook | VLANClientState *qdev_get_vlan_client(DeviceState *dev, |
157 | cda9046b | Mark McLoughlin | NetCanReceive *can_receive, |
158 | cda9046b | Mark McLoughlin | NetReceive *receive, |
159 | cda9046b | Mark McLoughlin | NetReceiveIOV *receive_iov, |
160 | 9d07d757 | Paul Brook | NetCleanup *cleanup, |
161 | 9d07d757 | Paul Brook | void *opaque);
|
162 | 9d07d757 | Paul Brook | |
163 | 87ecb68b | pbrook | #endif |