]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_mroute.h
zebra: Allow ns delete to happen after under/over flow checks
[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 defined(HAVE_LINUX_MROUTE_H)
41 #include <linux/mroute.h>
42 #else
43 /*
44 Below: from <linux/mroute.h>
45 */
46
47 #ifndef MAXVIFS
48 #define MAXVIFS (256)
49 #endif
50
51 #ifndef SIOCGETVIFCNT
52 #define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
53 #define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
54 #define SIOCGETRPF (SIOCPROTOPRIVATE+2)
55 #endif
56
57 #ifndef MRT_INIT
58 #define MRT_BASE 200
59 #define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
60 #define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
61 #define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
62 #define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
63 #define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
64 #define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
65 #define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
66 #define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
67 #define MRT_PIM (MRT_BASE+8) /* enable PIM code */
68 #endif
69
70 #ifndef MRT_TABLE
71 #define MRT_TABLE (209) /* Specify mroute table ID */
72 #endif
73
74 #ifndef HAVE_VIFI_T
75 typedef unsigned short vifi_t;
76 #endif
77
78 #ifndef HAVE_STRUCT_VIFCTL
79 struct vifctl {
80 vifi_t vifc_vifi; /* Index of VIF */
81 unsigned char vifc_flags; /* VIFF_ flags */
82 unsigned char vifc_threshold; /* ttl limit */
83 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
84 struct in_addr vifc_lcl_addr; /* Our address */
85 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
86 };
87 #endif
88
89 #ifndef HAVE_STRUCT_MFCCTL
90 struct mfcctl {
91 struct in_addr mfcc_origin; /* Origin of mcast */
92 struct in_addr mfcc_mcastgrp; /* Group in question */
93 vifi_t mfcc_parent; /* Where it arrived */
94 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
95 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
96 unsigned int mfcc_byte_cnt;
97 unsigned int mfcc_wrong_if;
98 int mfcc_expire;
99 };
100 #endif
101
102 /*
103 * Group count retrieval for mrouted
104 */
105 /*
106 struct sioc_sg_req sgreq;
107 memset(&sgreq, 0, sizeof(sgreq));
108 memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
109 memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
110 ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
111 */
112 #ifndef HAVE_STRUCT_SIOC_SG_REQ
113 struct sioc_sg_req {
114 struct in_addr src;
115 struct in_addr grp;
116 unsigned long pktcnt;
117 unsigned long bytecnt;
118 unsigned long wrong_if;
119 };
120 #endif
121
122 /*
123 * To get vif packet counts
124 */
125 /*
126 struct sioc_vif_req vreq;
127 memset(&vreq, 0, sizeof(vreq));
128 vreq.vifi = vif_index;
129 ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
130 */
131 #ifndef HAVE_STRUCT_SIOC_VIF_REQ
132 struct sioc_vif_req {
133 vifi_t vifi; /* Which iface */
134 unsigned long icount; /* In packets */
135 unsigned long ocount; /* Out packets */
136 unsigned long ibytes; /* In bytes */
137 unsigned long obytes; /* Out bytes */
138 };
139 #endif
140
141 /*
142 * Pseudo messages used by mrouted
143 */
144 #ifndef IGMPMSG_NOCACHE
145 #define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
146 #define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
147 #define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
148 #endif
149
150 #ifndef HAVE_STRUCT_IGMPMSG
151 struct igmpmsg {
152 uint32_t unused1, unused2;
153 unsigned char im_msgtype; /* What is this */
154 unsigned char im_mbz; /* Must be zero */
155 unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
156 unsigned char unused3;
157 struct in_addr im_src, im_dst;
158 };
159 #endif
160 #endif
161
162 #ifndef IGMPMSG_WRVIFWHOLE
163 #define IGMPMSG_WRVIFWHOLE 4 /* For PIM processing */
164 #endif
165
166 /*
167 Above: from <linux/mroute.h>
168 */
169
170 int pim_mroute_socket_enable(struct pim_instance *pim);
171 int pim_mroute_socket_disable(struct pim_instance *pim);
172
173 int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
174 unsigned char flags);
175 int pim_mroute_del_vif(struct interface *ifp);
176
177 int pim_mroute_add(struct channel_oil *c_oil, const char *name);
178 int pim_mroute_del(struct channel_oil *c_oil, const char *name);
179
180 void pim_mroute_update_counters(struct channel_oil *c_oil);
181 #endif /* PIM_MROUTE_H */