]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
7f57883e DS |
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 | |
7f57883e DS |
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 | ||
d62a17ae | 25 | struct eigrp_metrics { |
d7c0a89a QY |
26 | uint32_t delay; |
27 | uint32_t bandwidth; | |
7c6ff2c5 | 28 | uint8_t mtu[3]; |
d7c0a89a QY |
29 | uint8_t hop_count; |
30 | uint8_t reliability; | |
31 | uint8_t load; | |
32 | uint8_t tag; | |
33 | uint8_t flags; | |
7f57883e DS |
34 | }; |
35 | ||
dc4accdd DS |
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 | ||
d62a17ae | 46 | struct eigrp { |
c371cd6b DS |
47 | vrf_id_t vrf_id; |
48 | ||
d7c0a89a QY |
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*/ | |
7f57883e | 54 | |
d62a17ae | 55 | /*Name of this EIGRP instance*/ |
56 | char *name; | |
7f57883e | 57 | |
d62a17ae | 58 | /* EIGRP Router ID. */ |
900e2d42 DS |
59 | struct in_addr router_id; /* Configured automatically. */ |
60 | struct in_addr router_id_static; /* Configured manually. */ | |
7f57883e | 61 | |
d62a17ae | 62 | struct list *eiflist; /* eigrp interfaces */ |
d7c0a89a | 63 | uint8_t passive_interface_default; /* passive-interface default */ |
7f57883e | 64 | |
128ed760 | 65 | int fd; |
d62a17ae | 66 | unsigned int maxsndbuflen; |
7f57883e | 67 | |
d7c0a89a | 68 | uint32_t sequence_number; /*Global EIGRP sequence number*/ |
7f57883e | 69 | |
d62a17ae | 70 | struct stream *ibuf; |
71 | struct list *oi_write_q; | |
7f57883e | 72 | |
d62a17ae | 73 | /*Threads*/ |
74 | struct thread *t_write; | |
75 | struct thread *t_read; | |
76 | struct thread *t_distribute; /* timer for distribute list */ | |
7f57883e | 77 | |
d62a17ae | 78 | struct route_table *networks; /* EIGRP config networks. */ |
7f57883e | 79 | |
9ca66cc7 | 80 | struct route_table *topology_table; |
7f57883e | 81 | |
d62a17ae | 82 | uint64_t serno; /* Global serial number counter for topology entry |
83 | changes*/ | |
996c9314 LB |
84 | uint64_t serno_last_update; /* Highest serial number of information send |
85 | by last update*/ | |
d62a17ae | 86 | struct list *topology_changes_internalIPV4; |
87 | struct list *topology_changes_externalIPV4; | |
7f57883e | 88 | |
d62a17ae | 89 | /*Neighbor self*/ |
90 | struct eigrp_neighbor *neighbor_self; | |
7f57883e | 91 | |
d62a17ae | 92 | /*Configured metric for redistributed routes*/ |
93 | struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1]; | |
94 | int redistribute; /* Num of redistributed protocols. */ | |
7f57883e | 95 | |
d62a17ae | 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]; | |
7f57883e | 102 | |
d62a17ae | 103 | /* For redistribute route map. */ |
104 | struct { | |
105 | char *name; | |
106 | struct route_map *map; | |
107 | int metric_config; | |
d7c0a89a | 108 | uint32_t metric; |
d62a17ae | 109 | } route_map[ZEBRA_ROUTE_MAX]; |
7f57883e | 110 | |
03a38493 PG |
111 | /* distribute_ctx */ |
112 | struct distribute_ctx *distribute_ctx; | |
113 | ||
96244aca | 114 | QOBJ_FIELDS; |
7f57883e | 115 | }; |
96244aca | 116 | DECLARE_QOBJ_TYPE(eigrp); |
79b30876 DS |
117 | |
118 | struct eigrp_if_params { | |
d7c0a89a QY |
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; | |
b748db67 DS |
127 | |
128 | char *auth_keychain; /* Associated keychain with interface*/ | |
996c9314 | 129 | int auth_type; /* EIGRP authentication type */ |
79b30876 DS |
130 | }; |
131 | ||
132 | enum { MEMBER_ALLROUTERS = 0, | |
133 | MEMBER_MAX, | |
134 | }; | |
7f57883e DS |
135 | |
136 | /*EIGRP interface structure*/ | |
d62a17ae | 137 | struct eigrp_interface { |
b748db67 | 138 | struct eigrp_if_params params; |
79b30876 DS |
139 | |
140 | /*multicast group refcnts */ | |
b748db67 | 141 | bool member_allrouters; |
996c9314 | 142 | |
d62a17ae | 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 | ||
85d25587 DS |
154 | uint32_t curr_bandwidth; |
155 | uint32_t curr_mtu; | |
d62a17ae | 156 | |
d7c0a89a | 157 | uint8_t multicast_memberships; |
d62a17ae | 158 | |
159 | /* EIGRP Network Type. */ | |
d7c0a89a | 160 | uint8_t type; |
d62a17ae | 161 | |
b245781a | 162 | struct prefix address; /* Interface prefix */ |
d62a17ae | 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. */ | |
d7c0a89a QY |
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 */ | |
d62a17ae | 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]; | |
7f57883e DS |
197 | }; |
198 | ||
7f57883e DS |
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) */ | |
d62a17ae | 203 | enum Packet_part_type { |
7f57883e DS |
204 | EIGRP_PACKET_PART_NA, |
205 | EIGRP_PACKET_PART_FIRST, | |
206 | EIGRP_PACKET_PART_LAST | |
207 | }; | |
208 | ||
209 | /* Neighbor Data Structure */ | |
d62a17ae | 210 | struct eigrp_neighbor { |
211 | /* This neighbor's parent eigrp interface. */ | |
212 | struct eigrp_interface *ei; | |
7f57883e | 213 | |
d62a17ae | 214 | /* EIGRP neighbor Information */ |
d7c0a89a | 215 | uint8_t state; /* neigbor status. */ |
7f57883e | 216 | |
d7c0a89a QY |
217 | uint32_t recv_sequence_number; /* Last received sequence Number. */ |
218 | uint32_t init_sequence_number; | |
7f57883e | 219 | |
d62a17ae | 220 | /*If packet is unacknowledged, we try to send it again 16 times*/ |
d7c0a89a | 221 | uint8_t retrans_counter; |
7f57883e | 222 | |
d62a17ae | 223 | struct in_addr src; /* Neighbor Src address. */ |
7f57883e | 224 | |
d7c0a89a QY |
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 | |
7f57883e | 231 | |
d7c0a89a QY |
232 | uint8_t K1; |
233 | uint8_t K2; | |
234 | uint8_t K3; | |
235 | uint8_t K4; | |
236 | uint8_t K5; | |
237 | uint8_t K6; | |
7f57883e | 238 | |
d62a17ae | 239 | /* Timer values. */ |
d7c0a89a | 240 | uint16_t v_holddown; |
7f57883e | 241 | |
d62a17ae | 242 | /* Threads. */ |
243 | struct thread *t_holddown; | |
244 | struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet | |
245 | chunks */ | |
7f57883e | 246 | |
d62a17ae | 247 | struct eigrp_fifo *retrans_queue; |
248 | struct eigrp_fifo *multicast_queue; | |
7f57883e | 249 | |
d7c0a89a | 250 | uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */ |
7f57883e | 251 | |
d62a17ae | 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; | |
7f57883e DS |
258 | }; |
259 | ||
260 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
261 | ||
262 | ||
d62a17ae | 263 | struct eigrp_packet { |
264 | struct eigrp_packet *next; | |
265 | struct eigrp_packet *previous; | |
7f57883e | 266 | |
d62a17ae | 267 | /* Pointer to data stream. */ |
268 | struct stream *s; | |
7f57883e | 269 | |
d62a17ae | 270 | /* IP destination address. */ |
271 | struct in_addr dst; | |
7f57883e | 272 | |
d62a17ae | 273 | /*Packet retransmission thread*/ |
274 | struct thread *t_retrans_timer; | |
7f57883e | 275 | |
d62a17ae | 276 | /*Packet retransmission counter*/ |
d7c0a89a | 277 | uint8_t retrans_counter; |
7f57883e | 278 | |
d7c0a89a | 279 | uint32_t sequence_number; |
7f57883e | 280 | |
d62a17ae | 281 | /* EIGRP packet length. */ |
d7c0a89a | 282 | uint16_t length; |
907b4303 DS |
283 | |
284 | struct eigrp_neighbor *nbr; | |
7f57883e DS |
285 | }; |
286 | ||
d62a17ae | 287 | struct eigrp_fifo { |
288 | struct eigrp_packet *head; | |
289 | struct eigrp_packet *tail; | |
7f57883e | 290 | |
d62a17ae | 291 | unsigned long count; |
7f57883e DS |
292 | }; |
293 | ||
d62a17ae | 294 | struct eigrp_header { |
d7c0a89a QY |
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; | |
d62a17ae | 303 | char *tlv[0]; |
7f57883e | 304 | |
d62a17ae | 305 | } __attribute__((packed)); |
7f57883e DS |
306 | |
307 | ||
308 | /** | |
309 | * Generic TLV type used for packet decoding. | |
310 | * | |
311 | * +-----+------------------+ | |
312 | * | | | | | |
313 | * | Type| Len | Vector | | |
314 | * | | | | | |
315 | * +-----+------------------+ | |
316 | */ | |
d62a17ae | 317 | struct eigrp_tlv_hdr_type { |
d7c0a89a QY |
318 | uint16_t type; |
319 | uint16_t length; | |
d62a17ae | 320 | uint8_t value[0]; |
321 | } __attribute__((packed)); | |
322 | ||
323 | struct TLV_Parameter_Type { | |
d7c0a89a QY |
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; | |
d62a17ae | 333 | } __attribute__((packed)); |
334 | ||
335 | struct TLV_MD5_Authentication_Type { | |
d7c0a89a QY |
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]; | |
d62a17ae | 344 | |
345 | } __attribute__((packed)); | |
346 | ||
347 | struct TLV_SHA256_Authentication_Type { | |
d7c0a89a QY |
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]; | |
d62a17ae | 356 | |
357 | } __attribute__((packed)); | |
358 | ||
359 | struct TLV_Sequence_Type { | |
d7c0a89a QY |
360 | uint16_t type; |
361 | uint16_t length; | |
362 | uint8_t addr_length; | |
d62a17ae | 363 | struct in_addr *addresses; |
364 | } __attribute__((packed)); | |
365 | ||
366 | struct TLV_Next_Multicast_Sequence { | |
d7c0a89a QY |
367 | uint16_t type; |
368 | uint16_t length; | |
369 | uint32_t multicast_sequence; | |
d62a17ae | 370 | } __attribute__((packed)); |
371 | ||
372 | struct TLV_Software_Type { | |
d7c0a89a QY |
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; | |
d62a17ae | 379 | } __attribute__((packed)); |
380 | ||
381 | struct TLV_IPv4_Internal_type { | |
d7c0a89a QY |
382 | uint16_t type; |
383 | uint16_t length; | |
d62a17ae | 384 | struct in_addr forward; |
385 | ||
386 | /*Metrics*/ | |
387 | struct eigrp_metrics metric; | |
388 | ||
d7c0a89a | 389 | uint8_t prefix_length; |
d62a17ae | 390 | |
d62a17ae | 391 | struct in_addr destination; |
392 | } __attribute__((packed)); | |
393 | ||
394 | struct TLV_IPv4_External_type { | |
d7c0a89a QY |
395 | uint16_t type; |
396 | uint16_t length; | |
d62a17ae | 397 | struct in_addr next_hop; |
398 | struct in_addr originating_router; | |
d7c0a89a QY |
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; | |
d62a17ae | 405 | |
406 | /*Metrics*/ | |
407 | struct eigrp_metrics metric; | |
408 | ||
d7c0a89a | 409 | uint8_t prefix_length; |
d62a17ae | 410 | unsigned char destination_part[4]; |
411 | struct in_addr destination; | |
412 | } __attribute__((packed)); | |
7f57883e DS |
413 | |
414 | /* EIGRP Peer Termination TLV - used for hard restart */ | |
d62a17ae | 415 | struct TLV_Peer_Termination_type { |
d7c0a89a QY |
416 | uint16_t type; |
417 | uint16_t length; | |
418 | uint8_t unknown; | |
419 | uint32_t neighbor_ip; | |
7f57883e DS |
420 | } __attribute__((packed)); |
421 | ||
422 | /* Who executed Graceful restart */ | |
d62a17ae | 423 | enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER }; |
7f57883e DS |
424 | |
425 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
426 | ||
427 | /* EIGRP Topology table node structure */ | |
dc4accdd | 428 | struct eigrp_prefix_descriptor { |
d62a17ae | 429 | struct list *entries, *rij; |
d7c0a89a QY |
430 | uint32_t fdistance; // FD |
431 | uint32_t rdistance; // RD | |
432 | uint32_t distance; // D | |
d62a17ae | 433 | struct eigrp_metrics reported_metric; // RD for sending |
434 | ||
d7c0a89a QY |
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 | |
d62a17ae | 439 | |
02b45998 | 440 | struct prefix *destination; |
d62a17ae | 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*/ | |
7f57883e DS |
448 | }; |
449 | ||
450 | /* EIGRP Topology table record structure */ | |
dc4accdd DS |
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 | ||
d7c0a89a QY |
459 | uint32_t reported_distance; // distance reported by neighbor |
460 | uint32_t distance; // sum of reported distance and link cost to | |
461 | // advertised neighbor | |
7f57883e | 462 | |
d62a17ae | 463 | struct eigrp_metrics reported_metric; |
464 | struct eigrp_metrics total_metric; | |
7f57883e | 465 | |
dc4accdd DS |
466 | struct eigrp_metrics metric; |
467 | struct eigrp_extdata extdata; | |
468 | ||
d7c0a89a | 469 | uint8_t flags; // used for marking successor and FS |
7f57883e | 470 | |
d62a17ae | 471 | struct eigrp_interface *ei; // pointer for case of connected entry |
7f57883e DS |
472 | }; |
473 | ||
474 | //--------------------------------------------------------------------------------------------------------------------------------------------- | |
7cfa4322 DS |
475 | typedef enum { |
476 | EIGRP_CONNECTED, | |
477 | EIGRP_INT, | |
478 | EIGRP_EXT, | |
479 | } msg_data_t; | |
7f57883e DS |
480 | |
481 | /* EIGRP Finite State Machine */ | |
482 | ||
d62a17ae | 483 | struct eigrp_fsm_action_message { |
d7c0a89a | 484 | uint8_t packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY |
d62a17ae | 485 | struct eigrp *eigrp; // which thread sent mesg |
486 | struct eigrp_neighbor *adv_router; // advertising neighbor | |
dc4accdd DS |
487 | struct eigrp_route_descriptor *entry; |
488 | struct eigrp_prefix_descriptor *prefix; | |
7cfa4322 | 489 | msg_data_t data_type; // internal or external tlv type |
db6ec9ff | 490 | struct eigrp_metrics metrics; |
377f30c3 | 491 | enum metric_change change; |
7f57883e DS |
492 | }; |
493 | ||
494 | #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */ |