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 u_int16_t AS
; /* Autonomous system number */
73 u_int16_t vrid
; /* Virtual Router ID */
74 u_char k_values
[6]; /*Array for K values configuration*/
75 u_char variance
; /*Metric variance multiplier*/
76 u_char max_paths
; /*Maximum allowed paths for 1 prefix*/
78 /*Name of this EIGRP instance*/
81 /* EIGRP Router ID. */
82 u_int32_t router_id
; /* Configured automatically. */
83 u_int32_t router_id_static
; /* Configured manually. */
85 struct list
*eiflist
; /* eigrp interfaces */
86 u_char passive_interface_default
; /* passive-interface default */
89 unsigned int maxsndbuflen
;
91 u_int32_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 list
*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
)
137 //------------------------------------------------------------------------------------------------------------------------------------------
139 /*EIGRP interface structure*/
140 struct eigrp_interface
{
141 /* This interface's parent eigrp instance. */
144 /* Interface data from zebra. */
145 struct interface
*ifp
;
147 /* Packet send buffer. */
148 struct eigrp_fifo
*obuf
; /* Output queue */
150 /* To which multicast groups do we currently belong? */
152 /* Configured varables. */
153 struct eigrp_if_params
*params
;
155 u_char multicast_memberships
;
157 /* EIGRP Network Type. */
160 struct prefix
*address
; /* Interface prefix */
161 struct connected
*connected
; /* Pointer to connected */
163 /* Neighbor information. */
164 struct list
*nbrs
; /* EIGRP Neighbor List */
167 struct thread
*t_hello
; /* timer */
168 struct thread
*t_distribute
; /* timer for distribute list */
172 /* Statistics fields. */
173 u_int32_t hello_in
; /* Hello message input count. */
174 u_int32_t update_in
; /* Update message input count. */
175 u_int32_t query_in
; /* Querry message input count. */
176 u_int32_t reply_in
; /* Reply message input count. */
177 u_int32_t hello_out
; /* Hello message output count. */
178 u_int32_t update_out
; /* Update message output count. */
179 u_int32_t query_out
; /* Query message output count. */
180 u_int32_t reply_out
; /* Reply message output count. */
181 u_int32_t siaQuery_in
;
182 u_int32_t siaQuery_out
;
183 u_int32_t siaReply_in
;
184 u_int32_t siaReply_out
;
188 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number */
191 struct access_list
*list
[EIGRP_FILTER_MAX
];
193 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
195 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
198 struct eigrp_if_params
{
199 DECLARE_IF_PARAM(u_char
, passive_interface
); /* EIGRP Interface is
200 passive: no sending or
201 receiving (no need to
202 join multicast groups)
204 DECLARE_IF_PARAM(u_int32_t
, v_hello
); /* Hello Interval */
205 DECLARE_IF_PARAM(u_int16_t
, v_wait
); /* Router Hold Time Interval */
206 DECLARE_IF_PARAM(u_char
, type
); /* type of interface */
207 DECLARE_IF_PARAM(u_int32_t
, bandwidth
);
208 DECLARE_IF_PARAM(u_int32_t
, delay
);
209 DECLARE_IF_PARAM(u_char
, reliability
);
210 DECLARE_IF_PARAM(u_char
, load
);
212 DECLARE_IF_PARAM(char *,
213 auth_keychain
); /* Associated keychain with interface*/
214 DECLARE_IF_PARAM(int, auth_type
); /* EIGRP authentication type */
217 enum { MEMBER_ALLROUTERS
= 0,
221 struct eigrp_if_info
{
222 struct eigrp_if_params
*def_params
;
223 struct route_table
*params
;
224 struct route_table
*eifs
;
226 membership_counts
[MEMBER_MAX
]; /* multicast group refcnts */
229 //------------------------------------------------------------------------------------------------------------------------------------------
231 /* Determines if it is first or last packet
232 * when packet consists of multiple packet
233 * chunks because of many route TLV
234 * (all won't fit into one packet) */
235 enum Packet_part_type
{
236 EIGRP_PACKET_PART_NA
,
237 EIGRP_PACKET_PART_FIRST
,
238 EIGRP_PACKET_PART_LAST
241 /* Neighbor Data Structure */
242 struct eigrp_neighbor
{
243 /* This neighbor's parent eigrp interface. */
244 struct eigrp_interface
*ei
;
246 /* EIGRP neighbor Information */
247 u_char state
; /* neigbor status. */
249 u_int32_t recv_sequence_number
; /* Last received sequence Number. */
250 u_int32_t init_sequence_number
;
252 /*If packet is unacknowledged, we try to send it again 16 times*/
253 u_char retrans_counter
;
255 struct in_addr src
; /* Neighbor Src address. */
257 u_char os_rel_major
; // system version - just for show
258 u_char os_rel_minor
; // system version - just for show
259 u_char tlv_rel_major
; // eigrp version - tells us what TLV format to use
260 u_char tlv_rel_minor
; // eigrp version - tells us what TLV format to use
270 u_int16_t v_holddown
;
273 struct thread
*t_holddown
;
274 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
277 struct eigrp_fifo
*retrans_queue
;
278 struct eigrp_fifo
*multicast_queue
;
280 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
282 /* prefixes not received from neighbor during Graceful restart */
283 struct list
*nbr_gr_prefixes
;
284 /* prefixes not yet send to neighbor during Graceful restart */
285 struct list
*nbr_gr_prefixes_send
;
286 /* if packet is first or last during Graceful restart */
287 enum Packet_part_type nbr_gr_packet_type
;
290 //---------------------------------------------------------------------------------------------------------------------------------------------
293 struct eigrp_packet
{
294 struct eigrp_packet
*next
;
295 struct eigrp_packet
*previous
;
297 /* Pointer to data stream. */
300 /* IP destination address. */
303 /*Packet retransmission thread*/
304 struct thread
*t_retrans_timer
;
306 /*Packet retransmission counter*/
307 u_char retrans_counter
;
309 u_int32_t sequence_number
;
311 /* EIGRP packet length. */
316 struct eigrp_packet
*head
;
317 struct eigrp_packet
*tail
;
322 struct eigrp_header
{
333 } __attribute__((packed
));
337 * Generic TLV type used for packet decoding.
339 * +-----+------------------+
341 * | Type| Len | Vector |
343 * +-----+------------------+
345 struct eigrp_tlv_hdr_type
{
349 } __attribute__((packed
));
351 struct TLV_Parameter_Type
{
361 } __attribute__((packed
));
363 struct TLV_MD5_Authentication_Type
{
367 u_int16_t auth_length
;
369 u_int32_t key_sequence
;
371 u_char digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
373 } __attribute__((packed
));
375 struct TLV_SHA256_Authentication_Type
{
379 u_int16_t auth_length
;
381 u_int32_t key_sequence
;
383 u_char digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
385 } __attribute__((packed
));
387 struct TLV_Sequence_Type
{
391 struct in_addr
*addresses
;
392 } __attribute__((packed
));
394 struct TLV_Next_Multicast_Sequence
{
397 u_int32_t multicast_sequence
;
398 } __attribute__((packed
));
400 struct TLV_Software_Type
{
407 } __attribute__((packed
));
409 struct TLV_IPv4_Internal_type
{
412 struct in_addr forward
;
415 struct eigrp_metrics metric
;
417 u_char prefix_length
;
419 unsigned char destination_part
[4];
420 struct in_addr destination
;
421 } __attribute__((packed
));
423 struct TLV_IPv4_External_type
{
426 struct in_addr next_hop
;
427 struct in_addr originating_router
;
428 u_int32_t originating_as
;
429 u_int32_t administrative_tag
;
430 u_int32_t external_metric
;
432 u_char external_protocol
;
433 u_char external_flags
;
436 struct eigrp_metrics metric
;
438 u_char prefix_length
;
439 unsigned char destination_part
[4];
440 struct in_addr destination
;
441 } __attribute__((packed
));
443 /* EIGRP Peer Termination TLV - used for hard restart */
444 struct TLV_Peer_Termination_type
{
448 u_int32_t neighbor_ip
;
449 } __attribute__((packed
));
451 /* Who executed Graceful restart */
452 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
454 //---------------------------------------------------------------------------------------------------------------------------------------------
456 /* EIGRP Topology table node structure */
457 struct eigrp_prefix_entry
{
458 struct list
*entries
, *rij
;
459 u_int32_t fdistance
; // FD
460 u_int32_t rdistance
; // RD
461 u_int32_t distance
; // D
462 struct eigrp_metrics reported_metric
; // RD for sending
464 u_char nt
; // network type
465 u_char state
; // route fsm state
466 u_char af
; // address family
467 u_char req_action
; // required action
470 *destination_ipv4
; // pointer to struct with ipv4 address
472 *destination_ipv6
; // pointer to struct with ipv6 address
474 // If network type is REMOTE_EXTERNAL, pointer will have reference to
476 struct TLV_IPv4_External_type
*extTLV
;
478 uint64_t serno
; /*Serial number for this entry. Increased with each
482 /* EIGRP Topology table record structure */
483 struct eigrp_neighbor_entry
{
484 struct eigrp_prefix_entry
*prefix
;
485 u_int32_t reported_distance
; // distance reported by neighbor
486 u_int32_t distance
; // sum of reported distance and link cost to
487 // advertised neighbor
489 struct eigrp_metrics reported_metric
;
490 struct eigrp_metrics total_metric
;
492 struct eigrp_neighbor
*adv_router
; // ip address of advertising neighbor
493 u_char flags
; // used for marking successor and FS
495 struct eigrp_interface
*ei
; // pointer for case of connected entry
498 //---------------------------------------------------------------------------------------------------------------------------------------------
500 /* EIGRP Finite State Machine */
502 struct eigrp_fsm_action_message
{
503 u_char packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
504 struct eigrp
*eigrp
; // which thread sent mesg
505 struct eigrp_neighbor
*adv_router
; // advertising neighbor
506 struct eigrp_neighbor_entry
*entry
;
507 struct eigrp_prefix_entry
*prefix
;
508 int data_type
; // internal or external tlv type
510 struct TLV_IPv4_External_type
*ipv4_ext_data
;
511 struct TLV_IPv4_Internal_type
*ipv4_int_type
;
515 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */