Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
genetlink.c File Reference
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/errno.h>
#include <linux/types.h>
#include <linux/socket.h>
#include <linux/string.h>
#include <linux/skbuff.h>
#include <linux/mutex.h>
#include <linux/bitmap.h>
#include <net/sock.h>
#include <net/genetlink.h>

Go to the source code of this file.

Macros

#define GENL_FAM_TAB_SIZE   16
 
#define GENL_FAM_TAB_MASK   (GENL_FAM_TAB_SIZE - 1)
 

Functions

void genl_lock (void)
 
 EXPORT_SYMBOL (genl_lock)
 
void genl_unlock (void)
 
 EXPORT_SYMBOL (genl_unlock)
 
int genl_register_mc_group (struct genl_family *family, struct genl_multicast_group *grp)
 
 EXPORT_SYMBOL (genl_register_mc_group)
 
void genl_unregister_mc_group (struct genl_family *family, struct genl_multicast_group *grp)
 
 EXPORT_SYMBOL (genl_unregister_mc_group)
 
int genl_register_ops (struct genl_family *family, struct genl_ops *ops)
 
 EXPORT_SYMBOL (genl_register_ops)
 
int genl_unregister_ops (struct genl_family *family, struct genl_ops *ops)
 
 EXPORT_SYMBOL (genl_unregister_ops)
 
int genl_register_family (struct genl_family *family)
 
 EXPORT_SYMBOL (genl_register_family)
 
int genl_register_family_with_ops (struct genl_family *family, struct genl_ops *ops, size_t n_ops)
 
 EXPORT_SYMBOL (genl_register_family_with_ops)
 
int genl_unregister_family (struct genl_family *family)
 
 EXPORT_SYMBOL (genl_unregister_family)
 
voidgenlmsg_put (struct sk_buff *skb, u32 portid, u32 seq, struct genl_family *family, int flags, u8 cmd)
 
 EXPORT_SYMBOL (genlmsg_put)
 
 subsys_initcall (genl_init)
 
int genlmsg_multicast_allns (struct sk_buff *skb, u32 portid, unsigned int group, gfp_t flags)
 
 EXPORT_SYMBOL (genlmsg_multicast_allns)
 
void genl_notify (struct sk_buff *skb, struct net *net, u32 portid, u32 group, struct nlmsghdr *nlh, gfp_t flags)
 
 EXPORT_SYMBOL (genl_notify)
 

Macro Definition Documentation

#define GENL_FAM_TAB_MASK   (GENL_FAM_TAB_SIZE - 1)

Definition at line 45 of file genetlink.c.

#define GENL_FAM_TAB_SIZE   16

Definition at line 44 of file genetlink.c.

Function Documentation

EXPORT_SYMBOL ( genl_lock  )
EXPORT_SYMBOL ( genl_unlock  )
EXPORT_SYMBOL ( genl_register_mc_group  )
EXPORT_SYMBOL ( genl_unregister_mc_group  )
EXPORT_SYMBOL ( genl_register_ops  )
EXPORT_SYMBOL ( genl_unregister_ops  )
EXPORT_SYMBOL ( genl_register_family  )
EXPORT_SYMBOL ( genl_register_family_with_ops  )
EXPORT_SYMBOL ( genl_unregister_family  )
EXPORT_SYMBOL ( genlmsg_put  )
EXPORT_SYMBOL ( genlmsg_multicast_allns  )
EXPORT_SYMBOL ( genl_notify  )
void genl_lock ( void  )

Definition at line 24 of file genetlink.c.

void genl_notify ( struct sk_buff skb,
struct net net,
u32  portid,
u32  group,
struct nlmsghdr nlh,
gfp_t  flags 
)

Definition at line 1010 of file genetlink.c.

int genl_register_family ( struct genl_family family)

genl_register_family - register a generic netlink family : generic netlink family

Registers the specified family after validating it first. Only one family may be registered with the same family name or identifier. The family id may equal GENL_ID_GENERATE causing an unique id to be automatically generated and assigned.

Return 0 on success or a negative error code.

Definition at line 362 of file genetlink.c.

int genl_register_family_with_ops ( struct genl_family family,
struct genl_ops ops,
size_t  n_ops 
)

genl_register_family_with_ops - register a generic netlink family : generic netlink family : operations to be registered : number of elements to register

Registers the specified family and operations from the specified table. Only one family may be registered with the same family name or identifier.

The family id may equal GENL_ID_GENERATE causing an unique id to be automatically generated and assigned.

Either a doit or dumpit callback must be specified for every registered operation or the function will fail. Only one operation structure per command identifier may be registered.

See include/net/genetlink.h for more documenation on the operations structure.

This is equivalent to calling genl_register_family() followed by genl_register_ops() for every operation entry in the table taking care to unregister the family on error path.

Return 0 on success or a negative error code.

Definition at line 445 of file genetlink.c.

int genl_register_mc_group ( struct genl_family family,
struct genl_multicast_group grp 
)

genl_register_mc_group - register a multicast group

Registers the specified multicast group and notifies userspace about the new group.

Returns 0 on success or a negative error code.

: The generic netlink family the group shall be registered for. : The group to register, must have a name.

Definition at line 137 of file genetlink.c.

int genl_register_ops ( struct genl_family family,
struct genl_ops ops 
)

genl_register_ops - register generic netlink operations : generic netlink family : operations to be registered

Registers the specified operations and assigns them to the specified family. Either a doit or dumpit callback must be specified or the operation will fail. Only one operation structure per command identifier may be registered.

See include/net/genetlink.h for more documenation on the operations structure.

Returns 0 on success or a negative error code.

Definition at line 286 of file genetlink.c.

void genl_unlock ( void  )

Definition at line 30 of file genetlink.c.

int genl_unregister_family ( struct genl_family family)

genl_unregister_family - unregister generic netlink family : generic netlink family

Unregisters the specified family.

Returns 0 on success or a negative error code.

Definition at line 474 of file genetlink.c.

void genl_unregister_mc_group ( struct genl_family family,
struct genl_multicast_group grp 
)

genl_unregister_mc_group - unregister a multicast group

Unregisters the specified multicast group and notifies userspace about it. All current listeners on the group are removed.

Note: It is not necessary to unregister all multicast groups before unregistering the family, unregistering the family will cause all assigned multicast groups to be unregistered automatically.

: Generic netlink family the group belongs to. : The group to unregister, must have been registered successfully previously.

Definition at line 254 of file genetlink.c.

int genl_unregister_ops ( struct genl_family family,
struct genl_ops ops 
)

genl_unregister_ops - unregister generic netlink operations : generic netlink family : operations to be unregistered

Unregisters the specified operations and unassigns them from the specified family. The operation blocks until the current message processing has finished and doesn't start again until the unregister process has finished.

Note: It is not necessary to unregister all operations before unregistering the family, unregistering the family will cause all assigned operations to be unregistered automatically.

Returns 0 on success or a negative error code.

Definition at line 332 of file genetlink.c.

int genlmsg_multicast_allns ( struct sk_buff skb,
u32  portid,
unsigned int  group,
gfp_t  flags 
)

genlmsg_multicast_allns - multicast a netlink message to all net namespaces : netlink message as socket buffer : own netlink portid to avoid sending to yourself : multicast group id : allocation flags

This function must hold the RTNL or rcu_read_lock().

Definition at line 1003 of file genetlink.c.

void* genlmsg_put ( struct sk_buff skb,
u32  portid,
u32  seq,
struct genl_family family,
int  flags,
u8  cmd 
)

genlmsg_put - Add generic netlink header to netlink message : socket buffer holding the message : netlink portid the message is addressed to : sequence number (usually the one of the sender) : generic netlink family : netlink message flags : generic netlink command

Returns pointer to user specific header

Definition at line 512 of file genetlink.c.

subsys_initcall ( genl_init  )