mroute.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI__LINUX_MROUTE_H
  3. #define _UAPI__LINUX_MROUTE_H
  4. #include <linux/sockios.h>
  5. #include <linux/types.h>
  6. #include <linux/in.h> /* For struct in_addr. */
  7. /* Based on the MROUTING 3.5 defines primarily to keep
  8. * source compatibility with BSD.
  9. *
  10. * See the mrouted code for the original history.
  11. *
  12. * Protocol Independent Multicast (PIM) data structures included
  13. * Carlos Picoto ([email protected])
  14. */
  15. #define MRT_BASE 200
  16. #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
  17. #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
  18. #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
  19. #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
  20. #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
  21. #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
  22. #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
  23. #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
  24. #define MRT_PIM (MRT_BASE+8) /* enable PIM code */
  25. #define MRT_TABLE (MRT_BASE+9) /* Specify mroute table ID */
  26. #define MRT_ADD_MFC_PROXY (MRT_BASE+10) /* Add a (*,*|G) mfc entry */
  27. #define MRT_DEL_MFC_PROXY (MRT_BASE+11) /* Del a (*,*|G) mfc entry */
  28. #define MRT_FLUSH (MRT_BASE+12) /* Flush all mfc entries and/or vifs */
  29. #define MRT_MAX (MRT_BASE+12)
  30. #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
  31. #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
  32. #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
  33. /* MRT_FLUSH optional flags */
  34. #define MRT_FLUSH_MFC 1 /* Flush multicast entries */
  35. #define MRT_FLUSH_MFC_STATIC 2 /* Flush static multicast entries */
  36. #define MRT_FLUSH_VIFS 4 /* Flush multicast vifs */
  37. #define MRT_FLUSH_VIFS_STATIC 8 /* Flush static multicast vifs */
  38. #define MAXVIFS 32
  39. typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */
  40. typedef unsigned short vifi_t;
  41. #define ALL_VIFS ((vifi_t)(-1))
  42. /* Same idea as select */
  43. #define VIFM_SET(n,m) ((m)|=(1<<(n)))
  44. #define VIFM_CLR(n,m) ((m)&=~(1<<(n)))
  45. #define VIFM_ISSET(n,m) ((m)&(1<<(n)))
  46. #define VIFM_CLRALL(m) ((m)=0)
  47. #define VIFM_COPY(mfrom,mto) ((mto)=(mfrom))
  48. #define VIFM_SAME(m1,m2) ((m1)==(m2))
  49. /* Passed by mrouted for an MRT_ADD_VIF - again we use the
  50. * mrouted 3.6 structures for compatibility
  51. */
  52. struct vifctl {
  53. vifi_t vifc_vifi; /* Index of VIF */
  54. unsigned char vifc_flags; /* VIFF_ flags */
  55. unsigned char vifc_threshold; /* ttl limit */
  56. unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
  57. union {
  58. struct in_addr vifc_lcl_addr; /* Local interface address */
  59. int vifc_lcl_ifindex; /* Local interface index */
  60. };
  61. struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
  62. };
  63. #define VIFF_TUNNEL 0x1 /* IPIP tunnel */
  64. #define VIFF_SRCRT 0x2 /* NI */
  65. #define VIFF_REGISTER 0x4 /* register vif */
  66. #define VIFF_USE_IFINDEX 0x8 /* use vifc_lcl_ifindex instead of
  67. vifc_lcl_addr to find an interface */
  68. /* Cache manipulation structures for mrouted and PIMd */
  69. struct mfcctl {
  70. struct in_addr mfcc_origin; /* Origin of mcast */
  71. struct in_addr mfcc_mcastgrp; /* Group in question */
  72. vifi_t mfcc_parent; /* Where it arrived */
  73. unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
  74. unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
  75. unsigned int mfcc_byte_cnt;
  76. unsigned int mfcc_wrong_if;
  77. int mfcc_expire;
  78. };
  79. /* Group count retrieval for mrouted */
  80. struct sioc_sg_req {
  81. struct in_addr src;
  82. struct in_addr grp;
  83. unsigned long pktcnt;
  84. unsigned long bytecnt;
  85. unsigned long wrong_if;
  86. };
  87. /* To get vif packet counts */
  88. struct sioc_vif_req {
  89. vifi_t vifi; /* Which iface */
  90. unsigned long icount; /* In packets */
  91. unsigned long ocount; /* Out packets */
  92. unsigned long ibytes; /* In bytes */
  93. unsigned long obytes; /* Out bytes */
  94. };
  95. /* This is the format the mroute daemon expects to see IGMP control
  96. * data. Magically happens to be like an IP packet as per the original
  97. */
  98. struct igmpmsg {
  99. __u32 unused1,unused2;
  100. unsigned char im_msgtype; /* What is this */
  101. unsigned char im_mbz; /* Must be zero */
  102. unsigned char im_vif; /* Low 8 bits of Interface */
  103. unsigned char im_vif_hi; /* High 8 bits of Interface */
  104. struct in_addr im_src,im_dst;
  105. };
  106. /* ipmr netlink table attributes */
  107. enum {
  108. IPMRA_TABLE_UNSPEC,
  109. IPMRA_TABLE_ID,
  110. IPMRA_TABLE_CACHE_RES_QUEUE_LEN,
  111. IPMRA_TABLE_MROUTE_REG_VIF_NUM,
  112. IPMRA_TABLE_MROUTE_DO_ASSERT,
  113. IPMRA_TABLE_MROUTE_DO_PIM,
  114. IPMRA_TABLE_VIFS,
  115. IPMRA_TABLE_MROUTE_DO_WRVIFWHOLE,
  116. __IPMRA_TABLE_MAX
  117. };
  118. #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1)
  119. /* ipmr netlink vif attribute format
  120. * [ IPMRA_TABLE_VIFS ] - nested attribute
  121. * [ IPMRA_VIF ] - nested attribute
  122. * [ IPMRA_VIFA_xxx ]
  123. */
  124. enum {
  125. IPMRA_VIF_UNSPEC,
  126. IPMRA_VIF,
  127. __IPMRA_VIF_MAX
  128. };
  129. #define IPMRA_VIF_MAX (__IPMRA_VIF_MAX - 1)
  130. /* vif-specific attributes */
  131. enum {
  132. IPMRA_VIFA_UNSPEC,
  133. IPMRA_VIFA_IFINDEX,
  134. IPMRA_VIFA_VIF_ID,
  135. IPMRA_VIFA_FLAGS,
  136. IPMRA_VIFA_BYTES_IN,
  137. IPMRA_VIFA_BYTES_OUT,
  138. IPMRA_VIFA_PACKETS_IN,
  139. IPMRA_VIFA_PACKETS_OUT,
  140. IPMRA_VIFA_LOCAL_ADDR,
  141. IPMRA_VIFA_REMOTE_ADDR,
  142. IPMRA_VIFA_PAD,
  143. __IPMRA_VIFA_MAX
  144. };
  145. #define IPMRA_VIFA_MAX (__IPMRA_VIFA_MAX - 1)
  146. /* ipmr netlink cache report attributes */
  147. enum {
  148. IPMRA_CREPORT_UNSPEC,
  149. IPMRA_CREPORT_MSGTYPE,
  150. IPMRA_CREPORT_VIF_ID,
  151. IPMRA_CREPORT_SRC_ADDR,
  152. IPMRA_CREPORT_DST_ADDR,
  153. IPMRA_CREPORT_PKT,
  154. IPMRA_CREPORT_TABLE,
  155. __IPMRA_CREPORT_MAX
  156. };
  157. #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1)
  158. /* That's all usermode folks */
  159. #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
  160. /* Pseudo messages used by mrouted */
  161. #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
  162. #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
  163. #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
  164. #define IGMPMSG_WRVIFWHOLE 4 /* For PIM Register and assert processing */
  165. #endif /* _UAPI__LINUX_MROUTE_H */