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
{
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*/
78 /*Name of this EIGRP instance*/
81 /* EIGRP Router ID. */
82 u_int32_t router_id
; /* Configured automatically. */
83 u_int32_t router_id_static
; /* Configured manually. */
85 struct list
*eiflist
; /* eigrp interfaces */
86 u_char passive_interface_default
; /* passive-interface default */
89 unsigned int maxsndbuflen
;
91 u_int32_t sequence_number
; /*Global EIGRP sequence number*/
94 struct list
*oi_write_q
;
97 struct thread
*t_write
;
98 struct thread
*t_read
;
99 struct thread
*t_distribute
; /* timer for distribute list */
101 struct route_table
*networks
; /* EIGRP config networks. */
103 struct route_table
*topology_table
;
105 uint64_t serno
; /* Global serial number counter for topology entry
107 uint64_t serno_last_update
; /* Highest serial number of information send
109 struct list
*topology_changes_internalIPV4
;
110 struct list
*topology_changes_externalIPV4
;
113 struct eigrp_neighbor
*neighbor_self
;
115 /*Configured metric for redistributed routes*/
116 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
117 int redistribute
; /* Num of redistributed protocols. */
120 struct access_list
*list
[EIGRP_FILTER_MAX
];
122 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
124 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
126 /* For redistribute route map. */
129 struct route_map
*map
;
132 } route_map
[ZEBRA_ROUTE_MAX
];
136 DECLARE_QOBJ_TYPE(eigrp
)
138 struct eigrp_if_params
{
139 u_char passive_interface
;
142 u_char type
; /* type of interface */
148 char *auth_keychain
; /* Associated keychain with interface*/
149 int auth_type
; /* EIGRP authentication type */
152 enum { MEMBER_ALLROUTERS
= 0,
156 /*EIGRP interface structure*/
157 struct eigrp_interface
{
158 struct eigrp_if_params params
;
160 /*multicast group refcnts */
161 bool member_allrouters
;
163 /* This interface's parent eigrp instance. */
166 /* Interface data from zebra. */
167 struct interface
*ifp
;
169 /* Packet send buffer. */
170 struct eigrp_fifo
*obuf
; /* Output queue */
172 /* To which multicast groups do we currently belong? */
175 u_char multicast_memberships
;
177 /* EIGRP Network Type. */
180 struct prefix
*address
; /* Interface prefix */
181 struct connected
*connected
; /* Pointer to connected */
183 /* Neighbor information. */
184 struct list
*nbrs
; /* EIGRP Neighbor List */
187 struct thread
*t_hello
; /* timer */
188 struct thread
*t_distribute
; /* timer for distribute list */
192 /* Statistics fields. */
193 u_int32_t hello_in
; /* Hello message input count. */
194 u_int32_t update_in
; /* Update message input count. */
195 u_int32_t query_in
; /* Querry message input count. */
196 u_int32_t reply_in
; /* Reply message input count. */
197 u_int32_t hello_out
; /* Hello message output count. */
198 u_int32_t update_out
; /* Update message output count. */
199 u_int32_t query_out
; /* Query message output count. */
200 u_int32_t reply_out
; /* Reply message output count. */
201 u_int32_t siaQuery_in
;
202 u_int32_t siaQuery_out
;
203 u_int32_t siaReply_in
;
204 u_int32_t siaReply_out
;
208 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number */
211 struct access_list
*list
[EIGRP_FILTER_MAX
];
213 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
215 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
218 /* Determines if it is first or last packet
219 * when packet consists of multiple packet
220 * chunks because of many route TLV
221 * (all won't fit into one packet) */
222 enum Packet_part_type
{
223 EIGRP_PACKET_PART_NA
,
224 EIGRP_PACKET_PART_FIRST
,
225 EIGRP_PACKET_PART_LAST
228 /* Neighbor Data Structure */
229 struct eigrp_neighbor
{
230 /* This neighbor's parent eigrp interface. */
231 struct eigrp_interface
*ei
;
233 /* EIGRP neighbor Information */
234 u_char state
; /* neigbor status. */
236 u_int32_t recv_sequence_number
; /* Last received sequence Number. */
237 u_int32_t init_sequence_number
;
239 /*If packet is unacknowledged, we try to send it again 16 times*/
240 u_char retrans_counter
;
242 struct in_addr src
; /* Neighbor Src address. */
244 u_char os_rel_major
; // system version - just for show
245 u_char os_rel_minor
; // system version - just for show
246 u_char tlv_rel_major
; // eigrp version - tells us what TLV format to use
247 u_char tlv_rel_minor
; // eigrp version - tells us what TLV format to use
257 u_int16_t v_holddown
;
260 struct thread
*t_holddown
;
261 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
264 struct eigrp_fifo
*retrans_queue
;
265 struct eigrp_fifo
*multicast_queue
;
267 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
269 /* prefixes not received from neighbor during Graceful restart */
270 struct list
*nbr_gr_prefixes
;
271 /* prefixes not yet send to neighbor during Graceful restart */
272 struct list
*nbr_gr_prefixes_send
;
273 /* if packet is first or last during Graceful restart */
274 enum Packet_part_type nbr_gr_packet_type
;
277 //---------------------------------------------------------------------------------------------------------------------------------------------
280 struct eigrp_packet
{
281 struct eigrp_packet
*next
;
282 struct eigrp_packet
*previous
;
284 /* Pointer to data stream. */
287 /* IP destination address. */
290 /*Packet retransmission thread*/
291 struct thread
*t_retrans_timer
;
293 /*Packet retransmission counter*/
294 u_char retrans_counter
;
296 u_int32_t sequence_number
;
298 /* EIGRP packet length. */
301 struct eigrp_neighbor
*nbr
;
305 struct eigrp_packet
*head
;
306 struct eigrp_packet
*tail
;
311 struct eigrp_header
{
322 } __attribute__((packed
));
326 * Generic TLV type used for packet decoding.
328 * +-----+------------------+
330 * | Type| Len | Vector |
332 * +-----+------------------+
334 struct eigrp_tlv_hdr_type
{
338 } __attribute__((packed
));
340 struct TLV_Parameter_Type
{
350 } __attribute__((packed
));
352 struct TLV_MD5_Authentication_Type
{
356 u_int16_t auth_length
;
358 u_int32_t key_sequence
;
360 u_char digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
362 } __attribute__((packed
));
364 struct TLV_SHA256_Authentication_Type
{
368 u_int16_t auth_length
;
370 u_int32_t key_sequence
;
372 u_char digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
374 } __attribute__((packed
));
376 struct TLV_Sequence_Type
{
380 struct in_addr
*addresses
;
381 } __attribute__((packed
));
383 struct TLV_Next_Multicast_Sequence
{
386 u_int32_t multicast_sequence
;
387 } __attribute__((packed
));
389 struct TLV_Software_Type
{
396 } __attribute__((packed
));
398 struct TLV_IPv4_Internal_type
{
401 struct in_addr forward
;
404 struct eigrp_metrics metric
;
406 u_char prefix_length
;
408 unsigned char destination_part
[4];
409 struct in_addr destination
;
410 } __attribute__((packed
));
412 struct TLV_IPv4_External_type
{
415 struct in_addr next_hop
;
416 struct in_addr originating_router
;
417 u_int32_t originating_as
;
418 u_int32_t administrative_tag
;
419 u_int32_t external_metric
;
421 u_char external_protocol
;
422 u_char external_flags
;
425 struct eigrp_metrics metric
;
427 u_char prefix_length
;
428 unsigned char destination_part
[4];
429 struct in_addr destination
;
430 } __attribute__((packed
));
432 /* EIGRP Peer Termination TLV - used for hard restart */
433 struct TLV_Peer_Termination_type
{
437 u_int32_t neighbor_ip
;
438 } __attribute__((packed
));
440 /* Who executed Graceful restart */
441 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
443 //---------------------------------------------------------------------------------------------------------------------------------------------
445 /* EIGRP Topology table node structure */
446 struct eigrp_prefix_entry
{
447 struct list
*entries
, *rij
;
448 u_int32_t fdistance
; // FD
449 u_int32_t rdistance
; // RD
450 u_int32_t distance
; // D
451 struct eigrp_metrics reported_metric
; // RD for sending
453 u_char nt
; // network type
454 u_char state
; // route fsm state
455 u_char af
; // address family
456 u_char req_action
; // required action
458 struct prefix
*destination
;
460 // If network type is REMOTE_EXTERNAL, pointer will have reference to
462 struct TLV_IPv4_External_type
*extTLV
;
464 uint64_t serno
; /*Serial number for this entry. Increased with each
468 /* EIGRP Topology table record structure */
469 struct eigrp_nexthop_entry
{
470 struct eigrp_prefix_entry
*prefix
;
471 u_int32_t reported_distance
; // distance reported by neighbor
472 u_int32_t distance
; // sum of reported distance and link cost to
473 // advertised neighbor
475 struct eigrp_metrics reported_metric
;
476 struct eigrp_metrics total_metric
;
478 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
479 u_char flags
; // used for marking successor and FS
481 struct eigrp_interface
*ei
; // pointer for case of connected entry
484 //---------------------------------------------------------------------------------------------------------------------------------------------
491 /* EIGRP Finite State Machine */
493 struct eigrp_fsm_action_message
{
494 u_char packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
495 struct eigrp
*eigrp
; // which thread sent mesg
496 struct eigrp_neighbor
*adv_router
; // advertising neighbor
497 struct eigrp_nexthop_entry
*entry
;
498 struct eigrp_prefix_entry
*prefix
;
499 msg_data_t data_type
; // internal or external tlv type
500 struct eigrp_metrics metrics
;
501 enum metric_change change
;
504 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */