aboutsummaryrefslogtreecommitdiffstats
path: root/package/libnl-tiny/src/include/netlink/genl/mngt.h
blob: 8b0244f2cca13a7c3c13c851830a57e3608b09b4 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * netlink/genl/mngt.h		Generic Netlink Management
 *
 *	This library is free software; you can redistribute it and/or
 *	modify it under the terms of the GNU Lesser General Public
 *	License as published by the Free Software Foundation version 2.1
 *	of the License.
 *
 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
 */

#ifndef NETLINK_GENL_MNGT_H_
#define NETLINK_GENL_MNGT_H_

#include <netlink/netlink.h>
#include <netlink/attr.h>
#include <netlink/list.h>

#ifdef __cplusplus
extern "C" {
#endif

struct nl_cache_ops;

struct genl_info
{
	struct sockaddr_nl *    who;
	struct nlmsghdr *       nlh;
	struct genlmsghdr *     genlhdr;
	void *                  userhdr;
	struct nlattr **        attrs;
};

/**
 * @ingroup genl_mngt
 * Generic Netlink Command
 */
struct genl_cmd
{
	/** Unique command identifier */
	int			c_id;

	/** Name/description of command */
	char *			c_name;

	/**
	 * Maximum attribute identifier, must be provided if
	 * a message parser is available.
	 */
	int			c_maxattr;

	int		      (*c_msg_parser)(struct nl_cache_ops *,
					      struct genl_cmd *,
					      struct genl_info *, void *);

	/**
	 * Attribute validation policy (optional)
	 */
	struct nla_policy *	c_attr_policy;
};

/**
 * @ingroup genl_mngt
 * Generic Netlink Operations
 */
struct genl_ops
{
	int			o_family;
	int			o_id;
	char *			o_name;
	struct nl_cache_ops *	o_cache_ops;
	struct genl_cmd	*	o_cmds;
	int			o_ncmds;

	/* linked list of all genl cache operations */
	struct nl_list_head	o_list;
};


extern int		genl_register(struct nl_cache_ops *);
extern void		genl_unregister(struct nl_cache_ops *);

#ifdef __cplusplus
}
#endif

#endif