2 * EIGRP Definition of Data Structures.
3 * Copyright (C) 2013-2016
15 * This file is part of GNU Zebra.
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
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.
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
32 #ifndef _ZEBRA_EIGRP_STRUCTS_H_
33 #define _ZEBRA_EIGRP_STRUCTS_H_
37 #include "eigrpd/eigrp_const.h"
38 #include "eigrpd/eigrp_macros.h"
40 /* EIGRP master for system wide configuration and variables. */
46 /* EIGRP thread master. */
47 struct thread_master
*master
;
49 /* Zebra interface list. */
52 /* EIGRP start time. */
55 /* Various EIGRP global configuration. */
58 #define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
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*/
81 /*Name of this EIGRP instance*/
84 /* EIGRP Router ID. */
85 u_int32_t router_id
; /* Configured automatically. */
86 u_int32_t router_id_static
; /* Configured manually. */
88 struct list
*eiflist
; /* eigrp interfaces */
89 u_char passive_interface_default
; /* passive-interface default */
92 unsigned int maxsndbuflen
;
94 u_int32_t sequence_number
; /*Global EIGRP sequence number*/
97 struct list
*oi_write_q
;
100 struct thread
*t_write
;
101 struct thread
*t_read
;
102 struct thread
*t_distribute
; /* timer for distribute list */
104 struct route_table
*networks
; /* EIGRP config networks. */
106 struct list
*topology_table
;
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*/
110 struct list
*topology_changes_internalIPV4
;
111 struct list
*topology_changes_externalIPV4
;
114 struct eigrp_neighbor
*neighbor_self
;
116 /*Configured metric for redistributed routes*/
117 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
118 int redistribute
; /* Num of redistributed protocols. */
121 struct access_list
*list
[EIGRP_FILTER_MAX
];
123 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
125 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
127 /* For redistribute route map. */
131 struct route_map
*map
;
134 } route_map
[ZEBRA_ROUTE_MAX
];
138 DECLARE_QOBJ_TYPE(eigrp
)
139 //------------------------------------------------------------------------------------------------------------------------------------------
141 /*EIGRP interface structure*/
142 struct eigrp_interface
144 /* This interface's parent eigrp instance. */
147 /* Interface data from zebra. */
148 struct interface
*ifp
;
150 /* Packet send buffer. */
151 struct eigrp_fifo
*obuf
; /* Output queue */
153 /* To which multicast groups do we currently belong? */
155 /* Configured varables. */
156 struct eigrp_if_params
*params
;
158 u_char multicast_memberships
;
160 /* EIGRP Network Type. */
163 struct prefix
*address
; /* Interface prefix */
164 struct connected
*connected
; /* Pointer to connected */
166 /* Neighbor information. */
167 struct list
*nbrs
; /* EIGRP Neighbor List */
170 struct thread
*t_hello
; /* timer */
171 struct thread
*t_distribute
; /* timer for distribute list */
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
;
191 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number */
194 struct access_list
*list
[EIGRP_FILTER_MAX
];
196 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
198 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
201 struct eigrp_if_params
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
);
212 DECLARE_IF_PARAM (char *, auth_keychain
); /* Associated keychain with interface*/
213 DECLARE_IF_PARAM (int, auth_type
); /* EIGRP authentication type */
218 MEMBER_ALLROUTERS
= 0, MEMBER_MAX
,
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 */
229 //------------------------------------------------------------------------------------------------------------------------------------------
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
237 EIGRP_PACKET_PART_NA
,
238 EIGRP_PACKET_PART_FIRST
,
239 EIGRP_PACKET_PART_LAST
242 /* Neighbor Data Structure */
243 struct eigrp_neighbor
245 /* This neighbor's parent eigrp interface. */
246 struct eigrp_interface
*ei
;
248 /* EIGRP neighbor Information */
249 u_char state
; /* neigbor status. */
251 u_int32_t recv_sequence_number
; /* Last received sequence Number. */
252 u_int32_t init_sequence_number
;
254 /*If packet is unacknowledged, we try to send it again 16 times*/
255 u_char retrans_counter
;
257 struct in_addr src
; /* Neighbor Src address. */
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
272 u_int16_t v_holddown
;
275 struct thread
*t_holddown
;
276 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet chunks */
278 struct eigrp_fifo
*retrans_queue
;
279 struct eigrp_fifo
*multicast_queue
;
281 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
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
;
291 //---------------------------------------------------------------------------------------------------------------------------------------------
296 struct eigrp_packet
*next
;
297 struct eigrp_packet
*previous
;
299 /* Pointer to data stream. */
302 /* IP destination address. */
305 /*Packet retransmission thread*/
306 struct thread
*t_retrans_timer
;
308 /*Packet retransmission counter*/
309 u_char retrans_counter
;
311 u_int32_t sequence_number
;
313 /* EIGRP packet length. */
319 struct eigrp_packet
*head
;
320 struct eigrp_packet
*tail
;
337 }__attribute__((packed
));
341 * Generic TLV type used for packet decoding.
343 * +-----+------------------+
345 * | Type| Len | Vector |
347 * +-----+------------------+
349 struct eigrp_tlv_hdr_type
354 }__attribute__((packed
));
356 struct TLV_Parameter_Type
367 }__attribute__((packed
));
369 struct TLV_MD5_Authentication_Type
374 u_int16_t auth_length
;
376 u_int32_t key_sequence
;
378 u_char digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
380 }__attribute__((packed
));
382 struct TLV_SHA256_Authentication_Type
387 u_int16_t auth_length
;
389 u_int32_t key_sequence
;
391 u_char digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
393 }__attribute__((packed
));
395 struct TLV_Sequence_Type
400 struct in_addr
*addresses
;
401 }__attribute__((packed
));
403 struct TLV_Next_Multicast_Sequence
407 u_int32_t multicast_sequence
;
408 }__attribute__((packed
));
410 struct TLV_Software_Type
418 }__attribute__((packed
));
420 struct TLV_IPv4_Internal_type
424 struct in_addr forward
;
427 struct eigrp_metrics metric
;
429 u_char prefix_length
;
431 unsigned char destination_part
[4];
432 struct in_addr destination
;
433 }__attribute__((packed
));
435 struct TLV_IPv4_External_type
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
;
445 u_char external_protocol
;
446 u_char external_flags
;
449 struct eigrp_metrics metric
;
451 u_char prefix_length
;
452 unsigned char destination_part
[4];
453 struct in_addr destination
;
454 }__attribute__((packed
));
456 /* EIGRP Peer Termination TLV - used for hard restart */
457 struct TLV_Peer_Termination_type
462 u_int32_t neighbor_ip
;
463 } __attribute__((packed
));
465 /* Who executed Graceful restart */
472 //---------------------------------------------------------------------------------------------------------------------------------------------
474 /* EIGRP Topology table node structure */
475 struct eigrp_prefix_entry
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
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
488 struct prefix_ipv4
*destination_ipv4
; // pointer to struct with ipv4 address
489 struct prefix_ipv6
*destination_ipv6
; // pointer to struct with ipv6 address
491 //If network type is REMOTE_EXTERNAL, pointer will have reference to its external TLV
492 struct TLV_IPv4_External_type
*extTLV
;
494 uint64_t serno
; /*Serial number for this entry. Increased with each change of entry*/
497 /* EIGRP Topology table record structure */
498 struct eigrp_neighbor_entry
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
504 struct eigrp_metrics reported_metric
;
505 struct eigrp_metrics total_metric
;
507 struct eigrp_neighbor
*adv_router
; //ip address of advertising neighbor
508 u_char flags
; //used for marking successor and FS
510 struct eigrp_interface
*ei
; //pointer for case of connected entry
514 //---------------------------------------------------------------------------------------------------------------------------------------------
516 /* EIGRP Finite State Machine */
518 struct eigrp_fsm_action_message
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
527 struct TLV_IPv4_External_type
*ipv4_ext_data
;
528 struct TLV_IPv4_Internal_type
*ipv4_int_type
;
532 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */