1
0

netlink-kernel.h 3.0 KB

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