# 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/netrom.h>
include <asm/ioctls.h>

resource sock_netrom[sock]

socket$netrom(domain const[AF_NETROM], type const[SOCK_SEQPACKET], proto const[0]) sock_netrom
bind$netrom(fd sock_netrom, addr ptr[in, sockaddr_netrom], addrlen len[addr])
connect$netrom(fd sock_netrom, addr ptr[in, sockaddr_netrom], addrlen len[addr])
accept$netrom(fd sock_netrom, peer ptr[out, sockaddr_netrom, opt], peerlen ptr[inout, len[peer, int32]]) sock_netrom
accept4$netrom(fd sock_netrom, peer ptr[out, sockaddr_netrom, opt], peerlen ptr[inout, len[peer, int32]], flags flags[accept_flags]) sock_netrom
listen$netrom(fd sock_netrom, backlog int32)
sendmsg$netrom(fd sock_netrom, msg ptr[in, msghdr_netrom], f flags[send_flags])
recvmsg$netrom(fd sock_netrom, msg ptr[in, msghdr_netrom], f flags[recv_flags])
getsockname$netrom(fd sock_netrom, addr ptr[out, sockaddr_netrom], addrlen ptr[inout, len[addr, int32]])
getpeername$netrom(fd sock_netrom, peer ptr[out, sockaddr_netrom], peerlen ptr[inout, len[peer, int32]])

setsockopt$netrom_NETROM_T1(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T1], arg ptr[in, int32], arglen len[arg])
setsockopt$netrom_NETROM_T2(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T2], arg ptr[in, int32], arglen len[arg])
setsockopt$netrom_NETROM_N2(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_N2], arg ptr[in, int32], arglen len[arg])
setsockopt$netrom_NETROM_T4(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T4], arg ptr[in, int32], arglen len[arg])
setsockopt$netrom_NETROM_IDLE(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_IDLE], arg ptr[in, int32], arglen len[arg])

getsockopt$netrom_NETROM_T1(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T1], arg ptr[out, int32], arglen ptr[inout, len[arg, int32]])
getsockopt$netrom_NETROM_T2(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T2], arg ptr[in, int32], arglen ptr[inout, len[arg, int32]])
getsockopt$netrom_NETROM_N2(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_N2], arg ptr[in, int32], arglen ptr[inout, len[arg, int32]])
getsockopt$netrom_NETROM_T4(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_T4], arg ptr[in, int32], arglen ptr[inout, len[arg, int32]])
getsockopt$netrom_NETROM_IDLE(fd sock_netrom, level const[SOL_NETROM], opt const[NETROM_IDLE], arg ptr[in, int32], arglen ptr[inout, len[arg, int32]])

# TODO: make these more generic
ioctl$sock_netrom_TIOCOUTQ(fd sock_netrom, cmd const[TIOCOUTQ], arg ptr[out, int32])
ioctl$sock_netrom_TIOCINQ(fd sock_netrom, cmd const[TIOCINQ], arg ptr[out, int32])
ioctl$sock_netrom_SIOCGSTAMP(fd sock_netrom, cmd const[SIOCGSTAMP], arg ptr[out, int32])
ioctl$sock_netrom_SIOCGSTAMPNS(fd sock_netrom, cmd const[SIOCGSTAMPNS], arg ptr[out, int32])
ioctl$sock_netrom_SIOCADDRT(fd sock_netrom, cmd const[SIOCADDRT], arg ptr[out, int32])

sockaddr_netrom [
	ax25	sockaddr_ax25
	full	full_sockaddr_ax25
] [varlen]

msghdr_netrom {
	addr	ptr[in, sockaddr_netrom]
	addrlen	len[addr, int32]
	vec	ptr[in, array[iovec_in]]
	vlen	len[vec, intptr]
	ctrl	ptr[in, array[cmsghdr], opt]
	ctrllen	bytesize[ctrl, intptr]
	f	flags[send_flags, int32]
}