2 * netlink/genl/family.h Generic Netlink Family
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation version 2.1
9 * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
12 #ifndef NETLINK_GENL_FAMILY_H_
13 #define NETLINK_GENL_FAMILY_H_
15 #include <netlink/netlink.h>
16 #include <netlink/cache.h>
23 #define FAMILY_ATTR_ID 0x01
24 #define FAMILY_ATTR_NAME 0x02
25 #define FAMILY_ATTR_VERSION 0x04
26 #define FAMILY_ATTR_HDRSIZE 0x08
27 #define FAMILY_ATTR_MAXATTR 0x10
28 #define FAMILY_ATTR_OPS 0x20
36 char gf_name
[GENL_NAMSIZ
];
41 struct nl_list_head gf_ops
;
42 struct nl_list_head gf_mc_grps
;
46 extern struct genl_family
* genl_family_alloc(void);
47 extern void genl_family_put(struct genl_family
*);
49 extern int genl_family_add_op(struct genl_family
*,
51 extern int genl_family_add_grp(struct genl_family
*,
52 uint32_t , const char *);
60 static inline unsigned int genl_family_get_id(struct genl_family
*family
)
62 if (family
->ce_mask
& FAMILY_ATTR_ID
)
68 static inline void genl_family_set_id(struct genl_family
*family
, unsigned int id
)
71 family
->ce_mask
|= FAMILY_ATTR_ID
;
74 static inline char *genl_family_get_name(struct genl_family
*family
)
76 if (family
->ce_mask
& FAMILY_ATTR_NAME
)
77 return family
->gf_name
;
82 static inline void genl_family_set_name(struct genl_family
*family
, const char *name
)
84 strncpy(family
->gf_name
, name
, GENL_NAMSIZ
-1);
85 family
->ce_mask
|= FAMILY_ATTR_NAME
;
88 static inline uint8_t genl_family_get_version(struct genl_family
*family
)
90 if (family
->ce_mask
& FAMILY_ATTR_VERSION
)
91 return family
->gf_version
;
96 static inline void genl_family_set_version(struct genl_family
*family
, uint8_t version
)
98 family
->gf_version
= version
;
99 family
->ce_mask
|= FAMILY_ATTR_VERSION
;
102 static inline uint32_t genl_family_get_hdrsize(struct genl_family
*family
)
104 if (family
->ce_mask
& FAMILY_ATTR_HDRSIZE
)
105 return family
->gf_hdrsize
;
110 static inline void genl_family_set_hdrsize(struct genl_family
*family
, uint32_t hdrsize
)
112 family
->gf_hdrsize
= hdrsize
;
113 family
->ce_mask
|= FAMILY_ATTR_HDRSIZE
;
116 static inline uint32_t genl_family_get_maxattr(struct genl_family
*family
)
118 if (family
->ce_mask
& FAMILY_ATTR_MAXATTR
)
119 return family
->gf_maxattr
;
121 return family
->gf_maxattr
;
124 static inline void genl_family_set_maxattr(struct genl_family
*family
, uint32_t maxattr
)
126 family
->gf_maxattr
= maxattr
;
127 family
->ce_mask
|= FAMILY_ATTR_MAXATTR
;