platform/upstream/neard.git
10 years agoadapter: Use dbus_bool_t for D-Bus functions
Daniel Wagner [Wed, 14 Aug 2013 07:27:45 +0000 (09:27 +0200)]
adapter: Use dbus_bool_t for D-Bus functions

10 years agonfctype1: Use the right offset after the CC
Samuel Ortiz [Mon, 19 Aug 2013 14:40:59 +0000 (16:40 +0200)]
nfctype1: Use the right offset after the CC

The Capability container is 4 bytes long and the NDEF data can be found
right after that. The offset for the static memory on a dynamic tag
should thus be the length of the CC and not more.

10 years agosrc: Remove redundant include config.h
Syam Sidhardhan [Tue, 30 Jul 2013 19:12:42 +0000 (04:12 +0900)]
src: Remove redundant include config.h

10 years agotag.h: Remove header declared but not defined
Syam Sidhardhan [Tue, 30 Jul 2013 17:49:08 +0000 (02:49 +0900)]
tag.h: Remove header declared but not defined

10 years agoadapter.h: Remove header declared but not defined
Syam Sidhardhan [Tue, 30 Jul 2013 17:49:07 +0000 (02:49 +0900)]
adapter.h: Remove header declared but not defined

10 years agohandover: Fix memory leak on reallocation error
Samuel Ortiz [Tue, 30 Jul 2013 09:59:19 +0000 (11:59 +0200)]
handover: Fix memory leak on reallocation error

A temporay variable is used for checking the realloc() return value.
Otherwise ndef->ndef is leaked when realloc fails as it is then set to
NULL.
With this fix, ndef->ndef is updated iff realloc() succeeds.

Reported by Szymon Janc <szymon.janc@tieto.com>

10 years agohandover: Fix incorrect NULL check
Syam Sidhardhan [Sun, 28 Jul 2013 17:38:28 +0000 (02:38 +0900)]
handover: Fix incorrect NULL check

Need to check the return value of g_try_realloc()
instead of (ndef == NULL).

10 years agonfc_copy: Update nfc_copy.h with SE and firmware upload APIs
Samuel Ortiz [Mon, 22 Jul 2013 13:39:06 +0000 (15:39 +0200)]
nfc_copy: Update nfc_copy.h with SE and firmware upload APIs

10 years agoTODO: Update and cleanup
Samuel Ortiz [Fri, 19 Jul 2013 23:28:34 +0000 (01:28 +0200)]
TODO: Update and cleanup

10 years agounit: Add test for Handover Select
Szymon Janc [Fri, 12 Jul 2013 08:55:53 +0000 (10:55 +0200)]
unit: Add test for Handover Select

This adds test for HS. Currently test is not enabled as it is not
possible to run HO code as unit test now as this code does both
parsing and acting (eg. trying to access HO agent) in same run.

This test is added for reference and should be enabled when handover
code is splitted into parsing and acting functions.

10 years agodoc: Remove monitor-tag and monitor-device
Samuel Ortiz [Fri, 19 Jul 2013 09:09:50 +0000 (11:09 +0200)]
doc: Remove monitor-tag and monitor-device

monitor-near also monitor tags and devices, so let's avoid redundancy.

Fixes #NFC-51

10 years agoTODO: Add NDEF split
Szymon Janc [Fri, 12 Jul 2013 08:55:54 +0000 (10:55 +0200)]
TODO: Add NDEF split

10 years agobuild: Add unit/test-snep-read to .gitignore
Szymon Janc [Fri, 12 Jul 2013 08:55:52 +0000 (10:55 +0200)]
build: Add unit/test-snep-read to .gitignore

10 years agondef: Make near_ndef_prepare_ac_message ready for multibyte cdr
Szymon Janc [Fri, 12 Jul 2013 08:55:51 +0000 (10:55 +0200)]
ndef: Make near_ndef_prepare_ac_message ready for multibyte cdr

This allows to acctually create multibye cdr if needed. Currently neard
always use one byte cdr but let us be in match with spec and a bit more
future proof.

10 years agondef: Make near_ndef_prepare_cfg_message accept cdr as pointer
Szymon Janc [Fri, 12 Jul 2013 08:55:50 +0000 (10:55 +0200)]
ndef: Make near_ndef_prepare_cfg_message accept cdr as pointer

This allows to acctually create multibye cdr if needed. Currently neard
always use one byte cdr but let us be in match with spec and a bit more
future proof.

10 years agondef: Remove unused struct near_ndef_carrier_data
Szymon Janc [Fri, 12 Jul 2013 08:55:49 +0000 (10:55 +0200)]
ndef: Remove unused struct near_ndef_carrier_data

This is not used anywhere in the code.

10 years agondef: Make cdr in near_ndef_ac_payload multibyte
Szymon Janc [Fri, 12 Jul 2013 08:55:48 +0000 (10:55 +0200)]
ndef: Make cdr in near_ndef_ac_payload multibyte

cdr is a multibyte field. This removes assumption in code that cdr is
one byte only.

10 years agodoc: Document the Push method dictionary content
Samuel Ortiz [Tue, 16 Jul 2013 09:15:19 +0000 (11:15 +0200)]
doc: Document the Push method dictionary content

10 years agodevice: Remove the SetProperty method
Samuel Ortiz [Fri, 12 Jul 2013 12:42:31 +0000 (14:42 +0200)]
device: Remove the SetProperty method

Records are read only.

10 years agomanager: Remove the SetProperty method
Samuel Ortiz [Wed, 3 Jul 2013 15:01:26 +0000 (17:01 +0200)]
manager: Remove the SetProperty method

The neard Manager properties are read only and they only contain the
Adapters.

10 years agoadapter: Restart polling when failing to connect to a new target
Samuel Ortiz [Wed, 3 Jul 2013 13:31:04 +0000 (15:31 +0200)]
adapter: Restart polling when failing to connect to a new target

If a newly detected target failed to be connected then a new polling
loop is started if constant poll is enabled.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
10 years agoAUTHORS: Mention Louis' contributions
Samuel Ortiz [Tue, 2 Jul 2013 17:52:07 +0000 (19:52 +0200)]
AUTHORS: Mention Louis' contributions

10 years agondef: Add raw MIME payload support
Louis Yung-Chieh Lo [Tue, 2 Jul 2013 17:16:47 +0000 (10:16 -0700)]
ndef: Add raw MIME payload support

Additional to wifi_wsc MIME type, raw parameter is provided for
sending raw MIME payload as NDEF.
See test/push-device for usage.

10 years agomain: Use signalfd instead of raw signals
Samuel Ortiz [Tue, 2 Jul 2013 11:10:14 +0000 (13:10 +0200)]
main: Use signalfd instead of raw signals

Copied from ConnMan's commit 6ad51830 where Daniel Wagner was
explaining:

   "It's unsafe to call syslog in the terminated signal handler
    because syslog takes a lock. So when the signal handler
    kicks in and we were already in syslog, we have a nice
    deadlock."

10 years agondef: Display AAR package name as a debug string
Samuel Ortiz [Tue, 2 Jul 2013 11:05:17 +0000 (13:05 +0200)]
ndef: Display AAR package name as a debug string

10 years agodevice: Cancel pending SNEP message when removing a device
Samuel Ortiz [Fri, 28 Jun 2013 15:09:32 +0000 (17:09 +0200)]
device: Cancel pending SNEP message when removing a device

10 years agoadapter: Add a DEP link establishment timer
Samuel Ortiz [Fri, 28 Jun 2013 13:00:47 +0000 (15:00 +0200)]
adapter: Add a DEP link establishment timer

Once a device in target mode is found, the polling loop restarts after 1
second if the dep_link_is_up is not received.

10 years agonfctool: Add a null pointer check in llcp_decode_cleanup
Thierry Escande [Thu, 27 Jun 2013 10:04:00 +0000 (12:04 +0200)]
nfctool: Add a null pointer check in llcp_decode_cleanup

g_hash_table_destroy raises an assert when called with a null pointer.
connection_hash can be NULL when sniffer_init() fails before calling
llcp_init().

10 years agounit: Add Android Application Record NDEF record unit test
Samuel Ortiz [Thu, 27 Jun 2013 15:13:57 +0000 (17:13 +0200)]
unit: Add Android Application Record NDEF record unit test

10 years agondef: Parse AAR payload
Samuel Ortiz [Thu, 27 Jun 2013 15:01:54 +0000 (17:01 +0200)]
ndef: Parse AAR payload

Android Application Record payload simply contains the Android Market
package name.

10 years agondef: Initial support for Android Application Records
Samuel Ortiz [Thu, 27 Jun 2013 14:38:34 +0000 (16:38 +0200)]
ndef: Initial support for Android Application Records

AAR are Android external NDEF records that contain an Android package
name.

10 years agotest: Add a device monitoring script
Samuel Ortiz [Thu, 27 Jun 2013 10:30:54 +0000 (12:30 +0200)]
test: Add a device monitoring script

It displays the device detection event and the received NDEF record
payloads if something is received from the device.

10 years agotest: Add a tag monitoring script
Samuel Ortiz [Thu, 27 Jun 2013 10:30:14 +0000 (12:30 +0200)]
test: Add a tag monitoring script

It displays the record payload available from a detected tag.

10 years agonfctool: sniffer: Fix ndef read-ahead check macro
Thierry Escande [Tue, 25 Jun 2013 13:41:09 +0000 (15:41 +0200)]
nfctool: sniffer: Fix ndef read-ahead check macro

This macro checks if we can safely read the next field in a ndef
record. So the check needs to be done at the current read position
in the current record.

10 years agoRelease 0.12 0.12 upstream/0.12
Samuel Ortiz [Mon, 24 Jun 2013 22:15:24 +0000 (00:15 +0200)]
Release 0.12

10 years agodevice: Pass the NDEF push cb status back to the caller
Samuel Ortiz [Thu, 20 Jun 2013 23:37:09 +0000 (01:37 +0200)]
device: Pass the NDEF push cb status back to the caller

Instead of hard coding it to EINVAL.

10 years agoerror: Add I/O error routine
Samuel Ortiz [Thu, 20 Jun 2013 23:36:40 +0000 (01:36 +0200)]
error: Add I/O error routine

10 years agondef: Support receiving empty Handover select frames
Samuel Ortiz [Thu, 20 Jun 2013 23:04:33 +0000 (01:04 +0200)]
ndef: Support receiving empty Handover select frames

Empty handover select frames are received when the peer notifies us
about not supporting any of the carrier sent in the handover request
frame.
In that case there is nothing to do but disconnecting from the handover
service.

10 years agondef: Send empty WiFi carrier in Hr message when running as a STA
Ravi kumar Veeramally [Thu, 2 May 2013 11:27:52 +0000 (14:27 +0300)]
ndef: Send empty WiFi carrier in Hr message when running as a STA

When running as a 802.11 STA, the Hr should contain an empty WiFi
carrier as we're just asking for WiFi availability from the peer.
Also when running in AP mode, an Hr is not a valid frame to send as
an AP will not be able to initiate the association.

10 years agondef: Implement static handover
Samuel Ortiz [Thu, 20 Jun 2013 12:46:17 +0000 (14:46 +0200)]
ndef: Implement static handover

static handover is going through a different D-Bus path as it would not
make sense to handle both static and dynamic handover from the same code
path.
Static handover means an application explicitely requires to send a
handover select without having previously received a handover request.
This could typically be used for handling WiFi handover through
configuration token from the registrar perspective. The registrar
(a.k.a. the Access Point) would send a configuration token via Handover
and expects the Enrolle (a.k.a. the WiFi STA) to initiate the WiFi
association.

10 years agondef: Generalize near_ndef_prepare_hr_message()
Samuel Ortiz [Thu, 20 Jun 2013 12:43:19 +0000 (14:43 +0200)]
ndef: Generalize near_ndef_prepare_hr_message()

near_ndef_prepare_hr_message can be used for building Hr frames but also
Hs ones for static handover. So generalize and factorize it and also
rename it to near_ndef_prepare_ho_message().

10 years agotest: Check for dump-* scripts argument
Samuel Ortiz [Thu, 20 Jun 2013 12:39:11 +0000 (14:39 +0200)]
test: Check for dump-* scripts argument

Check that there at least is one argument and dump a usage example
otherwise.

10 years agotest: Explicitely unregister the NDEF agent when being interrupted
Samuel Ortiz [Thu, 20 Jun 2013 10:57:17 +0000 (12:57 +0200)]
test: Explicitely unregister the NDEF agent when being interrupted

10 years agondef: Rename near_ndef_prepare_hs_message
Samuel Ortiz [Wed, 19 Jun 2013 13:38:11 +0000 (15:38 +0200)]
ndef: Rename near_ndef_prepare_hs_message

near_ndef_prepare_hs_message() does not prepare a generic handover
select message but rather a reply to a handover request.
Those 2 have to be differentiated in order to implement static handover
where a handover select frame is sent without having first seen a
handover request.

10 years agondef: Rename build_ho_record
Samuel Ortiz [Wed, 19 Jun 2013 13:32:31 +0000 (15:32 +0200)]
ndef: Rename build_ho_record

build_ho_record is used for initiating negotiated handover, so it will
only send handover requests.
As such, rename build_ho_record to build_hr_record.

10 years agonfctool: sniffer: Dump unknown WSC data elements
Samuel Ortiz [Wed, 19 Jun 2013 08:41:50 +0000 (10:41 +0200)]
nfctool: sniffer: Dump unknown WSC data elements

Don't drop them silently.

10 years agogdbus: Remove proxies when client disconnects
Henrique Dante de Almeida [Mon, 27 May 2013 17:15:34 +0000 (14:15 -0300)]
gdbus: Remove proxies when client disconnects

Remove proxies and generate proxy_removed callbacks even when there are
no corresponding InterfaceRemoved signals.

This patch fixes having zombie gdbus proxy object when a server
disconnects without sending InterfaceRemoved signals. These objects
may interact with new server instances, for example, making
InterfaceAdded signals of new objects with the same name be filtered
out as duplicated, or staying allocated, but unused, if the new server
doesn't reuse the object paths. Note that as a side-effect, the
lifetime of a gdbus proxy becomes stricter: it lives at most for the
duration of a single connection to a single instance of a server
process.

10 years agonfctool: sniffer: Decode application/vnd.wfa.wsc MIME records
Samuel Ortiz [Tue, 18 Jun 2013 17:40:22 +0000 (19:40 +0200)]
nfctool: sniffer: Decode application/vnd.wfa.wsc MIME records

10 years agotest: Add MIME type to the Device pushing options
Samuel Ortiz [Tue, 18 Jun 2013 17:38:26 +0000 (19:38 +0200)]
test: Add MIME type to the Device pushing options

Only wifi_wsc is supported for now, i.e. one can only push WSC
configuration tokens over SNEP.

10 years agondef: Fallback to the WiFi agent when missing an SSID
Samuel Ortiz [Tue, 18 Jun 2013 17:35:13 +0000 (19:35 +0200)]
ndef: Fallback to the WiFi agent when missing an SSID

When the D-Bus message does not contain an SSID (and optionalyy a
passphrase) then we fallback to the WiFi WSC agent. If it's running
in tethering mode then it will reply with an already built WSC TLV
array.
This is needed to push WiFi WSC configuration token over SNEP. Android
is going to support that as a simplified WiFi Handover.

10 years agonfctype4: Fix segmentation fault on invalid access key
Olivier Guiter [Mon, 17 Jun 2013 14:42:41 +0000 (16:42 +0200)]
nfctype4: Fix segmentation fault on invalid access key

If length is < 0, further access to the resp buffer will cause neard to
seg fault.

10 years agobluetooth: Fix memory leaks on error or when not pairing
Guillem Jover [Sat, 1 Jun 2013 16:01:57 +0000 (18:01 +0200)]
bluetooth: Fix memory leaks on error or when not pairing

Warned-by: cppcheck
10 years agonpp: Fix memory leak on allocation error
Guillem Jover [Sat, 1 Jun 2013 16:00:15 +0000 (18:00 +0200)]
npp: Fix memory leak on allocation error

The pointer to a realloc() function does not get touched on error, so
we need to check if the function failed and either free or update the
pointer.

Warned-by: cppcheck
10 years agop2p: Coding style violation fixes
Olivier Guiter [Mon, 10 Jun 2013 15:47:13 +0000 (17:47 +0200)]
p2p: Coding style violation fixes

10 years agop2p: Check for an already existing p2p driver from near_p2p_register
Olivier Guiter [Mon, 10 Jun 2013 15:44:06 +0000 (17:44 +0200)]
p2p: Check for an already existing p2p driver from near_p2p_register

If there already is a driver handling this service name, -EALREADY is
returned.

10 years agonfctool: sniffer: Print Handover I frames as NDEF
Samuel Ortiz [Fri, 14 Jun 2013 15:30:11 +0000 (17:30 +0200)]
nfctool: sniffer: Print Handover I frames as NDEF

Handover information frames are actually pure NDEFs, so decode them as
such since it is now possible to detect Handover specific traffic.

10 years agonfctool: sniffer: CONNECT and CC frames tracking
Samuel Ortiz [Fri, 14 Jun 2013 15:23:03 +0000 (17:23 +0200)]
nfctool: sniffer: CONNECT and CC frames tracking

In order to map an SAP with the righ service name, CONNECT and CC frames
need to be tracked along with their dsap/ssap.
When finding an SN, it means a CONNECT frame has been monitored. The SN
string is then associated with the SSAP. Upon CC sniffing, the DSAP is
fetched and if a pending SN for this DSAP is found, the service name
lookup is done.
With this mechanism it is now possible to know the e.g. the Handover SAP
and decode its I frames as pure NDEF ones.
This tracking will only work with connection by name (Which is what the
vast majority of platforms do). An enhancement would be to track SNL
packets as well.

10 years agonfctool: sniffer: Handle Bluetooth Handover records
Samuel Ortiz [Fri, 14 Jun 2013 13:37:49 +0000 (15:37 +0200)]
nfctool: sniffer: Handle Bluetooth Handover records

If the MIME string is "application/vnd.bluetooth.ep.oob" then the
Bluetooth OOB data is parsed and output appropriately.
AC and CR records are not parsed yet.

10 years agonfctool: sniffer: Output the MIME type value
Samuel Ortiz [Thu, 13 Jun 2013 14:45:55 +0000 (16:45 +0200)]
nfctool: sniffer: Output the MIME type value

This is needed for handover sniffing.

10 years agonfctool: sniffer: A record's TNF is not a boolean
Samuel Ortiz [Thu, 13 Jun 2013 14:18:23 +0000 (16:18 +0200)]
nfctool: sniffer: A record's TNF is not a boolean

A record TNF (Type Name Format) is on 3 bits and thus should not be the
result of a boolean comparison.

10 years agonfctool: sniffer: Support multiple records per NDEF
Samuel Ortiz [Thu, 13 Jun 2013 13:57:56 +0000 (15:57 +0200)]
nfctool: sniffer: Support multiple records per NDEF

Two offsets are needed to track the record current pointer and the NDEF
one.

10 years agoagent: Do not call NDEF agent Release when agent leaves
Samuel Ortiz [Wed, 12 Jun 2013 16:32:58 +0000 (18:32 +0200)]
agent: Do not call NDEF agent Release when agent leaves

The Release method should only be called when neard leaves. neard
doesn't need to notify an agent that's explicitly leaving.

10 years agotest: Fix Text NDEF representation
Samuel Ortiz [Wed, 12 Jun 2013 15:07:39 +0000 (17:07 +0200)]
test: Fix Text NDEF representation

The Text NDEF representation could be non ASCII strings (UTF-8 or
UTF-16) and the dumping scripts need to know about that.

Fixes #NFC-48

10 years agondef: Do not fail if NDEF record MIME type is not a handover one
Samuel Ortiz [Wed, 12 Jun 2013 08:49:18 +0000 (10:49 +0200)]
ndef: Do not fail if NDEF record MIME type is not a handover one

NDEFs with MIME type records that are not WSC or Bluetooth ones are not
wrong. Their payload won't be processed but the record is kept and
linked to the discovered tag.
NDEF agents will get the binary payload.

Fixes #NFC-45

10 years agoadapter: Pass the right adapter index when auto powering adapters
Samuel Ortiz [Mon, 10 Jun 2013 13:37:17 +0000 (15:37 +0200)]
adapter: Pass the right adapter index when auto powering adapters

When calling __near_netlink_adapter_enable(), adapter->idx is not yet
set. The right adapter index to pass is the __near_adapter_create()
argument.

10 years agovalidation: Add MIUX support
Olivier Guiter [Mon, 3 Jun 2013 13:45:08 +0000 (15:45 +0200)]
validation: Add MIUX support

The MIUX value is now read from the socket options, allowing for a dynamic
SDU buffer allocation.

10 years agosnep: Fix fragmented GET
Samuel Ortiz [Sat, 8 Jun 2013 00:23:46 +0000 (02:23 +0200)]
snep: Fix fragmented GET

When receiving a CONTINUE while nfc_data_length is set to 0, it must
be a CONTINUE for a fragmented GET. The headers are thus read in order
to modify snep_data->request and then process the right request.
This fixes the GET fragmented unit test.

10 years agosnep: Fix SNEP fragmentation
Samuel Ortiz [Sat, 8 Jun 2013 00:11:18 +0000 (02:11 +0200)]
snep: Fix SNEP fragmentation

The intial request is kept through the snep_data and
snep_core_process_request no longer relies on the last read frame to
build an answer but only on the snep_data pointer.
Without this fix, each fragment from a fragmented PUT was handled as
a complete SNEP frame (header included) which caused process_request
to get completely confused about how to handle fragments.
Now that snep_core_read is fixed, the fragmentation SNEP unit test can
be fixed as well.

10 years agovalidation: Fix memory leak from llcp_send_data
Olivier Guiter [Wed, 29 May 2013 08:33:10 +0000 (10:33 +0200)]
validation: Fix memory leak from llcp_send_data

When send or sendto fails the SDU still needs to be freed.

10 years agodoc: Fix NDEF agent GetNDEF prototype
Samuel Ortiz [Fri, 31 May 2013 09:08:22 +0000 (11:08 +0200)]
doc: Fix NDEF agent GetNDEF prototype

GetNDEF does not return any dictionary, it takes one as a parameter.

10 years agonfctype4: Add support for type4 B tags
Samuel Ortiz [Thu, 30 May 2013 16:15:31 +0000 (18:15 +0200)]
nfctype4: Add support for type4 B tags

4a and 4b tags follow the same specs: the type 4 one from the NFC
Forum.

10 years agotag: Set type B tag type properly
Samuel Ortiz [Thu, 30 May 2013 16:09:50 +0000 (18:09 +0200)]
tag: Set type B tag type properly

When receiving a 14443-B protocol mask, we should set the tag type to
NFC-B.

10 years agonfctool: sniffer: Fix fragmented SNEP output
Samuel Ortiz [Thu, 30 May 2013 12:47:30 +0000 (14:47 +0200)]
nfctool: sniffer: Fix fragmented SNEP output

Display the right string depending ont the direction.

10 years agop2p: Fall back to blocking sockets if the async connection fails
Samuel Ortiz [Wed, 22 May 2013 16:12:56 +0000 (18:12 +0200)]
p2p: Fall back to blocking sockets if the async connection fails

Due to a kernel bug, trying to connect through a non blocking socket
may fail and return POLLHUP. In that case the connection procedure falls
back to using blocking sockets and this needs to be delayed until the
kernel sends a DM to the peer.
This is slightly hackish but this code path should get obsolete once
neard runs on top of 3.10 or later kernels.

10 years agop2p: Non blocking client socket
Samuel Ortiz [Wed, 22 May 2013 15:48:26 +0000 (17:48 +0200)]
p2p: Non blocking client socket

The p2p client connection used to be a blocking one, which can be quite
harmful when for some reason the peer does not reply to a connection
request.
The client socket is non blocking now and the actual push is handled
by a GLib watch callback.

10 years agop2p: Set connection timeout
Samuel Ortiz [Tue, 21 May 2013 17:02:05 +0000 (19:02 +0200)]
p2p: Set connection timeout

The connect() call should not block forever. The 8 seconds timeout makes
it for approximately 3 times the maximum LTO and that seems to be plenty
of time for a peer to reply to an LLCP connection.

10 years agonfctool: sniffer: Set the time string first character to 0
Samuel Ortiz [Tue, 21 May 2013 10:35:30 +0000 (12:35 +0200)]
nfctool: sniffer: Set the time string first character to 0

If the show_timestamp option is disabled, the string needs to be properly
terminated.

10 years agonfctool: Power up the device when start poll
Thierry Escande [Fri, 3 May 2013 15:03:05 +0000 (17:03 +0200)]
nfctool: Power up the device when start poll

with --poll, --enable is now implicit

10 years agonfctool: Add command line options to power up or down a device
Thierry Escande [Fri, 3 May 2013 15:03:04 +0000 (17:03 +0200)]
nfctool: Add command line options to power up or down a device

--enable (-1 for short) turns the specified device on
--disable (-0) turns it off

If both are specified, only --enable is applied

11 years agogdbus: Fix using NULL DBusPendingCall when disconnected from D-Bus
Anderson Lizardo [Sat, 4 May 2013 19:39:43 +0000 (15:39 -0400)]
gdbus: Fix using NULL DBusPendingCall when disconnected from D-Bus

From D-Bus documentation for dbus_connection_send_with_reply():

"Warning: if the connection is disconnected or you try to send Unix file
descriptors on a connection that does not support them, the
DBusPendingCall will be set to NULL, so be careful with this."

Fix these errors when killing D-Bus daemon with the client still
running:

process 5712: arguments to dbus_pending_call_set_notify() were
incorrect, assertion "pending != NULL" failed in file
../../dbus/dbus-pending-call.c line 596.
This is normally a bug in some application using the D-Bus library.
process 5712: arguments to dbus_pending_call_unref() were incorrect,
assertion "pending != NULL" failed in file
../../dbus/dbus-pending-call.c line 572.
This is normally a bug in some application using the D-Bus library.

11 years agogdbus: Fix segfault when D-Bus daemon exits
Anderson Lizardo [Sat, 4 May 2013 19:39:42 +0000 (15:39 -0400)]
gdbus: Fix segfault when D-Bus daemon exits

Fix this crash if D-Bus exits while the client is still connected to it:

==5570== Invalid read of size 1
==5570==    at 0x402D28E: strcmp (in
/usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==5570==    by 0x4070E22: g_str_equal (ghash.c:1704)
==5570==    by 0x8055F61: message_filter (client.c:1123)
==5570==    by 0x4141500: dbus_connection_dispatch (in
/lib/i386-linux-gnu/libdbus-1.so.3.5.8)
==5570==    by 0x80506F7: message_dispatch (mainloop.c:76)
==5570==    by 0x4081A7E: g_timeout_dispatch (gmain.c:3882)
==5570==    by 0x4080D85: g_main_context_dispatch (gmain.c:2539)
==5570==    by 0x4081124: g_main_context_iterate.isra.21 (gmain.c:3146)
==5570==    by 0x408156A: g_main_loop_run (gmain.c:3340)
==5570==    by 0x41BF4D2: (below main) (libc-start.c:226)
==5570==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==5570==
==5570==

11 years agogdbus: Fix calling GetManagedObjects twice in a row
Luiz Augusto von Dentz [Thu, 18 Apr 2013 20:34:03 +0000 (23:34 +0300)]
gdbus: Fix calling GetManagedObjects twice in a row

Calling g_dbus_client_new followed by g_dbus_client_set_proxy_handlers
cause two calls to GetManagedObjects in a row as GetNameOwner reply is
asyncronously it triggers the second call because the handlers have
been set by g_dbus_client_set_proxy_handlers.

11 years agonfctool: sniffer: Add NDEF decoding support
Thierry Escande [Thu, 2 May 2013 16:19:29 +0000 (18:19 +0200)]
nfctool: sniffer: Add NDEF decoding support

This adds support for decoding NDEF records embedded in SNEP packets

11 years agonfctool: sniffer: Reduce hexa dump line width
Thierry Escande [Thu, 2 May 2013 16:19:28 +0000 (18:19 +0200)]
nfctool: sniffer: Reduce hexa dump line width

If we display less than 0xFFFF bytes (which will be the case 99.999%
of the time) the offset value is truncated and the 2 first zero bytes
are not displayed.

11 years agonfctool: sniffer: Add a snep_printf_error
Thierry Escande [Thu, 2 May 2013 16:19:27 +0000 (18:19 +0200)]
nfctool: sniffer: Add a snep_printf_error

This will print SNEP decoding errors in bold red

11 years agonfctool: sniffer: Fix over 80 chars macro
Samuel Ortiz [Thu, 2 May 2013 16:02:18 +0000 (18:02 +0200)]
nfctool: sniffer: Fix over 80 chars macro

11 years agonftool: sniffer: Remove new line from snep_printf_msg calls
Samuel Ortiz [Thu, 2 May 2013 15:58:23 +0000 (17:58 +0200)]
nftool: sniffer: Remove new line from snep_printf_msg calls

snep_printf_msg already contains one.

11 years agonfctool: sniffer: Color LLCP dumps
Samuel Ortiz [Thu, 2 May 2013 14:28:46 +0000 (16:28 +0200)]
nfctool: sniffer: Color LLCP dumps

11 years agonfctool: sniffer: Simplify print_pdu routine
Samuel Ortiz [Thu, 2 May 2013 11:10:44 +0000 (13:10 +0200)]
nfctool: sniffer: Simplify print_pdu routine

And prepare for more colors...

11 years agonfctool: Initial color support
Samuel Ortiz [Thu, 2 May 2013 10:51:37 +0000 (12:51 +0200)]
nfctool: Initial color support

SNEP decoding is colored now, for a more readable output.

11 years agonfctool: sniffer: Change the sniffer hexdump prototype
Samuel Ortiz [Thu, 2 May 2013 10:48:04 +0000 (12:48 +0200)]
nfctool: sniffer: Change the sniffer hexdump prototype

Take an indentation length instead of a generic prefix, as this is
what's only used anyway.

11 years agonfctool: sniffer: Fix SNEP output string
Samuel Ortiz [Thu, 2 May 2013 08:21:26 +0000 (10:21 +0200)]
nfctool: sniffer: Fix SNEP output string

SNEP stands for Simple NDEF Exchange Protocol, not Messaging Protocol.

11 years agonfctool: sniffer: Add SNEP decoding
Thierry Escande [Thu, 25 Apr 2013 11:03:03 +0000 (13:03 +0200)]
nfctool: sniffer: Add SNEP decoding

This adds support for decoding Simple NDF Message Protocol. The SNEP decoder
supports aggregation of fragmented messages.

11 years agonfctool: sniffer: ssap and dsap were displayed switched
Thierry Escande [Thu, 25 Apr 2013 11:03:02 +0000 (13:03 +0200)]
nfctool: sniffer: ssap and dsap were displayed switched

In the LLCP header of a received frame, dsap is the local port and ssap is the
remote port. ssap and dsap fields of the sniffer_packet structure have been
renamed to local_sap and remote_sap to avoid confusion.

11 years agonfctool: sniffer: Group sniffed packet info into the same struct
Thierry Escande [Thu, 25 Apr 2013 11:03:01 +0000 (13:03 +0200)]
nfctool: sniffer: Group sniffed packet info into the same struct

Raw socket header (direction and adapter index) and LLCP info are now stored
into the same struct (sniffer_packet). This structure is then passed to PDU
specific decoding functions.

11 years agonfctool: Fix a memory leak
Thierry Escande [Thu, 25 Apr 2013 11:03:00 +0000 (13:03 +0200)]
nfctool: Fix a memory leak

The handlers hash table was not freed

11 years agonfctyp3: Set cookie cb to NULL when read succeeds
Arron Wang [Mon, 22 Apr 2013 09:19:53 +0000 (17:19 +0800)]
nfctyp3: Set cookie cb to NULL when read succeeds

Otherwise the callback function may be call twice and
write_msg is unreferenced twice:

process 1868: arguments to dbus_message_unref() were incorrect,
assertion "message != NULL" failed in file dbus-message.c line 1616
0  0xb7fe1424 in __kernel_vsyscall ()
1  0xb7bcfcc1 in raise () from /lib/libc.so.6
2  0xb7bd30ee in abort () from /lib/libc.so.6
3  0xb7da5045 in _dbus_abort () from /usr/lib/libdbus-1.so.3
4  0xb7d99f86 in _dbus_warn_check_failed () from /usr/lib/libdbus-1.so.3
5  0xb7d8856e in dbus_message_unref () from /usr/lib/libdbus-1.so.3
6  0x08062a63 in tag_read_cb (adapter_idx=0, target_idx=6, status=0)
    at src/tag.c:240
7  0x08063277 in near_tag_add_records (tag=0x8081a30, records=0x8080270,
    cb=0x8062a30 <tag_read_cb>, status=0) at src/tag.c:814

11 years agobluetooth: Get name value from right message iterator
Arron Wang [Mon, 22 Apr 2013 09:19:23 +0000 (17:19 +0800)]
bluetooth: Get name value from right message iterator

We need to get name value from var instead of the container iter
else it may also cause neard crash:
process 1044: type variant 118 not a basic type
0  0xb7fe1424 in __kernel_vsyscall ()
1  0xb7bcfcc1 in raise () from /lib/libc.so.6
2  0xb7bd30ee in abort () from /lib/libc.so.6
3  0xb7da5045 in _dbus_abort () from /usr/lib/libdbus-1.so.3
4  0xb7d99f86 in _dbus_warn_check_failed () from /usr/lib/libdbus-1.so.3
5  0xb7d9bc9c in _dbus_marshal_read_basic () from /usr/lib/libdbus-1.so.3
6  0xb7d84e0f in _dbus_type_reader_read_basic () from /usr/lib/libdbus-1.so.3
7  0xb7d89f0b in dbus_message_iter_get_basic () from /usr/lib/libdbus-1.so.3
8  0x0806b638 in bt_adapter_property_changed (conn=0x80814c8,
    message=0x8081870, user_data=0x0) at src/bluetooth.c:445

11 years agoRelease 0.11 0.11
Samuel Ortiz [Wed, 17 Apr 2013 10:33:32 +0000 (12:33 +0200)]
Release 0.11

11 years agounit: Fix broken SNEP read unit test
Olivier Guiter [Mon, 15 Apr 2013 11:36:55 +0000 (13:36 +0200)]
unit: Fix broken SNEP read unit test

In "crash-1" loop, the snep_data was added to the slist, but not removed
because of a specific exit condition. This fix swaps the test condition
and the action on slist, in order to add the fragment only when the length
test passed.