mroute6.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #ifndef __LINUX_MROUTE6_H
  2. #define __LINUX_MROUTE6_H
  3. #include <linux/pim.h>
  4. #include <linux/skbuff.h> /* for struct sk_buff_head */
  5. #include <net/net_namespace.h>
  6. #include <uapi/linux/mroute6.h>
  7. #ifdef CONFIG_IPV6_MROUTE
  8. static inline int ip6_mroute_opt(int opt)
  9. {
  10. return (opt >= MRT6_BASE) && (opt <= MRT6_MAX);
  11. }
  12. #else
  13. static inline int ip6_mroute_opt(int opt)
  14. {
  15. return 0;
  16. }
  17. #endif
  18. struct sock;
  19. #ifdef CONFIG_IPV6_MROUTE
  20. extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
  21. extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  22. extern int ip6_mr_input(struct sk_buff *skb);
  23. extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
  24. extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
  25. extern int ip6_mr_init(void);
  26. extern void ip6_mr_cleanup(void);
  27. #else
  28. static inline
  29. int ip6_mroute_setsockopt(struct sock *sock,
  30. int optname, char __user *optval, unsigned int optlen)
  31. {
  32. return -ENOPROTOOPT;
  33. }
  34. static inline
  35. int ip6_mroute_getsockopt(struct sock *sock,
  36. int optname, char __user *optval, int __user *optlen)
  37. {
  38. return -ENOPROTOOPT;
  39. }
  40. static inline
  41. int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
  42. {
  43. return -ENOIOCTLCMD;
  44. }
  45. static inline int ip6_mr_init(void)
  46. {
  47. return 0;
  48. }
  49. static inline void ip6_mr_cleanup(void)
  50. {
  51. return;
  52. }
  53. #endif
  54. struct mif_device {
  55. struct net_device *dev; /* Device we are using */
  56. unsigned long bytes_in,bytes_out;
  57. unsigned long pkt_in,pkt_out; /* Statistics */
  58. unsigned long rate_limit; /* Traffic shaping (NI) */
  59. unsigned char threshold; /* TTL threshold */
  60. unsigned short flags; /* Control flags */
  61. int link; /* Physical interface index */
  62. };
  63. #define VIFF_STATIC 0x8000
  64. struct mfc6_cache {
  65. struct list_head list;
  66. struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */
  67. struct in6_addr mf6c_origin; /* Source of packet */
  68. mifi_t mf6c_parent; /* Source interface */
  69. int mfc_flags; /* Flags on line */
  70. union {
  71. struct {
  72. unsigned long expires;
  73. struct sk_buff_head unresolved; /* Unresolved buffers */
  74. } unres;
  75. struct {
  76. unsigned long last_assert;
  77. int minvif;
  78. int maxvif;
  79. unsigned long bytes;
  80. unsigned long pkt;
  81. unsigned long wrong_if;
  82. unsigned long lastuse;
  83. unsigned char ttls[MAXMIFS]; /* TTL thresholds */
  84. } res;
  85. } mfc_un;
  86. };
  87. #define MFC_STATIC 1
  88. #define MFC_NOTIFY 2
  89. #define MFC6_LINES 64
  90. #define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
  91. (__force u32)(a)->s6_addr32[1] ^ \
  92. (__force u32)(a)->s6_addr32[2] ^ \
  93. (__force u32)(a)->s6_addr32[3] ^ \
  94. (__force u32)(g)->s6_addr32[0] ^ \
  95. (__force u32)(g)->s6_addr32[1] ^ \
  96. (__force u32)(g)->s6_addr32[2] ^ \
  97. (__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
  98. #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
  99. struct rtmsg;
  100. extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
  101. struct rtmsg *rtm, int nowait, u32 portid);
  102. #ifdef CONFIG_IPV6_MROUTE
  103. extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
  104. extern int ip6mr_sk_done(struct sock *sk);
  105. #else
  106. static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
  107. {
  108. return NULL;
  109. }
  110. static inline int ip6mr_sk_done(struct sock *sk)
  111. {
  112. return 0;
  113. }
  114. #endif
  115. #endif