]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_structs.h
doc: Add documentation for aggregate-address with route-map support
[mirror_frr.git] / eigrpd / eigrp_structs.h
1 /*
2 * EIGRP Definition of Data Structures.
3 * Copyright (C) 2013-2016
4 * Authors:
5 * Donnie Savage
6 * Jan Janovic
7 * Matej Perina
8 * Peter Orsag
9 * Peter Paluch
10 * Frantisek Gazo
11 * Tomas Hvorkovy
12 * Martin Kontsek
13 * Lukas Koribsky
14 *
15 * This file is part of GNU Zebra.
16 *
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
20 * later version.
21 *
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.
26 *
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
30 */
31
32 #ifndef _ZEBRA_EIGRP_STRUCTS_H_
33 #define _ZEBRA_EIGRP_STRUCTS_H_
34
35 #include "filter.h"
36
37 #include "eigrpd/eigrp_const.h"
38 #include "eigrpd/eigrp_macros.h"
39
40 /* EIGRP master for system wide configuration and variables. */
41 struct eigrp_master {
42 /* EIGRP instance. */
43 struct list *eigrp;
44
45 /* EIGRP thread master. */
46 struct thread_master *master;
47
48 /* Zebra interface list. */
49 struct list *iflist;
50
51 /* EIGRP start time. */
52 time_t start_time;
53
54 /* Various EIGRP global configuration. */
55 uint8_t options;
56
57 #define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
58 };
59
60 struct eigrp_metrics {
61 uint32_t delay;
62 uint32_t bandwidth;
63 unsigned char mtu[3];
64 uint8_t hop_count;
65 uint8_t reliability;
66 uint8_t load;
67 uint8_t tag;
68 uint8_t flags;
69 };
70
71 struct eigrp {
72 vrf_id_t vrf_id;
73
74 uint16_t AS; /* Autonomous system number */
75 uint16_t vrid; /* Virtual Router ID */
76 uint8_t k_values[6]; /*Array for K values configuration*/
77 uint8_t variance; /*Metric variance multiplier*/
78 uint8_t max_paths; /*Maximum allowed paths for 1 prefix*/
79
80 /*Name of this EIGRP instance*/
81 char *name;
82
83 /* EIGRP Router ID. */
84 struct in_addr router_id; /* Configured automatically. */
85 struct in_addr router_id_static; /* Configured manually. */
86
87 struct list *eiflist; /* eigrp interfaces */
88 uint8_t passive_interface_default; /* passive-interface default */
89
90 int fd;
91 unsigned int maxsndbuflen;
92
93 uint32_t sequence_number; /*Global EIGRP sequence number*/
94
95 struct stream *ibuf;
96 struct list *oi_write_q;
97
98 /*Threads*/
99 struct thread *t_write;
100 struct thread *t_read;
101 struct thread *t_distribute; /* timer for distribute list */
102
103 struct route_table *networks; /* EIGRP config networks. */
104
105 struct route_table *topology_table;
106
107 uint64_t serno; /* Global serial number counter for topology entry
108 changes*/
109 uint64_t serno_last_update; /* Highest serial number of information send
110 by last update*/
111 struct list *topology_changes_internalIPV4;
112 struct list *topology_changes_externalIPV4;
113
114 /*Neighbor self*/
115 struct eigrp_neighbor *neighbor_self;
116
117 /*Configured metric for redistributed routes*/
118 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
119 int redistribute; /* Num of redistributed protocols. */
120
121 /* Access-list. */
122 struct access_list *list[EIGRP_FILTER_MAX];
123 /* Prefix-list. */
124 struct prefix_list *prefix[EIGRP_FILTER_MAX];
125 /* Route-map. */
126 struct route_map *routemap[EIGRP_FILTER_MAX];
127
128 /* For redistribute route map. */
129 struct {
130 char *name;
131 struct route_map *map;
132 int metric_config;
133 uint32_t metric;
134 } route_map[ZEBRA_ROUTE_MAX];
135
136 /* distribute_ctx */
137 struct distribute_ctx *distribute_ctx;
138
139 QOBJ_FIELDS
140 };
141 DECLARE_QOBJ_TYPE(eigrp)
142
143 struct eigrp_if_params {
144 uint8_t passive_interface;
145 uint32_t v_hello;
146 uint16_t v_wait;
147 uint8_t type; /* type of interface */
148 uint32_t bandwidth;
149 uint32_t delay;
150 uint8_t reliability;
151 uint8_t load;
152
153 char *auth_keychain; /* Associated keychain with interface*/
154 int auth_type; /* EIGRP authentication type */
155 };
156
157 enum { MEMBER_ALLROUTERS = 0,
158 MEMBER_MAX,
159 };
160
161 /*EIGRP interface structure*/
162 struct eigrp_interface {
163 struct eigrp_if_params params;
164
165 /*multicast group refcnts */
166 bool member_allrouters;
167
168 /* This interface's parent eigrp instance. */
169 struct eigrp *eigrp;
170
171 /* Interface data from zebra. */
172 struct interface *ifp;
173
174 /* Packet send buffer. */
175 struct eigrp_fifo *obuf; /* Output queue */
176
177 /* To which multicast groups do we currently belong? */
178
179
180 uint8_t multicast_memberships;
181
182 /* EIGRP Network Type. */
183 uint8_t type;
184
185 struct prefix address; /* Interface prefix */
186
187 /* Neighbor information. */
188 struct list *nbrs; /* EIGRP Neighbor List */
189
190 /* Threads. */
191 struct thread *t_hello; /* timer */
192 struct thread *t_distribute; /* timer for distribute list */
193
194 int on_write_q;
195
196 /* Statistics fields. */
197 uint32_t hello_in; /* Hello message input count. */
198 uint32_t update_in; /* Update message input count. */
199 uint32_t query_in; /* Querry message input count. */
200 uint32_t reply_in; /* Reply message input count. */
201 uint32_t hello_out; /* Hello message output count. */
202 uint32_t update_out; /* Update message output count. */
203 uint32_t query_out; /* Query message output count. */
204 uint32_t reply_out; /* Reply message output count. */
205 uint32_t siaQuery_in;
206 uint32_t siaQuery_out;
207 uint32_t siaReply_in;
208 uint32_t siaReply_out;
209 uint32_t ack_out;
210 uint32_t ack_in;
211
212 uint32_t crypt_seqnum; /* Cryptographic Sequence Number */
213
214 /* Access-list. */
215 struct access_list *list[EIGRP_FILTER_MAX];
216 /* Prefix-list. */
217 struct prefix_list *prefix[EIGRP_FILTER_MAX];
218 /* Route-map. */
219 struct route_map *routemap[EIGRP_FILTER_MAX];
220 };
221
222 /* Determines if it is first or last packet
223 * when packet consists of multiple packet
224 * chunks because of many route TLV
225 * (all won't fit into one packet) */
226 enum Packet_part_type {
227 EIGRP_PACKET_PART_NA,
228 EIGRP_PACKET_PART_FIRST,
229 EIGRP_PACKET_PART_LAST
230 };
231
232 /* Neighbor Data Structure */
233 struct eigrp_neighbor {
234 /* This neighbor's parent eigrp interface. */
235 struct eigrp_interface *ei;
236
237 /* EIGRP neighbor Information */
238 uint8_t state; /* neigbor status. */
239
240 uint32_t recv_sequence_number; /* Last received sequence Number. */
241 uint32_t init_sequence_number;
242
243 /*If packet is unacknowledged, we try to send it again 16 times*/
244 uint8_t retrans_counter;
245
246 struct in_addr src; /* Neighbor Src address. */
247
248 uint8_t os_rel_major; // system version - just for show
249 uint8_t os_rel_minor; // system version - just for show
250 uint8_t tlv_rel_major; // eigrp version - tells us what TLV format to
251 // use
252 uint8_t tlv_rel_minor; // eigrp version - tells us what TLV format to
253 // use
254
255 uint8_t K1;
256 uint8_t K2;
257 uint8_t K3;
258 uint8_t K4;
259 uint8_t K5;
260 uint8_t K6;
261
262 /* Timer values. */
263 uint16_t v_holddown;
264
265 /* Threads. */
266 struct thread *t_holddown;
267 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
268 chunks */
269
270 struct eigrp_fifo *retrans_queue;
271 struct eigrp_fifo *multicast_queue;
272
273 uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */
274
275 /* prefixes not received from neighbor during Graceful restart */
276 struct list *nbr_gr_prefixes;
277 /* prefixes not yet send to neighbor during Graceful restart */
278 struct list *nbr_gr_prefixes_send;
279 /* if packet is first or last during Graceful restart */
280 enum Packet_part_type nbr_gr_packet_type;
281 };
282
283 //---------------------------------------------------------------------------------------------------------------------------------------------
284
285
286 struct eigrp_packet {
287 struct eigrp_packet *next;
288 struct eigrp_packet *previous;
289
290 /* Pointer to data stream. */
291 struct stream *s;
292
293 /* IP destination address. */
294 struct in_addr dst;
295
296 /*Packet retransmission thread*/
297 struct thread *t_retrans_timer;
298
299 /*Packet retransmission counter*/
300 uint8_t retrans_counter;
301
302 uint32_t sequence_number;
303
304 /* EIGRP packet length. */
305 uint16_t length;
306
307 struct eigrp_neighbor *nbr;
308 };
309
310 struct eigrp_fifo {
311 struct eigrp_packet *head;
312 struct eigrp_packet *tail;
313
314 unsigned long count;
315 };
316
317 struct eigrp_header {
318 uint8_t version;
319 uint8_t opcode;
320 uint16_t checksum;
321 uint32_t flags;
322 uint32_t sequence;
323 uint32_t ack;
324 uint16_t vrid;
325 uint16_t ASNumber;
326 char *tlv[0];
327
328 } __attribute__((packed));
329
330
331 /**
332 * Generic TLV type used for packet decoding.
333 *
334 * +-----+------------------+
335 * | | | |
336 * | Type| Len | Vector |
337 * | | | |
338 * +-----+------------------+
339 */
340 struct eigrp_tlv_hdr_type {
341 uint16_t type;
342 uint16_t length;
343 uint8_t value[0];
344 } __attribute__((packed));
345
346 struct TLV_Parameter_Type {
347 uint16_t type;
348 uint16_t length;
349 uint8_t K1;
350 uint8_t K2;
351 uint8_t K3;
352 uint8_t K4;
353 uint8_t K5;
354 uint8_t K6;
355 uint16_t hold_time;
356 } __attribute__((packed));
357
358 struct TLV_MD5_Authentication_Type {
359 uint16_t type;
360 uint16_t length;
361 uint16_t auth_type;
362 uint16_t auth_length;
363 uint32_t key_id;
364 uint32_t key_sequence;
365 uint8_t Nullpad[8];
366 uint8_t digest[EIGRP_AUTH_TYPE_MD5_LEN];
367
368 } __attribute__((packed));
369
370 struct TLV_SHA256_Authentication_Type {
371 uint16_t type;
372 uint16_t length;
373 uint16_t auth_type;
374 uint16_t auth_length;
375 uint32_t key_id;
376 uint32_t key_sequence;
377 uint8_t Nullpad[8];
378 uint8_t digest[EIGRP_AUTH_TYPE_SHA256_LEN];
379
380 } __attribute__((packed));
381
382 struct TLV_Sequence_Type {
383 uint16_t type;
384 uint16_t length;
385 uint8_t addr_length;
386 struct in_addr *addresses;
387 } __attribute__((packed));
388
389 struct TLV_Next_Multicast_Sequence {
390 uint16_t type;
391 uint16_t length;
392 uint32_t multicast_sequence;
393 } __attribute__((packed));
394
395 struct TLV_Software_Type {
396 uint16_t type;
397 uint16_t length;
398 uint8_t vender_major;
399 uint8_t vender_minor;
400 uint8_t eigrp_major;
401 uint8_t eigrp_minor;
402 } __attribute__((packed));
403
404 struct TLV_IPv4_Internal_type {
405 uint16_t type;
406 uint16_t length;
407 struct in_addr forward;
408
409 /*Metrics*/
410 struct eigrp_metrics metric;
411
412 uint8_t prefix_length;
413
414 struct in_addr destination;
415 } __attribute__((packed));
416
417 struct TLV_IPv4_External_type {
418 uint16_t type;
419 uint16_t length;
420 struct in_addr next_hop;
421 struct in_addr originating_router;
422 uint32_t originating_as;
423 uint32_t administrative_tag;
424 uint32_t external_metric;
425 uint16_t reserved;
426 uint8_t external_protocol;
427 uint8_t external_flags;
428
429 /*Metrics*/
430 struct eigrp_metrics metric;
431
432 uint8_t prefix_length;
433 unsigned char destination_part[4];
434 struct in_addr destination;
435 } __attribute__((packed));
436
437 /* EIGRP Peer Termination TLV - used for hard restart */
438 struct TLV_Peer_Termination_type {
439 uint16_t type;
440 uint16_t length;
441 uint8_t unknown;
442 uint32_t neighbor_ip;
443 } __attribute__((packed));
444
445 /* Who executed Graceful restart */
446 enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
447
448 //---------------------------------------------------------------------------------------------------------------------------------------------
449
450 /* EIGRP Topology table node structure */
451 struct eigrp_prefix_entry {
452 struct list *entries, *rij;
453 uint32_t fdistance; // FD
454 uint32_t rdistance; // RD
455 uint32_t distance; // D
456 struct eigrp_metrics reported_metric; // RD for sending
457
458 uint8_t nt; // network type
459 uint8_t state; // route fsm state
460 uint8_t af; // address family
461 uint8_t req_action; // required action
462
463 struct prefix *destination;
464
465 // If network type is REMOTE_EXTERNAL, pointer will have reference to
466 // its external TLV
467 struct TLV_IPv4_External_type *extTLV;
468
469 uint64_t serno; /*Serial number for this entry. Increased with each
470 change of entry*/
471 };
472
473 /* EIGRP Topology table record structure */
474 struct eigrp_nexthop_entry {
475 struct eigrp_prefix_entry *prefix;
476 uint32_t reported_distance; // distance reported by neighbor
477 uint32_t distance; // sum of reported distance and link cost to
478 // advertised neighbor
479
480 struct eigrp_metrics reported_metric;
481 struct eigrp_metrics total_metric;
482
483 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
484 uint8_t flags; // used for marking successor and FS
485
486 struct eigrp_interface *ei; // pointer for case of connected entry
487 };
488
489 //---------------------------------------------------------------------------------------------------------------------------------------------
490 typedef enum {
491 EIGRP_CONNECTED,
492 EIGRP_INT,
493 EIGRP_EXT,
494 } msg_data_t;
495
496 /* EIGRP Finite State Machine */
497
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_nexthop_entry *entry;
503 struct eigrp_prefix_entry *prefix;
504 msg_data_t data_type; // internal or external tlv type
505 struct eigrp_metrics metrics;
506 enum metric_change change;
507 };
508
509 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */