]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_mroute.h
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
[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 along
16 * with this program; see the file COPYING; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef PIM_MROUTE_H
21 #define PIM_MROUTE_H
22
23 /*
24 For msghdr.msg_control in Solaris 10
25 */
26 #ifndef _XPG4_2
27 #define _XPG4_2
28 #endif
29 #ifndef __EXTENSIONS__
30 #define __EXTENSIONS__
31 #endif
32
33 #include <netinet/in.h>
34 #ifdef HAVE_NETINET_IP_MROUTE_H
35 #include <netinet/ip_mroute.h>
36 #endif
37
38 #define PIM_MROUTE_MIN_TTL (1)
39
40 #if PIM_IPV == 4
41 #if defined(HAVE_LINUX_MROUTE_H)
42 #include <linux/mroute.h>
43 #else
44 /*
45 Below: from <linux/mroute.h>
46 */
47
48 #ifndef MAXVIFS
49 #define MAXVIFS (256)
50 #endif
51
52 #ifndef SIOCGETVIFCNT
53 #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
54 #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
55 #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
56 #endif
57
58 #ifndef MRT_INIT
59 #define MRT_BASE 200
60 #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
61 #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
62 #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
63 #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
64 #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
65 #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
66 #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
67 #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
68 #define MRT_PIM (MRT_BASE+8) /* enable PIM code */
69 #endif
70
71 #ifndef MRT_TABLE
72 #define MRT_TABLE (209) /* Specify mroute table ID */
73 #endif
74
75 #ifndef HAVE_VIFI_T
76 typedef unsigned short vifi_t;
77 #endif
78
79 #ifndef HAVE_STRUCT_VIFCTL
80 struct vifctl {
81 vifi_t vifc_vifi; /* Index of VIF */
82 unsigned char vifc_flags; /* VIFF_ flags */
83 unsigned char vifc_threshold; /* ttl limit */
84 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
85 struct in_addr vifc_lcl_addr; /* Our address */
86 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
87 };
88 #endif
89
90 #ifndef HAVE_STRUCT_MFCCTL
91 struct mfcctl {
92 struct in_addr mfcc_origin; /* Origin of mcast */
93 struct in_addr mfcc_mcastgrp; /* Group in question */
94 vifi_t mfcc_parent; /* Where it arrived */
95 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
96 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
97 unsigned int mfcc_byte_cnt;
98 unsigned int mfcc_wrong_if;
99 int mfcc_expire;
100 };
101 #endif
102
103 /*
104 * Group count retrieval for mrouted
105 */
106 /*
107 struct sioc_sg_req sgreq;
108 memset(&sgreq, 0, sizeof(sgreq));
109 memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
110 memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
111 ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
112 */
113 #ifndef HAVE_STRUCT_SIOC_SG_REQ
114 struct sioc_sg_req {
115 struct in_addr src;
116 struct in_addr grp;
117 unsigned long pktcnt;
118 unsigned long bytecnt;
119 unsigned long wrong_if;
120 };
121 #endif
122
123 /*
124 * To get vif packet counts
125 */
126 /*
127 struct sioc_vif_req vreq;
128 memset(&vreq, 0, sizeof(vreq));
129 vreq.vifi = vif_index;
130 ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
131 */
132 #ifndef HAVE_STRUCT_SIOC_VIF_REQ
133 struct sioc_vif_req {
134 vifi_t vifi; /* Which iface */
135 unsigned long icount; /* In packets */
136 unsigned long ocount; /* Out packets */
137 unsigned long ibytes; /* In bytes */
138 unsigned long obytes; /* Out bytes */
139 };
140 #endif
141
142 /*
143 * Pseudo messages used by mrouted
144 */
145 #ifndef IGMPMSG_NOCACHE
146 #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
147 #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
148 #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
149 #endif
150
151 #ifndef HAVE_STRUCT_IGMPMSG
152 struct igmpmsg {
153 uint32_t unused1, unused2;
154 unsigned char im_msgtype; /* What is this */
155 unsigned char im_mbz; /* Must be zero */
156 unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
157 unsigned char unused3;
158 struct in_addr im_src, im_dst;
159 };
160 #endif
161
162 #endif /* HAVE_LINUX_MROUTE_H */
163
164 typedef struct mfcctl pim_mfcctl;
165
166 #else /* PIM_IPV != 4 */
167 #if defined(HAVE_LINUX_MROUTE6_H)
168 #include <linux/mroute6.h>
169 #endif
170
171 typedef struct mf6cctl pim_mfcctl;
172
173 #define MAXVIFS IF_SETSIZE
174 #endif
175
176 #ifndef IGMPMSG_WRVIFWHOLE
177 #define IGMPMSG_WRVIFWHOLE 4 /* For PIM processing */
178 #endif
179
180 /*
181 Above: from <linux/mroute.h>
182 */
183
184 struct channel_oil;
185
186 int pim_mroute_socket_enable(struct pim_instance *pim);
187 int pim_mroute_socket_disable(struct pim_instance *pim);
188
189 int pim_mroute_add_vif(struct interface *ifp, pim_addr ifaddr,
190 unsigned char flags);
191 int pim_mroute_del_vif(struct interface *ifp);
192
193 int pim_upstream_mroute_add(struct channel_oil *c_oil, const char *name);
194 int pim_upstream_mroute_iif_update(struct channel_oil *c_oil, const char *name);
195 int pim_static_mroute_add(struct channel_oil *c_oil, const char *name);
196 void pim_static_mroute_iif_update(struct channel_oil *c_oil,
197 int input_vif_index,
198 const char *name);
199 int pim_mroute_del(struct channel_oil *c_oil, const char *name);
200
201 void pim_mroute_update_counters(struct channel_oil *c_oil);
202 bool pim_mroute_allow_iif_in_oil(struct channel_oil *c_oil,
203 int oif_index);
204 #endif /* PIM_MROUTE_H */