]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_structs.h
Merge pull request #3543 from donaldsharp/eigrp_router_id_is_the_bee
[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 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*/
77
78 /*Name of this EIGRP instance*/
79 char *name;
80
81 /* EIGRP Router ID. */
82 struct in_addr router_id; /* Configured automatically. */
83 struct in_addr router_id_static; /* Configured manually. */
84
85 struct list *eiflist; /* eigrp interfaces */
86 uint8_t passive_interface_default; /* passive-interface default */
87
88 unsigned int fd;
89 unsigned int maxsndbuflen;
90
91 uint32_t sequence_number; /*Global EIGRP sequence number*/
92
93 struct stream *ibuf;
94 struct list *oi_write_q;
95
96 /*Threads*/
97 struct thread *t_write;
98 struct thread *t_read;
99 struct thread *t_distribute; /* timer for distribute list */
100
101 struct route_table *networks; /* EIGRP config networks. */
102
103 struct route_table *topology_table;
104
105 uint64_t serno; /* Global serial number counter for topology entry
106 changes*/
107 uint64_t serno_last_update; /* Highest serial number of information send
108 by last update*/
109 struct list *topology_changes_internalIPV4;
110 struct list *topology_changes_externalIPV4;
111
112 /*Neighbor self*/
113 struct eigrp_neighbor *neighbor_self;
114
115 /*Configured metric for redistributed routes*/
116 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
117 int redistribute; /* Num of redistributed protocols. */
118
119 /* Access-list. */
120 struct access_list *list[EIGRP_FILTER_MAX];
121 /* Prefix-list. */
122 struct prefix_list *prefix[EIGRP_FILTER_MAX];
123 /* Route-map. */
124 struct route_map *routemap[EIGRP_FILTER_MAX];
125
126 /* For redistribute route map. */
127 struct {
128 char *name;
129 struct route_map *map;
130 int metric_config;
131 uint32_t metric;
132 } route_map[ZEBRA_ROUTE_MAX];
133
134 /* distribute_ctx */
135 struct distribute_ctx *distribute_ctx;
136
137 QOBJ_FIELDS
138 };
139 DECLARE_QOBJ_TYPE(eigrp)
140
141 struct eigrp_if_params {
142 uint8_t passive_interface;
143 uint32_t v_hello;
144 uint16_t v_wait;
145 uint8_t type; /* type of interface */
146 uint32_t bandwidth;
147 uint32_t delay;
148 uint8_t reliability;
149 uint8_t load;
150
151 char *auth_keychain; /* Associated keychain with interface*/
152 int auth_type; /* EIGRP authentication type */
153 };
154
155 enum { MEMBER_ALLROUTERS = 0,
156 MEMBER_MAX,
157 };
158
159 /*EIGRP interface structure*/
160 struct eigrp_interface {
161 struct eigrp_if_params params;
162
163 /*multicast group refcnts */
164 bool member_allrouters;
165
166 /* This interface's parent eigrp instance. */
167 struct eigrp *eigrp;
168
169 /* Interface data from zebra. */
170 struct interface *ifp;
171
172 /* Packet send buffer. */
173 struct eigrp_fifo *obuf; /* Output queue */
174
175 /* To which multicast groups do we currently belong? */
176
177
178 uint8_t multicast_memberships;
179
180 /* EIGRP Network Type. */
181 uint8_t type;
182
183 struct prefix *address; /* Interface prefix */
184
185 /* Neighbor information. */
186 struct list *nbrs; /* EIGRP Neighbor List */
187
188 /* Threads. */
189 struct thread *t_hello; /* timer */
190 struct thread *t_distribute; /* timer for distribute list */
191
192 int on_write_q;
193
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;
207 uint32_t ack_out;
208 uint32_t ack_in;
209
210 uint32_t crypt_seqnum; /* Cryptographic Sequence Number */
211
212 /* Access-list. */
213 struct access_list *list[EIGRP_FILTER_MAX];
214 /* Prefix-list. */
215 struct prefix_list *prefix[EIGRP_FILTER_MAX];
216 /* Route-map. */
217 struct route_map *routemap[EIGRP_FILTER_MAX];
218 };
219
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
228 };
229
230 /* Neighbor Data Structure */
231 struct eigrp_neighbor {
232 /* This neighbor's parent eigrp interface. */
233 struct eigrp_interface *ei;
234
235 /* EIGRP neighbor Information */
236 uint8_t state; /* neigbor status. */
237
238 uint32_t recv_sequence_number; /* Last received sequence Number. */
239 uint32_t init_sequence_number;
240
241 /*If packet is unacknowledged, we try to send it again 16 times*/
242 uint8_t retrans_counter;
243
244 struct in_addr src; /* Neighbor Src address. */
245
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
249 // use
250 uint8_t tlv_rel_minor; // eigrp version - tells us what TLV format to
251 // use
252
253 uint8_t K1;
254 uint8_t K2;
255 uint8_t K3;
256 uint8_t K4;
257 uint8_t K5;
258 uint8_t K6;
259
260 /* Timer values. */
261 uint16_t v_holddown;
262
263 /* Threads. */
264 struct thread *t_holddown;
265 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
266 chunks */
267
268 struct eigrp_fifo *retrans_queue;
269 struct eigrp_fifo *multicast_queue;
270
271 uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */
272
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;
279 };
280
281 //---------------------------------------------------------------------------------------------------------------------------------------------
282
283
284 struct eigrp_packet {
285 struct eigrp_packet *next;
286 struct eigrp_packet *previous;
287
288 /* Pointer to data stream. */
289 struct stream *s;
290
291 /* IP destination address. */
292 struct in_addr dst;
293
294 /*Packet retransmission thread*/
295 struct thread *t_retrans_timer;
296
297 /*Packet retransmission counter*/
298 uint8_t retrans_counter;
299
300 uint32_t sequence_number;
301
302 /* EIGRP packet length. */
303 uint16_t length;
304
305 struct eigrp_neighbor *nbr;
306 };
307
308 struct eigrp_fifo {
309 struct eigrp_packet *head;
310 struct eigrp_packet *tail;
311
312 unsigned long count;
313 };
314
315 struct eigrp_header {
316 uint8_t version;
317 uint8_t opcode;
318 uint16_t checksum;
319 uint32_t flags;
320 uint32_t sequence;
321 uint32_t ack;
322 uint16_t vrid;
323 uint16_t ASNumber;
324 char *tlv[0];
325
326 } __attribute__((packed));
327
328
329 /**
330 * Generic TLV type used for packet decoding.
331 *
332 * +-----+------------------+
333 * | | | |
334 * | Type| Len | Vector |
335 * | | | |
336 * +-----+------------------+
337 */
338 struct eigrp_tlv_hdr_type {
339 uint16_t type;
340 uint16_t length;
341 uint8_t value[0];
342 } __attribute__((packed));
343
344 struct TLV_Parameter_Type {
345 uint16_t type;
346 uint16_t length;
347 uint8_t K1;
348 uint8_t K2;
349 uint8_t K3;
350 uint8_t K4;
351 uint8_t K5;
352 uint8_t K6;
353 uint16_t hold_time;
354 } __attribute__((packed));
355
356 struct TLV_MD5_Authentication_Type {
357 uint16_t type;
358 uint16_t length;
359 uint16_t auth_type;
360 uint16_t auth_length;
361 uint32_t key_id;
362 uint32_t key_sequence;
363 uint8_t Nullpad[8];
364 uint8_t digest[EIGRP_AUTH_TYPE_MD5_LEN];
365
366 } __attribute__((packed));
367
368 struct TLV_SHA256_Authentication_Type {
369 uint16_t type;
370 uint16_t length;
371 uint16_t auth_type;
372 uint16_t auth_length;
373 uint32_t key_id;
374 uint32_t key_sequence;
375 uint8_t Nullpad[8];
376 uint8_t digest[EIGRP_AUTH_TYPE_SHA256_LEN];
377
378 } __attribute__((packed));
379
380 struct TLV_Sequence_Type {
381 uint16_t type;
382 uint16_t length;
383 uint8_t addr_length;
384 struct in_addr *addresses;
385 } __attribute__((packed));
386
387 struct TLV_Next_Multicast_Sequence {
388 uint16_t type;
389 uint16_t length;
390 uint32_t multicast_sequence;
391 } __attribute__((packed));
392
393 struct TLV_Software_Type {
394 uint16_t type;
395 uint16_t length;
396 uint8_t vender_major;
397 uint8_t vender_minor;
398 uint8_t eigrp_major;
399 uint8_t eigrp_minor;
400 } __attribute__((packed));
401
402 struct TLV_IPv4_Internal_type {
403 uint16_t type;
404 uint16_t length;
405 struct in_addr forward;
406
407 /*Metrics*/
408 struct eigrp_metrics metric;
409
410 uint8_t prefix_length;
411
412 unsigned char destination_part[4];
413 struct in_addr destination;
414 } __attribute__((packed));
415
416 struct TLV_IPv4_External_type {
417 uint16_t type;
418 uint16_t length;
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;
424 uint16_t reserved;
425 uint8_t external_protocol;
426 uint8_t external_flags;
427
428 /*Metrics*/
429 struct eigrp_metrics metric;
430
431 uint8_t prefix_length;
432 unsigned char destination_part[4];
433 struct in_addr destination;
434 } __attribute__((packed));
435
436 /* EIGRP Peer Termination TLV - used for hard restart */
437 struct TLV_Peer_Termination_type {
438 uint16_t type;
439 uint16_t length;
440 uint8_t unknown;
441 uint32_t neighbor_ip;
442 } __attribute__((packed));
443
444 /* Who executed Graceful restart */
445 enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
446
447 //---------------------------------------------------------------------------------------------------------------------------------------------
448
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
456
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
461
462 struct prefix *destination;
463
464 // If network type is REMOTE_EXTERNAL, pointer will have reference to
465 // its external TLV
466 struct TLV_IPv4_External_type *extTLV;
467
468 uint64_t serno; /*Serial number for this entry. Increased with each
469 change of entry*/
470 };
471
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
478
479 struct eigrp_metrics reported_metric;
480 struct eigrp_metrics total_metric;
481
482 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
483 uint8_t flags; // used for marking successor and FS
484
485 struct eigrp_interface *ei; // pointer for case of connected entry
486 };
487
488 //---------------------------------------------------------------------------------------------------------------------------------------------
489 typedef enum {
490 EIGRP_CONNECTED,
491 EIGRP_INT,
492 EIGRP_EXT,
493 } msg_data_t;
494
495 /* EIGRP Finite State Machine */
496
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;
506 };
507
508 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */