1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * EIGRP Definition of Data Structures.
4 * Copyright (C) 2013-2016
17 #ifndef _ZEBRA_EIGRP_STRUCTS_H_
18 #define _ZEBRA_EIGRP_STRUCTS_H_
22 #include "eigrpd/eigrp_const.h"
23 #include "eigrpd/eigrp_macros.h"
25 struct eigrp_metrics
{
36 struct eigrp_extdata
{
49 uint16_t AS
; /* Autonomous system number */
50 uint16_t vrid
; /* Virtual Router ID */
51 uint8_t k_values
[6]; /*Array for K values configuration*/
52 uint8_t variance
; /*Metric variance multiplier*/
53 uint8_t max_paths
; /*Maximum allowed paths for 1 prefix*/
55 /*Name of this EIGRP instance*/
58 /* EIGRP Router ID. */
59 struct in_addr router_id
; /* Configured automatically. */
60 struct in_addr router_id_static
; /* Configured manually. */
62 struct list
*eiflist
; /* eigrp interfaces */
63 uint8_t passive_interface_default
; /* passive-interface default */
66 unsigned int maxsndbuflen
;
68 uint32_t sequence_number
; /*Global EIGRP sequence number*/
71 struct list
*oi_write_q
;
74 struct thread
*t_write
;
75 struct thread
*t_read
;
76 struct thread
*t_distribute
; /* timer for distribute list */
78 struct route_table
*networks
; /* EIGRP config networks. */
80 struct route_table
*topology_table
;
82 uint64_t serno
; /* Global serial number counter for topology entry
84 uint64_t serno_last_update
; /* Highest serial number of information send
86 struct list
*topology_changes_internalIPV4
;
87 struct list
*topology_changes_externalIPV4
;
90 struct eigrp_neighbor
*neighbor_self
;
92 /*Configured metric for redistributed routes*/
93 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
94 int redistribute
; /* Num of redistributed protocols. */
97 struct access_list
*list
[EIGRP_FILTER_MAX
];
99 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
101 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
103 /* For redistribute route map. */
106 struct route_map
*map
;
109 } route_map
[ZEBRA_ROUTE_MAX
];
112 struct distribute_ctx
*distribute_ctx
;
116 DECLARE_QOBJ_TYPE(eigrp
);
118 struct eigrp_if_params
{
119 uint8_t passive_interface
;
122 uint8_t type
; /* type of interface */
128 char *auth_keychain
; /* Associated keychain with interface*/
129 int auth_type
; /* EIGRP authentication type */
132 enum { MEMBER_ALLROUTERS
= 0,
136 /*EIGRP interface structure*/
137 struct eigrp_interface
{
138 struct eigrp_if_params params
;
140 /*multicast group refcnts */
141 bool member_allrouters
;
143 /* This interface's parent eigrp instance. */
146 /* Interface data from zebra. */
147 struct interface
*ifp
;
149 /* Packet send buffer. */
150 struct eigrp_fifo
*obuf
; /* Output queue */
152 /* To which multicast groups do we currently belong? */
154 uint32_t curr_bandwidth
;
157 uint8_t multicast_memberships
;
159 /* EIGRP Network Type. */
162 struct prefix address
; /* Interface prefix */
164 /* Neighbor information. */
165 struct list
*nbrs
; /* EIGRP Neighbor List */
168 struct thread
*t_hello
; /* timer */
169 struct thread
*t_distribute
; /* timer for distribute list */
173 /* Statistics fields. */
174 uint32_t hello_in
; /* Hello message input count. */
175 uint32_t update_in
; /* Update message input count. */
176 uint32_t query_in
; /* Querry message input count. */
177 uint32_t reply_in
; /* Reply message input count. */
178 uint32_t hello_out
; /* Hello message output count. */
179 uint32_t update_out
; /* Update message output count. */
180 uint32_t query_out
; /* Query message output count. */
181 uint32_t reply_out
; /* Reply message output count. */
182 uint32_t siaQuery_in
;
183 uint32_t siaQuery_out
;
184 uint32_t siaReply_in
;
185 uint32_t siaReply_out
;
189 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
192 struct access_list
*list
[EIGRP_FILTER_MAX
];
194 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
196 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
199 /* Determines if it is first or last packet
200 * when packet consists of multiple packet
201 * chunks because of many route TLV
202 * (all won't fit into one packet) */
203 enum Packet_part_type
{
204 EIGRP_PACKET_PART_NA
,
205 EIGRP_PACKET_PART_FIRST
,
206 EIGRP_PACKET_PART_LAST
209 /* Neighbor Data Structure */
210 struct eigrp_neighbor
{
211 /* This neighbor's parent eigrp interface. */
212 struct eigrp_interface
*ei
;
214 /* EIGRP neighbor Information */
215 uint8_t state
; /* neigbor status. */
217 uint32_t recv_sequence_number
; /* Last received sequence Number. */
218 uint32_t init_sequence_number
;
220 /*If packet is unacknowledged, we try to send it again 16 times*/
221 uint8_t retrans_counter
;
223 struct in_addr src
; /* Neighbor Src address. */
225 uint8_t os_rel_major
; // system version - just for show
226 uint8_t os_rel_minor
; // system version - just for show
227 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
229 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
243 struct thread
*t_holddown
;
244 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
247 struct eigrp_fifo
*retrans_queue
;
248 struct eigrp_fifo
*multicast_queue
;
250 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
252 /* prefixes not received from neighbor during Graceful restart */
253 struct list
*nbr_gr_prefixes
;
254 /* prefixes not yet send to neighbor during Graceful restart */
255 struct list
*nbr_gr_prefixes_send
;
256 /* if packet is first or last during Graceful restart */
257 enum Packet_part_type nbr_gr_packet_type
;
260 //---------------------------------------------------------------------------------------------------------------------------------------------
263 struct eigrp_packet
{
264 struct eigrp_packet
*next
;
265 struct eigrp_packet
*previous
;
267 /* Pointer to data stream. */
270 /* IP destination address. */
273 /*Packet retransmission thread*/
274 struct thread
*t_retrans_timer
;
276 /*Packet retransmission counter*/
277 uint8_t retrans_counter
;
279 uint32_t sequence_number
;
281 /* EIGRP packet length. */
284 struct eigrp_neighbor
*nbr
;
288 struct eigrp_packet
*head
;
289 struct eigrp_packet
*tail
;
294 struct eigrp_header
{
305 } __attribute__((packed
));
309 * Generic TLV type used for packet decoding.
311 * +-----+------------------+
313 * | Type| Len | Vector |
315 * +-----+------------------+
317 struct eigrp_tlv_hdr_type
{
321 } __attribute__((packed
));
323 struct TLV_Parameter_Type
{
333 } __attribute__((packed
));
335 struct TLV_MD5_Authentication_Type
{
339 uint16_t auth_length
;
341 uint32_t key_sequence
;
343 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
345 } __attribute__((packed
));
347 struct TLV_SHA256_Authentication_Type
{
351 uint16_t auth_length
;
353 uint32_t key_sequence
;
355 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
357 } __attribute__((packed
));
359 struct TLV_Sequence_Type
{
363 struct in_addr
*addresses
;
364 } __attribute__((packed
));
366 struct TLV_Next_Multicast_Sequence
{
369 uint32_t multicast_sequence
;
370 } __attribute__((packed
));
372 struct TLV_Software_Type
{
375 uint8_t vender_major
;
376 uint8_t vender_minor
;
379 } __attribute__((packed
));
381 struct TLV_IPv4_Internal_type
{
384 struct in_addr forward
;
387 struct eigrp_metrics metric
;
389 uint8_t prefix_length
;
391 struct in_addr destination
;
392 } __attribute__((packed
));
394 struct TLV_IPv4_External_type
{
397 struct in_addr next_hop
;
398 struct in_addr originating_router
;
399 uint32_t originating_as
;
400 uint32_t administrative_tag
;
401 uint32_t external_metric
;
403 uint8_t external_protocol
;
404 uint8_t external_flags
;
407 struct eigrp_metrics metric
;
409 uint8_t prefix_length
;
410 unsigned char destination_part
[4];
411 struct in_addr destination
;
412 } __attribute__((packed
));
414 /* EIGRP Peer Termination TLV - used for hard restart */
415 struct TLV_Peer_Termination_type
{
419 uint32_t neighbor_ip
;
420 } __attribute__((packed
));
422 /* Who executed Graceful restart */
423 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
425 //---------------------------------------------------------------------------------------------------------------------------------------------
427 /* EIGRP Topology table node structure */
428 struct eigrp_prefix_descriptor
{
429 struct list
*entries
, *rij
;
430 uint32_t fdistance
; // FD
431 uint32_t rdistance
; // RD
432 uint32_t distance
; // D
433 struct eigrp_metrics reported_metric
; // RD for sending
435 uint8_t nt
; // network type
436 uint8_t state
; // route fsm state
437 uint8_t af
; // address family
438 uint8_t req_action
; // required action
440 struct prefix
*destination
;
442 // If network type is REMOTE_EXTERNAL, pointer will have reference to
444 struct TLV_IPv4_External_type
*extTLV
;
446 uint64_t serno
; /*Serial number for this entry. Increased with each
450 /* EIGRP Topology table record structure */
451 struct eigrp_route_descriptor
{
455 struct eigrp_prefix_descriptor
*prefix
;
456 struct eigrp_neighbor
*adv_router
;
457 struct in_addr nexthop
;
459 uint32_t reported_distance
; // distance reported by neighbor
460 uint32_t distance
; // sum of reported distance and link cost to
461 // advertised neighbor
463 struct eigrp_metrics reported_metric
;
464 struct eigrp_metrics total_metric
;
466 struct eigrp_metrics metric
;
467 struct eigrp_extdata extdata
;
469 uint8_t flags
; // used for marking successor and FS
471 struct eigrp_interface
*ei
; // pointer for case of connected entry
474 //---------------------------------------------------------------------------------------------------------------------------------------------
481 /* EIGRP Finite State Machine */
483 struct eigrp_fsm_action_message
{
484 uint8_t packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
485 struct eigrp
*eigrp
; // which thread sent mesg
486 struct eigrp_neighbor
*adv_router
; // advertising neighbor
487 struct eigrp_route_descriptor
*entry
;
488 struct eigrp_prefix_descriptor
*prefix
;
489 msg_data_t data_type
; // internal or external tlv type
490 struct eigrp_metrics metrics
;
491 enum metric_change change
;
494 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */