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. */
45 /* EIGRP thread master. */
46 struct thread_master
*master
;
48 /* Zebra interface list. */
51 /* EIGRP start time. */
54 /* Various EIGRP global configuration. */
57 #define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
60 struct eigrp_metrics
{
74 uint16_t AS
; /* Autonomous system number */
75 uint16_t vrid
; /* Virtual Router ID */
76 uint8_t k_values
[6]; /*Array for K values configuration*/
77 uint8_t variance
; /*Metric variance multiplier*/
78 uint8_t max_paths
; /*Maximum allowed paths for 1 prefix*/
80 /*Name of this EIGRP instance*/
83 /* EIGRP Router ID. */
84 struct in_addr router_id
; /* Configured automatically. */
85 struct in_addr router_id_static
; /* Configured manually. */
87 struct list
*eiflist
; /* eigrp interfaces */
88 uint8_t passive_interface_default
; /* passive-interface default */
91 unsigned int maxsndbuflen
;
93 uint32_t sequence_number
; /*Global EIGRP sequence number*/
96 struct list
*oi_write_q
;
99 struct thread
*t_write
;
100 struct thread
*t_read
;
101 struct thread
*t_distribute
; /* timer for distribute list */
103 struct route_table
*networks
; /* EIGRP config networks. */
105 struct route_table
*topology_table
;
107 uint64_t serno
; /* Global serial number counter for topology entry
109 uint64_t serno_last_update
; /* Highest serial number of information send
111 struct list
*topology_changes_internalIPV4
;
112 struct list
*topology_changes_externalIPV4
;
115 struct eigrp_neighbor
*neighbor_self
;
117 /*Configured metric for redistributed routes*/
118 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
119 int redistribute
; /* Num of redistributed protocols. */
122 struct access_list
*list
[EIGRP_FILTER_MAX
];
124 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
126 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
128 /* For redistribute route map. */
131 struct route_map
*map
;
134 } route_map
[ZEBRA_ROUTE_MAX
];
137 struct distribute_ctx
*distribute_ctx
;
141 DECLARE_QOBJ_TYPE(eigrp
)
143 struct eigrp_if_params
{
144 uint8_t passive_interface
;
147 uint8_t type
; /* type of interface */
153 char *auth_keychain
; /* Associated keychain with interface*/
154 int auth_type
; /* EIGRP authentication type */
157 enum { MEMBER_ALLROUTERS
= 0,
161 /*EIGRP interface structure*/
162 struct eigrp_interface
{
163 struct eigrp_if_params params
;
165 /*multicast group refcnts */
166 bool member_allrouters
;
168 /* This interface's parent eigrp instance. */
171 /* Interface data from zebra. */
172 struct interface
*ifp
;
174 /* Packet send buffer. */
175 struct eigrp_fifo
*obuf
; /* Output queue */
177 /* To which multicast groups do we currently belong? */
179 uint32_t curr_bandwidth
;
182 uint8_t multicast_memberships
;
184 /* EIGRP Network Type. */
187 struct prefix address
; /* Interface prefix */
189 /* Neighbor information. */
190 struct list
*nbrs
; /* EIGRP Neighbor List */
193 struct thread
*t_hello
; /* timer */
194 struct thread
*t_distribute
; /* timer for distribute list */
198 /* Statistics fields. */
199 uint32_t hello_in
; /* Hello message input count. */
200 uint32_t update_in
; /* Update message input count. */
201 uint32_t query_in
; /* Querry message input count. */
202 uint32_t reply_in
; /* Reply message input count. */
203 uint32_t hello_out
; /* Hello message output count. */
204 uint32_t update_out
; /* Update message output count. */
205 uint32_t query_out
; /* Query message output count. */
206 uint32_t reply_out
; /* Reply message output count. */
207 uint32_t siaQuery_in
;
208 uint32_t siaQuery_out
;
209 uint32_t siaReply_in
;
210 uint32_t siaReply_out
;
214 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
217 struct access_list
*list
[EIGRP_FILTER_MAX
];
219 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
221 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
224 /* Determines if it is first or last packet
225 * when packet consists of multiple packet
226 * chunks because of many route TLV
227 * (all won't fit into one packet) */
228 enum Packet_part_type
{
229 EIGRP_PACKET_PART_NA
,
230 EIGRP_PACKET_PART_FIRST
,
231 EIGRP_PACKET_PART_LAST
234 /* Neighbor Data Structure */
235 struct eigrp_neighbor
{
236 /* This neighbor's parent eigrp interface. */
237 struct eigrp_interface
*ei
;
239 /* EIGRP neighbor Information */
240 uint8_t state
; /* neigbor status. */
242 uint32_t recv_sequence_number
; /* Last received sequence Number. */
243 uint32_t init_sequence_number
;
245 /*If packet is unacknowledged, we try to send it again 16 times*/
246 uint8_t retrans_counter
;
248 struct in_addr src
; /* Neighbor Src address. */
250 uint8_t os_rel_major
; // system version - just for show
251 uint8_t os_rel_minor
; // system version - just for show
252 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
254 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
268 struct thread
*t_holddown
;
269 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
272 struct eigrp_fifo
*retrans_queue
;
273 struct eigrp_fifo
*multicast_queue
;
275 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
277 /* prefixes not received from neighbor during Graceful restart */
278 struct list
*nbr_gr_prefixes
;
279 /* prefixes not yet send to neighbor during Graceful restart */
280 struct list
*nbr_gr_prefixes_send
;
281 /* if packet is first or last during Graceful restart */
282 enum Packet_part_type nbr_gr_packet_type
;
285 //---------------------------------------------------------------------------------------------------------------------------------------------
288 struct eigrp_packet
{
289 struct eigrp_packet
*next
;
290 struct eigrp_packet
*previous
;
292 /* Pointer to data stream. */
295 /* IP destination address. */
298 /*Packet retransmission thread*/
299 struct thread
*t_retrans_timer
;
301 /*Packet retransmission counter*/
302 uint8_t retrans_counter
;
304 uint32_t sequence_number
;
306 /* EIGRP packet length. */
309 struct eigrp_neighbor
*nbr
;
313 struct eigrp_packet
*head
;
314 struct eigrp_packet
*tail
;
319 struct eigrp_header
{
330 } __attribute__((packed
));
334 * Generic TLV type used for packet decoding.
336 * +-----+------------------+
338 * | Type| Len | Vector |
340 * +-----+------------------+
342 struct eigrp_tlv_hdr_type
{
346 } __attribute__((packed
));
348 struct TLV_Parameter_Type
{
358 } __attribute__((packed
));
360 struct TLV_MD5_Authentication_Type
{
364 uint16_t auth_length
;
366 uint32_t key_sequence
;
368 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
370 } __attribute__((packed
));
372 struct TLV_SHA256_Authentication_Type
{
376 uint16_t auth_length
;
378 uint32_t key_sequence
;
380 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
382 } __attribute__((packed
));
384 struct TLV_Sequence_Type
{
388 struct in_addr
*addresses
;
389 } __attribute__((packed
));
391 struct TLV_Next_Multicast_Sequence
{
394 uint32_t multicast_sequence
;
395 } __attribute__((packed
));
397 struct TLV_Software_Type
{
400 uint8_t vender_major
;
401 uint8_t vender_minor
;
404 } __attribute__((packed
));
406 struct TLV_IPv4_Internal_type
{
409 struct in_addr forward
;
412 struct eigrp_metrics metric
;
414 uint8_t prefix_length
;
416 struct in_addr destination
;
417 } __attribute__((packed
));
419 struct TLV_IPv4_External_type
{
422 struct in_addr next_hop
;
423 struct in_addr originating_router
;
424 uint32_t originating_as
;
425 uint32_t administrative_tag
;
426 uint32_t external_metric
;
428 uint8_t external_protocol
;
429 uint8_t external_flags
;
432 struct eigrp_metrics metric
;
434 uint8_t prefix_length
;
435 unsigned char destination_part
[4];
436 struct in_addr destination
;
437 } __attribute__((packed
));
439 /* EIGRP Peer Termination TLV - used for hard restart */
440 struct TLV_Peer_Termination_type
{
444 uint32_t neighbor_ip
;
445 } __attribute__((packed
));
447 /* Who executed Graceful restart */
448 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
450 //---------------------------------------------------------------------------------------------------------------------------------------------
452 /* EIGRP Topology table node structure */
453 struct eigrp_prefix_entry
{
454 struct list
*entries
, *rij
;
455 uint32_t fdistance
; // FD
456 uint32_t rdistance
; // RD
457 uint32_t distance
; // D
458 struct eigrp_metrics reported_metric
; // RD for sending
460 uint8_t nt
; // network type
461 uint8_t state
; // route fsm state
462 uint8_t af
; // address family
463 uint8_t req_action
; // required action
465 struct prefix
*destination
;
467 // If network type is REMOTE_EXTERNAL, pointer will have reference to
469 struct TLV_IPv4_External_type
*extTLV
;
471 uint64_t serno
; /*Serial number for this entry. Increased with each
475 /* EIGRP Topology table record structure */
476 struct eigrp_nexthop_entry
{
477 struct eigrp_prefix_entry
*prefix
;
478 uint32_t reported_distance
; // distance reported by neighbor
479 uint32_t distance
; // sum of reported distance and link cost to
480 // advertised neighbor
482 struct eigrp_metrics reported_metric
;
483 struct eigrp_metrics total_metric
;
485 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
486 uint8_t flags
; // used for marking successor and FS
488 struct eigrp_interface
*ei
; // pointer for case of connected entry
491 //---------------------------------------------------------------------------------------------------------------------------------------------
498 /* EIGRP Finite State Machine */
500 struct eigrp_fsm_action_message
{
501 uint8_t packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
502 struct eigrp
*eigrp
; // which thread sent mesg
503 struct eigrp_neighbor
*adv_router
; // advertising neighbor
504 struct eigrp_nexthop_entry
*entry
;
505 struct eigrp_prefix_entry
*prefix
;
506 msg_data_t data_type
; // internal or external tlv type
507 struct eigrp_metrics metrics
;
508 enum metric_change change
;
511 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */