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
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();
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
26 if (rctl & E1000_RCTL_UPE) // promiscuous
29 - if ((buf[0] & 1) && (rctl & E1000_RCTL_MPE)) // promiscuous mcast
30 + if ((buf[0] & 1)) //&& (rctl & E1000_RCTL_MPE)) // promiscuous mcast
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
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
50 + * QEMU System Emulator
52 + * Copyright (c) 2003-2008 Fabrice Bellard
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:
61 + * The above copyright notice and this permission notice shall be included in
62 + * all copies or substantial portions of the Software.
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
74 +#include "config-host.h"
77 +#include <arpa/inet.h>
78 +#include <netinet/in.h>
79 +#include <netinet/udp.h>
83 +#include "qemu-char.h"
84 +#include "qemu-common.h"
85 +#include "qemu-option.h"
86 +#include "qemu_socket.h"
90 +typedef struct UDPState {
93 + struct sockaddr_in sender;
96 +static void udp_to_qemu(void *opaque)
98 + UDPState *s = opaque;
102 + size = recvfrom(s->rfd, (char *)buf, sizeof(buf), 0, NULL, NULL);
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);
114 + ret = sendto(s->rfd, (const char *)buf, size, 0, (struct sockaddr *)&s->sender, sizeof (s->sender));
115 + } while (ret < 0 && errno == EINTR);
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);
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;
140 + struct sockaddr_in receiver;
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));
157 + fprintf (stderr, "bind error:%s\n", strerror(errno));
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);
171 +int net_init_udp(QemuOpts *opts, Monitor *mon, const char *name, VLANState *vlan)
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) {
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
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
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
227 #include "net/dump.h"
228 #include "net/slirp.h"
230 +#include "net/udp.h"
231 #include "net/util.h"
234 @@ -1085,9 +1086,31 @@
235 .help = "permissions for socket",
237 { /* end of list */ }
244 + .init = net_init_udp,
246 + NET_COMMON_PARAMS_DESC,
249 + .type = QEMU_OPT_NUMBER,
251 + .help = "source port number",
254 + .type = QEMU_OPT_STRING,
255 + .help = "destination IP address",
258 + .type = QEMU_OPT_NUMBER,
259 + .help = "destination port number",
261 + { /* end of list */ }
265 .init = net_init_dump,
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
272 NET_CLIENT_TYPE_SOCKET,
274 + NET_CLIENT_TYPE_UDP,
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"
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"