aboutsummaryrefslogtreecommitdiffstats
path: root/net/nfc/llcp/llcp.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/nfc/llcp/llcp.h')
-rw-r--r--net/nfc/llcp/llcp.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/net/nfc/llcp/llcp.h b/net/nfc/llcp/llcp.h
index 50680ce5ae43..83b8bba5a280 100644
--- a/net/nfc/llcp/llcp.h
+++ b/net/nfc/llcp/llcp.h
@@ -37,15 +37,22 @@ enum llcp_state {
37#define LLCP_LOCAL_NUM_SAP 32 37#define LLCP_LOCAL_NUM_SAP 32
38#define LLCP_LOCAL_SAP_OFFSET (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP) 38#define LLCP_LOCAL_SAP_OFFSET (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP)
39#define LLCP_MAX_SAP (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP + LLCP_LOCAL_NUM_SAP) 39#define LLCP_MAX_SAP (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP + LLCP_LOCAL_NUM_SAP)
40#define LLCP_SDP_UNBOUND (LLCP_MAX_SAP + 1)
40 41
41struct nfc_llcp_sock; 42struct nfc_llcp_sock;
42 43
44struct llcp_sock_list {
45 struct hlist_head head;
46 rwlock_t lock;
47};
48
43struct nfc_llcp_local { 49struct nfc_llcp_local {
44 struct list_head list; 50 struct list_head list;
45 struct nfc_dev *dev; 51 struct nfc_dev *dev;
46 52
53 struct kref ref;
54
47 struct mutex sdp_lock; 55 struct mutex sdp_lock;
48 struct mutex socket_lock;
49 56
50 struct timer_list link_timer; 57 struct timer_list link_timer;
51 struct sk_buff_head tx_queue; 58 struct sk_buff_head tx_queue;
@@ -63,6 +70,7 @@ struct nfc_llcp_local {
63 unsigned long local_wks; /* Well known services */ 70 unsigned long local_wks; /* Well known services */
64 unsigned long local_sdp; /* Local services */ 71 unsigned long local_sdp; /* Local services */
65 unsigned long local_sap; /* Local SAPs, not available for discovery */ 72 unsigned long local_sap; /* Local SAPs, not available for discovery */
73 atomic_t local_sdp_cnt[LLCP_SDP_NUM_SAP];
66 74
67 /* local */ 75 /* local */
68 u8 gb[NFC_MAX_GT_LEN]; 76 u8 gb[NFC_MAX_GT_LEN];
@@ -77,24 +85,26 @@ struct nfc_llcp_local {
77 u16 remote_lto; 85 u16 remote_lto;
78 u8 remote_opt; 86 u8 remote_opt;
79 u16 remote_wks; 87 u16 remote_wks;
80 u8 remote_rw;
81 88
82 /* sockets array */ 89 /* sockets array */
83 struct nfc_llcp_sock *sockets[LLCP_MAX_SAP]; 90 struct llcp_sock_list sockets;
91 struct llcp_sock_list connecting_sockets;
84}; 92};
85 93
86struct nfc_llcp_sock { 94struct nfc_llcp_sock {
87 struct sock sk; 95 struct sock sk;
88 struct list_head list;
89 struct nfc_dev *dev; 96 struct nfc_dev *dev;
90 struct nfc_llcp_local *local; 97 struct nfc_llcp_local *local;
91 u32 target_idx; 98 u32 target_idx;
92 u32 nfc_protocol; 99 u32 nfc_protocol;
93 100
101 /* Link parameters */
94 u8 ssap; 102 u8 ssap;
95 u8 dsap; 103 u8 dsap;
96 char *service_name; 104 char *service_name;
97 size_t service_name_len; 105 size_t service_name_len;
106 u8 rw;
107 u16 miu;
98 108
99 /* Link variables */ 109 /* Link variables */
100 u8 send_n; 110 u8 send_n;
@@ -105,6 +115,9 @@ struct nfc_llcp_sock {
105 /* Is the remote peer ready to receive */ 115 /* Is the remote peer ready to receive */
106 u8 remote_ready; 116 u8 remote_ready;
107 117
118 /* Reserved source SAP */
119 u8 reserved_ssap;
120
108 struct sk_buff_head tx_queue; 121 struct sk_buff_head tx_queue;
109 struct sk_buff_head tx_pending_queue; 122 struct sk_buff_head tx_pending_queue;
110 struct sk_buff_head tx_backlog_queue; 123 struct sk_buff_head tx_backlog_queue;
@@ -164,7 +177,11 @@ struct nfc_llcp_sock {
164#define LLCP_DM_REJ 0x03 177#define LLCP_DM_REJ 0x03
165 178
166 179
180void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s);
181void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s);
167struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); 182struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);
183struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local);
184int nfc_llcp_local_put(struct nfc_llcp_local *local);
168u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, 185u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,
169 struct nfc_llcp_sock *sock); 186 struct nfc_llcp_sock *sock);
170u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); 187u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local);
@@ -179,8 +196,10 @@ void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk);
179struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); 196struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock);
180 197
181/* TLV API */ 198/* TLV API */
182int nfc_llcp_parse_tlv(struct nfc_llcp_local *local, 199int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local,
183 u8 *tlv_array, u16 tlv_array_len); 200 u8 *tlv_array, u16 tlv_array_len);
201int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock,
202 u8 *tlv_array, u16 tlv_array_len);
184 203
185/* Commands API */ 204/* Commands API */
186void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); 205void nfc_llcp_recv(void *data, struct sk_buff *skb, int err);