• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/libnl-tiny/include/netlink/genl/family.h

  1 /*
  2  * netlink/genl/family.h        Generic Netlink Family
  3  *
  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
  7  *      of the License.
  8  *
  9  * Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch>
 10  */
 11 
 12 #ifndef NETLINK_GENL_FAMILY_H_
 13 #define NETLINK_GENL_FAMILY_H_
 14 
 15 #include <netlink/netlink.h>
 16 #include <netlink/cache.h>
 17 
 18 #ifdef __cplusplus
 19 extern "C" {
 20 #endif
 21 
 22 /** @cond SKIP */
 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
 29 
 30 
 31 struct genl_family
 32 {
 33         NLHDR_COMMON
 34 
 35         uint16_t                gf_id;
 36         char                    gf_name[GENL_NAMSIZ];
 37         uint32_t                gf_version;
 38         uint32_t                gf_hdrsize;
 39         uint32_t                gf_maxattr;
 40 
 41         struct nl_list_head     gf_ops;
 42         struct nl_list_head     gf_mc_grps;
 43 };
 44 
 45 
 46 extern struct genl_family *     genl_family_alloc(void);
 47 extern void                     genl_family_put(struct genl_family *);
 48 
 49 extern int                      genl_family_add_op(struct genl_family *,
 50                                                    int, int);
 51 extern int                      genl_family_add_grp(struct genl_family *,
 52                                         uint32_t , const char *);
 53 
 54 
 55 /**
 56  * @name Attributes
 57  * @{
 58  */
 59 
 60 static inline unsigned int genl_family_get_id(struct genl_family *family)
 61 {
 62         if (family->ce_mask & FAMILY_ATTR_ID)
 63                 return family->gf_id;
 64         else
 65                 return 0;
 66 }
 67 
 68 static inline void genl_family_set_id(struct genl_family *family, unsigned int id)
 69 {
 70         family->gf_id = id;
 71         family->ce_mask |= FAMILY_ATTR_ID;
 72 }
 73 
 74 static inline char *genl_family_get_name(struct genl_family *family)
 75 {
 76         if (family->ce_mask & FAMILY_ATTR_NAME)
 77                 return family->gf_name;
 78         else
 79                 return NULL;
 80 }
 81 
 82 static inline void genl_family_set_name(struct genl_family *family, const char *name)
 83 {
 84         strncpy(family->gf_name, name, GENL_NAMSIZ-1);
 85         family->gf_name[GENL_NAMSIZ - 1] = '\0';
 86         family->ce_mask |= FAMILY_ATTR_NAME;
 87 }
 88 
 89 static inline uint8_t genl_family_get_version(struct genl_family *family)
 90 {
 91         if (family->ce_mask & FAMILY_ATTR_VERSION)
 92                 return family->gf_version;
 93         else
 94                 return 0;
 95 }
 96 
 97 static inline void genl_family_set_version(struct genl_family *family, uint8_t version)
 98 {
 99         family->gf_version = version;
100         family->ce_mask |= FAMILY_ATTR_VERSION;
101 }
102 
103 static inline uint32_t genl_family_get_hdrsize(struct genl_family *family)
104 {
105         if (family->ce_mask & FAMILY_ATTR_HDRSIZE)
106                 return family->gf_hdrsize;
107         else
108                 return 0;
109 }
110 
111 static inline void genl_family_set_hdrsize(struct genl_family *family, uint32_t hdrsize)
112 {
113         family->gf_hdrsize = hdrsize;
114         family->ce_mask |= FAMILY_ATTR_HDRSIZE;
115 }
116 
117 static inline uint32_t genl_family_get_maxattr(struct genl_family *family)
118 {
119         if (family->ce_mask & FAMILY_ATTR_MAXATTR)
120                 return family->gf_maxattr;
121         else
122                 return 0;
123 }
124 
125 static inline void genl_family_set_maxattr(struct genl_family *family, uint32_t maxattr)
126 {
127         family->gf_maxattr = maxattr;
128         family->ce_mask |= FAMILY_ATTR_MAXATTR;
129 }
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif
136 

This page was automatically generated by LXR 0.3.1.  •  OpenWrt