Age | Commit message (Collapse) | Author |
|
In some conditions these would persist
over a link tear-down, causing them to
be sent out the next time the link comes up.
Also, don't overwrite them if a send is
still in progress.
Change-Id: I19dec5d79ae4b25f41fb5e8a0514e565ceca7a91
|
|
When a call to disconnect() failed, the
connect() callback was cleared, not the
disconnect() one. This would cause deadlocks,
where JNI threads were forever blocked on
doConnect().
Bug: 7324226
Change-Id: I784c8d700c87d643315f2417610ca75ef8f9aa7c
|
|
On Android we now start connecting SNEP/other LLCP
services as soon as the link comes up. That means
we will have connect requests incoming, accept
responses outgoing, connect requests outgoing and
accept responses incoming.
This lays bare a lot of threading issues in this lib.
Since the receives come in serialized, those typically
do not cause any issue. However, we may be sending
something on a thread coming from the NfcService,
while at the same time we'll receive for example
a connect frame from the remote, to which the receive
thread immediately wants to send a response.
This is a first attempt at making sends thread-safe:
already there was a lot of logic to deal with the fact
that another send was in progress, in the form of the
bSendPending variable. That variable was however
not checked atomically, and some operations did not
even set it correctly.
This change tests and sets that variable atomically,
more or less implementing a semaphore with try-acquires
and fallbacks for the failure case.
The generic structure is:
if (testAndSetSendPending()) {
// Another thread is sending, stash data
// and most importantly do *NOT* change shared data
} else {
// We're now the only one sending, we're free
// to change shared data until the callback is
// called.
}
This is just a band-aid fix, but given the fact that
this stack will be deprecated it is hopefully enough
for our planned usecases.
A decent fix would involve switching to
a TX-queue per socket, and a generic TX-queue
for the whole LLCP link. This allows us to fully
decouple the connection layer from the transport
layer, as it should be.
Change-Id: Ibd8742f7350a58459771f5036a049af3a487f783
|
|
DSAP and SSAP were switched on with the other at multiple location
in the code. This patch fix those.
Change-Id: Iea8e499049a2cd4a234155a3044b875eb9c6ca7a
|
|
If phLibNfc_Llcp_Recv() is called in the callback of a previous
phLibNfc_Llcp_Recv(), it could be rejected due to the
bSocketRecvPending flag which was not properly reset.
Change-Id: I6c41469480b50bb7adc9a721ec96f715e5d56a60
|
|
Some internal variables used in reveive window checkings were not
reset on socket closure/re-opening. This was leading to have the
send() function waiting forever for remote acknowledgments.
Change-Id: Ic7741b004de80af3f851f620842d46c42f654804
|
|
The V(SA) is an internal variable used in LLCP connection-oriented
data links to check receive window conditions. It corresponds to
the last frame number acknowledged by remote peer + 1.
The patch makes sure this variable is updated evry time it is needed.
Change-Id: Ie5ac925a6f1dfa19b22ac2b6e96659440d5daf21
|
|
- Clear out send callback if send was not accepted.
- Set transport busy status for RR/RNR frames.
Change-Id: Idf8986f6b82995644b176247a644e36d2c879ebf
|
|
Previously, in LLCP v1.0, the only way to use the SDP (Service
Discovery Protocol) service was to send a CONNECT frame containing
the Service Name to the SDP service. This was implicitly
preforming a connection request to the requested service.
LLCP v1.1 introduced a way to discover services more efficiently
and without implicit connection. It also enables connectionless
services to have a service name. It is based on a new protocol
based on a new SNL frame containing discovery requests and
responses.
This update comes with new APIs:
- phLibNfc_Llcp_DiscoverServices() function can be used to discover
remote services. It can take multiple service names and resolve
all of them in a single call.
- Register service name at bind time. Cache LLCP service name/sap pairs.
In LLCP 1.1 specification defines at section 5.9 that any service
lookup answer must be valid for the whole LLCP session duration.
To enforce this, we cache the SAP/SN pairs locally and make sure
that the applications don't break the cache.
The stack remains fully retro-compatible with v1.0 devices.
Change-Id: I052edd3838013cee65e7415d0ed01fc3e9cad36d
|
|
The pending operations were handled at the connection-oriented sockets
level, with no possibility for other transport types to handle
pending operations.
A dispatcher has been added at the generic transport level to
remove this limitation.
This feature is needed to implement LLCP v1.1.
Change-Id: I69e37ba800d1c531396ca97ab0a0480e0f53d63f
|
|
In some situations, the working buffer may be full and some packets
are stored in the receive window when trying to read from upper
layer.
In this case, the receive function first reads data from the working
buffer and if possible, also tries to read data stored in the receive
window. The previous receive window data extraction algorithm could
lead to an infinite loop. With this fix, we can ensure that this won't
happen any more.
Change-Id: Iddb412213f4e9cb5fb42691bd282dbf0a21a936e
|
|
Send failures on LLCP sockets were not dealt with at all - the transport
was just left in a state where it thought there was a pending send
and a pending callback. Before we typically only did one send and
it didn't bite us so much, but now with multiple sockets we run
into this frequently.
This really just fixes part of the problem - we should also look
if state rollbacks are necessary, as those are not done either
on send failures.
Change-Id: I484ca598e043ead835251aedaabe47d3a1da7a8f
|
|
o Fix most libnfc warnings, from 360 to 18
o Make DAL_DEBUG much less verbose and more useful
o Clean up Android.mk
Done with minimal textual diff to minimize merge conflicts.
Change-Id: I918645500723ff7bb092ad9959628fcabac45bec
|
|
At some points, the V(RA) socket counter (used for Receive Window
checking in connection-oriented sockets) was not properly updated,
thus leading to sometimes reject (FRMR) inbound I-frames with valid
sequence numbers.
This patch factorize the I-frame emission and update V(RA) in the
factorized code to ensure this is done at any time.
Change-Id: Ic7ef92cb136c32e524a14e31a8d350f7b165c367
|
|
The LLCP specification defines that if a TLV cannot be interpreted,
it shall be ignored rather than generating an error.
This patch removed all error reporting on TLV interpretation. The
only error that can still happen is length inconsistency in the
whole TLV array buffer.
Change-Id: Ibf289fceb2283bfddcdc0ddee9e687ece3e90887
|
|
This should avoid calling a irrelevant callback at abort.
Change-Id: Ied8d54268613f248fd505d4b25d0ab8a0905a336
|
|
The phLibNfc_Llcp_Send() function is expected to trigger a callback
when the packet is actually sent but, in some situations, the callback
was triggered by another frame sending (such as RR or DM frames).
This patch fixes the following socket internal flags handling:
- pfSocketSend_Cb: set to non-NULL value when a send operation is
pending,
- bSocketSendPending: set to TRUE if the LLCP link layer is not
available for sending and reset to FALSE once the frame is
actually forwarded to the LLCP link layer.
The send callback triggering has been updated to ensure it is only
done for the expected data frame (i.e.: send pending and already
forwarded to link layer).
Change-Id: Id7410ee4075fbbbc9de382abf54e89a97f6a8b37
|
|
Moved data allocation from stack memory to heap in order
to avoid invalid memory access.
Previously, When trying to send a DM (acknowledgment to
socket disconnect request), the stack was allocating some
frame data on the stack but these data were used after the
function returned.
Other calls to the same function are already using variables
allocated on heap.
Change-Id: Id7356a876fdecdd979ed3ddc6dbe100d6e92d43d
|
|
Before sending a packet, the LLCP stack have to check if the remote
peer is ready to send. To do so, a Receive Window mechanism based on
packet numbering and acknowledgment is used.
Basically, the sender have to make sure that he must have not sent
more than RW-1 unaknowledged frames before sending a new one. This
patch is correcting this test which was failing in some situations.
Change-Id: I525f6b472a909ce48feb938aa02858b9456edc11
|
|
The correct behavior of asynchronous functions should be:
Immediate operation => function returns with success/error status,
callback never invoked
Delayed operation => function returns with pending status,
callback is invoked at the end of operation
Some minor fixes are also included in this commit (code style).
Change-Id: Ieb801ab759045c5c5d9fc59b4715f3c142d5b33e
|
|
The listen callback is a notification callback, not an
end-of-operation callback so, when the socket is closed,
it should not be triggered since there is no connection
event.
Change-Id: I6e6994f6bcb09f9fadda04800d22528d76aff121
|
|
The sequence value may not be provided in some situations, when
rejecting a connection oriented frame.
Change-Id: I116179191f9a23072442cf9da7a4c4207128bd32
|
|
This avoids an application to be stuck in a send request while the
LLCP link has been lost (i.e. remote peer lost).
Change-Id: I74982d497c410ae4bdb466afac013efc9eb17b03
|
|
The receive function was failing when trying to read the data present in
the linear buffer after receiving a remote disconnection request (DISC).
Change-Id: I48a2aa058e85e265ca53e61dcde281e47a6e187f
|
|
This would prohibit detection of multiple incoming socket in a row.
Change-Id: I9e3907a92b706de2da7642ccd92668b9868d1996
|
|
Change-Id: Ifa17a3a05790fece3f5aee747b186f721c510b7f
|
|
Mark a socket as disconnecting as soon as the disconnect request is received
instead of waiting for the DISC packet to be sent.
Change-Id: I95330b7039c6fa741adc69ab1323852a60b7d49e
|
|
This ensure the lib client not to be stuck waiting for a callback when
the socket has been closed meanwhile.
Change-Id: I9cdfa3c2cc75ee9451c3ad5b92eb338b5e68f53a
|
|
The same variable was shared for multiple usages and the status value
was overwritten is some situations. One variable is now defined for
each usage.
Change-Id: I877cc8027a184dfe3b6d8d2832c73417f40c1ba7
|
|
Change-Id: Ia0426198d0edd325edcc2bb5a3c6d7d623e28a9f
|
|
Socket options are now copied in the libnfc to avoid referencing a pointer that
may not be valid during the whole socket life cycle.
Change-Id: I7266164bf157242df1ce7fb7a0f9cffd52938140
Signed-off-by: Nick Pelly <npelly@google.com>
|
|
Service Name is now copied in the libnfc to avoid referencing a pointer that
may not be valid during the whole socket life.
Change-Id: I6572366ac51502d189cc8f1350fa089c11cc2bea
|
|
Source: Trusted_NFC_Device_Host_AA03.01e02_google.zip code drop (23-Sep-2010)
Change-Id: Ie47f18423f949a8d3e0815d13f55c814312add24
Signed-off-by: Nick Pelly <npelly@google.com>
|