priv_netlink.h 2.9 KB

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