summaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-10-15 17:44:44 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-26 18:26:50 +0200
commit31ca61a8dffa5c7171d00cfa40a2845e190863c0 (patch)
treed2a1bf33e53f7225edcc72eab8f36dc1b6b79606 /net/nfc
parentNFC: Handle LLCP UI frames (diff)
downloadlinux-31ca61a8dffa5c7171d00cfa40a2845e190863c0.tar.xz
linux-31ca61a8dffa5c7171d00cfa40a2845e190863c0.zip
NFC: Forward LLCP datagrams to userspace
With connection less PDUs we have to send the SSAP and DSAP as well. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp/sock.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/net/nfc/llcp/sock.c b/net/nfc/llcp/sock.c
index debc54aa8a41..d511a4c2fef6 100644
--- a/net/nfc/llcp/sock.c
+++ b/net/nfc/llcp/sock.c
@@ -663,11 +663,28 @@ static int llcp_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
return -EFAULT;
}
+ if (sk->sk_type == SOCK_DGRAM && msg->msg_name) {
+ struct nfc_llcp_ui_cb *ui_cb = nfc_llcp_ui_skb_cb(skb);
+ struct sockaddr_nfc_llcp sockaddr;
+
+ pr_debug("Datagram socket %d %d\n", ui_cb->dsap, ui_cb->ssap);
+
+ sockaddr.sa_family = AF_NFC;
+ sockaddr.nfc_protocol = NFC_PROTO_NFC_DEP;
+ sockaddr.dsap = ui_cb->dsap;
+ sockaddr.ssap = ui_cb->ssap;
+
+ memcpy(msg->msg_name, &sockaddr, sizeof(sockaddr));
+ msg->msg_namelen = sizeof(sockaddr);
+ }
+
/* Mark read part of skb as used */
if (!(flags & MSG_PEEK)) {
/* SOCK_STREAM: re-queue skb if it contains unreceived data */
- if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_RAW) {
+ if (sk->sk_type == SOCK_STREAM ||
+ sk->sk_type == SOCK_DGRAM ||
+ sk->sk_type == SOCK_RAW) {
skb_pull(skb, copied);
if (skb->len) {
skb_queue_head(&sk->sk_receive_queue, skb);