Commit 064f370c5fd982e1264c03f5b704e00f5e41eb36
Committed by
Samuel Ortiz
1 parent
abd18d4330
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
NFC: llcp: Add support in getsockopt for RW, LTO, and MIU remote parameters
Useful for LLCP validation tests. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Showing 2 changed files with 27 additions and 3 deletions Side-by-side Diff
include/uapi/linux/nfc.h
... | ... | @@ -233,8 +233,11 @@ |
233 | 233 | #define NFC_LLCP_DIRECTION_TX 0x01 |
234 | 234 | |
235 | 235 | /* socket option names */ |
236 | -#define NFC_LLCP_RW 0 | |
237 | -#define NFC_LLCP_MIUX 1 | |
236 | +#define NFC_LLCP_RW 0 | |
237 | +#define NFC_LLCP_MIUX 1 | |
238 | +#define NFC_LLCP_REMOTE_MIU 2 | |
239 | +#define NFC_LLCP_REMOTE_LTO 3 | |
240 | +#define NFC_LLCP_REMOTE_RW 4 | |
238 | 241 | |
239 | 242 | #endif /*__LINUX_NFC_H */ |
net/nfc/llcp/sock.c
... | ... | @@ -303,7 +303,7 @@ |
303 | 303 | struct sock *sk = sock->sk; |
304 | 304 | struct nfc_llcp_sock *llcp_sock = nfc_llcp_sock(sk); |
305 | 305 | int len, err = 0; |
306 | - u16 miux; | |
306 | + u16 miux, remote_miu; | |
307 | 307 | u8 rw; |
308 | 308 | |
309 | 309 | pr_debug("%p optname %d\n", sk, optname); |
... | ... | @@ -335,6 +335,27 @@ |
335 | 335 | be16_to_cpu(local->miux) : be16_to_cpu(llcp_sock->miux); |
336 | 336 | |
337 | 337 | if (put_user(miux, (u32 __user *) optval)) |
338 | + err = -EFAULT; | |
339 | + | |
340 | + break; | |
341 | + | |
342 | + case NFC_LLCP_REMOTE_MIU: | |
343 | + remote_miu = llcp_sock->remote_miu > LLCP_MAX_MIU ? | |
344 | + local->remote_miu : llcp_sock->remote_miu; | |
345 | + | |
346 | + if (put_user(remote_miu, (u32 __user *) optval)) | |
347 | + err = -EFAULT; | |
348 | + | |
349 | + break; | |
350 | + | |
351 | + case NFC_LLCP_REMOTE_LTO: | |
352 | + if (put_user(local->remote_lto / 10, (u32 __user *) optval)) | |
353 | + err = -EFAULT; | |
354 | + | |
355 | + break; | |
356 | + | |
357 | + case NFC_LLCP_REMOTE_RW: | |
358 | + if (put_user(llcp_sock->remote_rw, (u32 __user *) optval)) | |
338 | 359 | err = -EFAULT; |
339 | 360 | |
340 | 361 | break; |