Changeset View
Changeset View
Standalone View
Standalone View
head/emulators/qemu-devel/files/pcap-patch
--- configure.orig 2015-08-11 19:11:05 UTC | configure | ||||
+++ configure | --- configure 2015-12-17 04:04:48.000000000 +0600 | ||||
@@ -338,6 +338,9 @@ libssh2="" | +++ configure 2015-12-25 01:32:09.000000000 +0600 | ||||
@@ -342,6 +342,10 @@ | |||||
tpm="yes" | |||||
libssh2="" | |||||
vhdx="" | vhdx="" | ||||
numa="" | +quorum="no" | ||||
tcmalloc="no" | |||||
+pcap="no" | +pcap="no" | ||||
+pcap_create="no" | +pcap_create="no" | ||||
+bpf="no" | +bpf="no" | ||||
numa="" | |||||
# parse CC options first | tcmalloc="no" | ||||
for opt do | jemalloc="no" | ||||
@@ -896,6 +899,10 @@ for opt do | @@ -602,7 +606,7 @@ | ||||
audio_drv_list="oss" | |||||
audio_possible_drivers="oss sdl pa" | |||||
# needed for kinfo_getvmmap(3) in libutil.h | |||||
- LIBS="-lutil $LIBS" | |||||
+ LIBS="-lprocstat -lkvm -lelf -lutil $LIBS" | |||||
netmap="" # enable netmap autodetect | |||||
HOST_VARIANT_DIR="freebsd" | |||||
;; | ;; | ||||
@@ -905,6 +909,10 @@ | |||||
;; | |||||
--enable-vnc-png) vnc_png="yes" | --enable-vnc-png) vnc_png="yes" | ||||
;; | ;; | ||||
+ --enable-pcap) pcap="yes" | + --enable-pcap) pcap="yes" | ||||
+ ;; | + ;; | ||||
+ --disable-pcap) pcap="no" | + --disable-pcap) pcap="no" | ||||
+ ;; | + ;; | ||||
--disable-slirp) slirp="no" | --disable-slirp) slirp="no" | ||||
;; | ;; | ||||
--disable-uuid) uuid="no" | --disable-uuid) uuid="no" | ||||
@@ -2354,6 +2361,51 @@ EOF | @@ -2427,6 +2435,14 @@ | ||||
fi | |||||
########################################## | ########################################## | ||||
+# getifaddrs (for tests/test-io-channel-socket ) | |||||
+ | |||||
+have_ifaddrs_h=yes | |||||
+if ! check_include "ifaddrs.h" ; then | |||||
+ have_ifaddrs_h=no | |||||
+fi | |||||
+ | |||||
+########################################## | |||||
# VTE probe | |||||
if test "$vte" != "no"; then | |||||
@@ -2569,6 +2585,50 @@ | |||||
fi | |||||
fi | |||||
+########################################## | |||||
+# pcap probe | +# pcap probe | ||||
+ | + | ||||
+if test "$pcap" = "yes" -a "$pcap" != "no"; then | +if test "$pcap" = "yes" -a "$pcap" != "no"; then | ||||
+ cat > $TMPC << EOF | + cat > $TMPC << EOF | ||||
+#include <pcap.h> | +#include <pcap.h> | ||||
+int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); } | +int main(void) { return (pcap_lib_version() == (char *)0 ? 1 : 0); } | ||||
+EOF | +EOF | ||||
+ if test "$mingw32" = "no" ; then | + if test "$mingw32" = "no" ; then | ||||
Show All 27 Lines | |||||
+#include <net/bpf.h> | +#include <net/bpf.h> | ||||
+int main(void) { return (BPF_MAJOR_VERSION); } | +int main(void) { return (BPF_MAJOR_VERSION); } | ||||
+EOF | +EOF | ||||
+ if compile_prog ; then | + if compile_prog ; then | ||||
+ bpf="yes" | + bpf="yes" | ||||
+ fi | + fi | ||||
+ libs_softmmu="$libpcap $libs_softmmu" | + libs_softmmu="$libpcap $libs_softmmu" | ||||
+fi # test "$pcap" | +fi # test "$pcap" | ||||
+ | |||||
+########################################## | ########################################## | ||||
# VNC TLS/WS detection | # VNC SASL detection | ||||
if test "$vnc" = "yes" -a "$vnc_tls" != "no" ; then | @@ -4758,7 +4833,11 @@ | ||||
cat > $TMPC <<EOF | echo "GNUTLS support $gnutls" | ||||
@@ -4515,6 +4567,7 @@ echo "Audio drivers $audio_drv_list" | echo "GNUTLS hash $gnutls_hash" | ||||
echo "libgcrypt $gcrypt" | |||||
-echo "nettle $nettle ${nettle+($nettle_version)}" | |||||
+if test "$nettle" = "yes"; then | |||||
+ echo "nettle $nettle ($nettle_version)" | |||||
+else | |||||
+ echo "nettle $nettle" | |||||
+fi | |||||
echo "libtasn1 $tasn1" | |||||
echo "VTE support $vte" | |||||
echo "curses support $curses" | |||||
@@ -4769,6 +4848,7 @@ | |||||
echo "Block whitelist (rw) $block_drv_rw_whitelist" | echo "Block whitelist (rw) $block_drv_rw_whitelist" | ||||
echo "Block whitelist (ro) $block_drv_ro_whitelist" | echo "Block whitelist (ro) $block_drv_ro_whitelist" | ||||
echo "VirtFS support $virtfs" | echo "VirtFS support $virtfs" | ||||
+echo "pcap support $pcap" | +echo "pcap support $pcap" | ||||
echo "VNC support $vnc" | echo "VNC support $vnc" | ||||
if test "$vnc" = "yes" ; then | if test "$vnc" = "yes" ; then | ||||
echo "VNC TLS support $vnc_tls" | echo "VNC SASL support $vnc_sasl" | ||||
@@ -4692,6 +4745,15 @@ fi | @@ -4947,6 +5027,15 @@ | ||||
if test "$profiler" = "yes" ; then | if test "$profiler" = "yes" ; then | ||||
echo "CONFIG_PROFILER=y" >> $config_host_mak | echo "CONFIG_PROFILER=y" >> $config_host_mak | ||||
fi | fi | ||||
+if test "$pcap" = "yes" ; then | +if test "$pcap" = "yes" ; then | ||||
+ echo "CONFIG_PCAP=y" >> $config_host_mak | + echo "CONFIG_PCAP=y" >> $config_host_mak | ||||
+ if test "$pcap_create" = "yes" ; then | + if test "$pcap_create" = "yes" ; then | ||||
+ echo "CONFIG_PCAP_CREATE=y" >> $config_host_mak | + echo "CONFIG_PCAP_CREATE=y" >> $config_host_mak | ||||
+ fi | + fi | ||||
+ if test "$bpf" = "yes" ; then | + if test "$bpf" = "yes" ; then | ||||
+ echo "CONFIG_BPF=y" >> $config_host_mak | + echo "CONFIG_BPF=y" >> $config_host_mak | ||||
+ fi | + fi | ||||
+fi | +fi | ||||
if test "$slirp" = "yes" ; then | if test "$slirp" = "yes" ; then | ||||
echo "CONFIG_SLIRP=y" >> $config_host_mak | echo "CONFIG_SLIRP=y" >> $config_host_mak | ||||
echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak | echo "CONFIG_SMBD_COMMAND=\"$smbd\"" >> $config_host_mak | ||||
--- net/clients.h.orig 2015-08-11 19:11:09 UTC | @@ -5137,6 +5226,9 @@ | ||||
+++ net/clients.h | if test "$tasn1" = "yes" ; then | ||||
@@ -49,6 +49,12 @@ int net_init_bridge(const NetClientOptio | echo "CONFIG_TASN1=y" >> $config_host_mak | ||||
fi | |||||
int net_init_l2tpv3(const NetClientOptions *opts, const char *name, | +if test "$have_ifaddrs_h" = "yes" ; then | ||||
+ echo "HAVE_IFADDRS_H=y" >> $config_host_mak | |||||
+fi | |||||
if test "$vte" = "yes" ; then | |||||
echo "CONFIG_VTE=y" >> $config_host_mak | |||||
echo "VTE_CFLAGS=$vte_cflags" >> $config_host_mak | |||||
diff -ruN net/clients.h net/clients.h | |||||
--- net/clients.h 2015-12-17 04:04:50.000000000 +0600 | |||||
+++ net/clients.h 2015-12-25 01:32:09.000000000 +0600 | |||||
@@ -47,6 +47,11 @@ | |||||
int net_init_bridge(const NetClientOptions *opts, const char *name, | |||||
NetClientState *peer, Error **errp); | NetClientState *peer, Error **errp); | ||||
+ | |||||
+#ifdef CONFIG_PCAP | +#ifdef CONFIG_PCAP | ||||
+int net_init_pcap(const NetClientOptions *opts, const char *name, | +int net_init_pcap(const NetClientOptions *opts, const char *name, | ||||
+ NetClientState *peer); | + NetClientState *peer, Error **errp); | ||||
+#endif | +#endif | ||||
+ | + | ||||
#ifdef CONFIG_VDE | int net_init_l2tpv3(const NetClientOptions *opts, const char *name, | ||||
int net_init_vde(const NetClientOptions *opts, const char *name, | |||||
NetClientState *peer, Error **errp); | NetClientState *peer, Error **errp); | ||||
--- net/hub.c.orig 2015-08-11 19:11:09 UTC | #ifdef CONFIG_VDE | ||||
+++ net/hub.c | diff -ruN net/hub.c net/hub.c | ||||
@@ -322,6 +322,7 @@ void net_hub_check_clients(void) | --- net/hub.c 2015-12-17 04:04:50.000000000 +0600 | ||||
+++ net/hub.c 2015-12-25 01:32:09.000000000 +0600 | |||||
@@ -322,6 +322,7 @@ | |||||
case NET_CLIENT_OPTIONS_KIND_SOCKET: | case NET_CLIENT_OPTIONS_KIND_SOCKET: | ||||
case NET_CLIENT_OPTIONS_KIND_VDE: | case NET_CLIENT_OPTIONS_KIND_VDE: | ||||
case NET_CLIENT_OPTIONS_KIND_VHOST_USER: | case NET_CLIENT_OPTIONS_KIND_VHOST_USER: | ||||
+ case NET_CLIENT_OPTIONS_KIND_PCAP: | + case NET_CLIENT_OPTIONS_KIND_PCAP: | ||||
has_host_dev = 1; | has_host_dev = 1; | ||||
break; | break; | ||||
default: | default: | ||||
--- net/net.c.orig 2015-08-11 19:11:09 UTC | diff -ruN net/net.c net/net.c | ||||
+++ net/net.c | --- net/net.c 2015-12-17 04:04:50.000000000 +0600 | ||||
@@ -45,6 +45,11 @@ | +++ net/net.c 2015-12-25 01:32:09.000000000 +0600 | ||||
#include "qapi/dealloc-visitor.h" | @@ -46,6 +46,11 @@ | ||||
#include "sysemu/sysemu.h" | #include "sysemu/sysemu.h" | ||||
#include "net/filter.h" | |||||
+#include <sys/ioctl.h> | +#include <sys/ioctl.h> | ||||
+#ifdef __FreeBSD__ | +#ifdef __FreeBSD__ | ||||
+#include <net/if.h> | +#include <net/if.h> | ||||
+#endif | +#endif | ||||
+ | + | ||||
/* Net bridge is currently not supported for W32. */ | /* Net bridge is currently not supported for W32. */ | ||||
#if !defined(_WIN32) | #if !defined(_WIN32) | ||||
# define CONFIG_NET_BRIDGE | # define CONFIG_NET_BRIDGE | ||||
@@ -880,6 +885,221 @@ static int net_init_nic(const NetClientO | @@ -942,8 +947,224 @@ | ||||
return idx; | return idx; | ||||
} | } | ||||
+#if defined(CONFIG_PCAP) | +#if defined(CONFIG_PCAP) | ||||
+#if defined(CONFIG_BPF) | +#if defined(CONFIG_BPF) | ||||
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H | +#define PCAP_DONT_INCLUDE_PCAP_BPF_H | ||||
+#include <net/bpf.h> | +#include <net/bpf.h> | ||||
+#endif | +#endif | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | |||||
+// .receive_iov = pcap_receive_iov, | +// .receive_iov = pcap_receive_iov, | ||||
+// .poll = pcap_poll, | +// .poll = pcap_poll, | ||||
+ .cleanup = pcap_cleanup, | + .cleanup = pcap_cleanup, | ||||
+}; | +}; | ||||
+/* | +/* | ||||
+ * ... -net pcap,ifname="..." | + * ... -net pcap,ifname="..." | ||||
+ */ | + */ | ||||
+ | + | ||||
+int net_init_pcap(const NetClientOptions *opts, const char *name, NetClientState *peer) | +int net_init_pcap(const NetClientOptions *opts, | ||||
+ const char *name, NetClientState *peer, Error **errp) | |||||
+{ | +{ | ||||
+ const NetdevPcapOptions *pcap_opts = opts->pcap; | + const NetdevPcapOptions *pcap_opts = opts->u.pcap; | ||||
+ NetClientState *nc; | + NetClientState *nc; | ||||
+ struct PCAPState *s; | + struct PCAPState *s; | ||||
+ const char *ifname; | + const char *ifname; | ||||
+ char errbuf[PCAP_ERRBUF_SIZE]; | + char errbuf[PCAP_ERRBUF_SIZE]; | ||||
+#if defined(_WIN32) | +#if defined(_WIN32) | ||||
+ HANDLE h; | + HANDLE h; | ||||
+#endif | +#endif | ||||
+ int i; | + int i; | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
+ pcap_close(s->handle); | + pcap_close(s->handle); | ||||
+ } | + } | ||||
+ | + | ||||
+ return -1; | + return -1; | ||||
+} | +} | ||||
+ | + | ||||
+#endif | +#endif | ||||
static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( | -static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( | ||||
+static int (* const net_client_init_fun[NET_CLIENT_OPTIONS_KIND_MAX])( | |||||
const NetClientOptions *opts, | const NetClientOptions *opts, | ||||
@@ -901,6 +1121,9 @@ static int (* const net_client_init_fun[ | const char *name, | ||||
NetClientState *peer, Error **errp) = { | |||||
@@ -963,6 +1184,9 @@ | |||||
#ifdef CONFIG_NET_BRIDGE | #ifdef CONFIG_NET_BRIDGE | ||||
[NET_CLIENT_OPTIONS_KIND_BRIDGE] = net_init_bridge, | [NET_CLIENT_OPTIONS_KIND_BRIDGE] = net_init_bridge, | ||||
#endif | #endif | ||||
+#ifdef CONFIG_PCAP | +#ifdef CONFIG_PCAP | ||||
+ [NET_CLIENT_OPTIONS_KIND_PCAP] = net_init_pcap, | + [NET_CLIENT_OPTIONS_KIND_PCAP] = net_init_pcap, | ||||
+#endif | +#endif | ||||
[NET_CLIENT_OPTIONS_KIND_HUBPORT] = net_init_hubport, | [NET_CLIENT_OPTIONS_KIND_HUBPORT] = net_init_hubport, | ||||
#ifdef CONFIG_VHOST_NET_USED | #ifdef CONFIG_VHOST_NET_USED | ||||
[NET_CLIENT_OPTIONS_KIND_VHOST_USER] = net_init_vhost_user, | [NET_CLIENT_OPTIONS_KIND_VHOST_USER] = net_init_vhost_user, | ||||
--- qapi-schema.json.orig 2015-08-11 19:11:09 UTC | diff -ruN qapi-schema.json qapi-schema.json | ||||
+++ qapi-schema.json | --- qapi-schema.json 2015-12-17 04:04:50.000000000 +0600 | ||||
@@ -2423,6 +2423,10 @@ | +++ qapi-schema.json 2015-12-25 01:32:09.000000000 +0600 | ||||
@@ -2538,6 +2538,10 @@ | |||||
'*br': 'str', | '*br': 'str', | ||||
'*helper': 'str' } } | '*helper': 'str' } } | ||||
+{ 'struct': 'NetdevPcapOptions', | +{ 'struct': 'NetdevPcapOptions', | ||||
+ 'data': { | + 'data': { | ||||
+ '*ifname': 'str' } } | + '*ifname': 'str' } } | ||||
+ | + | ||||
## | ## | ||||
# @NetdevHubPortOptions | # @NetdevHubPortOptions | ||||
# | # | ||||
@@ -2490,6 +2494,7 @@ | @@ -2608,6 +2612,7 @@ | ||||
'nic': 'NetLegacyNicOptions', | |||||
'user': 'NetdevUserOptions', | 'user': 'NetdevUserOptions', | ||||
'tap': 'NetdevTapOptions', | 'tap': 'NetdevTapOptions', | ||||
'l2tpv3': 'NetdevL2TPv3Options', | |||||
+ 'pcap': 'NetdevPcapOptions', | + 'pcap': 'NetdevPcapOptions', | ||||
'l2tpv3': 'NetdevL2TPv3Options', | |||||
'socket': 'NetdevSocketOptions', | 'socket': 'NetdevSocketOptions', | ||||
'vde': 'NetdevVdeOptions', | 'vde': 'NetdevVdeOptions', | ||||
'dump': 'NetdevDumpOptions', |