mroute.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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 (cap@di.fc.ul.pt)
  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_MAX (MRT_BASE+11)
  29. #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
  30. #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
  31. #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
  32. #define MAXVIFS 32
  33. typedef unsigned long vifbitmap_t; /* User mode code depends on this lot */
  34. typedef unsigned short vifi_t;
  35. #define ALL_VIFS ((vifi_t)(-1))
  36. /* Same idea as select */
  37. #define VIFM_SET(n,m) ((m)|=(1<<(n)))
  38. #define VIFM_CLR(n,m) ((m)&=~(1<<(n)))
  39. #define VIFM_ISSET(n,m) ((m)&(1<<(n)))
  40. #define VIFM_CLRALL(m) ((m)=0)
  41. #define VIFM_COPY(mfrom,mto) ((mto)=(mfrom))
  42. #define VIFM_SAME(m1,m2) ((m1)==(m2))
  43. /* Passed by mrouted for an MRT_ADD_VIF - again we use the
  44. * mrouted 3.6 structures for compatibility
  45. */
  46. struct vifctl {
  47. vifi_t vifc_vifi; /* Index of VIF */
  48. unsigned char vifc_flags; /* VIFF_ flags */
  49. unsigned char vifc_threshold; /* ttl limit */
  50. unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
  51. union {
  52. struct in_addr vifc_lcl_addr; /* Local interface address */
  53. int vifc_lcl_ifindex; /* Local interface index */
  54. };
  55. struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
  56. };
  57. #define VIFF_TUNNEL 0x1 /* IPIP tunnel */
  58. #define VIFF_SRCRT 0x2 /* NI */
  59. #define VIFF_REGISTER 0x4 /* register vif */
  60. #define VIFF_USE_IFINDEX 0x8 /* use vifc_lcl_ifindex instead of
  61. vifc_lcl_addr to find an interface */
  62. /* Cache manipulation structures for mrouted and PIMd */
  63. struct mfcctl {
  64. struct in_addr mfcc_origin; /* Origin of mcast */
  65. struct in_addr mfcc_mcastgrp; /* Group in question */
  66. vifi_t mfcc_parent; /* Where it arrived */
  67. unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
  68. unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
  69. unsigned int mfcc_byte_cnt;
  70. unsigned int mfcc_wrong_if;
  71. int mfcc_expire;
  72. };
  73. /* Group count retrieval for mrouted */
  74. struct sioc_sg_req {
  75. struct in_addr src;
  76. struct in_addr grp;
  77. unsigned long pktcnt;
  78. unsigned long bytecnt;
  79. unsigned long wrong_if;
  80. };
  81. /* To get vif packet counts */
  82. struct sioc_vif_req {
  83. vifi_t vifi; /* Which iface */
  84. unsigned long icount; /* In packets */
  85. unsigned long ocount; /* Out packets */
  86. unsigned long ibytes; /* In bytes */
  87. unsigned long obytes; /* Out bytes */
  88. };
  89. /* This is the format the mroute daemon expects to see IGMP control
  90. * data. Magically happens to be like an IP packet as per the original
  91. */
  92. struct igmpmsg {
  93. __u32 unused1,unused2;
  94. unsigned char im_msgtype; /* What is this */
  95. unsigned char im_mbz; /* Must be zero */
  96. unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
  97. unsigned char unused3;
  98. struct in_addr im_src,im_dst;
  99. };
  100. /* ipmr netlink table attributes */
  101. enum {
  102. IPMRA_TABLE_UNSPEC,
  103. IPMRA_TABLE_ID,
  104. IPMRA_TABLE_CACHE_RES_QUEUE_LEN,
  105. IPMRA_TABLE_MROUTE_REG_VIF_NUM,
  106. IPMRA_TABLE_MROUTE_DO_ASSERT,
  107. IPMRA_TABLE_MROUTE_DO_PIM,
  108. IPMRA_TABLE_VIFS,
  109. __IPMRA_TABLE_MAX
  110. };
  111. #define IPMRA_TABLE_MAX (__IPMRA_TABLE_MAX - 1)
  112. /* ipmr netlink vif attribute format
  113. * [ IPMRA_TABLE_VIFS ] - nested attribute
  114. * [ IPMRA_VIF ] - nested attribute
  115. * [ IPMRA_VIFA_xxx ]
  116. */
  117. enum {
  118. IPMRA_VIF_UNSPEC,
  119. IPMRA_VIF,
  120. __IPMRA_VIF_MAX
  121. };
  122. #define IPMRA_VIF_MAX (__IPMRA_VIF_MAX - 1)
  123. /* vif-specific attributes */
  124. enum {
  125. IPMRA_VIFA_UNSPEC,
  126. IPMRA_VIFA_IFINDEX,
  127. IPMRA_VIFA_VIF_ID,
  128. IPMRA_VIFA_FLAGS,
  129. IPMRA_VIFA_BYTES_IN,
  130. IPMRA_VIFA_BYTES_OUT,
  131. IPMRA_VIFA_PACKETS_IN,
  132. IPMRA_VIFA_PACKETS_OUT,
  133. IPMRA_VIFA_LOCAL_ADDR,
  134. IPMRA_VIFA_REMOTE_ADDR,
  135. IPMRA_VIFA_PAD,
  136. __IPMRA_VIFA_MAX
  137. };
  138. #define IPMRA_VIFA_MAX (__IPMRA_VIFA_MAX - 1)
  139. /* ipmr netlink cache report attributes */
  140. enum {
  141. IPMRA_CREPORT_UNSPEC,
  142. IPMRA_CREPORT_MSGTYPE,
  143. IPMRA_CREPORT_VIF_ID,
  144. IPMRA_CREPORT_SRC_ADDR,
  145. IPMRA_CREPORT_DST_ADDR,
  146. IPMRA_CREPORT_PKT,
  147. __IPMRA_CREPORT_MAX
  148. };
  149. #define IPMRA_CREPORT_MAX (__IPMRA_CREPORT_MAX - 1)
  150. /* That's all usermode folks */
  151. #define MFC_ASSERT_THRESH (3*HZ) /* Maximal freq. of asserts */
  152. /* Pseudo messages used by mrouted */
  153. #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
  154. #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
  155. #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
  156. #endif /* _UAPI__LINUX_MROUTE_H */