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 uint16_t AS
; /* Autonomous system number */
73 uint16_t vrid
; /* Virtual Router ID */
74 uint8_t k_values
[6]; /*Array for K values configuration*/
75 uint8_t variance
; /*Metric variance multiplier*/
76 uint8_t max_paths
; /*Maximum allowed paths for 1 prefix*/
78 /*Name of this EIGRP instance*/
81 /* EIGRP Router ID. */
82 uint32_t router_id
; /* Configured automatically. */
83 uint32_t router_id_static
; /* Configured manually. */
85 struct list
*eiflist
; /* eigrp interfaces */
86 uint8_t passive_interface_default
; /* passive-interface default */
89 unsigned int maxsndbuflen
;
91 uint32_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 uint8_t passive_interface
;
142 uint8_t 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 uint8_t 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 uint32_t hello_in
; /* Hello message input count. */
194 uint32_t update_in
; /* Update message input count. */
195 uint32_t query_in
; /* Querry message input count. */
196 uint32_t reply_in
; /* Reply message input count. */
197 uint32_t hello_out
; /* Hello message output count. */
198 uint32_t update_out
; /* Update message output count. */
199 uint32_t query_out
; /* Query message output count. */
200 uint32_t reply_out
; /* Reply message output count. */
201 uint32_t siaQuery_in
;
202 uint32_t siaQuery_out
;
203 uint32_t siaReply_in
;
204 uint32_t siaReply_out
;
208 uint32_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 uint8_t state
; /* neigbor status. */
236 uint32_t recv_sequence_number
; /* Last received sequence Number. */
237 uint32_t init_sequence_number
;
239 /*If packet is unacknowledged, we try to send it again 16 times*/
240 uint8_t retrans_counter
;
242 struct in_addr src
; /* Neighbor Src address. */
244 uint8_t os_rel_major
; // system version - just for show
245 uint8_t os_rel_minor
; // system version - just for show
246 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
248 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
262 struct thread
*t_holddown
;
263 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
266 struct eigrp_fifo
*retrans_queue
;
267 struct eigrp_fifo
*multicast_queue
;
269 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
271 /* prefixes not received from neighbor during Graceful restart */
272 struct list
*nbr_gr_prefixes
;
273 /* prefixes not yet send to neighbor during Graceful restart */
274 struct list
*nbr_gr_prefixes_send
;
275 /* if packet is first or last during Graceful restart */
276 enum Packet_part_type nbr_gr_packet_type
;
279 //---------------------------------------------------------------------------------------------------------------------------------------------
282 struct eigrp_packet
{
283 struct eigrp_packet
*next
;
284 struct eigrp_packet
*previous
;
286 /* Pointer to data stream. */
289 /* IP destination address. */
292 /*Packet retransmission thread*/
293 struct thread
*t_retrans_timer
;
295 /*Packet retransmission counter*/
296 uint8_t retrans_counter
;
298 uint32_t sequence_number
;
300 /* EIGRP packet length. */
303 struct eigrp_neighbor
*nbr
;
307 struct eigrp_packet
*head
;
308 struct eigrp_packet
*tail
;
313 struct eigrp_header
{
324 } __attribute__((packed
));
328 * Generic TLV type used for packet decoding.
330 * +-----+------------------+
332 * | Type| Len | Vector |
334 * +-----+------------------+
336 struct eigrp_tlv_hdr_type
{
340 } __attribute__((packed
));
342 struct TLV_Parameter_Type
{
352 } __attribute__((packed
));
354 struct TLV_MD5_Authentication_Type
{
358 uint16_t auth_length
;
360 uint32_t key_sequence
;
362 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
364 } __attribute__((packed
));
366 struct TLV_SHA256_Authentication_Type
{
370 uint16_t auth_length
;
372 uint32_t key_sequence
;
374 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
376 } __attribute__((packed
));
378 struct TLV_Sequence_Type
{
382 struct in_addr
*addresses
;
383 } __attribute__((packed
));
385 struct TLV_Next_Multicast_Sequence
{
388 uint32_t multicast_sequence
;
389 } __attribute__((packed
));
391 struct TLV_Software_Type
{
394 uint8_t vender_major
;
395 uint8_t vender_minor
;
398 } __attribute__((packed
));
400 struct TLV_IPv4_Internal_type
{
403 struct in_addr forward
;
406 struct eigrp_metrics metric
;
408 uint8_t prefix_length
;
410 unsigned char destination_part
[4];
411 struct in_addr destination
;
412 } __attribute__((packed
));
414 struct TLV_IPv4_External_type
{
417 struct in_addr next_hop
;
418 struct in_addr originating_router
;
419 uint32_t originating_as
;
420 uint32_t administrative_tag
;
421 uint32_t external_metric
;
423 uint8_t external_protocol
;
424 uint8_t external_flags
;
427 struct eigrp_metrics metric
;
429 uint8_t prefix_length
;
430 unsigned char destination_part
[4];
431 struct in_addr destination
;
432 } __attribute__((packed
));
434 /* EIGRP Peer Termination TLV - used for hard restart */
435 struct TLV_Peer_Termination_type
{
439 uint32_t neighbor_ip
;
440 } __attribute__((packed
));
442 /* Who executed Graceful restart */
443 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
445 //---------------------------------------------------------------------------------------------------------------------------------------------
447 /* EIGRP Topology table node structure */
448 struct eigrp_prefix_entry
{
449 struct list
*entries
, *rij
;
450 uint32_t fdistance
; // FD
451 uint32_t rdistance
; // RD
452 uint32_t distance
; // D
453 struct eigrp_metrics reported_metric
; // RD for sending
455 uint8_t nt
; // network type
456 uint8_t state
; // route fsm state
457 uint8_t af
; // address family
458 uint8_t req_action
; // required action
460 struct prefix
*destination
;
462 // If network type is REMOTE_EXTERNAL, pointer will have reference to
464 struct TLV_IPv4_External_type
*extTLV
;
466 uint64_t serno
; /*Serial number for this entry. Increased with each
470 /* EIGRP Topology table record structure */
471 struct eigrp_nexthop_entry
{
472 struct eigrp_prefix_entry
*prefix
;
473 uint32_t reported_distance
; // distance reported by neighbor
474 uint32_t distance
; // sum of reported distance and link cost to
475 // advertised neighbor
477 struct eigrp_metrics reported_metric
;
478 struct eigrp_metrics total_metric
;
480 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
481 uint8_t flags
; // used for marking successor and FS
483 struct eigrp_interface
*ei
; // pointer for case of connected entry
486 //---------------------------------------------------------------------------------------------------------------------------------------------
493 /* EIGRP Finite State Machine */
495 struct eigrp_fsm_action_message
{
496 uint8_t packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
497 struct eigrp
*eigrp
; // which thread sent mesg
498 struct eigrp_neighbor
*adv_router
; // advertising neighbor
499 struct eigrp_nexthop_entry
*entry
;
500 struct eigrp_prefix_entry
*prefix
;
501 msg_data_t data_type
; // internal or external tlv type
502 struct eigrp_metrics metrics
;
503 enum metric_change change
;
506 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */