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