# Copyright 2016 syzkaller project authors. All rights reserved.
# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.

include <linux/net.h>
include <linux/kcm.h>
include <linux/sockios.h>

resource sock_kcm[sock]

socket$kcm(domain const[AF_KCM], type flags[kcm_socket_type], proto const[KCMPROTO_CONNECTED]) sock_kcm
setsockopt$kcm_KCM_RECV_DISABLE(fd sock_kcm, level const[SOL_KCM], opt const[KCM_RECV_DISABLE], val ptr[in, int32], len len[val])
getsockopt$kcm_KCM_RECV_DISABLE(fd sock_kcm, level const[SOL_KCM], opt const[KCM_RECV_DISABLE], val ptr[out, int32], len len[val])
sendmsg$kcm(fd sock_kcm, msg ptr[in, send_msghdr], f flags[send_flags])
recvmsg$kcm(fd sock_kcm, msg ptr[in, recv_msghdr], f flags[recv_flags])

ioctl$sock_kcm_SIOCKCMATTACH(fd sock_kcm, cmd const[SIOCKCMATTACH], arg ptr[in, kcm_attach])
ioctl$sock_kcm_SIOCKCMUNATTACH(fd sock_kcm, cmd const[SIOCKCMUNATTACH], arg ptr[in, kcm_unattach])
ioctl$sock_kcm_SIOCKCMCLONE(fd sock_kcm, cmd const[SIOCKCMCLONE], arg ptr[inout, kcm_clone])

kcm_socket_type = SOCK_DGRAM, SOCK_SEQPACKET

kcm_attach {
	fd	sock
	bpf_fd	fd_bpf_prog
}

kcm_unattach {
	fd	sock
}

kcm_clone {
	fd	sock
}