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 struct in_addr router_id
; /* Configured automatically. */
83 struct in_addr 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
];
135 struct distribute_ctx
*distribute_ctx
;
139 DECLARE_QOBJ_TYPE(eigrp
)
141 struct eigrp_if_params
{
142 uint8_t passive_interface
;
145 uint8_t type
; /* type of interface */
151 char *auth_keychain
; /* Associated keychain with interface*/
152 int auth_type
; /* EIGRP authentication type */
155 enum { MEMBER_ALLROUTERS
= 0,
159 /*EIGRP interface structure*/
160 struct eigrp_interface
{
161 struct eigrp_if_params params
;
163 /*multicast group refcnts */
164 bool member_allrouters
;
166 /* This interface's parent eigrp instance. */
169 /* Interface data from zebra. */
170 struct interface
*ifp
;
172 /* Packet send buffer. */
173 struct eigrp_fifo
*obuf
; /* Output queue */
175 /* To which multicast groups do we currently belong? */
178 uint8_t multicast_memberships
;
180 /* EIGRP Network Type. */
183 struct prefix
*address
; /* Interface prefix */
185 /* Neighbor information. */
186 struct list
*nbrs
; /* EIGRP Neighbor List */
189 struct thread
*t_hello
; /* timer */
190 struct thread
*t_distribute
; /* timer for distribute list */
194 /* Statistics fields. */
195 uint32_t hello_in
; /* Hello message input count. */
196 uint32_t update_in
; /* Update message input count. */
197 uint32_t query_in
; /* Querry message input count. */
198 uint32_t reply_in
; /* Reply message input count. */
199 uint32_t hello_out
; /* Hello message output count. */
200 uint32_t update_out
; /* Update message output count. */
201 uint32_t query_out
; /* Query message output count. */
202 uint32_t reply_out
; /* Reply message output count. */
203 uint32_t siaQuery_in
;
204 uint32_t siaQuery_out
;
205 uint32_t siaReply_in
;
206 uint32_t siaReply_out
;
210 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
213 struct access_list
*list
[EIGRP_FILTER_MAX
];
215 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
217 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
220 /* Determines if it is first or last packet
221 * when packet consists of multiple packet
222 * chunks because of many route TLV
223 * (all won't fit into one packet) */
224 enum Packet_part_type
{
225 EIGRP_PACKET_PART_NA
,
226 EIGRP_PACKET_PART_FIRST
,
227 EIGRP_PACKET_PART_LAST
230 /* Neighbor Data Structure */
231 struct eigrp_neighbor
{
232 /* This neighbor's parent eigrp interface. */
233 struct eigrp_interface
*ei
;
235 /* EIGRP neighbor Information */
236 uint8_t state
; /* neigbor status. */
238 uint32_t recv_sequence_number
; /* Last received sequence Number. */
239 uint32_t init_sequence_number
;
241 /*If packet is unacknowledged, we try to send it again 16 times*/
242 uint8_t retrans_counter
;
244 struct in_addr src
; /* Neighbor Src address. */
246 uint8_t os_rel_major
; // system version - just for show
247 uint8_t os_rel_minor
; // system version - just for show
248 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
250 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
264 struct thread
*t_holddown
;
265 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
268 struct eigrp_fifo
*retrans_queue
;
269 struct eigrp_fifo
*multicast_queue
;
271 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
273 /* prefixes not received from neighbor during Graceful restart */
274 struct list
*nbr_gr_prefixes
;
275 /* prefixes not yet send to neighbor during Graceful restart */
276 struct list
*nbr_gr_prefixes_send
;
277 /* if packet is first or last during Graceful restart */
278 enum Packet_part_type nbr_gr_packet_type
;
281 //---------------------------------------------------------------------------------------------------------------------------------------------
284 struct eigrp_packet
{
285 struct eigrp_packet
*next
;
286 struct eigrp_packet
*previous
;
288 /* Pointer to data stream. */
291 /* IP destination address. */
294 /*Packet retransmission thread*/
295 struct thread
*t_retrans_timer
;
297 /*Packet retransmission counter*/
298 uint8_t retrans_counter
;
300 uint32_t sequence_number
;
302 /* EIGRP packet length. */
305 struct eigrp_neighbor
*nbr
;
309 struct eigrp_packet
*head
;
310 struct eigrp_packet
*tail
;
315 struct eigrp_header
{
326 } __attribute__((packed
));
330 * Generic TLV type used for packet decoding.
332 * +-----+------------------+
334 * | Type| Len | Vector |
336 * +-----+------------------+
338 struct eigrp_tlv_hdr_type
{
342 } __attribute__((packed
));
344 struct TLV_Parameter_Type
{
354 } __attribute__((packed
));
356 struct TLV_MD5_Authentication_Type
{
360 uint16_t auth_length
;
362 uint32_t key_sequence
;
364 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
366 } __attribute__((packed
));
368 struct TLV_SHA256_Authentication_Type
{
372 uint16_t auth_length
;
374 uint32_t key_sequence
;
376 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
378 } __attribute__((packed
));
380 struct TLV_Sequence_Type
{
384 struct in_addr
*addresses
;
385 } __attribute__((packed
));
387 struct TLV_Next_Multicast_Sequence
{
390 uint32_t multicast_sequence
;
391 } __attribute__((packed
));
393 struct TLV_Software_Type
{
396 uint8_t vender_major
;
397 uint8_t vender_minor
;
400 } __attribute__((packed
));
402 struct TLV_IPv4_Internal_type
{
405 struct in_addr forward
;
408 struct eigrp_metrics metric
;
410 uint8_t prefix_length
;
412 unsigned char destination_part
[4];
413 struct in_addr destination
;
414 } __attribute__((packed
));
416 struct TLV_IPv4_External_type
{
419 struct in_addr next_hop
;
420 struct in_addr originating_router
;
421 uint32_t originating_as
;
422 uint32_t administrative_tag
;
423 uint32_t external_metric
;
425 uint8_t external_protocol
;
426 uint8_t external_flags
;
429 struct eigrp_metrics metric
;
431 uint8_t prefix_length
;
432 unsigned char destination_part
[4];
433 struct in_addr destination
;
434 } __attribute__((packed
));
436 /* EIGRP Peer Termination TLV - used for hard restart */
437 struct TLV_Peer_Termination_type
{
441 uint32_t neighbor_ip
;
442 } __attribute__((packed
));
444 /* Who executed Graceful restart */
445 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
447 //---------------------------------------------------------------------------------------------------------------------------------------------
449 /* EIGRP Topology table node structure */
450 struct eigrp_prefix_entry
{
451 struct list
*entries
, *rij
;
452 uint32_t fdistance
; // FD
453 uint32_t rdistance
; // RD
454 uint32_t distance
; // D
455 struct eigrp_metrics reported_metric
; // RD for sending
457 uint8_t nt
; // network type
458 uint8_t state
; // route fsm state
459 uint8_t af
; // address family
460 uint8_t req_action
; // required action
462 struct prefix
*destination
;
464 // If network type is REMOTE_EXTERNAL, pointer will have reference to
466 struct TLV_IPv4_External_type
*extTLV
;
468 uint64_t serno
; /*Serial number for this entry. Increased with each
472 /* EIGRP Topology table record structure */
473 struct eigrp_nexthop_entry
{
474 struct eigrp_prefix_entry
*prefix
;
475 uint32_t reported_distance
; // distance reported by neighbor
476 uint32_t distance
; // sum of reported distance and link cost to
477 // advertised neighbor
479 struct eigrp_metrics reported_metric
;
480 struct eigrp_metrics total_metric
;
482 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
483 uint8_t flags
; // used for marking successor and FS
485 struct eigrp_interface
*ei
; // pointer for case of connected entry
488 //---------------------------------------------------------------------------------------------------------------------------------------------
495 /* EIGRP Finite State Machine */
497 struct eigrp_fsm_action_message
{
498 uint8_t packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
499 struct eigrp
*eigrp
; // which thread sent mesg
500 struct eigrp_neighbor
*adv_router
; // advertising neighbor
501 struct eigrp_nexthop_entry
*entry
;
502 struct eigrp_prefix_entry
*prefix
;
503 msg_data_t data_type
; // internal or external tlv type
504 struct eigrp_metrics metrics
;
505 enum metric_change change
;
508 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */