]> git.proxmox.com Git - mirror_frr.git/blob - pimd/pim_bsm.h
pimd: PIM BSM Processing datastructure definition/initialization/deinit
[mirror_frr.git] / pimd / pim_bsm.h
1 /*
2 * pim_bsm.h: PIM BSM handling related
3 *
4 * Copyright (C) 2018-19 Vmware, Inc.
5 * Saravanan K
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
20 * MA 02110-1301 USA
21 */
22
23 #ifndef __PIM_BSM_H__
24 #define __PIM_BSM_H__
25
26 #include "if.h"
27 #include "vty.h"
28 #include "linklist.h"
29 #include "table.h"
30 #include "pim_rp.h"
31 #include "pim_msg.h"
32
33 /* Defines */
34 #define PIM_GBL_SZ_ID 0 /* global scope zone id set to 0 */
35 #define PIM_BS_TIME 60 /* RFC 5059 - Sec 5 */
36 #define PIM_BSR_DEFAULT_TIMEOUT 130 /* RFC 5059 - Sec 5 */
37
38 /* These structures are only encoded IPv4 specific */
39 #define PIM_BSM_HDR_LEN sizeof(struct bsm_hdr)
40 #define PIM_BSM_GRP_LEN sizeof(struct bsmmsg_grpinfo)
41 #define PIM_BSM_RP_LEN sizeof(struct bsmmsg_rpinfo)
42
43 #define PIM_MIN_BSM_LEN (PIM_HDR_LEN + \
44 PIM_BSM_HDR_LEN + \
45 PIM_BSM_GRP_LEN + \
46 PIM_BSM_RP_LEN)
47 /* Datastructures
48 * ==============
49 */
50
51 /* Non candidate BSR states */
52 enum ncbsr_state{
53 NO_INFO = 0,
54 ACCEPT_ANY,
55 ACCEPT_PREFERRED
56 };
57
58 /* BSM scope - bsm processing is per scope */
59 struct bsm_scope {
60 int sz_id; /* scope zone id */
61 enum ncbsr_state state; /* non candidate BSR state */
62 bool accept_nofwd_bsm; /* no fwd bsm accepted for scope */
63 struct in_addr current_bsr; /* current elected BSR for the sz */
64 uint32_t current_bsr_prio; /* current BSR priority */
65 int64_t current_bsr_first_ts; /* current BSR elected time */
66 int64_t current_bsr_last_ts; /* Last BSM received from E-BSR */
67 uint16_t bsm_frag_tag; /* Last received frag tag from E-BSR */
68 uint8_t hashMasklen; /* Mask in hash calc RFC 7761 4.7.2 */
69 struct pim_instance *pim; /* Back pointer to pim instance */
70 struct list *bsm_list; /* list of bsm frag for frowarding */
71 struct route_table *bsrp_table; /* group2rp mapping rcvd from BSR */
72 struct thread *bs_timer; /* Boot strap timer */
73 struct thread *sz_timer;
74 };
75
76 /* BSM packet - this is stored as list in bsm_list inside scope
77 * This is used for forwarding to new neighbors or restarting mcast routers
78 */
79 struct bsm_info {
80 uint32_t size; /* size of the packet */
81 unsigned char *bsm; /* Actual packet */
82 };
83
84 /* This is the group node of the bsrp table in scope.
85 * this node maintains the list of rp for the group.
86 */
87 struct bsgrp_node {
88 struct prefix group; /* Group range */
89 struct bsm_scope *scope; /* Back ptr to scope */
90 struct list *bsrp_list; /* list of RPs adv by BSR */
91 struct list *partial_bsrp_list; /* maintained until all RPs received */
92 int pend_rp_cnt; /* Total RP - Received RP */
93 uint16_t frag_tag; /* frag tag to identify the fragment */
94 };
95
96 /* This is the list node of bsrp_list and partial bsrp list in
97 * bsgrp_node. Hold info of each RP received for the group
98 */
99 struct bsm_rpinfo {
100 uint32_t hash; /* Hash Value as per RFC 7761 4.7.2 */
101 uint32_t elapse_time; /* upd at expiry of elected RP node */
102 uint16_t rp_prio; /* RP priority */
103 uint16_t rp_holdtime; /* RP holdtime - g2rp timer value */
104 struct in_addr rp_address; /* RP Address */
105 struct bsgrp_node *bsgrp_node; /* Back ptr to bsgrp_node */
106 struct thread *g2rp_timer; /* Run only for elected RP node */
107 };
108
109 /* Structures to extract Bootstrap Message header and Grp to RP Mappings
110 * =====================================================================
111 * BSM Format:
112 *
113 * 0 1 2 3
114 * 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
115 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 * |PIM Ver| Type |N| Reserved | Checksum | PIM HDR
117 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118 * | Fragment Tag | Hash Mask Len | BSR Priority | BS HDR(1)
119 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 * | BSR Address (Encoded-Unicast format) | BS HDR(2)
121 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122 * | Group Address 1 (Encoded-Group format) |
123 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
124 * | RP Count 1 | Frag RP Cnt 1 | Reserved |
125 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
126 * | RP Address 1 (Encoded-Unicast format) |
127 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 * | RP1 Holdtime | RP1 Priority | Reserved |
129 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130 * | RP Address 2 (Encoded-Unicast format) |
131 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
132 * | RP2 Holdtime | RP2 Priority | Reserved |
133 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
134 * | . |
135 * | . |
136 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137 * | RP Address m (Encoded-Unicast format) |
138 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
139 * | RPm Holdtime | RPm Priority | Reserved |
140 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
141 * | Group Address 2 (Encoded-Group format) |
142 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 * | . |
144 * | . |
145 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
146 * | Group Address n (Encoded-Group format) |
147 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
148 * | RP Count n | Frag RP Cnt n | Reserved |
149 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
150 * | RP Address 1 (Encoded-Unicast format) |
151 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
152 * | RP1 Holdtime | RP1 Priority | Reserved |
153 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
154 * | RP Address 2 (Encoded-Unicast format) |
155 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
156 * | RP2 Holdtime | RP2 Priority | Reserved |
157 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
158 * | . |
159 * | . |
160 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
161 * | RP Address m (Encoded-Unicast format) |
162 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
163 * | RPm Holdtime | RPm Priority | Reserved |
164 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
165 */
166 struct bsm_hdr {
167 uint16_t frag_tag;
168 uint8_t hm_len;
169 uint8_t bsr_prio;
170 struct pim_encoded_ipv4_unicast bsr_addr;
171 }__attribute__((packed));
172
173 struct bsmmsg_grpinfo {
174 struct pim_encoded_group_ipv4 group;
175 uint8_t rp_count;
176 uint8_t frag_rp_count;
177 uint16_t reserved;
178 }__attribute__((packed));
179
180 struct bsmmsg_rpinfo {
181 struct pim_encoded_ipv4_unicast rpaddr;
182 uint16_t rp_holdtime;
183 uint8_t rp_pri;
184 uint8_t reserved;
185 }__attribute__((packed));
186
187 /* API */
188 void pim_bsm_proc_init(struct pim_instance *pim);
189 void pim_bsm_proc_free(struct pim_instance *pim);
190
191 #endif