]>
Commit | Line | Data |
---|---|---|
1 | // SPDX-License-Identifier: GPL-2.0-or-later | |
2 | /* | |
3 | * EIGRP Definition of Data Structures. | |
4 | * Copyright (C) 2013-2016 | |
5 | * Authors: | |
6 | * Donnie Savage | |
7 | * Jan Janovic | |
8 | * Matej Perina | |
9 | * Peter Orsag | |
10 | * Peter Paluch | |
11 | * Frantisek Gazo | |
12 | * Tomas Hvorkovy | |
13 | * Martin Kontsek | |
14 | * Lukas Koribsky | |
15 | */ | |
16 | ||
17 | #ifndef _ZEBRA_EIGRP_STRUCTS_H_ | |
18 | #define _ZEBRA_EIGRP_STRUCTS_H_ | |
19 | ||
20 | #include "filter.h" | |
21 | ||
22 | #include "eigrpd/eigrp_const.h" | |
23 | #include "eigrpd/eigrp_macros.h" | |
24 | ||
25 | struct eigrp_metrics { | |
26 | uint32_t delay; | |
27 | uint32_t bandwidth; | |
28 | uint8_t mtu[3]; | |
29 | uint8_t hop_count; | |
30 | uint8_t reliability; | |
31 | uint8_t load; | |
32 | uint8_t tag; | |
33 | uint8_t flags; | |
34 | }; | |
35 | ||
36 | struct eigrp_extdata { | |
37 | uint32_t orig; | |
38 | uint32_t as; | |
39 | uint32_t tag; | |
40 | uint32_t metric; | |
41 | uint16_t reserved; | |
42 | uint8_t protocol; | |
43 | uint8_t flags; | |
44 | }; | |
45 | ||
46 | struct eigrp { | |
47 | vrf_id_t vrf_id; | |
48 | ||
49 | uint16_t AS; /* Autonomous system number */ | |
50 | uint16_t vrid; /* Virtual Router ID */ | |
51 | uint8_t k_values[6]; /*Array for K values configuration*/ | |
52 | uint8_t variance; /*Metric variance multiplier*/ | |
53 | uint8_t max_paths; /*Maximum allowed paths for 1 prefix*/ | |
54 | ||
55 | /*Name of this EIGRP instance*/ | |
56 | char *name; | |
57 | ||
58 | /* EIGRP Router ID. */ | |
59 | struct in_addr router_id; /* Configured automatically. */ | |
60 | struct in_addr router_id_static; /* Configured manually. */ | |
61 | ||
62 | struct list *eiflist; /* eigrp interfaces */ | |
63 | uint8_t passive_interface_default; /* passive-interface default */ | |
64 | ||
65 | int fd; | |
66 | unsigned int maxsndbuflen; | |
67 | ||
68 | uint32_t sequence_number; /*Global EIGRP sequence number*/ | |
69 | ||
70 | struct stream *ibuf; | |
71 | struct list *oi_write_q; | |
72 | ||
73 | /*Threads*/ | |
74 | struct thread *t_write; | |
75 | struct thread *t_read; | |
76 | struct thread *t_distribute; /* timer for distribute list */ | |
77 | ||
78 | struct route_table *networks; /* EIGRP config networks. */ | |
79 | ||
80 | struct route_table *topology_table; | |
81 | ||
82 | uint64_t serno; /* Global serial number counter for topology entry | |
83 | changes*/ | |
84 | uint64_t serno_last_update; /* Highest serial number of information send | |
85 | by last update*/ | |
86 | struct list *topology_changes_internalIPV4; | |
87 | struct list *topology_changes_externalIPV4; | |
88 | ||
89 | /*Neighbor self*/ | |
90 | struct eigrp_neighbor *neighbor_self; | |
91 | ||
92 | /*Configured metric for redistributed routes*/ | |
93 | struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1]; | |
94 | int redistribute; /* Num of redistributed protocols. */ | |
95 | ||
96 | /* Access-list. */ | |
97 | struct access_list *list[EIGRP_FILTER_MAX]; | |
98 | /* Prefix-list. */ | |
99 | struct prefix_list *prefix[EIGRP_FILTER_MAX]; | |
100 | /* Route-map. */ | |
101 | struct route_map *routemap[EIGRP_FILTER_MAX]; | |
102 | ||
103 | /* For redistribute route map. */ | |
104 | struct { | |
105 | char *name; | |
106 | struct route_map *map; | |
107 | int metric_config; | |
108 | uint32_t metric; | |
109 | } route_map[ZEBRA_ROUTE_MAX]; | |
110 | ||
111 | /* distribute_ctx */ | |
112 | struct distribute_ctx *distribute_ctx; | |
113 | ||
114 | QOBJ_FIELDS; | |
115 | }; | |
116 | DECLARE_QOBJ_TYPE(eigrp); | |
117 | ||
118 | struct eigrp_if_params { | |
119 | uint8_t passive_interface; | |
120 | uint32_t v_hello; | |
121 | uint16_t v_wait; | |
122 | uint8_t type; /* type of interface */ | |
123 | uint32_t bandwidth; | |
124 | uint32_t delay; | |
125 | uint8_t reliability; | |
126 | uint8_t load; | |
127 | ||
128 | char *auth_keychain; /* Associated keychain with interface*/ | |
129 | int auth_type; /* EIGRP authentication type */ | |
130 | }; | |
131 | ||
132 | enum { MEMBER_ALLROUTERS = 0, | |
133 | MEMBER_MAX, | |
134 | }; | |
135 | ||
136 | /*EIGRP interface structure*/ | |
137 | struct eigrp_interface { | |
138 | struct eigrp_if_params params; | |
139 | ||
140 | /*multicast group refcnts */ | |
141 | bool member_allrouters; | |
142 | ||
143 | /* This interface's parent eigrp instance. */ | |
144 | struct eigrp *eigrp; | |
145 | ||
146 | /* Interface data from zebra. */ | |
147 | struct interface *ifp; | |
148 | ||
149 | /* Packet send buffer. */ | |
150 | struct eigrp_fifo *obuf; /* Output queue */ | |
151 | ||
152 | /* To which multicast groups do we currently belong? */ | |
153 | ||
154 | uint32_t curr_bandwidth; | |
155 | uint32_t curr_mtu; | |
156 | ||
157 | uint8_t multicast_memberships; | |
158 | ||
159 | /* EIGRP Network Type. */ | |
160 | uint8_t type; | |
161 | ||
162 | struct prefix address; /* Interface prefix */ | |
163 | ||
164 | /* Neighbor information. */ | |
165 | struct list *nbrs; /* EIGRP Neighbor List */ | |
166 | ||
167 | /* Threads. */ | |
168 | struct thread *t_hello; /* timer */ | |
169 | struct thread *t_distribute; /* timer for distribute list */ | |
170 | ||
171 | int on_write_q; | |
172 | ||
173 | /* Statistics fields. */ | |
174 | uint32_t hello_in; /* Hello message input count. */ | |
175 | uint32_t update_in; /* Update message input count. */ | |
176 | uint32_t query_in; /* Querry message input count. */ | |
177 | uint32_t reply_in; /* Reply message input count. */ | |
178 | uint32_t hello_out; /* Hello message output count. */ | |
179 | uint32_t update_out; /* Update message output count. */ | |
180 | uint32_t query_out; /* Query message output count. */ | |
181 | uint32_t reply_out; /* Reply message output count. */ | |
182 | uint32_t siaQuery_in; | |
183 | uint32_t siaQuery_out; | |
184 | uint32_t siaReply_in; | |
185 | uint32_t siaReply_out; | |
186 | uint32_t ack_out; | |
187 | uint32_t ack_in; | |
188 | ||
189 | uint32_t crypt_seqnum; /* Cryptographic Sequence Number */ | |
190 | ||
191 | /* Access-list. */ | |
192 | struct access_list *list[EIGRP_FILTER_MAX]; | |
193 | /* Prefix-list. */ | |
194 | struct prefix_list *prefix[EIGRP_FILTER_MAX]; | |
195 | /* Route-map. */ | |
196 | struct route_map *routemap[EIGRP_FILTER_MAX]; | |
197 | }; | |
198 | ||
199 | /* Determines if it is first or last packet | |
200 | * when packet consists of multiple packet | |
201 | * chunks because of many route TLV | |
202 | * (all won't fit into one packet) */ | |
203 | enum Packet_part_type { | |
204 | EIGRP_PACKET_PART_NA, | |
205 | EIGRP_PACKET_PART_FIRST, | |
206 | EIGRP_PACKET_PART_LAST | |
207 | }; | |
208 | ||
209 | /* Neighbor Data Structure */ | |
210 | struct eigrp_neighbor { | |
211 | /* This neighbor's parent eigrp interface. */ | |
212 | struct eigrp_interface *ei; | |
213 | ||
214 | /* EIGRP neighbor Information */ | |
215 | uint8_t state; /* neigbor status. */ | |
216 | ||
217 | uint32_t recv_sequence_number; /* Last received sequence Number. */ | |
218 | uint32_t init_sequence_number; | |
219 | ||
220 | /*If packet is unacknowledged, we try to send it again 16 times*/ | |
221 | uint8_t retrans_counter; | |
222 | ||
223 | struct in_addr src; /* Neighbor Src address. */ | |
224 | ||
225 | uint8_t os_rel_major; // system version - just for show | |
226 | uint8_t os_rel_minor; // system version - just for show | |
227 | uint8_t tlv_rel_major; // eigrp version - tells us what TLV format to | |
228 | // use | |
229 | uint8_t tlv_rel_minor; // eigrp version - tells us what TLV format to | |
230 | // use | |
231 | ||
232 | uint8_t K1; | |
233 | uint8_t K2; | |
234 | uint8_t K3; | |
235 | uint8_t K4; | |
236 | uint8_t K5; | |
237 | uint8_t K6; | |
238 | ||
239 | /* Timer values. */ | |
240 | uint16_t v_holddown; | |
241 | ||
242 | /* Threads. */ | |
243 | struct thread *t_holddown; | |
244 | struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet | |
245 | chunks */ | |
246 | ||
247 | struct eigrp_fifo *retrans_queue; | |
248 | struct eigrp_fifo *multicast_queue; | |
249 | ||
250 | uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */ | |
251 | ||
252 | /* prefixes not received from neighbor during Graceful restart */ | |
253 | struct list *nbr_gr_prefixes; | |
254 | /* prefixes not yet send to neighbor during Graceful restart */ | |
255 | struct list *nbr_gr_prefixes_send; | |
256 | /* if packet is first or last during Graceful restart */ | |
257 | enum Packet_part_type nbr_gr_packet_type; | |
258 | }; | |
259 | ||
260 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
261 | ||
262 | ||
263 | struct eigrp_packet { | |
264 | struct eigrp_packet *next; | |
265 | struct eigrp_packet *previous; | |
266 | ||
267 | /* Pointer to data stream. */ | |
268 | struct stream *s; | |
269 | ||
270 | /* IP destination address. */ | |
271 | struct in_addr dst; | |
272 | ||
273 | /*Packet retransmission thread*/ | |
274 | struct thread *t_retrans_timer; | |
275 | ||
276 | /*Packet retransmission counter*/ | |
277 | uint8_t retrans_counter; | |
278 | ||
279 | uint32_t sequence_number; | |
280 | ||
281 | /* EIGRP packet length. */ | |
282 | uint16_t length; | |
283 | ||
284 | struct eigrp_neighbor *nbr; | |
285 | }; | |
286 | ||
287 | struct eigrp_fifo { | |
288 | struct eigrp_packet *head; | |
289 | struct eigrp_packet *tail; | |
290 | ||
291 | unsigned long count; | |
292 | }; | |
293 | ||
294 | struct eigrp_header { | |
295 | uint8_t version; | |
296 | uint8_t opcode; | |
297 | uint16_t checksum; | |
298 | uint32_t flags; | |
299 | uint32_t sequence; | |
300 | uint32_t ack; | |
301 | uint16_t vrid; | |
302 | uint16_t ASNumber; | |
303 | char *tlv[0]; | |
304 | ||
305 | } __attribute__((packed)); | |
306 | ||
307 | ||
308 | /** | |
309 | * Generic TLV type used for packet decoding. | |
310 | * | |
311 | * +-----+------------------+ | |
312 | * | | | | | |
313 | * | Type| Len | Vector | | |
314 | * | | | | | |
315 | * +-----+------------------+ | |
316 | */ | |
317 | struct eigrp_tlv_hdr_type { | |
318 | uint16_t type; | |
319 | uint16_t length; | |
320 | uint8_t value[0]; | |
321 | } __attribute__((packed)); | |
322 | ||
323 | struct TLV_Parameter_Type { | |
324 | uint16_t type; | |
325 | uint16_t length; | |
326 | uint8_t K1; | |
327 | uint8_t K2; | |
328 | uint8_t K3; | |
329 | uint8_t K4; | |
330 | uint8_t K5; | |
331 | uint8_t K6; | |
332 | uint16_t hold_time; | |
333 | } __attribute__((packed)); | |
334 | ||
335 | struct TLV_MD5_Authentication_Type { | |
336 | uint16_t type; | |
337 | uint16_t length; | |
338 | uint16_t auth_type; | |
339 | uint16_t auth_length; | |
340 | uint32_t key_id; | |
341 | uint32_t key_sequence; | |
342 | uint8_t Nullpad[8]; | |
343 | uint8_t digest[EIGRP_AUTH_TYPE_MD5_LEN]; | |
344 | ||
345 | } __attribute__((packed)); | |
346 | ||
347 | struct TLV_SHA256_Authentication_Type { | |
348 | uint16_t type; | |
349 | uint16_t length; | |
350 | uint16_t auth_type; | |
351 | uint16_t auth_length; | |
352 | uint32_t key_id; | |
353 | uint32_t key_sequence; | |
354 | uint8_t Nullpad[8]; | |
355 | uint8_t digest[EIGRP_AUTH_TYPE_SHA256_LEN]; | |
356 | ||
357 | } __attribute__((packed)); | |
358 | ||
359 | struct TLV_Sequence_Type { | |
360 | uint16_t type; | |
361 | uint16_t length; | |
362 | uint8_t addr_length; | |
363 | struct in_addr *addresses; | |
364 | } __attribute__((packed)); | |
365 | ||
366 | struct TLV_Next_Multicast_Sequence { | |
367 | uint16_t type; | |
368 | uint16_t length; | |
369 | uint32_t multicast_sequence; | |
370 | } __attribute__((packed)); | |
371 | ||
372 | struct TLV_Software_Type { | |
373 | uint16_t type; | |
374 | uint16_t length; | |
375 | uint8_t vender_major; | |
376 | uint8_t vender_minor; | |
377 | uint8_t eigrp_major; | |
378 | uint8_t eigrp_minor; | |
379 | } __attribute__((packed)); | |
380 | ||
381 | struct TLV_IPv4_Internal_type { | |
382 | uint16_t type; | |
383 | uint16_t length; | |
384 | struct in_addr forward; | |
385 | ||
386 | /*Metrics*/ | |
387 | struct eigrp_metrics metric; | |
388 | ||
389 | uint8_t prefix_length; | |
390 | ||
391 | struct in_addr destination; | |
392 | } __attribute__((packed)); | |
393 | ||
394 | struct TLV_IPv4_External_type { | |
395 | uint16_t type; | |
396 | uint16_t length; | |
397 | struct in_addr next_hop; | |
398 | struct in_addr originating_router; | |
399 | uint32_t originating_as; | |
400 | uint32_t administrative_tag; | |
401 | uint32_t external_metric; | |
402 | uint16_t reserved; | |
403 | uint8_t external_protocol; | |
404 | uint8_t external_flags; | |
405 | ||
406 | /*Metrics*/ | |
407 | struct eigrp_metrics metric; | |
408 | ||
409 | uint8_t prefix_length; | |
410 | unsigned char destination_part[4]; | |
411 | struct in_addr destination; | |
412 | } __attribute__((packed)); | |
413 | ||
414 | /* EIGRP Peer Termination TLV - used for hard restart */ | |
415 | struct TLV_Peer_Termination_type { | |
416 | uint16_t type; | |
417 | uint16_t length; | |
418 | uint8_t unknown; | |
419 | uint32_t neighbor_ip; | |
420 | } __attribute__((packed)); | |
421 | ||
422 | /* Who executed Graceful restart */ | |
423 | enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER }; | |
424 | ||
425 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
426 | ||
427 | /* EIGRP Topology table node structure */ | |
428 | struct eigrp_prefix_descriptor { | |
429 | struct list *entries, *rij; | |
430 | uint32_t fdistance; // FD | |
431 | uint32_t rdistance; // RD | |
432 | uint32_t distance; // D | |
433 | struct eigrp_metrics reported_metric; // RD for sending | |
434 | ||
435 | uint8_t nt; // network type | |
436 | uint8_t state; // route fsm state | |
437 | uint8_t af; // address family | |
438 | uint8_t req_action; // required action | |
439 | ||
440 | struct prefix *destination; | |
441 | ||
442 | // If network type is REMOTE_EXTERNAL, pointer will have reference to | |
443 | // its external TLV | |
444 | struct TLV_IPv4_External_type *extTLV; | |
445 | ||
446 | uint64_t serno; /*Serial number for this entry. Increased with each | |
447 | change of entry*/ | |
448 | }; | |
449 | ||
450 | /* EIGRP Topology table record structure */ | |
451 | struct eigrp_route_descriptor { | |
452 | uint16_t type; | |
453 | uint16_t afi; | |
454 | ||
455 | struct eigrp_prefix_descriptor *prefix; | |
456 | struct eigrp_neighbor *adv_router; | |
457 | struct in_addr nexthop; | |
458 | ||
459 | uint32_t reported_distance; // distance reported by neighbor | |
460 | uint32_t distance; // sum of reported distance and link cost to | |
461 | // advertised neighbor | |
462 | ||
463 | struct eigrp_metrics reported_metric; | |
464 | struct eigrp_metrics total_metric; | |
465 | ||
466 | struct eigrp_metrics metric; | |
467 | struct eigrp_extdata extdata; | |
468 | ||
469 | uint8_t flags; // used for marking successor and FS | |
470 | ||
471 | struct eigrp_interface *ei; // pointer for case of connected entry | |
472 | }; | |
473 | ||
474 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
475 | typedef enum { | |
476 | EIGRP_CONNECTED, | |
477 | EIGRP_INT, | |
478 | EIGRP_EXT, | |
479 | } msg_data_t; | |
480 | ||
481 | /* EIGRP Finite State Machine */ | |
482 | ||
483 | struct eigrp_fsm_action_message { | |
484 | uint8_t packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY | |
485 | struct eigrp *eigrp; // which thread sent mesg | |
486 | struct eigrp_neighbor *adv_router; // advertising neighbor | |
487 | struct eigrp_route_descriptor *entry; | |
488 | struct eigrp_prefix_descriptor *prefix; | |
489 | msg_data_t data_type; // internal or external tlv type | |
490 | struct eigrp_metrics metrics; | |
491 | enum metric_change change; | |
492 | }; | |
493 | ||
494 | #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */ |