PageRenderTime 28ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/include/linux/mroute6.h

https://gitlab.com/culot/kernel_lge_madai
C Header | 269 lines | 193 code | 43 blank | 33 comment | 1 complexity | d9d47485ac10f043b729e73a4079a960 MD5 | raw file
  1. #ifndef __LINUX_MROUTE6_H
  2. #define __LINUX_MROUTE6_H
  3. #include <linux/types.h>
  4. #include <linux/sockios.h>
  5. /*
  6. * Based on the MROUTING 3.5 defines primarily to keep
  7. * source compatibility with BSD.
  8. *
  9. * See the pim6sd code for the original history.
  10. *
  11. * Protocol Independent Multicast (PIM) data structures included
  12. * Carlos Picoto (cap@di.fc.ul.pt)
  13. *
  14. */
  15. #define MRT6_BASE 200
  16. #define MRT6_INIT (MRT6_BASE) /* Activate the kernel mroute code */
  17. #define MRT6_DONE (MRT6_BASE+1) /* Shutdown the kernel mroute */
  18. #define MRT6_ADD_MIF (MRT6_BASE+2) /* Add a virtual interface */
  19. #define MRT6_DEL_MIF (MRT6_BASE+3) /* Delete a virtual interface */
  20. #define MRT6_ADD_MFC (MRT6_BASE+4) /* Add a multicast forwarding entry */
  21. #define MRT6_DEL_MFC (MRT6_BASE+5) /* Delete a multicast forwarding entry */
  22. #define MRT6_VERSION (MRT6_BASE+6) /* Get the kernel multicast version */
  23. #define MRT6_ASSERT (MRT6_BASE+7) /* Activate PIM assert mode */
  24. #define MRT6_PIM (MRT6_BASE+8) /* enable PIM code */
  25. #define MRT6_TABLE (MRT6_BASE+9) /* Specify mroute table ID */
  26. #define SIOCGETMIFCNT_IN6 SIOCPROTOPRIVATE /* IP protocol privates */
  27. #define SIOCGETSGCNT_IN6 (SIOCPROTOPRIVATE+1)
  28. #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
  29. #define MAXMIFS 32
  30. typedef unsigned long mifbitmap_t; /* User mode code depends on this lot */
  31. typedef unsigned short mifi_t;
  32. #define ALL_MIFS ((mifi_t)(-1))
  33. #ifndef IF_SETSIZE
  34. #define IF_SETSIZE 256
  35. #endif
  36. typedef __u32 if_mask;
  37. #define NIFBITS (sizeof(if_mask) * 8) /* bits per mask */
  38. #if !defined(__KERNEL__)
  39. #if !defined(DIV_ROUND_UP)
  40. #define DIV_ROUND_UP(x,y) (((x) + ((y) - 1)) / (y))
  41. #endif
  42. #endif
  43. typedef struct if_set {
  44. if_mask ifs_bits[DIV_ROUND_UP(IF_SETSIZE, NIFBITS)];
  45. } if_set;
  46. #define IF_SET(n, p) ((p)->ifs_bits[(n)/NIFBITS] |= (1 << ((n) % NIFBITS)))
  47. #define IF_CLR(n, p) ((p)->ifs_bits[(n)/NIFBITS] &= ~(1 << ((n) % NIFBITS)))
  48. #define IF_ISSET(n, p) ((p)->ifs_bits[(n)/NIFBITS] & (1 << ((n) % NIFBITS)))
  49. #define IF_COPY(f, t) bcopy(f, t, sizeof(*(f)))
  50. #define IF_ZERO(p) bzero(p, sizeof(*(p)))
  51. /*
  52. * Passed by mrouted for an MRT_ADD_MIF - again we use the
  53. * mrouted 3.6 structures for compatibility
  54. */
  55. struct mif6ctl {
  56. mifi_t mif6c_mifi; /* Index of MIF */
  57. unsigned char mif6c_flags; /* MIFF_ flags */
  58. unsigned char vifc_threshold; /* ttl limit */
  59. __u16 mif6c_pifi; /* the index of the physical IF */
  60. unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
  61. };
  62. #define MIFF_REGISTER 0x1 /* register vif */
  63. /*
  64. * Cache manipulation structures for mrouted and PIMd
  65. */
  66. struct mf6cctl {
  67. struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */
  68. struct sockaddr_in6 mf6cc_mcastgrp; /* Group in question */
  69. mifi_t mf6cc_parent; /* Where it arrived */
  70. struct if_set mf6cc_ifset; /* Where it is going */
  71. };
  72. /*
  73. * Group count retrieval for pim6sd
  74. */
  75. struct sioc_sg_req6 {
  76. struct sockaddr_in6 src;
  77. struct sockaddr_in6 grp;
  78. unsigned long pktcnt;
  79. unsigned long bytecnt;
  80. unsigned long wrong_if;
  81. };
  82. /*
  83. * To get vif packet counts
  84. */
  85. struct sioc_mif_req6 {
  86. mifi_t mifi; /* Which iface */
  87. unsigned long icount; /* In packets */
  88. unsigned long ocount; /* Out packets */
  89. unsigned long ibytes; /* In bytes */
  90. unsigned long obytes; /* Out bytes */
  91. };
  92. /*
  93. * That's all usermode folks
  94. */
  95. #ifdef __KERNEL__
  96. #include <linux/pim.h>
  97. #include <linux/skbuff.h> /* for struct sk_buff_head */
  98. #include <net/net_namespace.h>
  99. #ifdef CONFIG_IPV6_MROUTE
  100. static inline int ip6_mroute_opt(int opt)
  101. {
  102. return (opt >= MRT6_BASE) && (opt <= MRT6_BASE + 10);
  103. }
  104. #else
  105. static inline int ip6_mroute_opt(int opt)
  106. {
  107. return 0;
  108. }
  109. #endif
  110. struct sock;
  111. #ifdef CONFIG_IPV6_MROUTE
  112. extern int ip6_mroute_setsockopt(struct sock *, int, char __user *, unsigned int);
  113. extern int ip6_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
  114. extern int ip6_mr_input(struct sk_buff *skb);
  115. extern int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg);
  116. extern int ip6mr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
  117. extern int ip6_mr_init(void);
  118. extern void ip6_mr_cleanup(void);
  119. #else
  120. static inline
  121. int ip6_mroute_setsockopt(struct sock *sock,
  122. int optname, char __user *optval, unsigned int optlen)
  123. {
  124. return -ENOPROTOOPT;
  125. }
  126. static inline
  127. int ip6_mroute_getsockopt(struct sock *sock,
  128. int optname, char __user *optval, int __user *optlen)
  129. {
  130. return -ENOPROTOOPT;
  131. }
  132. static inline
  133. int ip6mr_ioctl(struct sock *sk, int cmd, void __user *arg)
  134. {
  135. return -ENOIOCTLCMD;
  136. }
  137. static inline int ip6_mr_init(void)
  138. {
  139. return 0;
  140. }
  141. static inline void ip6_mr_cleanup(void)
  142. {
  143. return;
  144. }
  145. #endif
  146. struct mif_device {
  147. struct net_device *dev; /* Device we are using */
  148. unsigned long bytes_in,bytes_out;
  149. unsigned long pkt_in,pkt_out; /* Statistics */
  150. unsigned long rate_limit; /* Traffic shaping (NI) */
  151. unsigned char threshold; /* TTL threshold */
  152. unsigned short flags; /* Control flags */
  153. int link; /* Physical interface index */
  154. };
  155. #define VIFF_STATIC 0x8000
  156. struct mfc6_cache {
  157. struct list_head list;
  158. struct in6_addr mf6c_mcastgrp; /* Group the entry belongs to */
  159. struct in6_addr mf6c_origin; /* Source of packet */
  160. mifi_t mf6c_parent; /* Source interface */
  161. int mfc_flags; /* Flags on line */
  162. union {
  163. struct {
  164. unsigned long expires;
  165. struct sk_buff_head unresolved; /* Unresolved buffers */
  166. } unres;
  167. struct {
  168. unsigned long last_assert;
  169. int minvif;
  170. int maxvif;
  171. unsigned long bytes;
  172. unsigned long pkt;
  173. unsigned long wrong_if;
  174. unsigned char ttls[MAXMIFS]; /* TTL thresholds */
  175. } res;
  176. } mfc_un;
  177. };
  178. #define MFC_STATIC 1
  179. #define MFC_NOTIFY 2
  180. #define MFC6_LINES 64
  181. #define MFC6_HASH(a, g) (((__force u32)(a)->s6_addr32[0] ^ \
  182. (__force u32)(a)->s6_addr32[1] ^ \
  183. (__force u32)(a)->s6_addr32[2] ^ \
  184. (__force u32)(a)->s6_addr32[3] ^ \
  185. (__force u32)(g)->s6_addr32[0] ^ \
  186. (__force u32)(g)->s6_addr32[1] ^ \
  187. (__force u32)(g)->s6_addr32[2] ^ \
  188. (__force u32)(g)->s6_addr32[3]) % MFC6_LINES)
  189. #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
  190. #endif
  191. #ifdef __KERNEL__
  192. struct rtmsg;
  193. extern int ip6mr_get_route(struct net *net, struct sk_buff *skb,
  194. struct rtmsg *rtm, int nowait);
  195. #ifdef CONFIG_IPV6_MROUTE
  196. extern struct sock *mroute6_socket(struct net *net, struct sk_buff *skb);
  197. extern int ip6mr_sk_done(struct sock *sk);
  198. #else
  199. static inline struct sock *mroute6_socket(struct net *net, struct sk_buff *skb)
  200. {
  201. return NULL;
  202. }
  203. static inline int ip6mr_sk_done(struct sock *sk)
  204. {
  205. return 0;
  206. }
  207. #endif
  208. #endif
  209. /*
  210. * Structure used to communicate from kernel to multicast router.
  211. * We'll overlay the structure onto an MLD header (not an IPv6 heder like igmpmsg{}
  212. * used for IPv4 implementation). This is because this structure will be passed via an
  213. * IPv6 raw socket, on which an application will only receiver the payload i.e the data after
  214. * the IPv6 header and all the extension headers. (See section 3 of RFC 3542)
  215. */
  216. struct mrt6msg {
  217. #define MRT6MSG_NOCACHE 1
  218. #define MRT6MSG_WRONGMIF 2
  219. #define MRT6MSG_WHOLEPKT 3 /* used for use level encap */
  220. __u8 im6_mbz; /* must be zero */
  221. __u8 im6_msgtype; /* what type of message */
  222. __u16 im6_mif; /* mif rec'd on */
  223. __u32 im6_pad; /* padding for 64 bit arch */
  224. struct in6_addr im6_src, im6_dst;
  225. };
  226. #endif