summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authordima <dima.ky@gmail.com>2010-10-13 14:53:34 (GMT)
committerThomas Graf <tgraf@suug.ch>2010-10-14 11:46:02 (GMT)
commit2dbc1ca76c5b82c40749e609eb83877418abb006 (patch)
tree982336cb3676345e7ab79dcb5a881ceac7f7d36c /include
parent513e45ccce5ae286fc67fde1a1bf703e9c8d83aa (diff)
downloadlibnl-2dbc1ca76c5b82c40749e609eb83877418abb006.zip
libnl-2dbc1ca76c5b82c40749e609eb83877418abb006.tar.gz
libnl-2dbc1ca76c5b82c40749e609eb83877418abb006.tar.bz2
Generic Netlink multicast groups support
I have a patch against commit d378220c96c3c8b6f27dca33e7d8ba03318f9c2d extending libnl with a facility to receive generic netlink messages sent to multicast groups. Essentially it add one new function genl_ctrl_resolve_grp which prototype looks like this int genl_ctrl_resolve_grp(struct nl_sock *sk, const char *family_name, const char *grp_name) It resolves the family name and the group name to group id. Then the returned id can be used in nl_socket_add_membership to subscribe to multicast messages. Besides that it adds two more functions uint32_t nl_socket_get_peer_groups(struct nl_sock *sk) void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups) allowing to modify the socket peer groups field. So it's possible to multicast messages from the user space using the legacy interface. Looks like there is no way (or I was not able to find one?) to modify the netlink socket destination group from the user space, when the group id is greater then 32.
Diffstat (limited to 'include')
-rw-r--r--include/linux/genetlink.h14
-rw-r--r--include/netlink-types.h8
-rw-r--r--include/netlink/genl/ctrl.h3
-rw-r--r--include/netlink/genl/family.h3
-rw-r--r--include/netlink/genl/genl.h1
-rw-r--r--include/netlink/socket.h3
6 files changed, 30 insertions, 2 deletions
diff --git a/include/linux/genetlink.h b/include/linux/genetlink.h
index f7a9377..b834ef6 100644
--- a/include/linux/genetlink.h
+++ b/include/linux/genetlink.h
@@ -1,6 +1,7 @@
#ifndef __LINUX_GENERIC_NETLINK_H
#define __LINUX_GENERIC_NETLINK_H
+#include <linux/types.h>
#include <linux/netlink.h>
#define GENL_NAMSIZ 16 /* length of family name */
@@ -39,6 +40,9 @@ enum {
CTRL_CMD_NEWOPS,
CTRL_CMD_DELOPS,
CTRL_CMD_GETOPS,
+ CTRL_CMD_NEWMCAST_GRP,
+ CTRL_CMD_DELMCAST_GRP,
+ CTRL_CMD_GETMCAST_GRP, /* unused */
__CTRL_CMD_MAX,
};
@@ -52,6 +56,7 @@ enum {
CTRL_ATTR_HDRSIZE,
CTRL_ATTR_MAXATTR,
CTRL_ATTR_OPS,
+ CTRL_ATTR_MCAST_GROUPS,
__CTRL_ATTR_MAX,
};
@@ -66,4 +71,13 @@ enum {
#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
+enum {
+ CTRL_ATTR_MCAST_GRP_UNSPEC,
+ CTRL_ATTR_MCAST_GRP_NAME,
+ CTRL_ATTR_MCAST_GRP_ID,
+ __CTRL_ATTR_MCAST_GRP_MAX,
+};
+
+#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
+
#endif /* __LINUX_GENERIC_NETLINK_H */
diff --git a/include/netlink-types.h b/include/netlink-types.h
index ff699bb..1ffb70c 100644
--- a/include/netlink-types.h
+++ b/include/netlink-types.h
@@ -702,6 +702,13 @@ struct genl_family_op
struct nl_list_head o_list;
};
+struct genl_family_grp {
+ struct genl_family *family; /* private */
+ struct nl_list_head list; /* private */
+ char name[GENL_NAMSIZ];
+ u_int32_t id;
+};
+
struct genl_family
{
NLHDR_COMMON
@@ -713,6 +720,7 @@ struct genl_family
uint32_t gf_maxattr;
struct nl_list_head gf_ops;
+ struct nl_list_head gf_mc_grps;
};
union nfnl_ct_proto
diff --git a/include/netlink/genl/ctrl.h b/include/netlink/genl/ctrl.h
index 1ae62f4..26a0a99 100644
--- a/include/netlink/genl/ctrl.h
+++ b/include/netlink/genl/ctrl.h
@@ -29,6 +29,9 @@ extern struct genl_family * genl_ctrl_search_by_name(struct nl_cache *,
const char *);
extern int genl_ctrl_resolve(struct nl_sock *,
const char *);
+extern int genl_ctrl_resolve_grp(struct nl_sock *sk,
+ const char *family,
+ const char *grp);
#ifdef __cplusplus
}
diff --git a/include/netlink/genl/family.h b/include/netlink/genl/family.h
index 74319e5..721dc13 100644
--- a/include/netlink/genl/family.h
+++ b/include/netlink/genl/family.h
@@ -42,6 +42,9 @@ extern void genl_family_set_maxattr(struct genl_family *,
extern int genl_family_add_op(struct genl_family *,
int, int);
+extern int genl_family_add_grp(struct genl_family *,
+ uint32_t , const char *);
+
#ifdef __cplusplus
}
diff --git a/include/netlink/genl/genl.h b/include/netlink/genl/genl.h
index 3f3340c..364a471 100644
--- a/include/netlink/genl/genl.h
+++ b/include/netlink/genl/genl.h
@@ -21,7 +21,6 @@ extern "C" {
#endif
extern int genl_connect(struct nl_sock *);
-
extern int genl_send_simple(struct nl_sock *, int, int,
int, int);
diff --git a/include/netlink/socket.h b/include/netlink/socket.h
index 7e71aed..31a36d3 100644
--- a/include/netlink/socket.h
+++ b/include/netlink/socket.h
@@ -37,7 +37,8 @@ extern void nl_join_groups(struct nl_sock *, int);
extern uint32_t nl_socket_get_peer_port(struct nl_sock *);
extern void nl_socket_set_peer_port(struct nl_sock *,
uint32_t);
-
+extern uint32_t nl_socket_get_peer_groups(struct nl_sock *sk);
+extern void nl_socket_set_peer_groups(struct nl_sock *sk, uint32_t groups);
extern struct nl_cb * nl_socket_get_cb(struct nl_sock *);
extern void nl_socket_set_cb(struct nl_sock *,
struct nl_cb *);