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 struct eigrp_metrics
{
51 struct eigrp_extdata
{
64 uint16_t AS
; /* Autonomous system number */
65 uint16_t vrid
; /* Virtual Router ID */
66 uint8_t k_values
[6]; /*Array for K values configuration*/
67 uint8_t variance
; /*Metric variance multiplier*/
68 uint8_t max_paths
; /*Maximum allowed paths for 1 prefix*/
70 /*Name of this EIGRP instance*/
73 /* EIGRP Router ID. */
74 struct in_addr router_id
; /* Configured automatically. */
75 struct in_addr router_id_static
; /* Configured manually. */
77 struct list
*eiflist
; /* eigrp interfaces */
78 uint8_t passive_interface_default
; /* passive-interface default */
81 unsigned int maxsndbuflen
;
83 uint32_t sequence_number
; /*Global EIGRP sequence number*/
86 struct list
*oi_write_q
;
89 struct thread
*t_write
;
90 struct thread
*t_read
;
91 struct thread
*t_distribute
; /* timer for distribute list */
93 struct route_table
*networks
; /* EIGRP config networks. */
95 struct route_table
*topology_table
;
97 uint64_t serno
; /* Global serial number counter for topology entry
99 uint64_t serno_last_update
; /* Highest serial number of information send
101 struct list
*topology_changes_internalIPV4
;
102 struct list
*topology_changes_externalIPV4
;
105 struct eigrp_neighbor
*neighbor_self
;
107 /*Configured metric for redistributed routes*/
108 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
109 int redistribute
; /* Num of redistributed protocols. */
112 struct access_list
*list
[EIGRP_FILTER_MAX
];
114 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
116 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
118 /* For redistribute route map. */
121 struct route_map
*map
;
124 } route_map
[ZEBRA_ROUTE_MAX
];
127 struct distribute_ctx
*distribute_ctx
;
131 DECLARE_QOBJ_TYPE(eigrp
)
133 struct eigrp_if_params
{
134 uint8_t passive_interface
;
137 uint8_t type
; /* type of interface */
143 char *auth_keychain
; /* Associated keychain with interface*/
144 int auth_type
; /* EIGRP authentication type */
147 enum { MEMBER_ALLROUTERS
= 0,
151 /*EIGRP interface structure*/
152 struct eigrp_interface
{
153 struct eigrp_if_params params
;
155 /*multicast group refcnts */
156 bool member_allrouters
;
158 /* This interface's parent eigrp instance. */
161 /* Interface data from zebra. */
162 struct interface
*ifp
;
164 /* Packet send buffer. */
165 struct eigrp_fifo
*obuf
; /* Output queue */
167 /* To which multicast groups do we currently belong? */
169 uint32_t curr_bandwidth
;
172 uint8_t multicast_memberships
;
174 /* EIGRP Network Type. */
177 struct prefix address
; /* Interface prefix */
179 /* Neighbor information. */
180 struct list
*nbrs
; /* EIGRP Neighbor List */
183 struct thread
*t_hello
; /* timer */
184 struct thread
*t_distribute
; /* timer for distribute list */
188 /* Statistics fields. */
189 uint32_t hello_in
; /* Hello message input count. */
190 uint32_t update_in
; /* Update message input count. */
191 uint32_t query_in
; /* Querry message input count. */
192 uint32_t reply_in
; /* Reply message input count. */
193 uint32_t hello_out
; /* Hello message output count. */
194 uint32_t update_out
; /* Update message output count. */
195 uint32_t query_out
; /* Query message output count. */
196 uint32_t reply_out
; /* Reply message output count. */
197 uint32_t siaQuery_in
;
198 uint32_t siaQuery_out
;
199 uint32_t siaReply_in
;
200 uint32_t siaReply_out
;
204 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
207 struct access_list
*list
[EIGRP_FILTER_MAX
];
209 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
211 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
214 /* Determines if it is first or last packet
215 * when packet consists of multiple packet
216 * chunks because of many route TLV
217 * (all won't fit into one packet) */
218 enum Packet_part_type
{
219 EIGRP_PACKET_PART_NA
,
220 EIGRP_PACKET_PART_FIRST
,
221 EIGRP_PACKET_PART_LAST
224 /* Neighbor Data Structure */
225 struct eigrp_neighbor
{
226 /* This neighbor's parent eigrp interface. */
227 struct eigrp_interface
*ei
;
229 /* EIGRP neighbor Information */
230 uint8_t state
; /* neigbor status. */
232 uint32_t recv_sequence_number
; /* Last received sequence Number. */
233 uint32_t init_sequence_number
;
235 /*If packet is unacknowledged, we try to send it again 16 times*/
236 uint8_t retrans_counter
;
238 struct in_addr src
; /* Neighbor Src address. */
240 uint8_t os_rel_major
; // system version - just for show
241 uint8_t os_rel_minor
; // system version - just for show
242 uint8_t tlv_rel_major
; // eigrp version - tells us what TLV format to
244 uint8_t tlv_rel_minor
; // eigrp version - tells us what TLV format to
258 struct thread
*t_holddown
;
259 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
262 struct eigrp_fifo
*retrans_queue
;
263 struct eigrp_fifo
*multicast_queue
;
265 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
267 /* prefixes not received from neighbor during Graceful restart */
268 struct list
*nbr_gr_prefixes
;
269 /* prefixes not yet send to neighbor during Graceful restart */
270 struct list
*nbr_gr_prefixes_send
;
271 /* if packet is first or last during Graceful restart */
272 enum Packet_part_type nbr_gr_packet_type
;
275 //---------------------------------------------------------------------------------------------------------------------------------------------
278 struct eigrp_packet
{
279 struct eigrp_packet
*next
;
280 struct eigrp_packet
*previous
;
282 /* Pointer to data stream. */
285 /* IP destination address. */
288 /*Packet retransmission thread*/
289 struct thread
*t_retrans_timer
;
291 /*Packet retransmission counter*/
292 uint8_t retrans_counter
;
294 uint32_t sequence_number
;
296 /* EIGRP packet length. */
299 struct eigrp_neighbor
*nbr
;
303 struct eigrp_packet
*head
;
304 struct eigrp_packet
*tail
;
309 struct eigrp_header
{
320 } __attribute__((packed
));
324 * Generic TLV type used for packet decoding.
326 * +-----+------------------+
328 * | Type| Len | Vector |
330 * +-----+------------------+
332 struct eigrp_tlv_hdr_type
{
336 } __attribute__((packed
));
338 struct TLV_Parameter_Type
{
348 } __attribute__((packed
));
350 struct TLV_MD5_Authentication_Type
{
354 uint16_t auth_length
;
356 uint32_t key_sequence
;
358 uint8_t digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
360 } __attribute__((packed
));
362 struct TLV_SHA256_Authentication_Type
{
366 uint16_t auth_length
;
368 uint32_t key_sequence
;
370 uint8_t digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
372 } __attribute__((packed
));
374 struct TLV_Sequence_Type
{
378 struct in_addr
*addresses
;
379 } __attribute__((packed
));
381 struct TLV_Next_Multicast_Sequence
{
384 uint32_t multicast_sequence
;
385 } __attribute__((packed
));
387 struct TLV_Software_Type
{
390 uint8_t vender_major
;
391 uint8_t vender_minor
;
394 } __attribute__((packed
));
396 struct TLV_IPv4_Internal_type
{
399 struct in_addr forward
;
402 struct eigrp_metrics metric
;
404 uint8_t prefix_length
;
406 struct in_addr destination
;
407 } __attribute__((packed
));
409 struct TLV_IPv4_External_type
{
412 struct in_addr next_hop
;
413 struct in_addr originating_router
;
414 uint32_t originating_as
;
415 uint32_t administrative_tag
;
416 uint32_t external_metric
;
418 uint8_t external_protocol
;
419 uint8_t external_flags
;
422 struct eigrp_metrics metric
;
424 uint8_t prefix_length
;
425 unsigned char destination_part
[4];
426 struct in_addr destination
;
427 } __attribute__((packed
));
429 /* EIGRP Peer Termination TLV - used for hard restart */
430 struct TLV_Peer_Termination_type
{
434 uint32_t neighbor_ip
;
435 } __attribute__((packed
));
437 /* Who executed Graceful restart */
438 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
440 //---------------------------------------------------------------------------------------------------------------------------------------------
442 /* EIGRP Topology table node structure */
443 struct eigrp_prefix_descriptor
{
444 struct list
*entries
, *rij
;
445 uint32_t fdistance
; // FD
446 uint32_t rdistance
; // RD
447 uint32_t distance
; // D
448 struct eigrp_metrics reported_metric
; // RD for sending
450 uint8_t nt
; // network type
451 uint8_t state
; // route fsm state
452 uint8_t af
; // address family
453 uint8_t req_action
; // required action
455 struct prefix
*destination
;
457 // If network type is REMOTE_EXTERNAL, pointer will have reference to
459 struct TLV_IPv4_External_type
*extTLV
;
461 uint64_t serno
; /*Serial number for this entry. Increased with each
465 /* EIGRP Topology table record structure */
466 struct eigrp_route_descriptor
{
470 struct eigrp_prefix_descriptor
*prefix
;
471 struct eigrp_neighbor
*adv_router
;
472 struct in_addr nexthop
;
474 uint32_t reported_distance
; // distance reported by neighbor
475 uint32_t distance
; // sum of reported distance and link cost to
476 // advertised neighbor
478 struct eigrp_metrics reported_metric
;
479 struct eigrp_metrics total_metric
;
481 struct eigrp_metrics metric
;
482 struct eigrp_extdata extdata
;
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_route_descriptor
*entry
;
503 struct eigrp_prefix_descriptor
*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_ */