libnl
3.2.3
|
00001 #ifndef __NETLINK_KERNEL_H_ 00002 #define __NETLINK_KERNEL_H_ 00003 00004 #if 0 00005 00006 /* 00007 * FIXME: Goal is to preseve the documentation but make it simple 00008 * to keep linux/netlink.h in sync. Maybe use named documentation 00009 * sections. 00010 */ 00011 00012 /** 00013 * Netlink socket address 00014 * @ingroup nl 00015 */ 00016 struct sockaddr_nl 00017 { 00018 /** socket family (AF_NETLINK) */ 00019 sa_family_t nl_family; 00020 00021 /** Padding (unused) */ 00022 unsigned short nl_pad; 00023 00024 /** Unique process ID */ 00025 uint32_t nl_pid; 00026 00027 /** Multicast group subscriptions */ 00028 uint32_t nl_groups; 00029 }; 00030 00031 /** 00032 * @addtogroup msg 00033 * @{ 00034 */ 00035 00036 00037 /** 00038 * Netlink message header 00039 */ 00040 struct nlmsghdr 00041 { 00042 /** Length of message including header and padding. */ 00043 uint32_t nlmsg_len; 00044 00045 /** Message type (content type) */ 00046 uint16_t nlmsg_type; 00047 00048 /** Message flags */ 00049 uint16_t nlmsg_flags; 00050 00051 /** Sequence number of message \see core_sk_seq_num. */ 00052 uint32_t nlmsg_seq; 00053 00054 /** Netlink port */ 00055 uint32_t nlmsg_pid; 00056 }; 00057 00058 /** 00059 * @name Standard message flags 00060 * @{ 00061 */ 00062 00063 /** 00064 * Must be set on all request messages (typically from user space to 00065 * kernel space). 00066 */ 00067 #define NLM_F_REQUEST 1 00068 00069 /** 00070 * Indicates the message is part of a multipart message terminated 00071 * by NLMSG_DONE. 00072 */ 00073 #define NLM_F_MULTI 2 00074 00075 /** 00076 * Request for an acknowledgment on success. 00077 */ 00078 #define NLM_F_ACK 4 00079 00080 /** 00081 * Echo this request 00082 */ 00083 #define NLM_F_ECHO 8 00084 00085 /** @} */ 00086 00087 /** 00088 * @name Additional message flags for GET requests 00089 * @{ 00090 */ 00091 00092 /** 00093 * Return the complete table instead of a single entry. 00094 */ 00095 #define NLM_F_ROOT 0x100 00096 00097 /** 00098 * Return all entries matching criteria passed in message content. 00099 */ 00100 #define NLM_F_MATCH 0x200 00101 00102 /** 00103 * Return an atomic snapshot of the table being referenced. This 00104 * may require special privileges because it has the potential to 00105 * interrupt service in the FE for a longer time. 00106 */ 00107 #define NLM_F_ATOMIC 0x400 00108 00109 /** 00110 * Dump all entries 00111 */ 00112 #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH) 00113 00114 /** @} */ 00115 00116 /** 00117 * @name Additional messsage flags for NEW requests 00118 * @{ 00119 */ 00120 00121 /** 00122 * Replace existing matching config object with this request. 00123 */ 00124 #define NLM_F_REPLACE 0x100 00125 00126 /** 00127 * Don't replace the config object if it already exists. 00128 */ 00129 #define NLM_F_EXCL 0x200 00130 00131 /** 00132 * Create config object if it doesn't already exist. 00133 */ 00134 #define NLM_F_CREATE 0x400 00135 00136 /** 00137 * Add to the end of the object list. 00138 */ 00139 #define NLM_F_APPEND 0x800 00140 00141 /** @} */ 00142 00143 /** 00144 * @name Standard Message types 00145 * @{ 00146 */ 00147 00148 /** 00149 * No operation, message must be ignored 00150 */ 00151 #define NLMSG_NOOP 0x1 00152 00153 /** 00154 * The message signals an error and the payload contains a nlmsgerr 00155 * structure. This can be looked at as a NACK and typically it is 00156 * from FEC to CPC. 00157 */ 00158 #define NLMSG_ERROR 0x2 00159 00160 /** 00161 * Message terminates a multipart message. 00162 */ 00163 #define NLMSG_DONE 0x3 00164 00165 /** 00166 * The message signals that data got lost 00167 */ 00168 #define NLMSG_OVERRUN 0x4 00169 00170 /** 00171 * Lower limit of reserved message types 00172 */ 00173 #define NLMSG_MIN_TYPE 0x10 00174 00175 /** @} */ 00176 00177 /** 00178 * Netlink error message header 00179 */ 00180 struct nlmsgerr 00181 { 00182 /** Error code (errno number) */ 00183 int error; 00184 00185 /** Original netlink message causing the error */ 00186 struct nlmsghdr msg; 00187 }; 00188 00189 struct nl_pktinfo 00190 { 00191 __u32 group; 00192 }; 00193 00194 /** 00195 * Netlink alignment constant, all boundries within messages must be align to this. 00196 * 00197 * See \ref core_msg_fmt_align for more information on message alignment. 00198 */ 00199 #define NLMSG_ALIGNTO 4 00200 00201 /** 00202 * Returns \p len properly aligned to NLMSG_ALIGNTO. 00203 * 00204 * See \ref core_msg_fmt_align for more information on message alignment. 00205 */ 00206 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) 00207 00208 /** 00209 * Length of a netlink message header including padding. 00210 * 00211 * See \ref core_msg_fmt_align for more information on message alignment. 00212 */ 00213 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr))) 00214 00215 /** @} */ 00216 00217 /** 00218 * @addtogroup attr 00219 * @{ 00220 */ 00221 00222 /* 00223 */ 00224 00225 /** 00226 * Netlink attribute structure 00227 * 00228 * @code 00229 * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)--> 00230 * +---------------------+- - -+- - - - - - - - - -+- - -+ 00231 * | Header | Pad | Payload | Pad | 00232 * | (struct nlattr) | ing | | ing | 00233 * +---------------------+- - -+- - - - - - - - - -+- - -+ 00234 * <-------------- nlattr->nla_len --------------> 00235 * @endcode 00236 */ 00237 struct nlattr { 00238 /** 00239 * Attribute length in bytes including header 00240 */ 00241 __u16 nla_len; 00242 00243 /** 00244 * Netlink attribute type 00245 */ 00246 __u16 nla_type; 00247 }; 00248 00249 /** 00250 * @name Attribute Type Flags 00251 * 00252 * @code 00253 * nla_type (16 bits) 00254 * +---+---+-------------------------------+ 00255 * | N | O | Attribute Type | 00256 * +---+---+-------------------------------+ 00257 * N := Carries nested attributes 00258 * O := Payload stored in network byte order 00259 * @endcode 00260 * 00261 * @note The N and O flag are mutually exclusive. 00262 * 00263 * @{ 00264 */ 00265 00266 /* 00267 */ 00268 #define NLA_F_NESTED (1 << 15) 00269 #define NLA_F_NET_BYTEORDER (1 << 14) 00270 #define NLA_TYPE_MASK ~(NLA_F_NESTED | NLA_F_NET_BYTEORDER) 00271 00272 /** @} */ 00273 00274 #define NLA_ALIGNTO 4 00275 00276 /** 00277 * Returns \p len properly aligned to NLA_ALIGNTO. 00278 * 00279 * See \ref core_msg_fmt_align for more information on message alignment. 00280 */ 00281 #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1)) 00282 00283 /** 00284 * Length of a netlink attribute header including padding. 00285 * 00286 * See \ref core_msg_fmt_align for more information on message alignment. 00287 */ 00288 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr))) 00289 00290 /** @} */ 00291 00292 #endif 00293 #endif /* __LINUX_NETLINK_H */