1# Copyright 2017 syzkaller project authors. All rights reserved.
2# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3
4# AF_NFC support.
5
6include <linux/socket.h>
7include <linux/net.h>
8include <uapi/linux/nfc.h>
9
10resource sock_nfc_llcp[sock]
11
12syz_init_net_socket$nfc_llcp(domain const[AF_NFC], type flags[nfc_llcp_type], proto const[NFC_SOCKPROTO_LLCP]) sock_nfc_llcp
13bind$nfc_llcp(fd sock_nfc_llcp, addr ptr[in, sockaddr_nfc_llcp], addrlen len[addr])
14connect$nfc_llcp(fd sock_nfc_llcp, addr ptr[in, sockaddr_nfc_llcp], addrlen len[addr])
15accept$nfc_llcp(fd sock_nfc_llcp, peer ptr[out, sockaddr_nfc_llcp, opt], peerlen ptr[inout, len[peer, int32]]) sock_nfc_llcp
16accept4$nfc_llcp(fd sock_nfc_llcp, peer ptr[out, sockaddr_nfc_llcp, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock_nfc_llcp
17setsockopt$nfc_llcp_NFC_LLCP_RW(fd sock_nfc_llcp, level const[SOL_NFC], opt const[NFC_LLCP_RW], arg ptr[in, int32], arglen len[arg])
18setsockopt$nfc_llcp_NFC_LLCP_MIUX(fd sock_nfc_llcp, level const[SOL_NFC], opt const[NFC_LLCP_MIUX], arg ptr[in, int32], arglen len[arg])
19getsockopt$nfc_llcp(fd sock_nfc_llcp, level const[SOL_NFC], opt flags[nfc_llcp_opts], arg buffer[out], arglen len[arg])
20sendmsg$nfc_llcp(fd sock_nfc_llcp, msg ptr[in, nfc_llcp_send_msghdr], f flags[send_flags])
21sendmmsg$nfc_llcp(fd sock_nfc_llcp, mmsg ptr[in, array[nfc_llcp_send_msghdr]], vlen len[mmsg], f flags[send_flags])
22
23resource sock_nfc_raw[sock]
24
25syz_init_net_socket$nfc_raw(domain const[AF_NFC], type flags[nfc_raw_type], proto const[NFC_SOCKPROTO_RAW]) sock_nfc_raw
26connect$nfc_raw(fd sock_nfc_raw, addr ptr[in, sockaddr_nfc], addrlen len[addr])
27
28nfc_llcp_type = SOCK_STREAM, SOCK_DGRAM, SOCK_RAW
29nfc_raw_type = SOCK_STREAM, SOCK_RAW
30nfc_proto = NFC_PROTO_JEWEL, NFC_PROTO_MIFARE, NFC_PROTO_FELICA, NFC_PROTO_ISO14443, NFC_PROTO_NFC_DEP, NFC_PROTO_ISO14443_B, NFC_PROTO_ISO15693
31nfc_llcp_opts = NFC_LLCP_RW, NFC_LLCP_MIUX, NFC_LLCP_REMOTE_MIU, NFC_LLCP_REMOTE_LTO, NFC_LLCP_REMOTE_RW
32
33sockaddr_nfc_llcp {
34	family		const[AF_NFC, int16]
35	devidx		int32[0:1]
36	target		int32[0:2]
37	proto		flags[nfc_proto, int32]
38	dsap		int8
39	ssap		int8
40	service_name	array[int8, NFC_LLCP_MAX_SERVICE_NAME]
41	servlen		intptr[0:NFC_LLCP_MAX_SERVICE_NAME]
42}
43
44sockaddr_nfc {
45	sa_family	const[AF_NFC, int16]
46	dev_idx		int32[0:1]
47	target_idx	int32[0:2]
48	nfc_protocol	flags[nfc_proto, int32]
49}
50
51nfc_llcp_send_msghdr {
52	addr	ptr[in, sockaddr_nfc_llcp]
53	addrlen	len[addr, int32]
54	vec	ptr[in, array[iovec_in]]
55	vlen	len[vec, intptr]
56	ctrl	ptr[in, cmsghdr, opt]
57	ctrllen	bytesize[ctrl, intptr]
58	f	flags[send_flags, int32]
59}
60