mroute.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #ifndef __LINUX_MROUTE_H
  2. #define __LINUX_MROUTE_H
  3. #include <linux/in.h>
  4. #include <linux/pim.h>
  5. #include <net/sock.h>
  6. #include <uapi/linux/mroute.h>
  7. #ifdef CONFIG_IP_MROUTE
  8. static inline int ip_mroute_opt(int opt)
  9. {
  10. return (opt >= MRT_BASE) && (opt <= MRT_MAX);
  11. }
  12. #else
  13. static inline int ip_mroute_opt(int opt)
  14. {
  15. return 0;
  16. }
  17. #endif
  18. #ifdef CONFIG_IP_MROUTE
  19. extern int ip_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
  20. extern int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  21. extern int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
  22. extern int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
  23. extern int ip_mr_init(void);
  24. #else
  25. static inline
  26. int ip_mroute_setsockopt(struct sock *sock,
  27. int optname, char __user *optval, unsigned int optlen)
  28. {
  29. return -ENOPROTOOPT;
  30. }
  31. static inline
  32. int ip_mroute_getsockopt(struct sock *sock,
  33. int optname, char __user *optval, int __user *optlen)
  34. {
  35. return -ENOPROTOOPT;
  36. }
  37. static inline
  38. int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg)
  39. {
  40. return -ENOIOCTLCMD;
  41. }
  42. static inline int ip_mr_init(void)
  43. {
  44. return 0;
  45. }
  46. #endif
  47. struct vif_device {
  48. struct net_device *dev; /* Device we are using */
  49. unsigned long bytes_in,bytes_out;
  50. unsigned long pkt_in,pkt_out; /* Statistics */
  51. unsigned long rate_limit; /* Traffic shaping (NI) */
  52. unsigned char threshold; /* TTL threshold */
  53. unsigned short flags; /* Control flags */
  54. __be32 local,remote; /* Addresses(remote for tunnels)*/
  55. int link; /* Physical interface index */
  56. };
  57. #define VIFF_STATIC 0x8000
  58. /* mfc_flags:
  59. * MFC_STATIC - the entry was added statically (not by a routing daemon)
  60. */
  61. enum {
  62. MFC_STATIC = BIT(0),
  63. };
  64. struct mfc_cache {
  65. struct list_head list;
  66. __be32 mfc_mcastgrp; /* Group the entry belongs to */
  67. __be32 mfc_origin; /* Source of packet */
  68. vifi_t mfc_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 char ttls[MAXVIFS]; /* TTL thresholds */
  83. } res;
  84. } mfc_un;
  85. struct rcu_head rcu;
  86. };
  87. #define MFC_LINES 64
  88. #ifdef __BIG_ENDIAN
  89. #define MFC_HASH(a,b) (((((__force u32)(__be32)a)>>24)^(((__force u32)(__be32)b)>>26))&(MFC_LINES-1))
  90. #else
  91. #define MFC_HASH(a,b) ((((__force u32)(__be32)a)^(((__force u32)(__be32)b)>>2))&(MFC_LINES-1))
  92. #endif
  93. struct rtmsg;
  94. extern int ipmr_get_route(struct net *net, struct sk_buff *skb,
  95. __be32 saddr, __be32 daddr,
  96. struct rtmsg *rtm, int nowait);
  97. #endif