blob: 078dd18dd6c44de8ace821b0d6b9dda43e8ce338 [file] [log] [blame]
pbrook87ecb682007-11-17 17:14:51 +00001#ifndef QEMU_NET_H
2#define QEMU_NET_H
3
aliguorifbe78f42008-12-17 19:13:11 +00004#include "qemu-common.h"
5
pbrook87ecb682007-11-17 17:14:51 +00006/* VLANs support */
7
aliguorifbe78f42008-12-17 19:13:11 +00008typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int);
9
pbrook87ecb682007-11-17 17:14:51 +000010typedef struct VLANClientState VLANClientState;
11
12struct VLANClientState {
13 IOReadHandler *fd_read;
aliguorifbe78f42008-12-17 19:13:11 +000014 IOReadvHandler *fd_readv;
pbrook87ecb682007-11-17 17:14:51 +000015 /* Packets may still be sent if this returns zero. It's used to
16 rate-limit the slirp code. */
17 IOCanRWHandler *fd_can_read;
18 void *opaque;
19 struct VLANClientState *next;
20 struct VLANState *vlan;
aliguoribf38c1a2009-01-07 17:42:25 +000021 char *model;
aliguori676cff22009-01-07 17:43:44 +000022 char *name;
pbrook87ecb682007-11-17 17:14:51 +000023 char info_str[256];
24};
25
26struct VLANState {
27 int id;
28 VLANClientState *first_client;
29 struct VLANState *next;
30 unsigned int nb_guest_devs, nb_host_devs;
31};
32
33VLANState *qemu_find_vlan(int id);
34VLANClientState *qemu_new_vlan_client(VLANState *vlan,
aliguoribf38c1a2009-01-07 17:42:25 +000035 const char *model,
pbrook87ecb682007-11-17 17:14:51 +000036 IOReadHandler *fd_read,
37 IOCanRWHandler *fd_can_read,
38 void *opaque);
balrogdcf414d2008-07-17 21:00:05 +000039void qemu_del_vlan_client(VLANClientState *vc);
pbrook87ecb682007-11-17 17:14:51 +000040int qemu_can_send_packet(VLANClientState *vc);
aliguorifbe78f42008-12-17 19:13:11 +000041ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov,
42 int iovcnt);
pbrook87ecb682007-11-17 17:14:51 +000043void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size);
44void qemu_handler_true(void *opaque);
45
46void do_info_network(void);
47
48/* NIC info */
49
50#define MAX_NICS 8
51
52struct NICInfo {
53 uint8_t macaddr[6];
54 const char *model;
55 VLANState *vlan;
56};
57
58extern int nb_nics;
59extern NICInfo nd_table[MAX_NICS];
60
balrog1ae26a12008-09-28 23:19:47 +000061/* BT HCI info */
62
63struct HCIInfo {
64 int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr);
65 void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len);
66 void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len);
67 void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len);
68 void *opaque;
69 void (*evt_recv)(void *opaque, const uint8_t *data, int len);
70 void (*acl_recv)(void *opaque, const uint8_t *data, int len);
71};
72
73struct HCIInfo *qemu_next_hci(void);
74
aliguori48c64362008-07-29 19:40:04 +000075/* checksumming functions (net-checksum.c) */
76uint32_t net_checksum_add(int len, uint8_t *buf);
77uint16_t net_checksum_finish(uint32_t sum);
78uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto,
79 uint8_t *addrs, uint8_t *buf);
80void net_checksum_calculate(uint8_t *data, int length);
81
aliguori63a01ef2008-10-31 19:10:00 +000082/* from net.c */
83int net_client_init(const char *device, const char *p);
84int net_client_parse(const char *str);
85void net_slirp_smb(const char *exported_dir);
86void net_slirp_redir(const char *redir_str);
87void net_cleanup(void);
88int slirp_is_inited(void);
89void net_client_check(void);
90
aurel32f54825c2008-12-18 22:43:48 +000091#define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup"
92#define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown"
93#ifdef __sun__
94#define SMBD_COMMAND "/usr/sfw/sbin/smbd"
95#else
96#define SMBD_COMMAND "/usr/sbin/smbd"
97#endif
98
pbrook87ecb682007-11-17 17:14:51 +000099#endif