# Copyright 2017 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.

# AF_NETLINK/NETLINK_GENERIC support.

# TODO: describe APIs of specific genetlink families.

include <linux/net.h>
include <uapi/linux/netlink.h>
include <uapi/linux/genetlink.h>

resource sock_nl_generic[sock_netlink]

socket$nl_generic(domain const[AF_NETLINK], type const[SOCK_RAW], proto const[NETLINK_GENERIC]) sock_nl_generic

sendmsg$nl_generic(fd sock_nl_generic, msg ptr[in, msghdr_nl_generic], f flags[send_flags])

type msghdr_nl_generic msghdr_netlink[netlink_msg_t[netlink_random_msg_type, genlmsghdr, nl_generic_attr]]

genlmsghdr {
	cmd		int8[0:32]
	version		const[0, int8]
	reserved	const[0, int16]
} [align_4]

type genlmsghdr_t[CMD] {
	cmd		const[CMD, int8]
	version		const[0, int8]
	reserved	const[0, int16]
} [align_4]