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
108 serno_last_update
; /* Highest serial number of information send
110 struct list
*topology_changes_internalIPV4
;
111 struct list
*topology_changes_externalIPV4
;
114 struct eigrp_neighbor
*neighbor_self
;
116 /*Configured metric for redistributed routes*/
117 struct eigrp_metrics dmetric
[ZEBRA_ROUTE_MAX
+ 1];
118 int redistribute
; /* Num of redistributed protocols. */
121 struct access_list
*list
[EIGRP_FILTER_MAX
];
123 struct prefix_list
*prefix
[EIGRP_FILTER_MAX
];
125 struct route_map
*routemap
[EIGRP_FILTER_MAX
];
127 /* For redistribute route map. */
130 struct route_map
*map
;
133 } route_map
[ZEBRA_ROUTE_MAX
];
137 DECLARE_QOBJ_TYPE(eigrp
)
138 //------------------------------------------------------------------------------------------------------------------------------------------
140 /*EIGRP interface structure*/
141 struct eigrp_interface
{
142 /* This interface's parent eigrp instance. */
145 /* Interface data from zebra. */
146 struct interface
*ifp
;
148 /* Packet send buffer. */
149 struct eigrp_fifo
*obuf
; /* Output queue */
151 /* To which multicast groups do we currently belong? */
153 /* Configured varables. */
154 struct eigrp_if_params
*params
;
156 u_char multicast_memberships
;
158 /* EIGRP Network Type. */
161 struct prefix
*address
; /* Interface prefix */
162 struct connected
*connected
; /* Pointer to connected */
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 u_int32_t hello_in
; /* Hello message input count. */
175 u_int32_t update_in
; /* Update message input count. */
176 u_int32_t query_in
; /* Querry message input count. */
177 u_int32_t reply_in
; /* Reply message input count. */
178 u_int32_t hello_out
; /* Hello message output count. */
179 u_int32_t update_out
; /* Update message output count. */
180 u_int32_t query_out
; /* Query message output count. */
181 u_int32_t reply_out
; /* Reply message output count. */
182 u_int32_t siaQuery_in
;
183 u_int32_t siaQuery_out
;
184 u_int32_t siaReply_in
;
185 u_int32_t siaReply_out
;
189 u_int32_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 struct eigrp_if_params
{
200 DECLARE_IF_PARAM(u_char
, passive_interface
); /* EIGRP Interface is
201 passive: no sending or
202 receiving (no need to
203 join multicast groups)
205 DECLARE_IF_PARAM(u_int32_t
, v_hello
); /* Hello Interval */
206 DECLARE_IF_PARAM(u_int16_t
, v_wait
); /* Router Hold Time Interval */
207 DECLARE_IF_PARAM(u_char
, type
); /* type of interface */
208 DECLARE_IF_PARAM(u_int32_t
, bandwidth
);
209 DECLARE_IF_PARAM(u_int32_t
, delay
);
210 DECLARE_IF_PARAM(u_char
, reliability
);
211 DECLARE_IF_PARAM(u_char
, load
);
213 DECLARE_IF_PARAM(char *,
214 auth_keychain
); /* Associated keychain with interface*/
215 DECLARE_IF_PARAM(int, auth_type
); /* EIGRP authentication type */
218 enum { MEMBER_ALLROUTERS
= 0,
222 struct eigrp_if_info
{
223 struct eigrp_if_params
*def_params
;
224 struct route_table
*params
;
225 struct route_table
*eifs
;
227 membership_counts
[MEMBER_MAX
]; /* multicast group refcnts */
230 //------------------------------------------------------------------------------------------------------------------------------------------
232 /* Determines if it is first or last packet
233 * when packet consists of multiple packet
234 * chunks because of many route TLV
235 * (all won't fit into one packet) */
236 enum Packet_part_type
{
237 EIGRP_PACKET_PART_NA
,
238 EIGRP_PACKET_PART_FIRST
,
239 EIGRP_PACKET_PART_LAST
242 /* Neighbor Data Structure */
243 struct eigrp_neighbor
{
244 /* This neighbor's parent eigrp interface. */
245 struct eigrp_interface
*ei
;
247 /* EIGRP neighbor Information */
248 u_char state
; /* neigbor status. */
250 u_int32_t recv_sequence_number
; /* Last received sequence Number. */
251 u_int32_t init_sequence_number
;
253 /*If packet is unacknowledged, we try to send it again 16 times*/
254 u_char retrans_counter
;
256 struct in_addr src
; /* Neighbor Src address. */
258 u_char os_rel_major
; // system version - just for show
259 u_char os_rel_minor
; // system version - just for show
260 u_char tlv_rel_major
; // eigrp version - tells us what TLV format to use
261 u_char tlv_rel_minor
; // eigrp version - tells us what TLV format to use
271 u_int16_t v_holddown
;
274 struct thread
*t_holddown
;
275 struct thread
*t_nbr_send_gr
; /* thread for sending multiple GR packet
278 struct eigrp_fifo
*retrans_queue
;
279 struct eigrp_fifo
*multicast_queue
;
281 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number. */
283 /* prefixes not received from neighbor during Graceful restart */
284 struct list
*nbr_gr_prefixes
;
285 /* prefixes not yet send to neighbor during Graceful restart */
286 struct list
*nbr_gr_prefixes_send
;
287 /* if packet is first or last during Graceful restart */
288 enum Packet_part_type nbr_gr_packet_type
;
291 //---------------------------------------------------------------------------------------------------------------------------------------------
294 struct eigrp_packet
{
295 struct eigrp_packet
*next
;
296 struct eigrp_packet
*previous
;
298 /* Pointer to data stream. */
301 /* IP destination address. */
304 /*Packet retransmission thread*/
305 struct thread
*t_retrans_timer
;
307 /*Packet retransmission counter*/
308 u_char retrans_counter
;
310 u_int32_t sequence_number
;
312 /* EIGRP packet length. */
315 struct eigrp_neighbor
*nbr
;
319 struct eigrp_packet
*head
;
320 struct eigrp_packet
*tail
;
325 struct eigrp_header
{
336 } __attribute__((packed
));
340 * Generic TLV type used for packet decoding.
342 * +-----+------------------+
344 * | Type| Len | Vector |
346 * +-----+------------------+
348 struct eigrp_tlv_hdr_type
{
352 } __attribute__((packed
));
354 struct TLV_Parameter_Type
{
364 } __attribute__((packed
));
366 struct TLV_MD5_Authentication_Type
{
370 u_int16_t auth_length
;
372 u_int32_t key_sequence
;
374 u_char digest
[EIGRP_AUTH_TYPE_MD5_LEN
];
376 } __attribute__((packed
));
378 struct TLV_SHA256_Authentication_Type
{
382 u_int16_t auth_length
;
384 u_int32_t key_sequence
;
386 u_char digest
[EIGRP_AUTH_TYPE_SHA256_LEN
];
388 } __attribute__((packed
));
390 struct TLV_Sequence_Type
{
394 struct in_addr
*addresses
;
395 } __attribute__((packed
));
397 struct TLV_Next_Multicast_Sequence
{
400 u_int32_t multicast_sequence
;
401 } __attribute__((packed
));
403 struct TLV_Software_Type
{
410 } __attribute__((packed
));
412 struct TLV_IPv4_Internal_type
{
415 struct in_addr forward
;
418 struct eigrp_metrics metric
;
420 u_char prefix_length
;
422 unsigned char destination_part
[4];
423 struct in_addr destination
;
424 } __attribute__((packed
));
426 struct TLV_IPv4_External_type
{
429 struct in_addr next_hop
;
430 struct in_addr originating_router
;
431 u_int32_t originating_as
;
432 u_int32_t administrative_tag
;
433 u_int32_t external_metric
;
435 u_char external_protocol
;
436 u_char external_flags
;
439 struct eigrp_metrics metric
;
441 u_char prefix_length
;
442 unsigned char destination_part
[4];
443 struct in_addr destination
;
444 } __attribute__((packed
));
446 /* EIGRP Peer Termination TLV - used for hard restart */
447 struct TLV_Peer_Termination_type
{
451 u_int32_t neighbor_ip
;
452 } __attribute__((packed
));
454 /* Who executed Graceful restart */
455 enum GR_type
{ EIGRP_GR_MANUAL
, EIGRP_GR_FILTER
};
457 //---------------------------------------------------------------------------------------------------------------------------------------------
459 /* EIGRP Topology table node structure */
460 struct eigrp_prefix_entry
{
461 struct list
*entries
, *rij
;
462 u_int32_t fdistance
; // FD
463 u_int32_t rdistance
; // RD
464 u_int32_t distance
; // D
465 struct eigrp_metrics reported_metric
; // RD for sending
467 u_char nt
; // network type
468 u_char state
; // route fsm state
469 u_char af
; // address family
470 u_char req_action
; // required action
472 struct prefix
*destination
;
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_nexthop_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 //---------------------------------------------------------------------------------------------------------------------------------------------
505 /* EIGRP Finite State Machine */
507 struct eigrp_fsm_action_message
{
508 u_char packet_type
; // UPDATE, QUERY, SIAQUERY, SIAREPLY
509 struct eigrp
*eigrp
; // which thread sent mesg
510 struct eigrp_neighbor
*adv_router
; // advertising neighbor
511 struct eigrp_nexthop_entry
*entry
;
512 struct eigrp_prefix_entry
*prefix
;
513 msg_data_t data_type
; // internal or external tlv type
514 struct eigrp_metrics metrics
;
517 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */