root / net.h @ 4870852c
History | View | Annotate | Download (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 | fbe78f4f | aliguori | typedef ssize_t (IOReadvHandler)(void *, const struct iovec *, int); |
9 | fbe78f4f | aliguori | |
10 | 87ecb68b | pbrook | typedef struct VLANClientState VLANClientState; |
11 | 87ecb68b | pbrook | |
12 | b946a153 | aliguori | typedef void (NetCleanup) (VLANClientState *); |
13 | 34b25ca7 | aliguori | typedef void (LinkStatusChanged)(VLANClientState *); |
14 | 34b25ca7 | aliguori | |
15 | 87ecb68b | pbrook | struct VLANClientState {
|
16 | 87ecb68b | pbrook | IOReadHandler *fd_read; |
17 | fbe78f4f | aliguori | IOReadvHandler *fd_readv; |
18 | 87ecb68b | pbrook | /* Packets may still be sent if this returns zero. It's used to
|
19 | 87ecb68b | pbrook | rate-limit the slirp code. */
|
20 | 87ecb68b | pbrook | IOCanRWHandler *fd_can_read; |
21 | b946a153 | aliguori | NetCleanup *cleanup; |
22 | 34b25ca7 | aliguori | LinkStatusChanged *link_status_changed; |
23 | 436e5e53 | aliguori | int link_down;
|
24 | 87ecb68b | pbrook | void *opaque;
|
25 | 87ecb68b | pbrook | struct VLANClientState *next;
|
26 | 87ecb68b | pbrook | struct VLANState *vlan;
|
27 | bf38c1a0 | aliguori | char *model;
|
28 | 676cff29 | aliguori | char *name;
|
29 | 87ecb68b | pbrook | char info_str[256]; |
30 | 87ecb68b | pbrook | }; |
31 | 87ecb68b | pbrook | |
32 | 764a4d1d | aliguori | typedef struct VLANPacket VLANPacket; |
33 | 764a4d1d | aliguori | |
34 | 764a4d1d | aliguori | struct VLANPacket {
|
35 | 764a4d1d | aliguori | struct VLANPacket *next;
|
36 | 764a4d1d | aliguori | VLANClientState *sender; |
37 | 764a4d1d | aliguori | int size;
|
38 | 764a4d1d | aliguori | uint8_t data[0];
|
39 | 764a4d1d | aliguori | }; |
40 | 764a4d1d | aliguori | |
41 | 87ecb68b | pbrook | struct VLANState {
|
42 | 87ecb68b | pbrook | int id;
|
43 | 87ecb68b | pbrook | VLANClientState *first_client; |
44 | 87ecb68b | pbrook | struct VLANState *next;
|
45 | 87ecb68b | pbrook | unsigned int nb_guest_devs, nb_host_devs; |
46 | 764a4d1d | aliguori | VLANPacket *send_queue; |
47 | 764a4d1d | aliguori | int delivering;
|
48 | 87ecb68b | pbrook | }; |
49 | 87ecb68b | pbrook | |
50 | 87ecb68b | pbrook | VLANState *qemu_find_vlan(int id);
|
51 | 87ecb68b | pbrook | VLANClientState *qemu_new_vlan_client(VLANState *vlan, |
52 | bf38c1a0 | aliguori | const char *model, |
53 | 7a9f6e4a | aliguori | const char *name, |
54 | 87ecb68b | pbrook | IOReadHandler *fd_read, |
55 | 87ecb68b | pbrook | IOCanRWHandler *fd_can_read, |
56 | b946a153 | aliguori | NetCleanup *cleanup, |
57 | 87ecb68b | pbrook | void *opaque);
|
58 | dcf414d6 | balrog | void qemu_del_vlan_client(VLANClientState *vc);
|
59 | 8b13c4a7 | aliguori | VLANClientState *qemu_find_vlan_client(VLANState *vlan, void *opaque);
|
60 | 87ecb68b | pbrook | int qemu_can_send_packet(VLANClientState *vc);
|
61 | fbe78f4f | aliguori | ssize_t qemu_sendv_packet(VLANClientState *vc, const struct iovec *iov, |
62 | fbe78f4f | aliguori | int iovcnt);
|
63 | 87ecb68b | pbrook | void qemu_send_packet(VLANClientState *vc, const uint8_t *buf, int size); |
64 | 7cb7434b | aliguori | void qemu_format_nic_info_str(VLANClientState *vc, uint8_t macaddr[6]); |
65 | d07f22c5 | aliguori | void qemu_check_nic_model(NICInfo *nd, const char *model); |
66 | d07f22c5 | aliguori | void qemu_check_nic_model_list(NICInfo *nd, const char * const *models, |
67 | d07f22c5 | aliguori | const char *default_model); |
68 | 87ecb68b | pbrook | void qemu_handler_true(void *opaque); |
69 | 87ecb68b | pbrook | |
70 | 376253ec | aliguori | void do_info_network(Monitor *mon);
|
71 | 376253ec | aliguori | int do_set_link(Monitor *mon, const char *name, const char *up_or_down); |
72 | 87ecb68b | pbrook | |
73 | 87ecb68b | pbrook | /* NIC info */
|
74 | 87ecb68b | pbrook | |
75 | 87ecb68b | pbrook | #define MAX_NICS 8 |
76 | 87ecb68b | pbrook | |
77 | 87ecb68b | pbrook | struct NICInfo {
|
78 | 87ecb68b | pbrook | uint8_t macaddr[6];
|
79 | 87ecb68b | pbrook | const char *model; |
80 | 7a9f6e4a | aliguori | const char *name; |
81 | 87ecb68b | pbrook | VLANState *vlan; |
82 | 72da4208 | aliguori | void *private;
|
83 | 7697079b | aliguori | int used;
|
84 | 87ecb68b | pbrook | }; |
85 | 87ecb68b | pbrook | |
86 | 87ecb68b | pbrook | extern int nb_nics; |
87 | 87ecb68b | pbrook | extern NICInfo nd_table[MAX_NICS];
|
88 | 87ecb68b | pbrook | |
89 | 1ae26a18 | balrog | /* BT HCI info */
|
90 | 1ae26a18 | balrog | |
91 | 1ae26a18 | balrog | struct HCIInfo {
|
92 | 1ae26a18 | balrog | int (*bdaddr_set)(struct HCIInfo *hci, const uint8_t *bd_addr); |
93 | 1ae26a18 | balrog | void (*cmd_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
94 | 1ae26a18 | balrog | void (*sco_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
95 | 1ae26a18 | balrog | void (*acl_send)(struct HCIInfo *hci, const uint8_t *data, int len); |
96 | 1ae26a18 | balrog | void *opaque;
|
97 | 1ae26a18 | balrog | void (*evt_recv)(void *opaque, const uint8_t *data, int len); |
98 | 1ae26a18 | balrog | void (*acl_recv)(void *opaque, const uint8_t *data, int len); |
99 | 1ae26a18 | balrog | }; |
100 | 1ae26a18 | balrog | |
101 | 1ae26a18 | balrog | struct HCIInfo *qemu_next_hci(void); |
102 | 1ae26a18 | balrog | |
103 | 48c64363 | aliguori | /* checksumming functions (net-checksum.c) */
|
104 | 48c64363 | aliguori | uint32_t net_checksum_add(int len, uint8_t *buf);
|
105 | 48c64363 | aliguori | uint16_t net_checksum_finish(uint32_t sum); |
106 | 48c64363 | aliguori | uint16_t net_checksum_tcpudp(uint16_t length, uint16_t proto, |
107 | 48c64363 | aliguori | uint8_t *addrs, uint8_t *buf); |
108 | 48c64363 | aliguori | void net_checksum_calculate(uint8_t *data, int length); |
109 | 48c64363 | aliguori | |
110 | 63a01ef8 | aliguori | /* from net.c */
|
111 | 63a01ef8 | aliguori | int net_client_init(const char *device, const char *p); |
112 | 8b13c4a7 | aliguori | void net_client_uninit(NICInfo *nd);
|
113 | 63a01ef8 | aliguori | int net_client_parse(const char *str); |
114 | 63a01ef8 | aliguori | void net_slirp_smb(const char *exported_dir); |
115 | d4ebe193 | aliguori | void net_slirp_redir(Monitor *mon, const char *redir_str); |
116 | 63a01ef8 | aliguori | void net_cleanup(void); |
117 | 63a01ef8 | aliguori | int slirp_is_inited(void); |
118 | 63a01ef8 | aliguori | void net_client_check(void); |
119 | 376253ec | aliguori | void net_host_device_add(Monitor *mon, const char *device, const char *opts); |
120 | 376253ec | aliguori | void net_host_device_remove(Monitor *mon, int vlan_id, const char *device); |
121 | 63a01ef8 | aliguori | |
122 | f54825cc | aurel32 | #define DEFAULT_NETWORK_SCRIPT "/etc/qemu-ifup" |
123 | f54825cc | aurel32 | #define DEFAULT_NETWORK_DOWN_SCRIPT "/etc/qemu-ifdown" |
124 | f54825cc | aurel32 | #ifdef __sun__
|
125 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sfw/sbin/smbd" |
126 | f54825cc | aurel32 | #else
|
127 | f54825cc | aurel32 | #define SMBD_COMMAND "/usr/sbin/smbd" |
128 | f54825cc | aurel32 | #endif
|
129 | f54825cc | aurel32 | |
130 | 87ecb68b | pbrook | #endif |