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