updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / qemu-mcast / qemu-0.14.1-multicast.patch
blobfb464650bbf457db5e5ac758073f619a729f2c71
1 diff -uNr old-qemu-0.14.1//block/raw-win32.c qemu-0.14.1/block/raw-win32.c
2 --- old-qemu-0.14.1//block/raw-win32.c 2011-05-06 21:01:43.000000000 +0200
3 +++ qemu-0.14.1/block/raw-win32.c 2011-05-11 15:41:45.744749392 +0200
4 @@ -93,7 +93,7 @@
5 else if (!(flags & BDRV_O_CACHE_WB))
6 overlapped |= FILE_FLAG_WRITE_THROUGH;
7 s->hfile = CreateFile(filename, access_flags,
8 - FILE_SHARE_READ, NULL,
9 + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
10 OPEN_EXISTING, overlapped, NULL);
11 if (s->hfile == INVALID_HANDLE_VALUE) {
12 int err = GetLastError();
13 @@ -354,7 +354,7 @@
14 else if (!(flags & BDRV_O_CACHE_WB))
15 overlapped |= FILE_FLAG_WRITE_THROUGH;
16 s->hfile = CreateFile(filename, access_flags,
17 - FILE_SHARE_READ, NULL,
18 + FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
19 create_flags, overlapped, NULL);
20 if (s->hfile == INVALID_HANDLE_VALUE) {
21 int err = GetLastError();
22 diff -uNr old-qemu-0.14.1//hw/e1000.c qemu-0.14.1/hw/e1000.c
23 --- old-qemu-0.14.1//hw/e1000.c 2011-05-06 21:01:43.000000000 +0200
24 +++ qemu-0.14.1/hw/e1000.c 2011-05-11 15:41:45.744749392 +0200
25 @@ -573,7 +573,7 @@
26 if (rctl & E1000_RCTL_UPE) // promiscuous
27 return 1;
29 - if ((buf[0] & 1) && (rctl & E1000_RCTL_MPE)) // promiscuous mcast
30 + if ((buf[0] & 1)) //&& (rctl & E1000_RCTL_MPE)) // promiscuous mcast
31 return 1;
33 if ((rctl & E1000_RCTL_BAM) && !memcmp(buf, bcast, sizeof bcast))
34 diff -uNr old-qemu-0.14.1//Makefile.objs qemu-0.14.1/Makefile.objs
35 --- old-qemu-0.14.1//Makefile.objs 2011-05-06 21:01:43.000000000 +0200
36 +++ qemu-0.14.1/Makefile.objs 2011-05-11 15:41:45.751749392 +0200
37 @@ -34,6 +34,7 @@
38 net-nested-y = queue.o checksum.o util.o
39 net-nested-y += socket.o
40 net-nested-y += dump.o
41 +net-nested-y += udp.o
42 net-nested-$(CONFIG_POSIX) += tap.o
43 net-nested-$(CONFIG_LINUX) += tap-linux.o
44 net-nested-$(CONFIG_WIN32) += tap-win32.o
45 diff -uNr old-qemu-0.14.1//net/udp.c qemu-0.14.1/net/udp.c
46 --- old-qemu-0.14.1//net/udp.c 1970-01-01 01:00:00.000000000 +0100
47 +++ qemu-0.14.1/net/udp.c 2011-05-11 15:41:45.752749392 +0200
48 @@ -0,0 +1,138 @@
49 +/*
50 + * QEMU System Emulator
51 + *
52 + * Copyright (c) 2003-2008 Fabrice Bellard
53 + *
54 + * Permission is hereby granted, free of charge, to any person obtaining a copy
55 + * of this software and associated documentation files (the "Software"), to deal
56 + * in the Software without restriction, including without limitation the rights
57 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58 + * copies of the Software, and to permit persons to whom the Software is
59 + * furnished to do so, subject to the following conditions:
60 + *
61 + * The above copyright notice and this permission notice shall be included in
62 + * all copies or substantial portions of the Software.
63 + *
64 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
67 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
70 + * THE SOFTWARE.
71 + */
72 +#include "net/udp.h"
74 +#include "config-host.h"
76 +#ifndef _WIN32
77 +#include <arpa/inet.h>
78 +#include <netinet/in.h>
79 +#include <netinet/udp.h>
80 +#endif
82 +#include "net.h"
83 +#include "qemu-char.h"
84 +#include "qemu-common.h"
85 +#include "qemu-option.h"
86 +#include "qemu_socket.h"
87 +#include "sysemu.h"
90 +typedef struct UDPState {
91 + VLANClientState nc;
92 + int rfd;
93 + struct sockaddr_in sender;
94 +} UDPState;
96 +static void udp_to_qemu(void *opaque)
98 + UDPState *s = opaque;
99 + uint8_t buf[4096];
100 + int size;
102 + size = recvfrom(s->rfd, (char *)buf, sizeof(buf), 0, NULL, NULL);
103 + if (size > 0) {
104 + qemu_send_packet(&s->nc, buf, size);
108 +static ssize_t udp_receive(VLANClientState *nc, const uint8_t *buf, size_t size)
110 + UDPState *s = DO_UPCAST(UDPState, nc, nc);
111 + int ret;
113 + do {
114 + ret = sendto(s->rfd, (const char *)buf, size, 0, (struct sockaddr *)&s->sender, sizeof (s->sender));
115 + } while (ret < 0 && errno == EINTR);
117 + return ret;
120 +static void udp_cleanup(VLANClientState *nc)
122 + UDPState *s = DO_UPCAST(UDPState, nc, nc);
123 + qemu_set_fd_handler(s->rfd, NULL, NULL, NULL);
124 + close(s->rfd);
127 +static NetClientInfo net_udp_info = {
128 + .type = NET_CLIENT_TYPE_UDP,
129 + .size = sizeof(UDPState),
130 + .receive = udp_receive,
131 + .cleanup = udp_cleanup,
134 +static int net_udp_init(VLANState *vlan, const char *model,
135 + const char *name, int sport,
136 + const char *daddr, int dport)
138 + VLANClientState *nc;
139 + UDPState *s;
140 + struct sockaddr_in receiver;
141 + int ret;
143 + nc = qemu_new_net_client(&net_udp_info, vlan, NULL, model, name);
145 + snprintf(nc->info_str, sizeof(nc->info_str),"udp: %i->%s:%i",
146 + sport, daddr, dport);
148 + s = DO_UPCAST(UDPState, nc, nc);
150 + s->rfd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
151 + receiver.sin_family = AF_INET;
152 + receiver.sin_addr.s_addr = INADDR_ANY;
153 + receiver.sin_port = htons(sport);
154 + ret = bind(s->rfd, (struct sockaddr *)&receiver, sizeof(receiver));
156 + if (ret == -1) {
157 + fprintf (stderr, "bind error:%s\n", strerror(errno));
158 + return ret;
161 + memset((char*)&s->sender, 0,sizeof(s->sender));
162 + s->sender.sin_family = AF_INET;
163 + s->sender.sin_port = htons(dport);
164 + inet_aton(daddr, &s->sender.sin_addr);
166 + qemu_set_fd_handler(s->rfd, udp_to_qemu, NULL, s);
168 + return 0;
171 +int net_init_udp(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
173 + const char *daddr;
174 + int sport, dport;
176 + daddr = qemu_opt_get(opts, "daddr");
178 + sport = qemu_opt_get_number(opts, "sport", 0);
179 + dport = qemu_opt_get_number(opts, "dport", 0);
181 + if (net_udp_init(vlan, "udp", name, sport, daddr, dport) == -1) {
182 + return -1;
185 + return 0;
187 diff -uNr old-qemu-0.14.1//net/udp.h qemu-0.14.1/net/udp.h
188 --- old-qemu-0.14.1//net/udp.h 1970-01-01 01:00:00.000000000 +0100
189 +++ qemu-0.14.1/net/udp.h 2011-05-11 15:41:45.752749392 +0200
190 @@ -0,0 +1,32 @@
192 + * QEMU System Emulator
194 + * Copyright (c) 2003-2008 Fabrice Bellard
196 + * Permission is hereby granted, free of charge, to any person obtaining a copy
197 + * of this software and associated documentation files (the "Software"), to deal
198 + * in the Software without restriction, including without limitation the rights
199 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
200 + * copies of the Software, and to permit persons to whom the Software is
201 + * furnished to do so, subject to the following conditions:
203 + * The above copyright notice and this permission notice shall be included in
204 + * all copies or substantial portions of the Software.
206 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
207 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
208 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
209 + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
210 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
211 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
212 + * THE SOFTWARE.
213 + */
214 +#ifndef QEMU_NET_UDP_H
215 +#define QEMU_NET_UDP_H
217 +#include "qemu-common.h"
218 +#include "qemu-option.h"
220 +int net_init_udp(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan);
222 +#endif /* QEMU_NET_UDP_H */
223 diff -uNr old-qemu-0.14.1//net.c qemu-0.14.1/net.c
224 --- old-qemu-0.14.1//net.c 2011-05-06 21:01:44.000000000 +0200
225 +++ qemu-0.14.1/net.c 2011-05-11 15:42:53.145749408 +0200
226 @@ -30,6 +30,7 @@
227 #include "net/dump.h"
228 #include "net/slirp.h"
229 #include "net/vde.h"
230 +#include "net/udp.h"
231 #include "net/util.h"
232 #include "monitor.h"
233 #include "sysemu.h"
234 @@ -1085,9 +1086,31 @@
235 .help = "permissions for socket",
237 { /* end of list */ }
238 - },
239 + },
240 #endif
241 }, {
243 + .type = "udp",
244 + .init = net_init_udp,
245 + .desc = {
246 + NET_COMMON_PARAMS_DESC,
248 + .name = "sport",
249 + .type = QEMU_OPT_NUMBER,
251 + .help = "source port number",
252 + }, {
253 + .name = "daddr",
254 + .type = QEMU_OPT_STRING,
255 + .help = "destination IP address",
256 + }, {
257 + .name = "dport",
258 + .type = QEMU_OPT_NUMBER,
259 + .help = "destination port number",
260 + },
261 + { /* end of list */ }
262 + },
263 + }, {
264 .type = "dump",
265 .init = net_init_dump,
266 .desc = {
267 diff -uNr old-qemu-0.14.1//net.h qemu-0.14.1/net.h
268 --- old-qemu-0.14.1//net.h 2011-05-06 21:01:44.000000000 +0200
269 +++ qemu-0.14.1/net.h 2011-05-11 15:41:45.754749392 +0200
270 @@ -35,6 +35,7 @@
271 NET_CLIENT_TYPE_TAP,
272 NET_CLIENT_TYPE_SOCKET,
273 NET_CLIENT_TYPE_VDE,
274 + NET_CLIENT_TYPE_UDP,
275 NET_CLIENT_TYPE_DUMP
276 } net_client_type;
278 diff -uNr old-qemu-0.14.1//qemu-options.hx qemu-0.14.1/qemu-options.hx
279 --- old-qemu-0.14.1//qemu-options.hx 2011-05-06 21:01:44.000000000 +0200
280 +++ qemu-0.14.1/qemu-options.hx 2011-05-11 15:41:45.755749392 +0200
281 @@ -1070,6 +1070,8 @@
282 "-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port[,localaddr=addr]]\n"
283 " connect the vlan 'n' to multicast maddr and port\n"
284 " use 'localaddr=addr' to specify the host address to send packets from\n"
285 + "-net udp[,vlan=n]sport=sport,dport=dport,daddr=host\n"
286 + " connect the vlan 'n' to a UDP tunnel (for Dynamips/GNS3)\n"
287 #ifdef CONFIG_VDE
288 "-net vde[,vlan=n][,name=str][,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
289 " connect the vlan 'n' to port 'n' of a vde switch running\n"