diff options
author | Mikael Kanstrup <mikael.kanstrup@gmail.com> | 2017-08-16 11:20:19 +0200 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2017-10-16 04:29:21 +0000 |
commit | 282b59a853f95c7bf463b617f8d40949b8f8b3ef (patch) | |
tree | df8d61cb730dc9085670db7d36b032963f2e3d9e /extcap/androiddump.c | |
parent | 2cb717ec78e3479943dfe235e0c29c085a19ebfc (diff) |
[RFC]androiddump: Support extcap-dlts option
According to README.extcap documentation all extcap tools must
support the --extcap-dlts option. For performance reasons support
for this option was removed by commit:
9328eb6 androiddump: Register interfaces when list interfaces
A side effect of not implementing the option is that dumpcap is
then also called to try to retrieve interface capabilities
for all androiddump interfaces. As extcap interfaces are not
local network interfaces errors like these are logged
whenever the interface list is refreshed:
Capture Dbg sync_if_capabilities_open
Capture Info sync_pipe_run_command() starts
Capture Dbg argv[0]: /usr/local/bin/wireshark/dumpcap
Capture Dbg argv[1]: -i
Capture Dbg argv[2]: android-tcpdump-wlan0...
Capture Dbg argv[3]: -L
Capture Dbg argv[4]: -Z
Capture Dbg argv[5]: none
Capture Dbg sync_pipe_open_command
Capture Dbg read 25 ok indicator: E len: 333 msg: E
Capture Dbg sync_pipe_wait_for_child: wait till child closed
Capture Dbg sync_pipe_wait_for_child: capture child closed after 0.000s
Capture Info sync_pipe_run_command() ends, taking 0.012s, result=-1
Capture Msg Capture Interface Capabilities failed. Error -1, The
capabilities of the capture device "android-tcpdump-wlan0..."
could not be obtained (android-tcpdump-wlan0...:
SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: No such device).
Please check to make sure you have sufficient permissions, and
that you have the proper interface or pipe specified. ()
To avoid error prints and to fulfil the documented equirements for extcap
tools register a fake interface with what would be the properties of such
an interface.
Change-Id: If174adbb64c66132be4225f854bbf9f66d2f5ed1
Reviewed-on: https://code.wireshark.org/review/23093
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'extcap/androiddump.c')
-rw-r--r-- | extcap/androiddump.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/extcap/androiddump.c b/extcap/androiddump.c index 1e3829dec4..9635dd5e5d 100644 --- a/extcap/androiddump.c +++ b/extcap/androiddump.c @@ -278,18 +278,18 @@ struct extcap_dumper { static int endless_loop = 1; /* Functions */ -static inline int is_specified_interface(char *interface, const char *interface_prefix) { +static inline int is_specified_interface(const char *interface, const char *interface_prefix) { return !strncmp(interface, interface_prefix, strlen(interface_prefix)); } -static gboolean is_logcat_interface(char *interface) { +static gboolean is_logcat_interface(const char *interface) { return is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_MAIN) || is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_SYSTEM) || is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_RADIO) || is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_EVENTS); } -static gboolean is_logcat_text_interface(char *interface) { +static gboolean is_logcat_text_interface(const char *interface) { return is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_TEXT_MAIN) || is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_TEXT_SYSTEM) || is_specified_interface(interface, INTERFACE_ANDROID_LOGCAT_TEXT_RADIO) || @@ -882,6 +882,21 @@ static void new_interface(extcap_parameters * extcap_conf, const gchar *interfac } +static void new_fake_interface_for_list_dlts(extcap_parameters * extcap_conf, + const gchar *ifname) +{ + if (is_specified_interface(ifname, INTERFACE_ANDROID_BLUETOOTH_HCIDUMP) || + is_specified_interface(ifname, INTERFACE_ANDROID_BLUETOOTH_EXTERNAL_PARSER) || + is_specified_interface(ifname, INTERFACE_ANDROID_BLUETOOTH_BTSNOOP_NET)) { + extcap_base_register_interface_ext(extcap_conf, ifname, ifname, 99, "BluetoothH4", "Bluetooth HCI UART transport layer plus pseudo-header" ); + } else if (is_logcat_interface(ifname) || is_logcat_text_interface(ifname)) { + extcap_base_register_interface(extcap_conf, ifname, ifname, 252, "Upper PDU" ); + } else if (is_specified_interface(ifname, INTERFACE_ANDROID_TCPDUMP)) { + extcap_base_register_interface(extcap_conf, ifname, ifname, 1, "Ethernet"); + } +} + + static int add_tcpdump_interfaces(extcap_parameters * extcap_conf, const char *adb_server_ip, unsigned short *adb_server_tcp_port, const char *serial_number) { static const char *const adb_tcpdump_list = "shell:tcpdump -D"; @@ -2747,6 +2762,18 @@ int main(int argc, char **argv) { if (extcap_conf->do_list_interfaces) register_interfaces(extcap_conf, adb_server_ip, adb_server_tcp_port); + /* NOTE: + * extcap implementation calls androiddump --extcap-dlts for each interface. + * The only way to know whether an interface exists or not is to go through the + * whole process of listing all interfaces (i.e. calling register_interfaces + * function). Since being a system resource heavy operation and repeated for + * each interface instead register a fake interface to be returned for dlt + * listing only purpose + */ + if (extcap_conf->do_list_dlts) { + new_fake_interface_for_list_dlts(extcap_conf, extcap_conf->interface); + } + if (extcap_base_handle_interface(extcap_conf)) { ret = EXIT_CODE_SUCCESS; goto end; |