Blame view
net/nfc/llcp.h
7.32 KB
d646960f7 NFC: Initial LLCP... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
/* * Copyright (C) 2011 Intel Corporation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License |
98b32decc nfc: Fix FSF addr... |
15 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
d646960f7 NFC: Initial LLCP... |
16 17 18 19 |
*/ enum llcp_state { LLCP_CONNECTED = 1, /* wait_for_packet() wants that */ |
b4011239a NFC: llcp: Fix no... |
20 |
LLCP_CONNECTING, |
17f7ae16a NFC: Keep socket ... |
21 |
LLCP_DISCONNECTING, |
d646960f7 NFC: Initial LLCP... |
22 23 24 25 26 27 28 29 |
LLCP_CLOSED, LLCP_BOUND, LLCP_LISTEN, }; #define LLCP_DEFAULT_LTO 100 #define LLCP_DEFAULT_RW 1 #define LLCP_DEFAULT_MIU 128 |
eda21f16a NFC: Set MIU and ... |
30 31 32 |
#define LLCP_MAX_LTO 0xff #define LLCP_MAX_RW 15 #define LLCP_MAX_MIUX 0x7ff |
66cbfa10f NFC: llcp: Use lo... |
33 |
#define LLCP_MAX_MIU (LLCP_MAX_MIUX + 128) |
eda21f16a NFC: Set MIU and ... |
34 |
|
d646960f7 NFC: Initial LLCP... |
35 36 37 38 39 |
#define LLCP_WKS_NUM_SAP 16 #define LLCP_SDP_NUM_SAP 16 #define LLCP_LOCAL_NUM_SAP 32 #define LLCP_LOCAL_SAP_OFFSET (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP) #define LLCP_MAX_SAP (LLCP_WKS_NUM_SAP + LLCP_SDP_NUM_SAP + LLCP_LOCAL_NUM_SAP) |
8f50020ed NFC: LLCP late bi... |
40 |
#define LLCP_SDP_UNBOUND (LLCP_MAX_SAP + 1) |
d646960f7 NFC: Initial LLCP... |
41 42 |
struct nfc_llcp_sock; |
a69f32af8 NFC: Socket linke... |
43 44 45 46 |
struct llcp_sock_list { struct hlist_head head; rwlock_t lock; }; |
e0ae7bac0 NFC: llcp: Servic... |
47 48 49 50 51 52 53 |
struct nfc_llcp_sdp_tlv { u8 *tlv; u8 tlv_len; char *uri; u8 tid; u8 sap; |
40213fa85 NFC: llcp: Add cl... |
54 |
unsigned long time; |
e0ae7bac0 NFC: llcp: Servic... |
55 56 |
struct hlist_node node; }; |
d646960f7 NFC: Initial LLCP... |
57 58 59 |
struct nfc_llcp_local { struct list_head list; struct nfc_dev *dev; |
c7aa12252 NFC: Take a refer... |
60 |
struct kref ref; |
d646960f7 NFC: Initial LLCP... |
61 |
struct mutex sdp_lock; |
d646960f7 NFC: Initial LLCP... |
62 63 64 |
struct timer_list link_timer; struct sk_buff_head tx_queue; |
d646960f7 NFC: Initial LLCP... |
65 |
struct work_struct tx_work; |
d646960f7 NFC: Initial LLCP... |
66 67 |
struct work_struct rx_work; struct sk_buff *rx_pending; |
d646960f7 NFC: Initial LLCP... |
68 69 70 71 72 |
struct work_struct timeout_work; u32 target_idx; u8 rf_mode; u8 comm_mode; |
52feb444a NFC: Extend netli... |
73 74 75 |
u8 lto; u8 rw; __be16 miux; |
d646960f7 NFC: Initial LLCP... |
76 77 78 |
unsigned long local_wks; /* Well known services */ unsigned long local_sdp; /* Local services */ unsigned long local_sap; /* Local SAPs, not available for discovery */ |
8f50020ed NFC: LLCP late bi... |
79 |
atomic_t local_sdp_cnt[LLCP_SDP_NUM_SAP]; |
d646960f7 NFC: Initial LLCP... |
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
/* local */ u8 gb[NFC_MAX_GT_LEN]; u8 gb_len; /* remote */ u8 remote_gb[NFC_MAX_GT_LEN]; u8 remote_gb_len; u8 remote_version; u16 remote_miu; u16 remote_lto; u8 remote_opt; u16 remote_wks; |
d646960f7 NFC: Initial LLCP... |
94 |
|
d9b8d8e19 NFC: llcp: Servic... |
95 96 |
struct mutex sdreq_lock; struct hlist_head pending_sdreqs; |
40213fa85 NFC: llcp: Add cl... |
97 98 |
struct timer_list sdreq_timer; struct work_struct sdreq_timeout_work; |
d9b8d8e19 NFC: llcp: Servic... |
99 |
u8 sdreq_next_tid; |
d646960f7 NFC: Initial LLCP... |
100 |
/* sockets array */ |
a69f32af8 NFC: Socket linke... |
101 102 |
struct llcp_sock_list sockets; struct llcp_sock_list connecting_sockets; |
4463523be NFC: LLCP raw soc... |
103 |
struct llcp_sock_list raw_sockets; |
d646960f7 NFC: Initial LLCP... |
104 105 106 107 |
}; struct nfc_llcp_sock { struct sock sk; |
d646960f7 NFC: Initial LLCP... |
108 109 110 111 |
struct nfc_dev *dev; struct nfc_llcp_local *local; u32 target_idx; u32 nfc_protocol; |
7a06e586b NFC: Move LLCP re... |
112 |
/* Link parameters */ |
d646960f7 NFC: Initial LLCP... |
113 114 115 116 |
u8 ssap; u8 dsap; char *service_name; size_t service_name_len; |
26fd76cab NFC: llcp: Implem... |
117 |
u8 rw; |
5eef66697 NFC: llcp: Socket... |
118 |
__be16 miux; |
26fd76cab NFC: llcp: Implem... |
119 |
|
e4306bec4 NFC: llcp: Rename... |
120 121 122 123 |
/* Remote link parameters */ u8 remote_rw; u16 remote_miu; |
d646960f7 NFC: Initial LLCP... |
124 125 126 127 128 129 130 131 132 |
/* Link variables */ u8 send_n; u8 send_ack_n; u8 recv_n; u8 recv_ack_n; /* Is the remote peer ready to receive */ u8 remote_ready; |
cbbf47218 NFC: Release LLCP... |
133 134 |
/* Reserved source SAP */ u8 reserved_ssap; |
d646960f7 NFC: Initial LLCP... |
135 136 |
struct sk_buff_head tx_queue; struct sk_buff_head tx_pending_queue; |
d646960f7 NFC: Initial LLCP... |
137 138 139 140 |
struct list_head accept_queue; struct sock *parent; }; |
968272bf0 NFC: Handle LLCP ... |
141 142 143 144 145 146 |
struct nfc_llcp_ui_cb { __u8 dsap; __u8 ssap; }; #define nfc_llcp_ui_skb_cb(__skb) ((struct nfc_llcp_ui_cb *)&((__skb)->cb[0])) |
d646960f7 NFC: Initial LLCP... |
147 148 149 150 151 |
#define nfc_llcp_sock(sk) ((struct nfc_llcp_sock *) (sk)) #define nfc_llcp_dev(sk) (nfc_llcp_sock((sk))->dev) #define LLCP_HEADER_SIZE 2 #define LLCP_SEQUENCE_SIZE 1 |
098dafcfb NFC: llcp: Aggreg... |
152 |
#define LLCP_AGF_PDU_HEADER_SIZE 2 |
d646960f7 NFC: Initial LLCP... |
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
/* LLCP versions: 1.1 is 1.0 plus SDP */ #define LLCP_VERSION_10 0x10 #define LLCP_VERSION_11 0x11 /* LLCP PDU types */ #define LLCP_PDU_SYMM 0x0 #define LLCP_PDU_PAX 0x1 #define LLCP_PDU_AGF 0x2 #define LLCP_PDU_UI 0x3 #define LLCP_PDU_CONNECT 0x4 #define LLCP_PDU_DISC 0x5 #define LLCP_PDU_CC 0x6 #define LLCP_PDU_DM 0x7 #define LLCP_PDU_FRMR 0x8 #define LLCP_PDU_SNL 0x9 #define LLCP_PDU_I 0xc #define LLCP_PDU_RR 0xd #define LLCP_PDU_RNR 0xe /* Parameters TLV types */ #define LLCP_TLV_VERSION 0x1 #define LLCP_TLV_MIUX 0x2 #define LLCP_TLV_WKS 0x3 #define LLCP_TLV_LTO 0x4 #define LLCP_TLV_RW 0x5 #define LLCP_TLV_SN 0x6 #define LLCP_TLV_OPT 0x7 #define LLCP_TLV_SDREQ 0x8 #define LLCP_TLV_SDRES 0x9 #define LLCP_TLV_MAX 0xa /* Well known LLCP SAP */ #define LLCP_SAP_SDP 0x1 #define LLCP_SAP_IP 0x2 #define LLCP_SAP_OBEX 0x3 #define LLCP_SAP_SNEP 0x4 #define LLCP_SAP_MAX 0xff /* Disconnection reason code */ #define LLCP_DM_DISC 0x00 #define LLCP_DM_NOCONN 0x01 #define LLCP_DM_NOBOUND 0x02 #define LLCP_DM_REJ 0x03 |
a69f32af8 NFC: Socket linke... |
197 198 |
void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *s); void nfc_llcp_sock_unlink(struct llcp_sock_list *l, struct sock *s); |
abd18d433 NFC: llcp: Reset ... |
199 |
void nfc_llcp_socket_remote_param_init(struct nfc_llcp_sock *sock); |
d646960f7 NFC: Initial LLCP... |
200 |
struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev); |
c7aa12252 NFC: Take a refer... |
201 202 |
struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local); int nfc_llcp_local_put(struct nfc_llcp_local *local); |
d646960f7 NFC: Initial LLCP... |
203 |
u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local, |
427a2eb1f NFC: LLCP code id... |
204 |
struct nfc_llcp_sock *sock); |
d646960f7 NFC: Initial LLCP... |
205 206 |
u8 nfc_llcp_get_local_ssap(struct nfc_llcp_local *local); void nfc_llcp_put_ssap(struct nfc_llcp_local *local, u8 ssap); |
d094afa15 NFC: Send LLCP RR... |
207 |
int nfc_llcp_queue_i_frames(struct nfc_llcp_sock *sock); |
4463523be NFC: LLCP raw soc... |
208 209 |
void nfc_llcp_send_to_raw_sock(struct nfc_llcp_local *local, struct sk_buff *skb, u8 direction); |
d646960f7 NFC: Initial LLCP... |
210 211 |
/* Sock API */ |
11aa9c28b net: Pass kern fr... |
212 |
struct sock *nfc_llcp_sock_alloc(struct socket *sock, int type, gfp_t gfp, int kern); |
d646960f7 NFC: Initial LLCP... |
213 214 215 216 217 218 |
void nfc_llcp_sock_free(struct nfc_llcp_sock *sock); void nfc_llcp_accept_unlink(struct sock *sk); void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk); struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock); /* TLV API */ |
7a06e586b NFC: Move LLCP re... |
219 220 221 222 |
int nfc_llcp_parse_gb_tlv(struct nfc_llcp_local *local, u8 *tlv_array, u16 tlv_array_len); int nfc_llcp_parse_connection_tlv(struct nfc_llcp_sock *sock, u8 *tlv_array, u16 tlv_array_len); |
d646960f7 NFC: Initial LLCP... |
223 224 225 226 |
/* Commands API */ void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); u8 *nfc_llcp_build_tlv(u8 type, u8 *value, u8 value_length, u8 *tlv_length); |
e0ae7bac0 NFC: llcp: Servic... |
227 |
struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdres_tlv(u8 tid, u8 sap); |
d9b8d8e19 NFC: llcp: Servic... |
228 229 |
struct nfc_llcp_sdp_tlv *nfc_llcp_build_sdreq_tlv(u8 tid, char *uri, size_t uri_len); |
e0ae7bac0 NFC: llcp: Servic... |
230 |
void nfc_llcp_free_sdp_tlv(struct nfc_llcp_sdp_tlv *sdp); |
d9b8d8e19 NFC: llcp: Servic... |
231 |
void nfc_llcp_free_sdp_tlv_list(struct hlist_head *sdp_head); |
d646960f7 NFC: Initial LLCP... |
232 |
void nfc_llcp_recv(void *data, struct sk_buff *skb, int err); |
d646960f7 NFC: Initial LLCP... |
233 234 235 |
int nfc_llcp_send_symm(struct nfc_dev *dev); int nfc_llcp_send_connect(struct nfc_llcp_sock *sock); int nfc_llcp_send_cc(struct nfc_llcp_sock *sock); |
e0ae7bac0 NFC: llcp: Servic... |
236 237 |
int nfc_llcp_send_snl_sdres(struct nfc_llcp_local *local, struct hlist_head *tlv_list, size_t tlvs_len); |
d9b8d8e19 NFC: llcp: Servic... |
238 239 |
int nfc_llcp_send_snl_sdreq(struct nfc_llcp_local *local, struct hlist_head *tlv_list, size_t tlvs_len); |
d646960f7 NFC: Initial LLCP... |
240 241 |
int nfc_llcp_send_dm(struct nfc_llcp_local *local, u8 ssap, u8 dsap, u8 reason); int nfc_llcp_send_disconnect(struct nfc_llcp_sock *sock); |
53a0ac2ee NFC: LLCP socket ... |
242 |
int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, |
427a2eb1f NFC: LLCP code id... |
243 |
struct msghdr *msg, size_t len); |
94f418a20 NFC: UI frame sen... |
244 245 |
int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap, struct msghdr *msg, size_t len); |
d094afa15 NFC: Send LLCP RR... |
246 |
int nfc_llcp_send_rr(struct nfc_llcp_sock *sock); |
d646960f7 NFC: Initial LLCP... |
247 248 249 250 |
/* Socket API */ int __init nfc_llcp_sock_init(void); void nfc_llcp_sock_exit(void); |