OSDN Git Service

NFC: llcp: Use localy stored remote_miu value if not set at socket level
authorThierry Escande <thierry.escande@linux.intel.com>
Tue, 2 Apr 2013 08:25:14 +0000 (10:25 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Thu, 11 Apr 2013 14:28:58 +0000 (16:28 +0200)
If remote_miu value is not set in the socket (i.e. connection-less socket) the
value stored in the local is used.

Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
net/nfc/llcp/commands.c
net/nfc/llcp/llcp.h
net/nfc/llcp/sock.c

index 199e8b5..094f7e2 100644 (file)
@@ -658,6 +658,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
        struct nfc_llcp_local *local;
        size_t frag_len = 0, remaining_len;
        u8 *msg_data, *msg_ptr;
+       u16 remote_miu;
 
        pr_debug("Send I frame len %zd\n", len);
 
@@ -695,7 +696,10 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
        msg_ptr = msg_data;
 
        do {
-               frag_len = min_t(size_t, sock->remote_miu, remaining_len);
+               remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
+                               local->remote_miu : sock->remote_miu;
+
+               frag_len = min_t(size_t, remote_miu, remaining_len);
 
                pr_debug("Fragment %zd bytes remaining %zd",
                         frag_len, remaining_len);
@@ -734,6 +738,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
        struct nfc_llcp_local *local;
        size_t frag_len = 0, remaining_len;
        u8 *msg_ptr, *msg_data;
+       u16 remote_miu;
        int err;
 
        pr_debug("Send UI frame len %zd\n", len);
@@ -755,7 +760,10 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
        msg_ptr = msg_data;
 
        do {
-               frag_len = min_t(size_t, sock->remote_miu, remaining_len);
+               remote_miu = sock->remote_miu > LLCP_MAX_MIU ?
+                               local->remote_miu : sock->remote_miu;
+
+               frag_len = min_t(size_t, remote_miu, remaining_len);
 
                pr_debug("Fragment %zd bytes remaining %zd",
                         frag_len, remaining_len);
index 6dfde1e..3b2c67e 100644 (file)
@@ -31,6 +31,7 @@ enum llcp_state {
 #define LLCP_MAX_LTO  0xff
 #define LLCP_MAX_RW   15
 #define LLCP_MAX_MIUX 0x7ff
+#define LLCP_MAX_MIU (LLCP_MAX_MIUX + 128)
 
 #define LLCP_WKS_NUM_SAP   16
 #define LLCP_SDP_NUM_SAP   16
index f3027c2..dc94e39 100644 (file)
@@ -934,7 +934,7 @@ struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp)
        llcp_sock->rw = LLCP_MAX_RW + 1;
        llcp_sock->miux = cpu_to_be16(LLCP_MAX_MIUX + 1);
        llcp_sock->remote_rw = LLCP_DEFAULT_RW;
-       llcp_sock->remote_miu = LLCP_DEFAULT_MIU;
+       llcp_sock->remote_miu = LLCP_MAX_MIU + 1;
        llcp_sock->send_n = llcp_sock->send_ack_n = 0;
        llcp_sock->recv_n = llcp_sock->recv_ack_n = 0;
        llcp_sock->remote_ready = 1;