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? */
180 uint8_t multicast_memberships
;
182 /* EIGRP Network Type. */
185 struct prefix address
; /* Interface prefix */
187 /* Neighbor information. */
188 struct list
*nbrs
; /* EIGRP Neighbor List */
191 struct thread
*t_hello
; /* timer */
192 struct thread
*t_distribute
; /* timer for distribute list */
196 /* Statistics fields. */
197 uint32_t hello_in
; /* Hello message input count. */
198 uint32_t update_in
; /* Update message input count. */
199 uint32_t query_in
; /* Querry message input count. */
200 uint32_t reply_in
; /* Reply message input count. */
201 uint32_t hello_out
; /* Hello message output count. */
202 uint32_t update_out
; /* Update message output count. */
203 uint32_t query_out
; /* Query message output count. */
204 uint32_t reply_out
; /* Reply message output count. */
205 uint32_t siaQuery_in
;
206 uint32_t siaQuery_out
;
207 uint32_t siaReply_in
;
208 uint32_t siaReply_out
;
212 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
215 struct access_list
*list
[EIGRP_FILTER_MAX
];
217 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
219 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
222 /* Determines if it is first or last packet
223 * when packet consists of multiple packet
224 * chunks because of many route TLV
225 * (all won't fit into one packet) */
226 enum Packet_part_type
{
227 EIGRP_PACKET_PART_NA
,
228 EIGRP_PACKET_PART_FIRST
,
229 EIGRP_PACKET_PART_LAST
232 /* Neighbor Data Structure */
233 struct eigrp_neighbor
{
234 /* This neighbor's parent eigrp interface. */
235 struct eigrp_interface
*ei
;
237 /* EIGRP neighbor Information */
238 uint8_t state
; /* neigbor status. */
240 uint32_t recv_sequence_number
; /* Last received sequence Number. */
241 uint32_t init_sequence_number
;
243 /*If packet is unacknowledged, we try to send it again 16 times*/
244 uint8_t retrans_counter
;
246 struct in_addr src
; /* Neighbor Src address. */
248 uint8_t os_rel_major
; // system version - just for show
249 uint8_t os_rel_minor
; // system version - just for show
250 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
252 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
266 struct thread
*t_holddown
;
267 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
270 struct eigrp_fifo
*retrans_queue
;
271 struct eigrp_fifo
*multicast_queue
;
273 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
275 /* prefixes not received from neighbor during Graceful restart */
276 struct list
*nbr_gr_prefixes
;
277 /* prefixes not yet send to neighbor during Graceful restart */
278 struct list
*nbr_gr_prefixes_send
;
279 /* if packet is first or last during Graceful restart */
280 enum Packet_part_type nbr_gr_packet_type
;
283 //---------------------------------------------------------------------------------------------------------------------------------------------
286 struct eigrp_packet
{
287 struct eigrp_packet
*next
;
288 struct eigrp_packet
*previous
;
290 /* Pointer to data stream. */
293 /* IP destination address. */
296 /*Packet retransmission thread*/
297 struct thread
*t_retrans_timer
;
299 /*Packet retransmission counter*/
300 uint8_t retrans_counter
;
302 uint32_t sequence_number
;
304 /* EIGRP packet length. */
307 struct eigrp_neighbor
*nbr
;
311 struct eigrp_packet
*head
;
312 struct eigrp_packet
*tail
;
317 struct eigrp_header
{
328 } __attribute__((packed
));
332 * Generic TLV type used for packet decoding.
334 * +-----+------------------+
336 * | Type| Len | Vector |
338 * +-----+------------------+
340 struct eigrp_tlv_hdr_type
{
344 } __attribute__((packed
));
346 struct TLV_Parameter_Type
{
356 } __attribute__((packed
));
358 struct TLV_MD5_Authentication_Type
{
362 uint16_t auth_length
;
364 uint32_t key_sequence
;
366 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
368 } __attribute__((packed
));
370 struct TLV_SHA256_Authentication_Type
{
374 uint16_t auth_length
;
376 uint32_t key_sequence
;
378 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
380 } __attribute__((packed
));
382 struct TLV_Sequence_Type
{
386 struct in_addr
*addresses
;
387 } __attribute__((packed
));
389 struct TLV_Next_Multicast_Sequence
{
392 uint32_t multicast_sequence
;
393 } __attribute__((packed
));
395 struct TLV_Software_Type
{
398 uint8_t vender_major
;
399 uint8_t vender_minor
;
402 } __attribute__((packed
));
404 struct TLV_IPv4_Internal_type
{
407 struct in_addr forward
;
410 struct eigrp_metrics metric
;
412 uint8_t prefix_length
;
414 struct in_addr destination
;
415 } __attribute__((packed
));
417 struct TLV_IPv4_External_type
{
420 struct in_addr next_hop
;
421 struct in_addr originating_router
;
422 uint32_t originating_as
;
423 uint32_t administrative_tag
;
424 uint32_t external_metric
;
426 uint8_t external_protocol
;
427 uint8_t external_flags
;
430 struct eigrp_metrics metric
;
432 uint8_t prefix_length
;
433 unsigned char destination_part
[4];
434 struct in_addr destination
;
435 } __attribute__((packed
));
437 /* EIGRP Peer Termination TLV - used for hard restart */
438 struct TLV_Peer_Termination_type
{
442 uint32_t neighbor_ip
;
443 } __attribute__((packed
));
445 /* Who executed Graceful restart */
446 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
448 //---------------------------------------------------------------------------------------------------------------------------------------------
450 /* EIGRP Topology table node structure */
451 struct eigrp_prefix_entry
{
452 struct list
*entries
, *rij
;
453 uint32_t fdistance
; // FD
454 uint32_t rdistance
; // RD
455 uint32_t distance
; // D
456 struct eigrp_metrics reported_metric
; // RD for sending
458 uint8_t nt
; // network type
459 uint8_t state
; // route fsm state
460 uint8_t af
; // address family
461 uint8_t req_action
; // required action
463 struct prefix
*destination
;
465 // If network type is REMOTE_EXTERNAL, pointer will have reference to
467 struct TLV_IPv4_External_type
*extTLV
;
469 uint64_t serno
; /*Serial number for this entry. Increased with each
473 /* EIGRP Topology table record structure */
474 struct eigrp_nexthop_entry
{
475 struct eigrp_prefix_entry
*prefix
;
476 uint32_t reported_distance
; // distance reported by neighbor
477 uint32_t distance
; // sum of reported distance and link cost to
478 // advertised neighbor
480 struct eigrp_metrics reported_metric
;
481 struct eigrp_metrics total_metric
;
483 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
484 uint8_t flags
; // used for marking successor and FS
486 struct eigrp_interface
*ei
; // pointer for case of connected entry
489 //---------------------------------------------------------------------------------------------------------------------------------------------
496 /* EIGRP Finite State Machine */
498 struct eigrp_fsm_action_message
{
499 uint8_t packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
500 struct eigrp
*eigrp
; // which thread sent mesg
501 struct eigrp_neighbor
*adv_router
; // advertising neighbor
502 struct eigrp_nexthop_entry
*entry
;
503 struct eigrp_prefix_entry
*prefix
;
504 msg_data_t data_type
; // internal or external tlv type
505 struct eigrp_metrics metrics
;
506 enum metric_change change
;
509 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */