Add pcap-based host network bridge
PATCH 1/1 Add pcap-based host network bridge
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
While tap-based bridging provides basically the same support pcap does, the latter is often more handy to set up. Under Linux, it doesn't require to configure a bridge and it is able to bypass the ebtables if this is desired. Also under Windows, the bridge setup can be lengthy procedure compared to using the pcap interface.
---
Makefile.target | 2 configure | 35 ++++++++ net.c | 252 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 14 +++ vl.c | 4 + 5 files changed, 305 insertions(+), 2 deletions(-)
Makefile.target +1 -1
@@ -729,7 +729,7 @@ LDFLAGS+=-p main.o: CFLAGS+=-p endif -$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) +$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(PCAP_LIBS) $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(LINK)
configure +35 -0
@@ -160,6 +160,7 @@ EXESUF="" gdbstub="yes" slirp="yes" vde="yes" +pcap="yes" fmod_lib="" fmod_inc="" oss_lib=""
@@ -404,6 +405,8 @@ for opt do ;; --disable-vde) vde="no" ;; + --disable-pcap) pcap="no" + ;; --disable-kqemu) kqemu="no" ;; --disable-brlapi) brlapi="no"
@@ -576,6 +579,7 @@ echo " --oss-lib path to OSS library" echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-vde disable support for vde network" +echo " --disable-pcap disable support for pcap-based network" echo " --disable-aio disable AIO support" echo " --disable-blobs disable installing provided firmware blobs" echo " --kerneldir=PATH look for kernel includes in PATH"
@@ -906,6 +910,31 @@ EOF fi ########################################## +# pcap libraries probe +if test "$pcap" = "yes" ; then + cat > $TMPC << EOF +#include <pcap.h> +int main(void) +{ + char errbuf[PCAP_ERRBUF_SIZE]; + + pcap_lookupdev(errbuf); + return 0; +} +EOF + if test "$mingw32" = "yes" ; then + PCAP_LIBS=-lwpcap + else + PCAP_LIBS=-lpcap + fi + if $cc $ARCH_CFLAGS -o $TMPE $TMPC $PCAP_LIBS > /dev/null 2> /dev/null ; then + : + else + pcap="no" + fi +fi + +########################################## # Sound support libraries probe audio_drv_probe()
@@ -1209,6 +1238,7 @@ echo "Documentation $build_docs" echo "uname -r $uname_release" echo "NPTL support $nptl" echo "vde support $vde" +echo "pcap net support $pcap" echo "AIO support $aio" echo "Install blobs $blobs" echo "KVM support $kvm"
@@ -1412,6 +1442,11 @@ if test "$vde" = "yes" ; then echo "#define CONFIG_VDE 1" >> $config_h echo "VDE_LIBS=-lvdeplug" >> $config_mak fi +if test "$pcap" = "yes" ; then + echo "CONFIG_PCAP=yes" >> $config_mak + echo "#define CONFIG_PCAP 1" >> $config_h + echo "PCAP_LIBS="$PCAP_LIBS >> $config_mak +fi for card in $audio_card_list; do def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'` echo "$def=yes" >> $config_mak
net.c +252 -0
270 lines not on this page · raw message
qemu-doc.texi +13 -1
@@ -770,6 +770,18 @@ vde_switch -F -sock /tmp/myswitch qemu linux.img -net nic -net vde,sock=/tmp/myswitch @end example +@item -net pcap[,vlan=@var{n}][,name=@var{name}][,ifname=@var{name}] +Connect VLAN @var{n} to the host network interface @var{name} using the pcap +interface. This will switch the host's interface to promisc mode, enabling the +guest to receive all packets on this VLAN that the host sees, too. The pcap +host interface is a handy alternative to a TAP interface, attached via a +bridge to a host network interface. + +Example: +@example +qemu linux.img -net nic -net pcap,ifname=eth0 +@end example + @item -net none Indicate that no network devices should be configured. It is used to override the default configuration (@option{-net nic -net user}) which
@@ -3114,7 +3126,7 @@ MV88W8xx8 Ethernet controller @item MV88W8618 audio controller, WM8750 CODEC and mixer @item -128??64 display with brightness control +128?64 display with brightness control @item 2 buttons, 2 navigation wheels with button function @end itemize
vl.c +4 -0
@@ -4018,6 +4018,10 @@ static void help(int exitcode)" use '[down]script=no' to disable script execution;\n" " use 'fd=h' to connect to an already opened TAP interface\n"#endif +#ifdef CONFIG_PCAP +"-net pcap[,vlan=n][,name=str][,ifname=name]\n" + " connect the host network interface to VLAN 'n' using PCAP\n" +#endif "-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port]\n" " connect the vlan 'n' to another VLAN using a socket connection\n" "-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port]\n"
Quoted 2 lines · Jan Kiszka
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
Tested on host Windows 2000, guest DOS: works nice :-) This is great, because Windows 2000 doesn't support built-in bridging like in XP.
Robert Riebisch
Signature · 2 lines
BTTR Software http://www.bttr-software.de/
Quoted 8 lines · Jan Kiszka
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
While tap-based bridging provides basically the same support pcap does, the latter is often more handy to set up. Under Linux, it doesn't require to configure a bridge and it is able to bypass the ebtables if this is desired. Also under Windows, the bridge setup can be lengthy procedure compared to using the pcap interface.
This looks like the pcap approach by Jung-uk Kim [1]. It was reported that guest <-> host communication didn't work on Linux [2]. Is this also true for this patch?
[1] http://article.gmane.org/gmane.comp.emulators.qemu/27304
[2] http://article.gmane.org/gmane.comp.emulators.qemu/27553
Quoted 10 lines
Signed-off-by Klaus Wenninger <[email protected]>Signed-off-by Jan Kiszka <[email protected]>---
Makefile.target | 2 configure | 35 ++++++++ net.c | 252 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ qemu-doc.texi | 14 +++ vl.c | 4 + 5 files changed, 305 insertions(+), 2 deletions(-)
[snip]
Quoted 20 lines
net.c +7
-0@@ -93,6 +93,13 @@#endif #endif +#if defined(CONFIG_PCAP ) +#include <pcap.h> +#ifdef _WIN32 +#include <remote-ext.h> +#endif /* _WIN32 */ +#endif /* CONFIG_PCAP */ +#if defined(__OpenBSD__)#include <util.h> #endif @@ -1033,6 +1040,241 @@ static int net_tap_init(VLANState *vlan, const char *model,
net.c static int net_tap_init(VLANState *vlan, const char *model, · line 1050
Quoted 10 lines
net.c +8
-0#endif /* !_WIN32 */ +#if defined(CONFIG_PCAP ) + +#ifdef _WIN32 +#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class" \ + "\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network" \ + "\\{4D36E972-E325-11CE-BFC1-08002BE10318}" +#endif
ADAPTER_KEY doesn't seem to be used.
- Sebastian
Quoted 10 lines · Sebastian Herbszt
Quoted 8 lines · Jan Kiszka
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
While tap-based bridging provides basically the same support pcap does, the latter is often more handy to set up. Under Linux, it doesn't require to configure a bridge and it is able to bypass the ebtables if this is desired. Also under Windows, the bridge setup can be lengthy procedure compared to using the pcap interface.
Quoted 4 lines
This looks like the pcap approach by Jung-uk Kim [1]. It was reported that guest <-> host communication didn't work on Linux [2]. Is this also true for
this patch?
Yes, it is, see my reply to Anthony.
Quoted 41 lines
[1] http://article.gmane.org/gmane.comp.emulators.qemu/27304
[2] http://article.gmane.org/gmane.comp.emulators.qemu/27553Quoted 11 lines
Signed-off-by Klaus Wenninger <[email protected]>Signed-off-by Jan Kiszka <[email protected]>---
Makefile.target | 2 configure | 35 ++++++++
net.c| 252
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
qemu-doc.texi | 14 +++vl.c| 4 +5 files changed, 305 insertions(+), 2 deletions(-)[snip]
Quoted 23 lines
net.c +7
-0@@ -93,6 +93,13 @@#endif #endif +#if defined(CONFIG_PCAP ) +#include <pcap.h> +#ifdef _WIN32 +#include <remote-ext.h> +#endif /* _WIN32 */ +#endif /* CONFIG_PCAP */ +#if defined(__OpenBSD__)#include <util.h> #endif @@ -1033,6 +1040,241 @@ static int net_tap_init(VLANState *vlan, const char *model,#endif /* !_WIN32 */
Quoted 15 lines
Quoted 6 lines
net.c +5
-0+#if defined(CONFIG_PCAP ) + +#ifdef _WIN32 +#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class" \ +Quoted 6 lines
"\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
+#defineNETWORK_CONNECTIONS_KEY
"SYSTEM\\CurrentControlSet\\Control\\Network" \
+
"\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
+#endif
ADAPTER_KEYdoesn't seem to be used.
Thanks, will drop it when posting an update.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 12 lines · Jan Kiszka
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
While tap-based bridging provides basically the same support pcap does, the latter is often more handy to set up. Under Linux, it doesn't require to configure a bridge and it is able to bypass the ebtables if this is desired. Also under Windows, the bridge setup can be lengthy procedure compared to using the pcap interface.
Signed-off-by Klaus Wenninger <[email protected]>Signed-off-by Jan Kiszka <[email protected]>
The previous version of this had a fundamental flaw wrt guest->host communication on Linux. My understanding was that this was an intrinsic limitation of pcap.
That's a blocker IMHO because it will invariably lead to many folks asking why ping to the host doesn't work (just like slirp). Since it still requires root privileges, I don't think it improves a lot on tap.
Regards,
Anthony Liguori
Quoted 10 lines · Anthony Liguori
Quoted 9 lines · Jan Kiszka
This introduces bridged networking via pcap. Both Unix and Windows platforms are supported.
While tap-based bridging provides basically the same support pcap does, the latter is often more handy to set up. Under Linux, it doesn't require to configure a bridge and it is able to bypass the ebtables if this is desired. Also under Windows, the bridge setup can be lengthy procedure compared to using the pcap interface.
Quoted 7 lines
Quoted 3 lines
Signed-off-by Klaus Wenninger <[email protected]>Signed-off-by Jan Kiszka <[email protected]>The previous version of this had a fundamental flaw wrt
guest->hostcommunication on Linux. My understanding was that this was an intrinsic limitation of pcap.
To my understanding too. We will try to look closer at this, maybe there are smarter alternatives at least on some platforms (PF_PACKET under Linux...?).
Klaus explained to me that there is some switch in winpcap to support this, but it caused troubles due to weird packet loops. I don't have a Windows platform to test, but I will see if we can clarify this in some other way.
Quoted 5 lines
That's a blocker IMHO because it will invariably lead to many folks asking why ping to the host doesn't work (just like slirp). Since it still requires root privileges, I don't think it improves a lot on tap.
Well, in case we do not find a workaround for host<->guest communication, would the patch remain unacceptable even with proper, prominent documentation of this shortcoming?
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 16 lines · Jan Kiszka
To my understanding too. We will try to look closer at this, maybe there are smarter alternatives at least on some platforms (
PF_PACKETunder Linux...?).Klaus explained to me that there is some switch in winpcap to support this, but it caused troubles due to weird packet loops. I don't have a Windows platform to test, but I will see if we can clarify this in some other way.
Quoted 5 lines
That's a blocker IMHO because it will invariably lead to many folks asking why ping to the host doesn't work (just like slirp). Since it still requires root privileges, I don't think it improves a lot on tap.
Quoted 4 lines
Well, in case we do not find a workaround for host<->guest communication, would the patch remain unacceptable even with proper, prominent documentation of this shortcoming?
What's the use-case you're trying to address? Who do you expect to use this functionality?
Setting up bridging isn't really that bad on Linux. Is this primarily targeted at Windows? libpcap requires a kernel driver on Windows so I don't know that I believe it's a great general solution for Windows either.
Regards,
Anthony Liguori
Quoted 3 lines
Jan
Quoted 9 lines · Anthony Liguori
Quoted 4 lines · Jan Kiszka
Well, in case we do not find a workaround for host<->guest communication, would the patch remain unacceptable even with proper, prominent documentation of this shortcoming?
What's the use-case you're trying to address? Who do you expect to use this functionality?
Setting up bridging isn't really that bad on Linux. Is this primarily targeted at Windows? libpcap requires a kernel driver on Windows so I don't know that I believe it's a great general solution for Windows either.
I would really like to see pcap support in mainline (even as a windows only feature). Qemu networking with pcap is trivial on windows. No need to configure tap bridges, but just specify "ifname" and there you go.
- Sebastian
Quoted 10 lines · Sebastian Herbszt
Quoted 9 lines · Anthony Liguori
Quoted 4 lines · Jan Kiszka
Well, in case we do not find a workaround for host<->guest communication, would the patch remain unacceptable even with proper, prominent documentation of this shortcoming?
What's the use-case you're trying to address? Who do you expect to use this functionality?
Quoted 8 lines
Quoted 4 lines
Setting up bridging isn't really that bad on Linux. Is this primarily targeted at Windows? libpcap requires a kernel driver on Windows so I don't know that I believe it's a great general solution for Windows either.
I would really like to see pcap support in mainline (even as a windows only feature). Qemu networking with pcap is trivial on windows. No need to configure tap bridges, but just specify "ifname" and there you go.
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 2 lines · Jan Kiszka
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
Has anyone ever looked at how vmware's vmnet does it?
Signature · 1 line
Len Sorensen
Quoted 5 lines · Lennart Sorensen
Quoted 2 lines · Jan Kiszka
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
Has anyone ever looked at how vmware's vmnet does it?
Whatever they do (I bet it's nothing trivial): Everything that complicates the pcap-based approach beyond a certain level (roughly the one that is required for tap-based bridges) makes it unattractive. There are alternatives (except for ancient Win2k IIRC), pcap just appeared to be a cheap shortcut. But that turned out to be not true.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux
Quoted 5 lines · Jan Kiszka
Quoted 4 lines · Lennart Sorensen
Quoted 2 lines · Jan Kiszka
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
Quoted 7 lines
Quoted 1 line
Has anyone ever looked at how vmware's vmnet does it?
Whatever they do (I bet it's nothing trivial): Everything that complicates the pcap-based approach beyond a certain level (roughly the one that is required for tap-based bridges) makes it unattractive. There are alternatives (except for ancient Win2k IIRC), pcap just appeared to be a cheap shortcut. But that turned out to be not true.
Not sure. I just know with the vmware approache, the guest can be bridged to the network in a way that allows the guest to talk to the host as well as anything else on the external network, which to me is by far the nicest setup. I still haven't clued in to how to make vmware talk to the host system and allow incoming connections on a real IP yet. Guest to host works through 10.2.2.2 or something like that, but nothing else ever has for me. Maybe I just haven't managed to make sense of the -net documentation to figure out which of the very many options would do what I want.
Vmware's vmnet does look like a lot of code (somewhere near 400k) and has some binary only code included, so who knows. Certainly involves bridging though.
Signature · 1 line
Len Sorensen
Quoted 5 lines · Lennart Sorensen
Quoted 2 lines · Jan Kiszka
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
Has anyone ever looked at how vmware's vmnet does it?
I haven't actually looked at it, but my understanding was it involves a kernel module that effectively duplicates the existing bridge functionality.
Paul
Quoted 16 lines · Jan Kiszka
Quoted 15 lines · Sebastian Herbszt
Quoted 13 lines · Anthony Liguori
Quoted 4 lines · Jan Kiszka
Well, in case we do not find a workaround for host<->guest communication, would the patch remain unacceptable even with proper, prominent documentation of this shortcoming?
What's the use-case you're trying to address? Who do you expect to use this functionality?
Setting up bridging isn't really that bad on Linux. Is this primarily targeted at Windows? libpcap requires a kernel driver on Windows so I don't know that I believe it's a great general solution for Windows either.
Quoted 6 lines
Quoted 3 lines
I would really like to see pcap support in mainline (even as a windows only feature). Qemu networking with pcap is trivial on windows. No need to configure tap bridges, but just specify "ifname" and there you go.
We basically dropped the idea as it turned out that - at least under Linux - there is no host<->guest link realizable with reasonable effort.
That's really too bad. pcap-based networking works flawless on windows. Guest <-> host and guest <-> world communication works just fine. According to the previous threads about pcap-based networking it also should work fine on FreeBSD.
- Sebastian
Quoted 5 lines · Sebastian Herbszt
That's really too bad. pcap-based networking works flawless on windows. Guest <-> host and guest <-> world communication works just fine. According to the previous threads about pcap-based networking it also should work fine on FreeBSD.
Maybe make it compile conditionally for Windows only? Would you consider such patch? It would really be a valuable feature.
Alex.
Quoted 9 lines · Consul
Quoted 5 lines · Sebastian Herbszt
That's really too bad. pcap-based networking works flawless on windows. Guest <-> host and guest <-> world communication works just fine. According to the previous threads about pcap-based networking it also should work fine on FreeBSD.
Maybe make it compile conditionally for Windows only? Would you consider such patch? It would really be a valuable feature.
I did rebase the patch against git master and it still seems to work. I can post it if there is any interest.
- Sebastian
Quoted 8 lines · Sebastian Herbszt
Quoted 7 lines · Consul
Quoted 5 lines · Sebastian Herbszt
That's really too bad. pcap-based networking works flawless on windows. Guest <-> host and guest <-> world communication works just fine. According to the previous threads about pcap-based networking it also should work fine on FreeBSD.
Quoted 8 lines
Quoted 2 lines
Maybe make it compile conditionally for Windows only? Would you consider such patch? It would really be a valuable feature.
I did rebase the patch against git master and it still seems to work. I can post it if there is any interest.
- Sebastian
Yes, please post. I also have it rebased in my tree and it still works great. Easier to configure than TAP for sure. Maybe if we'll bug the list often enough and loud enough, it finally gets through.
Alex.
Quoted 12 lines · Consul
Quoted 11 lines · Sebastian Herbszt
Quoted 9 lines · Consul
Quoted 5 lines · Sebastian Herbszt
That's really too bad. pcap-based networking works flawless on windows. Guest <-> host and guest <-> world communication works just fine. According to the previous threads about pcap-based networking it also should work fine on FreeBSD.
Maybe make it compile conditionally for Windows only? Would you consider such patch? It would really be a valuable feature.
Quoted 7 lines
Quoted 5 lines
I did rebase the patch against git master and it still seems to work. I can post it if there is any interest.
- Sebastian
Yes, please post.
Find jan-pcap-updated-qdev3.diff attached.
Quoted 1 line
I also have it rebased in my tree and it still works great.
Is your tree available somewhere?
Quoted 2 lines
Easier to configure than TAP for sure. Maybe if we'll bug the list often enough and loud enough, it finally gets through.
- Sebastian
Makefile.target +1 -1
@@ -734,7 +734,7 @@ vl.o: qemu-options.h monitor.o: qemu-monitor.h -$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) +$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS) $(PCAP_LIBS) $(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB) $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB) $(call LINK,$(OBJS))
configure +35 -0
@@ -165,6 +165,7 @@ mingw32="no" EXESUF="" slirp="yes" vde="yes" +pcap="yes" fmod_lib="" fmod_inc="" oss_lib=""
@@ -432,6 +433,8 @@ for opt do ;; --disable-vde) vde="no" ;; + --disable-pcap) pcap="no" + ;; --disable-kqemu) kqemu="no" ;; --disable-xen) xen="no"
@@ -634,6 +637,7 @@ echo " --oss-lib path to OSS library" echo " --enable-uname-release=R Return R for uname -r in usermode emulation" echo " --sparc_cpu=V Build qemu for Sparc architecture v7, v8, v8plus, v8plusa, v9" echo " --disable-vde disable support for vde network" +echo " --disable-pcap disable support for pcap-based network" echo " --disable-pthread disable pthread support" echo " --disable-aio disable AIO support" echo " --enable-io-thread enable IO thread"
@@ -981,6 +985,31 @@ EOF fi ########################################## +# pcap libraries probe +if test "$pcap" = "yes" ; then + cat > $TMPC << EOF +#include <pcap.h> +int main(void) +{ + char errbuf[PCAP_ERRBUF_SIZE]; + + pcap_lookupdev(errbuf); + return 0; +} +EOF + if test "$mingw32" = "yes" ; then + PCAP_LIBS=-lwpcap + else + PCAP_LIBS=-lpcap + fi + if $cc $ARCH_CFLAGS -o $TMPE $TMPC $PCAP_LIBS > /dev/null 2> /dev/null ; then + : + else + pcap="no" + fi +fi + +########################################## # Sound support libraries probe audio_drv_probe()
@@ -1374,6 +1403,7 @@ echo "Documentation $build_docs" echo "uname -r $uname_release" echo "NPTL support $nptl" echo "vde support $vde" +echo "pcap net support $pcap" echo "AIO support $aio" echo "IO thread $io_thread" echo "Install blobs $blobs"
@@ -1587,6 +1617,11 @@ if test "$vde" = "yes" ; then echo "#define CONFIG_VDE 1" >> $config_h echo "VDE_LIBS=-lvdeplug" >> $config_mak fi +if test "$pcap" = "yes" ; then + echo "CONFIG_PCAP=yes" >> $config_mak + echo "#define CONFIG_PCAP 1" >> $config_h + echo "PCAP_LIBS="$PCAP_LIBS >> $config_mak +fi for card in $audio_card_list; do def=CONFIG_`echo $card | tr '[:lower:]' '[:upper:]'` echo "$def=yes" >> $config_mak
net.c +279 -0
297 lines not on this page · raw message
qemu-options.hx +16 -0
@@ -753,6 +753,10 @@ DEF("net", HAS_ARG, QEMU_OPTION_net, \ " Use group 'groupname' and mode 'octalmode' to change default\n" " ownership and permissions for communication port.\n" #endif +#ifdef CONFIG_PCAP + "-net pcap[,vlan=n][,name=str][,ifname=name]\n" + " connect the host network interface to VLAN 'n' using PCAP\n" +#endif "-net dump[,vlan=n][,file=f][,len=n]\n" " dump traffic on vlan 'n' to file 'f' (max n bytes per packet)\n" "-net none use it alone to have zero network devices; if no -net option\n"
@@ -875,6 +879,18 @@ vde_switch -F -sock /tmp/myswitch qemu linux.img -net nic -net vde,sock=/tmp/myswitch @end example +@item -net pcap[,vlan=@var{n}][,name=@var{name}][,ifname=@var{name}] +Connect VLAN @var{n} to the host network interface @var{name} using the pcap +interface. This will switch the host's interface to promisc mode, enabling the +guest to receive all packets on this VLAN that the host sees, too. The pcap +host interface is a handy alternative to a TAP interface, attached via a +bridge to a host network interface. + +Example: +@example +qemu linux.img -net nic -net pcap,ifname=eth0 +@end example + @item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}] Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default). At most @var{len} bytes (64k by default) per packet are stored. The file format is
"Sebastian Herbszt" <[email protected]> wrote in message news:C0648AF8B9CD4DE5A37965D11776A215@FSCPC...
Quoted 3 lines
Find jan-pcap-updated-qdev3.diff attached.
Thanks. I'll give it a shot next Monday.
Quoted 3 lines
Is your tree available somewhere?
No, it's private.
Alex
Quoted 5 lines · Alex
"Sebastian Herbszt" <[email protected]> wrote in message news:C0648AF8B9CD4DE5A37965D11776A215@FSCPC...
Quoted 2 lines
Find jan-pcap-updated-qdev3.diff attached.
Quoted 9 lines
Thanks. I'll give it a shot next Monday.
Quoted 2 lines
Is your tree available somewhere?
No, it's private.
Alex
This small patch was needed to compile it. Otherwise it appears to work... At least XP guest dot authenticated on the network ok.
The message box "Loading your personal settings..." appears to be sitting on the screen forever, but this is probably unrelated to your pcap patch.
$ git diff
net.c +2 -2
@@ -94,10 +94,10 @@#endif #if defined(CONFIG_PCAP ) -#include <pcap.h> #ifdef _WIN32 -#include <remote-ext.h> +#define HAVE_REMOTE #endif /* _WIN32 */ +#include <pcap.h> #endif /* CONFIG_PCAP */ #if defined(__OpenBSD__)
Quoted 1 line · Consul
This small patch was needed to compile it. Otherwise it appears to work...
Odd. It compiles here fine. Can you post the error please? Which wpdpack version are you using?
- Sebastian
Quoted 26 lines
At least XP guest dot authenticated on the network ok.
The message box "Loading your personal settings..." appears to be sitting on the screen forever, but this is probably unrelated to your pcap patch.$ git diffnet.c +2
-2@@ -94,10 +94,10 @@#endif #if defined(CONFIG_PCAP ) -#include <pcap.h> #ifdef _WIN32 -#include <remote-ext.h> +#define HAVE_REMOTE #endif /* _WIN32 */ +#include <pcap.h> #endif /* CONFIG_PCAP */ #if defined(__OpenBSD__)
Quoted 6 lines · Sebastian Herbszt
Quoted 1 line · Consul
This small patch was needed to compile it. Otherwise it appears to work...
Odd. It compiles here fine. Can you post the error please? Which wpdpack version are you using?
CC net.o
In file included from net.c:99:
c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/remote-ext.h:39:2: #error Please do not include this file directly. Just define HAVE_REMOTE and then include pcap.h In file included from qemu-common.h:74,
from net.c:120:
osdep.h:56:1: warning: "inline" redefined
In file included from c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/pcap/pcap.h:41,
from c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/pcap.h:45,
from net.c:97:c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/pcap-stdinc.h:66:1: warning: this is the location of the previous definition net.c: In function `pcap_cleanup':
net.c:1236: warning: implicit declaration of function `pcap_getevent'
net.c:1236: warning: assignment makes pointer from integer without a cast
net.c:1237: warning: assignment makes pointer from integer without a castnet.c: In function `net_pcap_init':
net.c:1236: warning: redundant redeclaration of 'pcap_getevent'
net.c:1236: warning: previous implicit declaration of 'pcap_getevent' was here
net.c:1422: warning: assignment makes pointer from integer without a cast
net.c:1423: warning: assignment makes pointer from integer without a cast
Quoted 11 lines · Consul
Quoted 6 lines · Sebastian Herbszt
Quoted 1 line · Consul
This small patch was needed to compile it. Otherwise it appears to work...
Odd. It compiles here fine. Can you post the error please? Which wpdpack version are you using?
CC net.o
In file included from net.c:99:
c:/mingw/bin/../lib/gcc/mingw32/3.4.2/../../../../include/remote-ext.h:39:2: #error Please do not include this file directly. Just defineHAVE_REMOTEand then includepcap.h
Looks like this error is introduced by wpdpack 4.1 beta. Version 4.0, which i am using, doesn't include it. Thanks for the patch.
- Sebastian