]>
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. */ |
55 | u_char options; | |
7f57883e DS |
56 | |
57 | #define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */ | |
58 | }; | |
59 | ||
d62a17ae | 60 | struct eigrp_metrics { |
61 | u_int32_t delay; | |
b1968f83 | 62 | u_int32_t bandwidth; |
d62a17ae | 63 | unsigned char mtu[3]; |
64 | u_char hop_count; | |
65 | u_char reliability; | |
66 | u_char load; | |
67 | u_char tag; | |
68 | u_char flags; | |
7f57883e DS |
69 | }; |
70 | ||
d62a17ae | 71 | struct eigrp { |
72 | u_int16_t AS; /* Autonomous system number */ | |
73 | u_int16_t vrid; /* Virtual Router ID */ | |
74 | u_char k_values[6]; /*Array for K values configuration*/ | |
75 | u_char variance; /*Metric variance multiplier*/ | |
76 | u_char 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. */ |
82 | u_int32_t router_id; /* Configured automatically. */ | |
83 | u_int32_t router_id_static; /* Configured manually. */ | |
7f57883e | 84 | |
d62a17ae | 85 | struct list *eiflist; /* eigrp interfaces */ |
86 | u_char passive_interface_default; /* passive-interface default */ | |
7f57883e | 87 | |
d62a17ae | 88 | unsigned int fd; |
89 | unsigned int maxsndbuflen; | |
7f57883e | 90 | |
d62a17ae | 91 | u_int32_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*/ | |
9d303b37 DL |
107 | uint64_t |
108 | serno_last_update; /* Highest serial number of information send | |
109 | by last update*/ | |
d62a17ae | 110 | struct list *topology_changes_internalIPV4; |
111 | struct list *topology_changes_externalIPV4; | |
7f57883e | 112 | |
d62a17ae | 113 | /*Neighbor self*/ |
114 | struct eigrp_neighbor *neighbor_self; | |
7f57883e | 115 | |
d62a17ae | 116 | /*Configured metric for redistributed routes*/ |
117 | struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1]; | |
118 | int redistribute; /* Num of redistributed protocols. */ | |
7f57883e | 119 | |
d62a17ae | 120 | /* Access-list. */ |
121 | struct access_list *list[EIGRP_FILTER_MAX]; | |
122 | /* Prefix-list. */ | |
123 | struct prefix_list *prefix[EIGRP_FILTER_MAX]; | |
124 | /* Route-map. */ | |
125 | struct route_map *routemap[EIGRP_FILTER_MAX]; | |
7f57883e | 126 | |
d62a17ae | 127 | /* For redistribute route map. */ |
128 | struct { | |
129 | char *name; | |
130 | struct route_map *map; | |
131 | int metric_config; | |
132 | u_int32_t metric; | |
133 | } route_map[ZEBRA_ROUTE_MAX]; | |
7f57883e | 134 | |
d62a17ae | 135 | QOBJ_FIELDS |
7f57883e DS |
136 | }; |
137 | DECLARE_QOBJ_TYPE(eigrp) | |
79b30876 DS |
138 | |
139 | struct eigrp_if_params { | |
b748db67 DS |
140 | u_char passive_interface; |
141 | u_int32_t v_hello; | |
142 | u_int16_t v_wait; | |
143 | u_char type; /* type of interface */ | |
144 | u_int32_t bandwidth; | |
145 | u_int32_t delay; | |
146 | u_char reliability; | |
147 | u_char load; | |
148 | ||
149 | char *auth_keychain; /* Associated keychain with interface*/ | |
150 | int auth_type; /* EIGRP authentication type */ | |
79b30876 DS |
151 | }; |
152 | ||
153 | enum { MEMBER_ALLROUTERS = 0, | |
154 | MEMBER_MAX, | |
155 | }; | |
7f57883e DS |
156 | |
157 | /*EIGRP interface structure*/ | |
d62a17ae | 158 | struct eigrp_interface { |
b748db67 | 159 | struct eigrp_if_params params; |
79b30876 DS |
160 | |
161 | /*multicast group refcnts */ | |
b748db67 | 162 | bool member_allrouters; |
79b30876 | 163 | |
d62a17ae | 164 | /* This interface's parent eigrp instance. */ |
165 | struct eigrp *eigrp; | |
166 | ||
167 | /* Interface data from zebra. */ | |
168 | struct interface *ifp; | |
169 | ||
170 | /* Packet send buffer. */ | |
171 | struct eigrp_fifo *obuf; /* Output queue */ | |
172 | ||
173 | /* To which multicast groups do we currently belong? */ | |
174 | ||
d62a17ae | 175 | |
176 | u_char multicast_memberships; | |
177 | ||
178 | /* EIGRP Network Type. */ | |
179 | u_char type; | |
180 | ||
181 | struct prefix *address; /* Interface prefix */ | |
182 | struct connected *connected; /* Pointer to connected */ | |
183 | ||
184 | /* Neighbor information. */ | |
185 | struct list *nbrs; /* EIGRP Neighbor List */ | |
186 | ||
187 | /* Threads. */ | |
188 | struct thread *t_hello; /* timer */ | |
189 | struct thread *t_distribute; /* timer for distribute list */ | |
190 | ||
191 | int on_write_q; | |
192 | ||
193 | /* Statistics fields. */ | |
194 | u_int32_t hello_in; /* Hello message input count. */ | |
195 | u_int32_t update_in; /* Update message input count. */ | |
196 | u_int32_t query_in; /* Querry message input count. */ | |
197 | u_int32_t reply_in; /* Reply message input count. */ | |
198 | u_int32_t hello_out; /* Hello message output count. */ | |
199 | u_int32_t update_out; /* Update message output count. */ | |
200 | u_int32_t query_out; /* Query message output count. */ | |
201 | u_int32_t reply_out; /* Reply message output count. */ | |
202 | u_int32_t siaQuery_in; | |
203 | u_int32_t siaQuery_out; | |
204 | u_int32_t siaReply_in; | |
205 | u_int32_t siaReply_out; | |
206 | u_int32_t ack_out; | |
207 | u_int32_t ack_in; | |
208 | ||
209 | u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */ | |
210 | ||
211 | /* Access-list. */ | |
212 | struct access_list *list[EIGRP_FILTER_MAX]; | |
213 | /* Prefix-list. */ | |
214 | struct prefix_list *prefix[EIGRP_FILTER_MAX]; | |
215 | /* Route-map. */ | |
216 | struct route_map *routemap[EIGRP_FILTER_MAX]; | |
7f57883e DS |
217 | }; |
218 | ||
7f57883e DS |
219 | /* Determines if it is first or last packet |
220 | * when packet consists of multiple packet | |
221 | * chunks because of many route TLV | |
222 | * (all won't fit into one packet) */ | |
d62a17ae | 223 | enum Packet_part_type { |
7f57883e DS |
224 | EIGRP_PACKET_PART_NA, |
225 | EIGRP_PACKET_PART_FIRST, | |
226 | EIGRP_PACKET_PART_LAST | |
227 | }; | |
228 | ||
229 | /* Neighbor Data Structure */ | |
d62a17ae | 230 | struct eigrp_neighbor { |
231 | /* This neighbor's parent eigrp interface. */ | |
232 | struct eigrp_interface *ei; | |
7f57883e | 233 | |
d62a17ae | 234 | /* EIGRP neighbor Information */ |
235 | u_char state; /* neigbor status. */ | |
7f57883e | 236 | |
d62a17ae | 237 | u_int32_t recv_sequence_number; /* Last received sequence Number. */ |
238 | u_int32_t init_sequence_number; | |
7f57883e | 239 | |
d62a17ae | 240 | /*If packet is unacknowledged, we try to send it again 16 times*/ |
241 | u_char retrans_counter; | |
7f57883e | 242 | |
d62a17ae | 243 | struct in_addr src; /* Neighbor Src address. */ |
7f57883e | 244 | |
d62a17ae | 245 | u_char os_rel_major; // system version - just for show |
246 | u_char os_rel_minor; // system version - just for show | |
247 | u_char tlv_rel_major; // eigrp version - tells us what TLV format to use | |
248 | u_char tlv_rel_minor; // eigrp version - tells us what TLV format to use | |
7f57883e | 249 | |
d62a17ae | 250 | u_char K1; |
251 | u_char K2; | |
252 | u_char K3; | |
253 | u_char K4; | |
254 | u_char K5; | |
255 | u_char K6; | |
7f57883e | 256 | |
d62a17ae | 257 | /* Timer values. */ |
258 | u_int16_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 | |
d62a17ae | 268 | u_int32_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*/ |
295 | u_char retrans_counter; | |
7f57883e | 296 | |
d62a17ae | 297 | u_int32_t sequence_number; |
7f57883e | 298 | |
d62a17ae | 299 | /* EIGRP packet length. */ |
300 | u_int16_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 { |
313 | u_char version; | |
314 | u_char opcode; | |
315 | u_int16_t checksum; | |
316 | u_int32_t flags; | |
317 | u_int32_t sequence; | |
318 | u_int32_t ack; | |
319 | u_int16_t vrid; | |
320 | u_int16_t ASNumber; | |
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 { |
336 | u_int16_t type; | |
337 | u_int16_t length; | |
338 | uint8_t value[0]; | |
339 | } __attribute__((packed)); | |
340 | ||
341 | struct TLV_Parameter_Type { | |
342 | u_int16_t type; | |
343 | u_int16_t length; | |
344 | u_char K1; | |
345 | u_char K2; | |
346 | u_char K3; | |
347 | u_char K4; | |
348 | u_char K5; | |
349 | u_char K6; | |
350 | u_int16_t hold_time; | |
351 | } __attribute__((packed)); | |
352 | ||
353 | struct TLV_MD5_Authentication_Type { | |
354 | u_int16_t type; | |
355 | u_int16_t length; | |
356 | u_int16_t auth_type; | |
357 | u_int16_t auth_length; | |
358 | u_int32_t key_id; | |
359 | u_int32_t key_sequence; | |
360 | u_char Nullpad[8]; | |
361 | u_char digest[EIGRP_AUTH_TYPE_MD5_LEN]; | |
362 | ||
363 | } __attribute__((packed)); | |
364 | ||
365 | struct TLV_SHA256_Authentication_Type { | |
366 | u_int16_t type; | |
367 | u_int16_t length; | |
368 | u_int16_t auth_type; | |
369 | u_int16_t auth_length; | |
370 | u_int32_t key_id; | |
371 | u_int32_t key_sequence; | |
372 | u_char Nullpad[8]; | |
373 | u_char digest[EIGRP_AUTH_TYPE_SHA256_LEN]; | |
374 | ||
375 | } __attribute__((packed)); | |
376 | ||
377 | struct TLV_Sequence_Type { | |
378 | u_int16_t type; | |
379 | u_int16_t length; | |
380 | u_char addr_length; | |
381 | struct in_addr *addresses; | |
382 | } __attribute__((packed)); | |
383 | ||
384 | struct TLV_Next_Multicast_Sequence { | |
385 | u_int16_t type; | |
386 | u_int16_t length; | |
387 | u_int32_t multicast_sequence; | |
388 | } __attribute__((packed)); | |
389 | ||
390 | struct TLV_Software_Type { | |
391 | u_int16_t type; | |
392 | u_int16_t length; | |
393 | u_char vender_major; | |
394 | u_char vender_minor; | |
395 | u_char eigrp_major; | |
396 | u_char eigrp_minor; | |
397 | } __attribute__((packed)); | |
398 | ||
399 | struct TLV_IPv4_Internal_type { | |
400 | u_int16_t type; | |
401 | u_int16_t length; | |
402 | struct in_addr forward; | |
403 | ||
404 | /*Metrics*/ | |
405 | struct eigrp_metrics metric; | |
406 | ||
407 | u_char prefix_length; | |
408 | ||
409 | unsigned char destination_part[4]; | |
410 | struct in_addr destination; | |
411 | } __attribute__((packed)); | |
412 | ||
413 | struct TLV_IPv4_External_type { | |
414 | u_int16_t type; | |
415 | u_int16_t length; | |
416 | struct in_addr next_hop; | |
417 | struct in_addr originating_router; | |
418 | u_int32_t originating_as; | |
419 | u_int32_t administrative_tag; | |
420 | u_int32_t external_metric; | |
421 | u_int16_t reserved; | |
422 | u_char external_protocol; | |
423 | u_char external_flags; | |
424 | ||
425 | /*Metrics*/ | |
426 | struct eigrp_metrics metric; | |
427 | ||
428 | u_char prefix_length; | |
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 { |
435 | u_int16_t type; | |
436 | u_int16_t length; | |
437 | u_char unknown; | |
438 | u_int32_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; | |
449 | u_int32_t fdistance; // FD | |
450 | u_int32_t rdistance; // RD | |
451 | u_int32_t distance; // D | |
452 | struct eigrp_metrics reported_metric; // RD for sending | |
453 | ||
454 | u_char nt; // network type | |
455 | u_char state; // route fsm state | |
456 | u_char af; // address family | |
457 | u_char req_action; // required action | |
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; |
472 | u_int32_t reported_distance; // distance reported by neighbor | |
473 | u_int32_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 |
480 | u_char 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 { |
495 | u_char packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY | |
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; |
7f57883e DS |
502 | }; |
503 | ||
504 | #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */ |