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