aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-10-15 08:28:13 -0400
committerSamuel Ortiz <sameo@linux.intel.com>2012-10-26 12:26:49 -0400
commite6904081dd2ff22b861d976810a55322b5aece82 (patch)
tree45b19cf32f9ff1190b7f5833575d8368fde5d232 /net/nfc
parent984d334f28c6a93231fe9de3ec42717469e90d4c (diff)
NFC: Reserve LLCP ssap when replying to an SNL frame
Replying to an SNL (Service Name Lookup) means that the other end of the link can now rely on our answer (Which is an ssap) and thus we have to reserve it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/llcp/llcp.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/net/nfc/llcp/llcp.c b/net/nfc/llcp/llcp.c
index 2e826c0d1b9a..dd2cc0e48a1d 100644
--- a/net/nfc/llcp/llcp.c
+++ b/net/nfc/llcp/llcp.c
@@ -1071,20 +1071,54 @@ static void nfc_llcp_recv_snl(struct nfc_llcp_local *local,
1071 service_name = (char *) &tlv[3]; 1071 service_name = (char *) &tlv[3];
1072 service_name_len = length - 1; 1072 service_name_len = length - 1;
1073 1073
1074 pr_debug("Looking for %s\n", service_name); 1074 pr_debug("Looking for %.16s\n", service_name);
1075 1075
1076 if (service_name_len == strlen("urn:nfc:sn:sdp") && 1076 if (service_name_len == strlen("urn:nfc:sn:sdp") &&
1077 !strncmp(service_name, "urn:nfc:sn:sdp", 1077 !strncmp(service_name, "urn:nfc:sn:sdp",
1078 service_name_len)) { 1078 service_name_len)) {
1079 sap = 1; 1079 sap = 1;
1080 goto send_snl;
1081 }
1082
1083 llcp_sock = nfc_llcp_sock_from_sn(local, service_name,
1084 service_name_len);
1085 if (!llcp_sock) {
1086 sap = 0;
1087 goto send_snl;
1088 }
1089
1090 /*
1091 * We found a socket but its ssap has not been reserved
1092 * yet. We need to assign it for good and send a reply.
1093 * The ssap will be freed when the socket is closed.
1094 */
1095 if (llcp_sock->ssap == LLCP_SDP_UNBOUND) {
1096 atomic_t *client_count;
1097
1098 sap = nfc_llcp_reserve_sdp_ssap(local);
1099
1100 pr_debug("Reserving %d\n", sap);
1101
1102 if (sap == LLCP_SAP_MAX) {
1103 sap = 0;
1104 goto send_snl;
1105 }
1106
1107 client_count =
1108 &local->local_sdp_cnt[sap -
1109 LLCP_WKS_NUM_SAP];
1110
1111 atomic_inc(client_count);
1112
1113 llcp_sock->ssap = sap;
1114 llcp_sock->reserved_ssap = sap;
1080 } else { 1115 } else {
1081 llcp_sock = 1116 sap = llcp_sock->ssap;
1082 nfc_llcp_sock_from_sn(local,
1083 service_name,
1084 service_name_len);
1085 sap = llcp_sock ? llcp_sock->ssap : 0;
1086 } 1117 }
1087 1118
1119 pr_debug("%p %d\n", llcp_sock, sap);
1120
1121 send_snl:
1088 nfc_llcp_send_snl(local, tid, sap); 1122 nfc_llcp_send_snl(local, tid, sap);
1089 break; 1123 break;
1090 1124