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