blob: 125d1901bf965a578d9e0fa8bf4f879fe04c14f5 [file] [log] [blame]
Everton Marques871dbcf2009-08-11 15:43:05 -03001/*
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 $QuaggaId: $Format:%an, %ai, %h$ $
21*/
22
23#ifndef PIM_MROUTE_H
24#define PIM_MROUTE_H
25
26/*
27 For msghdr.msg_control in Solaris 10
28*/
29#ifndef _XPG4_2
30#define _XPG4_2
31#endif
32#ifndef __EXTENSIONS__
33#define __EXTENSIONS__
34#endif
35
36#include <netinet/in.h>
37#ifdef HAVE_NETINET_IP_MROUTE_H
38#include <netinet/ip_mroute.h>
39#endif
40
41#define PIM_MROUTE_MIN_TTL (1)
42
Donald Sharp1934e782015-06-05 12:15:44 -070043#if defined(HAVE_LINUX_MROUTE_H)
44#include <linux/mroute.h>
45#else
Everton Marques871dbcf2009-08-11 15:43:05 -030046/*
47 Below: from <linux/mroute.h>
48*/
49
50#ifndef MAXVIFS
51#define MAXVIFS (32)
52#endif
53
54#ifndef SIOCGETVIFCNT
55#define SIOCGETVIFCNT SIOCPROTOPRIVATE /* IP protocol privates */
56#define SIOCGETSGCNT (SIOCPROTOPRIVATE+1)
57#define SIOCGETRPF (SIOCPROTOPRIVATE+2)
58#endif
59
60#ifndef MRT_INIT
61#define MRT_BASE 200
62#define MRT_INIT (MRT_BASE) /* Activate the kernel mroute code */
63#define MRT_DONE (MRT_BASE+1) /* Shutdown the kernel mroute */
64#define MRT_ADD_VIF (MRT_BASE+2) /* Add a virtual interface */
65#define MRT_DEL_VIF (MRT_BASE+3) /* Delete a virtual interface */
66#define MRT_ADD_MFC (MRT_BASE+4) /* Add a multicast forwarding entry */
67#define MRT_DEL_MFC (MRT_BASE+5) /* Delete a multicast forwarding entry */
68#define MRT_VERSION (MRT_BASE+6) /* Get the kernel multicast version */
69#define MRT_ASSERT (MRT_BASE+7) /* Activate PIM assert mode */
70#define MRT_PIM (MRT_BASE+8) /* enable PIM code */
71#endif
72
73#ifndef HAVE_VIFI_T
74typedef unsigned short vifi_t;
75#endif
76
77#ifndef HAVE_STRUCT_VIFCTL
78struct vifctl {
79 vifi_t vifc_vifi; /* Index of VIF */
80 unsigned char vifc_flags; /* VIFF_ flags */
81 unsigned char vifc_threshold; /* ttl limit */
82 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
83 struct in_addr vifc_lcl_addr; /* Our address */
84 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
85};
86#endif
87
88#ifndef HAVE_STRUCT_MFCCTL
89struct mfcctl {
90 struct in_addr mfcc_origin; /* Origin of mcast */
91 struct in_addr mfcc_mcastgrp; /* Group in question */
92 vifi_t mfcc_parent; /* Where it arrived */
93 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
94 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
95 unsigned int mfcc_byte_cnt;
96 unsigned int mfcc_wrong_if;
97 int mfcc_expire;
98};
99#endif
100
101/*
102 * Group count retrieval for mrouted
103 */
104/*
105 struct sioc_sg_req sgreq;
106 memset(&sgreq, 0, sizeof(sgreq));
107 memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
108 memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
109 ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
110 */
111#ifndef HAVE_STRUCT_SIOC_SG_REQ
112struct sioc_sg_req {
113 struct in_addr src;
114 struct in_addr grp;
115 unsigned long pktcnt;
116 unsigned long bytecnt;
117 unsigned long wrong_if;
118};
119#endif
120
121/*
122 * To get vif packet counts
123 */
124/*
125 struct sioc_vif_req vreq;
126 memset(&vreq, 0, sizeof(vreq));
127 vreq.vifi = vif_index;
128 ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
129 */
130#ifndef HAVE_STRUCT_SIOC_VIF_REQ
131struct sioc_vif_req {
132 vifi_t vifi; /* Which iface */
133 unsigned long icount; /* In packets */
134 unsigned long ocount; /* Out packets */
135 unsigned long ibytes; /* In bytes */
136 unsigned long obytes; /* Out bytes */
137};
138#endif
139
140/*
141 * Pseudo messages used by mrouted
142 */
143#ifndef IGMPMSG_NOCACHE
144#define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
145#define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
146#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
147#endif
148
149#ifndef HAVE_STRUCT_IGMPMSG
150struct igmpmsg
151{
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
Donald Sharp1934e782015-06-05 12:15:44 -0700160#endif
Everton Marques871dbcf2009-08-11 15:43:05 -0300161
162/*
163 Above: from <linux/mroute.h>
164*/
165
166int pim_mroute_socket_enable(void);
167int pim_mroute_socket_disable(void);
168
169int pim_mroute_add_vif(int vif_index, struct in_addr ifaddr);
170int pim_mroute_del_vif(int vif_index);
171
172int pim_mroute_add(struct mfcctl *mc);
173int pim_mroute_del(struct mfcctl *mc);
174
175int pim_mroute_msg(int fd, const char *buf, int buf_size);
176
177#endif /* PIM_MROUTE_H */