]> git.proxmox.com Git - mirror_frr.git/blame - pimd/pim_iface.h
pimd: add support for IGMPv2
[mirror_frr.git] / pimd / pim_iface.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.
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
12e41d03
DL
20*/
21
22#ifndef PIM_IFACE_H
23#define PIM_IFACE_H
24
25#include <zebra.h>
26
27#include "if.h"
28#include "vty.h"
29
30#include "pim_igmp.h"
31#include "pim_upstream.h"
32
33#define PIM_IF_MASK_PIM (1 << 0)
34#define PIM_IF_MASK_IGMP (1 << 1)
35#define PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS (1 << 2)
36#define PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION (1 << 3)
37
38#define PIM_IF_IS_DELETED(ifp) ((ifp)->ifindex == IFINDEX_INTERNAL)
39
40#define PIM_IF_TEST_PIM(options) (PIM_IF_MASK_PIM & (options))
41#define PIM_IF_TEST_IGMP(options) (PIM_IF_MASK_IGMP & (options))
42#define PIM_IF_TEST_IGMP_LISTEN_ALLROUTERS(options) (PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS & (options))
43#define PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) (PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION & (options))
44
45#define PIM_IF_DO_PIM(options) ((options) |= PIM_IF_MASK_PIM)
46#define PIM_IF_DO_IGMP(options) ((options) |= PIM_IF_MASK_IGMP)
47#define PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(options) ((options) |= PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
48#define PIM_IF_DO_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) |= PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
49
50#define PIM_IF_DONT_PIM(options) ((options) &= ~PIM_IF_MASK_PIM)
51#define PIM_IF_DONT_IGMP(options) ((options) &= ~PIM_IF_MASK_IGMP)
52#define PIM_IF_DONT_IGMP_LISTEN_ALLROUTERS(options) ((options) &= ~PIM_IF_MASK_IGMP_LISTEN_ALLROUTERS)
53#define PIM_IF_DONT_PIM_CAN_DISABLE_JOIN_SUPRESSION(options) ((options) &= ~PIM_IF_MASK_PIM_CAN_DISABLE_JOIN_SUPRESSION)
54
df696e3f 55#define PIM_I_am_DR(pim_ifp) (pim_ifp)->pim_dr_addr.s_addr == (pim_ifp)->primary_address.s_addr
84366c7e 56
981d6c7a
DS
57enum pim_interface_type {
58 PIM_INTERFACE_SSM,
59 PIM_INTERFACE_SM
60};
61
12e41d03 62struct pim_interface {
981d6c7a 63 enum pim_interface_type itype;
12e41d03 64 uint32_t options; /* bit vector */
b892f1dd 65 ifindex_t mroute_vif_index;
12e41d03
DL
66 struct in_addr primary_address; /* remember addr to detect change */
67
b05b72e8 68 int igmp_version; /* IGMP version */
12e41d03
DL
69 int igmp_default_robustness_variable; /* IGMPv3 QRV */
70 int igmp_default_query_interval; /* IGMPv3 secs between general queries */
71 int igmp_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for general queries */
72 int igmp_specific_query_max_response_time_dsec; /* IGMPv3 Max Response Time in dsecs for specific queries */
73 struct list *igmp_socket_list; /* list of struct igmp_sock */
74 struct list *igmp_join_list; /* list of struct igmp_join */
75
76 int pim_sock_fd; /* PIM socket file descriptor */
77 struct thread *t_pim_sock_read; /* thread for reading PIM socket */
78 int64_t pim_sock_creation; /* timestamp of PIM socket creation */
79
80 struct thread *t_pim_hello_timer;
81 int pim_hello_period;
82 int pim_default_holdtime;
83 int pim_triggered_hello_delay;
84 uint32_t pim_generation_id;
85 uint16_t pim_propagation_delay_msec; /* config */
86 uint16_t pim_override_interval_msec; /* config */
87 struct list *pim_neighbor_list; /* list of struct pim_neighbor */
88 struct list *pim_ifchannel_list; /* list of struct pim_ifchannel */
89
90 /* neighbors without lan_delay */
91 int pim_number_of_nonlandelay_neighbors;
92 uint16_t pim_neighbors_highest_propagation_delay_msec;
93 uint16_t pim_neighbors_highest_override_interval_msec;
94
95 /* DR Election */
96 int64_t pim_dr_election_last; /* timestamp */
97 int pim_dr_election_count;
98 int pim_dr_election_changes;
99 struct in_addr pim_dr_addr;
100 uint32_t pim_dr_priority; /* config */
101 int pim_dr_num_nondrpri_neighbors; /* neighbors without dr_pri */
102
103 int64_t pim_ifstat_start; /* start timestamp for stats */
104 uint32_t pim_ifstat_hello_sent;
105 uint32_t pim_ifstat_hello_sendfail;
106 uint32_t pim_ifstat_hello_recv;
107 uint32_t pim_ifstat_hello_recvfail;
108};
109
c992c9a0 110extern struct interface *pim_regiface;
12e41d03
DL
111/*
112 if default_holdtime is set (>= 0), use it;
113 otherwise default_holdtime is 3.5 * hello_period
114 */
115#define PIM_IF_DEFAULT_HOLDTIME(pim_ifp) \
116 (((pim_ifp)->pim_default_holdtime < 0) ? \
117 ((pim_ifp)->pim_hello_period * 7 / 2) : \
118 ((pim_ifp)->pim_default_holdtime))
119
120void pim_if_init(void);
121
122struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim);
123void pim_if_delete(struct interface *ifp);
124void pim_if_addr_add(struct connected *ifc);
125void pim_if_addr_del(struct connected *ifc, int force_prim_as_any);
126void pim_if_addr_add_all(struct interface *ifp);
127void pim_if_addr_del_all(struct interface *ifp);
128void pim_if_addr_del_all_igmp(struct interface *ifp);
129void pim_if_addr_del_all_pim(struct interface *ifp);
130
131int pim_if_add_vif(struct interface *ifp);
132int pim_if_del_vif(struct interface *ifp);
133void pim_if_add_vif_all(void);
134void pim_if_del_vif_all(void);
135
b892f1dd
PJ
136struct interface *pim_if_find_by_vif_index(ifindex_t vif_index);
137int pim_if_find_vifindex_by_ifindex(ifindex_t ifindex);
12e41d03
DL
138
139int pim_if_lan_delay_enabled(struct interface *ifp);
140uint16_t pim_if_effective_propagation_delay_msec(struct interface *ifp);
141uint16_t pim_if_effective_override_interval_msec(struct interface *ifp);
142uint16_t pim_if_jp_override_interval_msec(struct interface *ifp);
143struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp,
144 struct in_addr addr);
145
146long pim_if_t_suppressed_msec(struct interface *ifp);
147int pim_if_t_override_msec(struct interface *ifp);
148
149struct in_addr pim_find_primary_addr(struct interface *ifp);
150
151int pim_if_igmp_join_add(struct interface *ifp,
152 struct in_addr group_addr,
153 struct in_addr source_addr);
154int pim_if_igmp_join_del(struct interface *ifp,
155 struct in_addr group_addr,
156 struct in_addr source_addr);
157
158void pim_if_update_could_assert(struct interface *ifp);
159
160void pim_if_assert_on_neighbor_down(struct interface *ifp,
161 struct in_addr neigh_addr);
162
163void pim_if_rpf_interface_changed(struct interface *old_rpf_ifp,
164 struct pim_upstream *up);
165
166void pim_if_update_join_desired(struct pim_interface *pim_ifp);
167
168void pim_if_update_assert_tracking_desired(struct interface *ifp);
169
c992c9a0 170void pim_if_create_pimreg(void);
3565202d
DS
171
172int pim_if_connected_to_source (struct interface *ifp, struct in_addr src);
12e41d03 173#endif /* PIM_IFACE_H */