priv_netlink.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * wpa_supplicant - Private copy of Linux netlink/rtnetlink definitions.
  3. * Copyright (c) 2003-2005, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #ifndef PRIV_NETLINK_H
  9. #define PRIV_NETLINK_H
  10. /*
  11. * This should be replaced with user space header once one is available with C
  12. * library, etc..
  13. */
  14. #ifndef IFF_LOWER_UP
  15. #define IFF_LOWER_UP 0x10000 /* driver signals L1 up */
  16. #endif
  17. #ifndef IFF_DORMANT
  18. #define IFF_DORMANT 0x20000 /* driver signals dormant */
  19. #endif
  20. #ifndef IFLA_IFNAME
  21. #define IFLA_IFNAME 3
  22. #endif
  23. #ifndef IFLA_WIRELESS
  24. #define IFLA_WIRELESS 11
  25. #endif
  26. #ifndef IFLA_OPERSTATE
  27. #define IFLA_OPERSTATE 16
  28. #endif
  29. #ifndef IFLA_LINKMODE
  30. #define IFLA_LINKMODE 17
  31. #define IF_OPER_DORMANT 5
  32. #define IF_OPER_UP 6
  33. #endif
  34. #define NLM_F_REQUEST 1
  35. #define NETLINK_ROUTE 0
  36. #define RTMGRP_LINK 1
  37. #define RTM_BASE 0x10
  38. #define RTM_NEWLINK (RTM_BASE + 0)
  39. #define RTM_DELLINK (RTM_BASE + 1)
  40. #define RTM_SETLINK (RTM_BASE + 3)
  41. #define NLMSG_ALIGNTO 4
  42. #define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1))
  43. #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
  44. #define NLMSG_LENGTH(len) ((len) + NLMSG_ALIGN(sizeof(struct nlmsghdr)))
  45. #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
  46. #define NLMSG_DATA(nlh) ((void*) (((char*) nlh) + NLMSG_LENGTH(0)))
  47. #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
  48. (struct nlmsghdr *) \
  49. (((char *)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
  50. #define NLMSG_OK(nlh,len) ((len) >= (int) sizeof(struct nlmsghdr) && \
  51. (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
  52. (int) (nlh)->nlmsg_len <= (len))
  53. #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))
  54. #define RTA_ALIGNTO 4
  55. #define RTA_ALIGN(len) (((len) + RTA_ALIGNTO - 1) & ~(RTA_ALIGNTO - 1))
  56. #define RTA_OK(rta,len) \
  57. ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \
  58. (rta)->rta_len <= (len))
  59. #define RTA_NEXT(rta,attrlen) \
  60. ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
  61. (struct rtattr *) (((char *)(rta)) + RTA_ALIGN((rta)->rta_len)))
  62. #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
  63. #define RTA_DATA(rta) ((void *) (((char *) (rta)) + RTA_LENGTH(0)))
  64. #define RTA_PAYLOAD(rta) ((int) ((rta)->rta_len) - RTA_LENGTH(0))
  65. struct sockaddr_nl
  66. {
  67. sa_family_t nl_family;
  68. unsigned short nl_pad;
  69. u32 nl_pid;
  70. u32 nl_groups;
  71. };
  72. struct nlmsghdr
  73. {
  74. u32 nlmsg_len;
  75. u16 nlmsg_type;
  76. u16 nlmsg_flags;
  77. u32 nlmsg_seq;
  78. u32 nlmsg_pid;
  79. };
  80. struct ifinfomsg
  81. {
  82. unsigned char ifi_family;
  83. unsigned char __ifi_pad;
  84. unsigned short ifi_type;
  85. int ifi_index;
  86. unsigned ifi_flags;
  87. unsigned ifi_change;
  88. };
  89. struct rtattr
  90. {
  91. unsigned short rta_len;
  92. unsigned short rta_type;
  93. };
  94. #endif /* PRIV_NETLINK_H */