aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux/test/nfc
blob: 8dfff2457d2d4b293b5a2390f808b48b3376e89d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Create NCI NFC device.

r0 = openat$nci(AUTO, &AUTO, AUTO, AUTO)
ioctl$IOCTL_GET_NCIDEV_IDX(r0, AUTO, &AUTO=<r1=>0x0)

# Up the device.

r2 = syz_init_net_socket$nl_generic(AUTO, AUTO, AUTO)
r3 = syz_genetlink_get_family_id$nfc(&AUTO, r2)
sendmsg$NFC_CMD_DEV_UP(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)

# Mock communication with the device.
# NCI core should send reset, init and discover commands.

read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_CORE_RESET_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, 0x0}}, AUTO)
read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_CORE_INIT_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {{0x0, 0x0, 0x0, ""}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, AUTO)
read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_MAP_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, 0x0}, AUTO)

# Enable polling.

sendmsg$NFC_CMD_START_POLL(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}, @NFC_ATTR_PROTOCOLS={AUTO, AUTO, 0xffffffff, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)

read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_CORE_SET_CONFIG_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, ""}}, AUTO)
read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_CORE_SET_CONFIG_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, ""}}, AUTO)
read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, 0x0}, AUTO)

# Pretend we discovered target 0.

write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_NTF={AUTO, 0x0, AUTO, AUTO, 0x0, @b={0x0, 0x1, AUTO, 0x1, {0x1, "aa"}, 0x0}}, AUTO)

# Activate target 0.

sendmsg$NFC_CMD_ACTIVATE_TARGET(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}, @NFC_ATTR_TARGET_INDEX={AUTO, AUTO, 0x0, nil}, @NFC_ATTR_PROTOCOLS={AUTO, AUTO, 0x1, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)

read$nci(r0, &AUTO=""/100, AUTO)
write$nci(r0, &AUTO=@NCI_OP_CORE_CONN_CREATE_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, 0x0, 0x1}}, AUTO)