1#ifndef __LINUX_NETLINK_H 2#define __LINUX_NETLINK_H 3 4/** 5 * Netlink socket address 6 * @ingroup nl 7 */ 8struct sockaddr_nl 9{ 10 /** socket family (AF_NETLINK) */ 11 sa_family_t nl_family; 12 13 /** Padding (unused) */ 14 unsigned short nl_pad; 15 16 /** Unique process ID */ 17 uint32_t nl_pid; 18 19 /** Multicast group subscriptions */ 20 uint32_t nl_groups; 21}; 22 23/** 24 * Netlink message header 25 * @ingroup msg 26 */ 27struct nlmsghdr 28{ 29 /** 30 * Length of message including header. 31 */ 32 uint32_t nlmsg_len; 33 34 /** 35 * Message type (content type) 36 */ 37 uint16_t nlmsg_type; 38 39 /** 40 * Message flags 41 */ 42 uint16_t nlmsg_flags; 43 44 /** 45 * Sequence number 46 */ 47 uint32_t nlmsg_seq; 48 49 /** 50 * Netlink PID of the proccess sending the message. 51 */ 52 uint32_t nlmsg_pid; 53}; 54 55/** 56 * @name Standard message flags 57 * @{ 58 */ 59 60/** 61 * Must be set on all request messages (typically from user space to 62 * kernel space). 63 * @ingroup msg 64 */ 65#define NLM_F_REQUEST 1 66 67/** 68 * Indicates the message is part of a multipart message terminated 69 * by NLMSG_DONE. 70 */ 71#define NLM_F_MULTI 2 72 73/** 74 * Request for an acknowledgment on success. 75 */ 76#define NLM_F_ACK 4 77 78/** 79 * Echo this request 80 */ 81#define NLM_F_ECHO 8 82 83/** @} */ 84 85/** 86 * @name Additional message flags for GET requests 87 * @{ 88 */ 89 90/** 91 * Return the complete table instead of a single entry. 92 * @ingroup msg 93 */ 94#define NLM_F_ROOT 0x100 95 96/** 97 * Return all entries matching criteria passed in message content. 98 */ 99#define NLM_F_MATCH 0x200 100 101/** 102 * Return an atomic snapshot of the table being referenced. This 103 * may require special privileges because it has the potential to 104 * interrupt service in the FE for a longer time. 105 */ 106#define NLM_F_ATOMIC 0x400 107 108/** 109 * Dump all entries 110 */ 111#define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH) 112 113/** @} */ 114 115/** 116 * @name Additional messsage flags for NEW requests 117 * @{ 118 */ 119 120/** 121 * Replace existing matching config object with this request. 122 * @ingroup msg 123 */ 124#define NLM_F_REPLACE 0x100 125 126/** 127 * Don't replace the config object if it already exists. 128 */ 129#define NLM_F_EXCL 0x200 130 131/** 132 * Create config object if it doesn't already exist. 133 */ 134#define NLM_F_CREATE 0x400 135 136/** 137 * Add to the end of the object list. 138 */ 139#define NLM_F_APPEND 0x800 140 141/** @} */ 142 143/** 144 * @name Standard Message types 145 * @{ 146 */ 147 148/** 149 * No operation, message must be ignored 150 * @ingroup msg 151 */ 152#define NLMSG_NOOP 0x1 153 154/** 155 * The message signals an error and the payload contains a nlmsgerr 156 * structure. This can be looked at as a NACK and typically it is 157 * from FEC to CPC. 158 */ 159#define NLMSG_ERROR 0x2 160 161/** 162 * Message terminates a multipart message. 163 */ 164#define NLMSG_DONE 0x3 165 166/** 167 * The message signals that data got lost 168 */ 169#define NLMSG_OVERRUN 0x4 170 171/** 172 * Lower limit of reserved message types 173 */ 174#define NLMSG_MIN_TYPE 0x10 175 176/** @} */ 177 178/** 179 * Netlink error message 180 * @ingroup msg 181 */ 182struct nlmsgerr 183{ 184 /** Error code (errno number) */ 185 int error; 186 187 /** Original netlink message causing the error */ 188 struct nlmsghdr msg; 189}; 190 191struct nl_pktinfo 192{ 193 __u32 group; 194}; 195 196#endif /* __LINUX_NETLINK_H */ 197