pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 1 | #ifndef QEMU_NET_H |
| 2 | #define QEMU_NET_H |
| 3 | |
aliguori | fbe78f4 | 2008-12-17 19:13:11 +0000 | [diff] [blame] | 4 | #include "qemu-common.h" |
| 5 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 6 | /* VLANs support */ |
| 7 | |
aliguori | fbe78f4 | 2008-12-17 19:13:11 +0000 | [diff] [blame] | 8 | typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int); |
| 9 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 10 | typedef struct VLANClientState VLANClientState; |
| 11 | |
| 12 | struct VLANClientState { |
| 13 | IOReadHandler *fd_read; |
aliguori | fbe78f4 | 2008-12-17 19:13:11 +0000 | [diff] [blame] | 14 | IOReadvHandler *fd_readv; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 15 | /* 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; |
aliguori | bf38c1a | 2009-01-07 17:42:25 +0000 | [diff] [blame] | 21 | char *model; |
aliguori | 676cff2 | 2009-01-07 17:43:44 +0000 | [diff] [blame^] | 22 | char *name; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 23 | char info_str[256]; |
| 24 | }; |
| 25 | |
| 26 | struct VLANState { |
| 27 | int id; |
| 28 | VLANClientState *first_client; |
| 29 | struct VLANState *next; |
| 30 | unsigned int nb_guest_devs, nb_host_devs; |
| 31 | }; |
| 32 | |
| 33 | VLANState *qemu_find_vlan(int id); |
| 34 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
aliguori | bf38c1a | 2009-01-07 17:42:25 +0000 | [diff] [blame] | 35 | const char *model, |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 36 | IOReadHandler *fd_read, |
| 37 | IOCanRWHandler *fd_can_read, |
| 38 | void *opaque); |
balrog | dcf414d | 2008-07-17 21:00:05 +0000 | [diff] [blame] | 39 | void qemu_del_vlan_client(VLANClientState *vc); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 40 | int qemu_can_send_packet(VLANClientState *vc); |
aliguori | fbe78f4 | 2008-12-17 19:13:11 +0000 | [diff] [blame] | 41 | ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, |
| 42 | int iovcnt); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 43 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
| 44 | void qemu_handler_true(void *opaque); |
| 45 | |
| 46 | void do_info_network(void); |
| 47 | |
| 48 | /* NIC info */ |
| 49 | |
| 50 | #define MAX_NICS 8 |
| 51 | |
| 52 | struct NICInfo { |
| 53 | uint8_t macaddr[6]; |
| 54 | const char *model; |
| 55 | VLANState *vlan; |
| 56 | }; |
| 57 | |
| 58 | extern int nb_nics; |
| 59 | extern NICInfo nd_table[MAX_NICS]; |
| 60 | |
balrog | 1ae26a1 | 2008-09-28 23:19:47 +0000 | [diff] [blame] | 61 | /* BT HCI info */ |
| 62 | |
| 63 | struct 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 | |
| 73 | struct HCIInfo *qemu_next_hci(void); |
| 74 | |
aliguori | 48c6436 | 2008-07-29 19:40:04 +0000 | [diff] [blame] | 75 | /* checksumming functions (net-checksum.c) */ |
| 76 | uint32_t net_checksum_add(int len, uint8_t *buf); |
| 77 | uint16_t net_checksum_finish(uint32_t sum); |
| 78 | uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, |
| 79 | uint8_t *addrs, uint8_t *buf); |
| 80 | void net_checksum_calculate(uint8_t *data, int length); |
| 81 | |
aliguori | 63a01ef | 2008-10-31 19:10:00 +0000 | [diff] [blame] | 82 | /* from net.c */ |
| 83 | int net_client_init(const char *device, const char *p); |
| 84 | int net_client_parse(const char *str); |
| 85 | void net_slirp_smb(const char *exported_dir); |
| 86 | void net_slirp_redir(const char *redir_str); |
| 87 | void net_cleanup(void); |
| 88 | int slirp_is_inited(void); |
| 89 | void net_client_check(void); |
| 90 | |
aurel32 | f54825c | 2008-12-18 22:43:48 +0000 | [diff] [blame] | 91 | #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 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 99 | #endif |