priv_netlink.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef PRIV_NETLINK_H
  2. #define PRIV_NETLINK_H
  3. /* Private copy of needed Linux netlink/rtnetlink definitions.
  4. *
  5. * This should be replaced with user space header once one is available with C
  6. * library, etc..
  7. */
  8. #ifndef IFLA_IFNAME
  9. #define IFLA_IFNAME 3
  10. #endif
  11. #ifndef IFLA_WIRELESS
  12. #define IFLA_WIRELESS 11
  13. #endif
  14. #define NETLINK_ROUTE 0
  15. #define RTMGRP_LINK 1
  16. #define RTM_BASE 0x10
  17. #define RTM_NEWLINK (RTM_BASE + 0)
  18. #define RTM_DELLINK (RTM_BASE + 1)
  19. #define NLMSG_ALIGNTO 4
  20. #define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
  21. #define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
  22. #define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
  23. #define RTA_ALIGNTO 4
  24. #define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))
  25. #define RTA_OK(rta,len) \
  26. ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
  27. (rta)->rta_len <= (len))
  28. #define RTA_NEXT(rta,attrlen) \
  29. ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
  30. (struct rtattr *) (((char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
  31. struct sockaddr_nl
  32. {
  33. sa_family_t nl_family;
  34. unsigned short nl_pad;
  35. u32 nl_pid;
  36. u32 nl_groups;
  37. };
  38. struct nlmsghdr
  39. {
  40. u32 nlmsg_len;
  41. u16 nlmsg_type;
  42. u16 nlmsg_flags;
  43. u32 nlmsg_seq;
  44. u32 nlmsg_pid;
  45. };
  46. struct ifinfomsg
  47. {
  48. unsigned char ifi_family;
  49. unsigned char __ifi_pad;
  50. unsigned short ifi_type;
  51. int ifi_index;
  52. unsigned ifi_flags;
  53. unsigned ifi_change;
  54. };
  55. struct rtattr
  56. {
  57. unsigned short rta_len;
  58. unsigned short rta_type;
  59. };
  60. #endif /* PRIV_NETLINK_H */