#ifndef GENL_MAGIC_FUNC_H
#define GENL_MAGIC_FUNC_H
#include <linux/args.h>
#include <linux/build_bug.h>
#include <linux/genl_magic_struct.h>
#undef GENL_mc_group
#define GENL_mc_group(group) …
#undef GENL_notification
#define GENL_notification(op_name, op_num, mcast_group, tla_list) …
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) …
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) …
static struct nla_policy CONCATENATE(GENL_MAGIC_FAMILY, _tla_nl_policy)[] = …;
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) …
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, _type, __get, \
__put, __is_signed) …
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, _type, maxlen, \
__get, __put, __is_signed) …
#include GENL_MAGIC_INCLUDE_FILE
#ifndef __KERNEL__
#ifndef pr_info
#define pr_info …
#endif
#endif
#ifdef GENL_MAGIC_DEBUG
static void dprint_field(const char *dir, int nla_type,
const char *name, void *valp)
{
__u64 val = valp ? *(__u32 *)valp : 1;
switch (nla_type) {
case NLA_U8: val = (__u8)val;
case NLA_U16: val = (__u16)val;
case NLA_U32: val = (__u32)val;
pr_info("%s attr %s: %d 0x%08x\n", dir,
name, (int)val, (unsigned)val);
break;
case NLA_U64:
val = *(__u64*)valp;
pr_info("%s attr %s: %lld 0x%08llx\n", dir,
name, (long long)val, (unsigned long long)val);
break;
case NLA_FLAG:
if (val)
pr_info("%s attr %s: set\n", dir, name);
break;
}
}
static void dprint_array(const char *dir, int nla_type,
const char *name, const char *val, unsigned len)
{
switch (nla_type) {
case NLA_NUL_STRING:
if (len && val[len-1] == '\0')
len--;
pr_info("%s attr %s: [len:%u] '%s'\n", dir, name, len, val);
break;
default:
pr_info("%s attr %s: [len:%u] %02x%02x%02x%02x ...\n",
dir, name, len, val[0], val[1], val[2], val[3]);
}
}
#define DPRINT_TLA …
#define DPRINT_FIELD …
#define DPRINT_ARRAY …
#else
#define DPRINT_TLA(a, op, b) …
#define DPRINT_FIELD(dir, nla_type, name, s, nla) …
#define DPRINT_ARRAY(dir, nla_type, name, s, nla) …
#endif
static struct nlattr *nested_attr_tb[128];
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) … \
#define __assign(attr_nr, attr_flag, name, nla_type, type, assignment...) …
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) …
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) …
#include GENL_MAGIC_INCLUDE_FILE
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) …
static const char *CONCATENATE(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
{ … }
#ifdef __KERNEL__
#include <linux/stringify.h>
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) …
#define ZZZ_genl_ops …
static struct genl_ops ZZZ_genl_ops[] __read_mostly = …;
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) …
#define ZZZ_genl_family …
static struct genl_family ZZZ_genl_family;
#define ZZZ_genl_mcgrps …
static const struct genl_multicast_group ZZZ_genl_mcgrps[] = …;
enum CONCATENATE(GENL_MAGIC_FAMILY, group_ids) { … };
#undef GENL_mc_group
#define GENL_mc_group(group) …
#include GENL_MAGIC_INCLUDE_FILE
#undef GENL_mc_group
#define GENL_mc_group(group) …
static struct genl_family ZZZ_genl_family __ro_after_init = …;
int CONCATENATE(GENL_MAGIC_FAMILY, _genl_register)(void)
{ … }
void CONCATENATE(GENL_MAGIC_FAMILY, _genl_unregister)(void)
{ … }
#undef GENL_op
#define GENL_op(op_name, op_num, handler, tla_list) …
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) …
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) …
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) …
#include GENL_MAGIC_INCLUDE_FILE
#undef __field
#define __field(attr_nr, attr_flag, name, nla_type, type, __get, __put, \
__is_signed) …
#undef __array
#define __array(attr_nr, attr_flag, name, nla_type, type, maxlen, \
__get, __put, __is_signed) …
#undef __u32_field_def
#define __u32_field_def(attr_nr, attr_flag, name, default) …
#undef __s32_field_def
#define __s32_field_def(attr_nr, attr_flag, name, default) …
#undef __flg_field_def
#define __flg_field_def(attr_nr, attr_flag, name, default) …
#undef __str_field_def
#define __str_field_def(attr_nr, attr_flag, name, maxlen) …
#undef GENL_struct
#define GENL_struct(tag_name, tag_number, s_name, s_fields) …
#include GENL_MAGIC_INCLUDE_FILE
#endif
#endif