]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_mroute.h
Merge pull request #1369 from LabNConsulting/working/3.0/cherry-pick/minusS
[mirror_frr.git] / pimd / pim_mroute.h
CommitLineData
12e41d03
DL
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.
ac4d0be5 14
12e41d03
DL
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
12e41d03
DL
19*/
20
21#ifndef PIM_MROUTE_H
22#define PIM_MROUTE_H
23
24/*
25 For msghdr.msg_control in Solaris 10
26*/
27#ifndef _XPG4_2
28#define _XPG4_2
29#endif
30#ifndef __EXTENSIONS__
31#define __EXTENSIONS__
32#endif
33
34#include <netinet/in.h>
35#ifdef HAVE_NETINET_IP_MROUTE_H
36#include <netinet/ip_mroute.h>
37#endif
38
39#define PIM_MROUTE_MIN_TTL (1)
40
a724477d
DS
41#if defined(HAVE_LINUX_MROUTE_H)
42#include <linux/mroute.h>
43#else
12e41d03
DL
44/*
45 Below: from <linux/mroute.h>
46*/
47
48#ifndef MAXVIFS
1865a44a 49#define MAXVIFS (256)
12e41d03
DL
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 HAVE_VIFI_T
72typedef unsigned short vifi_t;
73#endif
74
75#ifndef HAVE_STRUCT_VIFCTL
76struct vifctl {
ac4d0be5 77 vifi_t vifc_vifi; /* Index of VIF */
78 unsigned char vifc_flags; /* VIFF_ flags */
79 unsigned char vifc_threshold; /* ttl limit */
80 unsigned int vifc_rate_limit; /* Rate limiter values (NI) */
81 struct in_addr vifc_lcl_addr; /* Our address */
82 struct in_addr vifc_rmt_addr; /* IPIP tunnel addr */
12e41d03
DL
83};
84#endif
85
86#ifndef HAVE_STRUCT_MFCCTL
87struct mfcctl {
ac4d0be5 88 struct in_addr mfcc_origin; /* Origin of mcast */
89 struct in_addr mfcc_mcastgrp; /* Group in question */
90 vifi_t mfcc_parent; /* Where it arrived */
91 unsigned char mfcc_ttls[MAXVIFS]; /* Where it is going */
92 unsigned int mfcc_pkt_cnt; /* pkt count for src-grp */
93 unsigned int mfcc_byte_cnt;
94 unsigned int mfcc_wrong_if;
95 int mfcc_expire;
12e41d03
DL
96};
97#endif
98
99/*
100 * Group count retrieval for mrouted
101 */
102/*
103 struct sioc_sg_req sgreq;
104 memset(&sgreq, 0, sizeof(sgreq));
105 memcpy(&sgreq.src, &source_addr, sizeof(sgreq.src));
106 memcpy(&sgreq.grp, &group_addr, sizeof(sgreq.grp));
107 ioctl(mrouter_s4, SIOCGETSGCNT, &sgreq);
108 */
109#ifndef HAVE_STRUCT_SIOC_SG_REQ
110struct sioc_sg_req {
ac4d0be5 111 struct in_addr src;
112 struct in_addr grp;
113 unsigned long pktcnt;
114 unsigned long bytecnt;
115 unsigned long wrong_if;
12e41d03
DL
116};
117#endif
118
119/*
120 * To get vif packet counts
121 */
122/*
123 struct sioc_vif_req vreq;
124 memset(&vreq, 0, sizeof(vreq));
125 vreq.vifi = vif_index;
126 ioctl(mrouter_s4, SIOCGETVIFCNT, &vreq);
127 */
128#ifndef HAVE_STRUCT_SIOC_VIF_REQ
129struct sioc_vif_req {
ac4d0be5 130 vifi_t vifi; /* Which iface */
131 unsigned long icount; /* In packets */
132 unsigned long ocount; /* Out packets */
133 unsigned long ibytes; /* In bytes */
134 unsigned long obytes; /* Out bytes */
12e41d03
DL
135};
136#endif
137
138/*
139 * Pseudo messages used by mrouted
140 */
141#ifndef IGMPMSG_NOCACHE
142#define IGMPMSG_NOCACHE 1 /* Kern cache fill request to mrouted */
143#define IGMPMSG_WRONGVIF 2 /* For PIM assert processing (unused) */
144#define IGMPMSG_WHOLEPKT 3 /* For PIM Register processing */
145#endif
146
147#ifndef HAVE_STRUCT_IGMPMSG
ac4d0be5 148struct igmpmsg {
149 uint32_t unused1, unused2;
150 unsigned char im_msgtype; /* What is this */
151 unsigned char im_mbz; /* Must be zero */
152 unsigned char im_vif; /* Interface (this ought to be a vifi_t!) */
153 unsigned char unused3;
154 struct in_addr im_src, im_dst;
12e41d03
DL
155};
156#endif
a724477d 157#endif
12e41d03 158
87243934 159#ifndef IGMPMSG_WRVIFWHOLE
75a26779 160#define IGMPMSG_WRVIFWHOLE 4 /* For PIM processing */
87243934
DS
161#endif
162
12e41d03
DL
163/*
164 Above: from <linux/mroute.h>
165*/
166
167int pim_mroute_socket_enable(void);
168int pim_mroute_socket_disable(void);
169
ac4d0be5 170int pim_mroute_add_vif(struct interface *ifp, struct in_addr ifaddr,
171 unsigned char flags);
12e41d03
DL
172int pim_mroute_del_vif(int vif_index);
173
6a78764e
DS
174int pim_mroute_add(struct channel_oil *c_oil, const char *name);
175int pim_mroute_del(struct channel_oil *c_oil, const char *name);
12e41d03
DL
176
177int pim_mroute_msg(int fd, const char *buf, int buf_size);
178
ac4d0be5 179void pim_mroute_update_counters(struct channel_oil *c_oil);
12e41d03 180#endif /* PIM_MROUTE_H */