pim_mroute.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /*
  2. PIM for Quagga
  3. Copyright (C) 2008 Everton da Silva Marques
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  15. MA 02110-1301 USA
  16. $QuaggaId: $Format:%an, %ai, %h$ $
  17. */
  18. #ifndef PIM_MROUTE_H
  19. #define PIM_MROUTE_H
  20. /*
  21. For msghdr.msg_control in Solaris 10
  22. */
  23. #ifndef _XPG4_2
  24. #define _XPG4_2
  25. #endif
  26. #ifndef __EXTENSIONS__
  27. #define __EXTENSIONS__
  28. #endif
  29. #include <netinet/in.h>
  30. #ifdef HAVE_NETINET_IP_MROUTE_H
  31. #include <netinet/ip_mroute.h>
  32. #endif
  33. #define PIM_MROUTE_MIN_TTL (1)
  34. /*
  35. Below: from <linux/mroute.h>
  36. */
  37. #ifndef MAXVIFS
  38. #define MAXVIFS (32)
  39. #endif
  40. #ifndef SIOCGETVIFCNT
  41. #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
  42. #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
  43. #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
  44. #endif
  45. #ifndef MRT_INIT
  46. #define MRT_BASE 200
  47. #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
  48. #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
  49. #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
  50. #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
  51. #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
  52. #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
  53. #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
  54. #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
  55. #define MRT_PIM (MRT_BASE+8) /* enable PIM code */
  56. #endif
  57. #ifndef HAVE_VIFI_T
  58. typedef unsigned short vifi_t;
  59. #endif
  60. #ifndef HAVE_STRUCT_VIFCTL
  61. struct vifctl {
  62. vifi_t vifc_vifi; /* Index of VIF */
  63. unsigned char vifc_flags; /* VIFF_ flags */
  64. unsigned char vifc_threshold; /* ttl limit */
  65. unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
  66. struct in_addr vifc_lcl_addr; /* Our address */
  67. struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
  68. };
  69. #endif
  70. #ifndef HAVE_STRUCT_MFCCTL
  71. struct mfcctl {
  72. struct in_addr mfcc_origin; /* Origin of mcast */
  73. struct in_addr mfcc_mcastgrp; /* Group in question */
  74. vifi_t mfcc_parent; /* Where it arrived */
  75. unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
  76. unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
  77. unsigned int mfcc_byte_cnt;
  78. unsigned int mfcc_wrong_if;
  79. int mfcc_expire;
  80. };
  81. #endif
  82. /*
  83. * Group count retrieval for mrouted
  84. */
  85. /*
  86. struct sioc_sg_req sgreq;
  87. memset(&sgreq, 0, sizeof(sgreq));
  88. memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
  89. memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
  90. ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
  91. */
  92. #ifndef HAVE_STRUCT_SIOC_SG_REQ
  93. struct sioc_sg_req {
  94. struct in_addr src;
  95. struct in_addr grp;
  96. unsigned long pktcnt;
  97. unsigned long bytecnt;
  98. unsigned long wrong_if;
  99. };
  100. #endif
  101. /*
  102. * To get vif packet counts
  103. */
  104. /*
  105. struct sioc_vif_req vreq;
  106. memset(&vreq, 0, sizeof(vreq));
  107. vreq.vifi = vif_index;
  108. ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
  109. */
  110. #ifndef HAVE_STRUCT_SIOC_VIF_REQ
  111. struct sioc_vif_req {
  112. vifi_t vifi; /* Which iface */
  113. unsigned long icount; /* In packets */
  114. unsigned long ocount; /* Out packets */
  115. unsigned long ibytes; /* In bytes */
  116. unsigned long obytes; /* Out bytes */
  117. };
  118. #endif
  119. /*
  120. * Pseudo messages used by mrouted
  121. */
  122. #ifndef IGMPMSG_NOCACHE
  123. #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
  124. #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
  125. #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
  126. #endif
  127. #ifndef HAVE_STRUCT_IGMPMSG
  128. struct igmpmsg
  129. {
  130. uint32_t unused1,unused2;
  131. unsigned char im_msgtype; /* What is this */
  132. unsigned char im_mbz; /* Must be zero */
  133. unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
  134. unsigned char unused3;
  135. struct in_addr im_src,im_dst;
  136. };
  137. #endif
  138. /*
  139. Above: from <linux/mroute.h>
  140. */
  141. int pim_mroute_socket_enable(void);
  142. int pim_mroute_socket_disable(void);
  143. int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr);
  144. int pim_mroute_del_vif(int vif_index);
  145. int pim_mroute_add(struct mfcctl *mc);
  146. int pim_mroute_del(struct mfcctl *mc);
  147. int pim_mroute_msg(int fd, const char *buf, int buf_size);
  148. #endif /* PIM_MROUTE_H */