pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 1 | #ifndef QEMU_NET_H |
| 2 | #define QEMU_NET_H |
| 3 | |
| 4 | /* VLANs support */ |
| 5 | |
| 6 | typedef struct VLANClientState VLANClientState; |
| 7 | |
| 8 | struct VLANClientState { |
| 9 | IOReadHandler *fd_read; |
| 10 | /* Packets may still be sent if this returns zero. It's used to |
| 11 | rate-limit the slirp code. */ |
| 12 | IOCanRWHandler *fd_can_read; |
| 13 | void *opaque; |
| 14 | struct VLANClientState *next; |
| 15 | struct VLANState *vlan; |
| 16 | char info_str[256]; |
| 17 | }; |
| 18 | |
| 19 | struct VLANState { |
| 20 | int id; |
| 21 | VLANClientState *first_client; |
| 22 | struct VLANState *next; |
| 23 | unsigned int nb_guest_devs, nb_host_devs; |
| 24 | }; |
| 25 | |
| 26 | VLANState *qemu_find_vlan(int id); |
| 27 | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
| 28 | IOReadHandler *fd_read, |
| 29 | IOCanRWHandler *fd_can_read, |
| 30 | void *opaque); |
balrog | dcf414d | 2008-07-17 21:00:05 +0000 | [diff] [blame] | 31 | void qemu_del_vlan_client(VLANClientState *vc); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 32 | int qemu_can_send_packet(VLANClientState *vc); |
| 33 | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
| 34 | void qemu_handler_true(void *opaque); |
| 35 | |
| 36 | void do_info_network(void); |
| 37 | |
| 38 | /* NIC info */ |
| 39 | |
| 40 | #define MAX_NICS 8 |
| 41 | |
| 42 | struct NICInfo { |
| 43 | uint8_t macaddr[6]; |
| 44 | const char *model; |
| 45 | VLANState *vlan; |
| 46 | }; |
| 47 | |
| 48 | extern int nb_nics; |
| 49 | extern NICInfo nd_table[MAX_NICS]; |
| 50 | |
aliguori | 48c6436 | 2008-07-29 19:40:04 +0000 | [diff] [blame] | 51 | /* checksumming functions (net-checksum.c) */ |
| 52 | uint32_t net_checksum_add(int len, uint8_t *buf); |
| 53 | uint16_t net_checksum_finish(uint32_t sum); |
| 54 | uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, |
| 55 | uint8_t *addrs, uint8_t *buf); |
| 56 | void net_checksum_calculate(uint8_t *data, int length); |
| 57 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 58 | #endif |