]> git.proxmox.com Git - mirror_frr.git/blob - eigrpd/eigrp_structs.h
Merge pull request #1069 from donaldsharp/rfc_plist
[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 u_char options;
56
57 #define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
58 };
59
60 struct eigrp_metrics {
61 u_int32_t delay;
62 u_int32_t bandwidth;
63 unsigned char mtu[3];
64 u_char hop_count;
65 u_char reliability;
66 u_char load;
67 u_char tag;
68 u_char flags;
69 };
70
71 struct eigrp {
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*/
77
78 /*Name of this EIGRP instance*/
79 char *name;
80
81 /* EIGRP Router ID. */
82 u_int32_t router_id; /* Configured automatically. */
83 u_int32_t router_id_static; /* Configured manually. */
84
85 struct list *eiflist; /* eigrp interfaces */
86 u_char passive_interface_default; /* passive-interface default */
87
88 unsigned int fd;
89 unsigned int maxsndbuflen;
90
91 u_int32_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 list *topology_table;
104
105 uint64_t serno; /* Global serial number counter for topology entry
106 changes*/
107 uint64_t
108 serno_last_update; /* Highest serial number of information send
109 by last update*/
110 struct list *topology_changes_internalIPV4;
111 struct list *topology_changes_externalIPV4;
112
113 /*Neighbor self*/
114 struct eigrp_neighbor *neighbor_self;
115
116 /*Configured metric for redistributed routes*/
117 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
118 int redistribute; /* Num of redistributed protocols. */
119
120 /* Access-list. */
121 struct access_list *list[EIGRP_FILTER_MAX];
122 /* Prefix-list. */
123 struct prefix_list *prefix[EIGRP_FILTER_MAX];
124 /* Route-map. */
125 struct route_map *routemap[EIGRP_FILTER_MAX];
126
127 /* For redistribute route map. */
128 struct {
129 char *name;
130 struct route_map *map;
131 int metric_config;
132 u_int32_t metric;
133 } route_map[ZEBRA_ROUTE_MAX];
134
135 QOBJ_FIELDS
136 };
137 DECLARE_QOBJ_TYPE(eigrp)
138 //------------------------------------------------------------------------------------------------------------------------------------------
139
140 /*EIGRP interface structure*/
141 struct eigrp_interface {
142 /* This interface's parent eigrp instance. */
143 struct eigrp *eigrp;
144
145 /* Interface data from zebra. */
146 struct interface *ifp;
147
148 /* Packet send buffer. */
149 struct eigrp_fifo *obuf; /* Output queue */
150
151 /* To which multicast groups do we currently belong? */
152
153 /* Configured varables. */
154 struct eigrp_if_params *params;
155
156 u_char multicast_memberships;
157
158 /* EIGRP Network Type. */
159 u_char type;
160
161 struct prefix *address; /* Interface prefix */
162 struct connected *connected; /* Pointer to connected */
163
164 /* Neighbor information. */
165 struct list *nbrs; /* EIGRP Neighbor List */
166
167 /* Threads. */
168 struct thread *t_hello; /* timer */
169 struct thread *t_distribute; /* timer for distribute list */
170
171 int on_write_q;
172
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;
186 u_int32_t ack_out;
187 u_int32_t ack_in;
188
189 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
190
191 /* Access-list. */
192 struct access_list *list[EIGRP_FILTER_MAX];
193 /* Prefix-list. */
194 struct prefix_list *prefix[EIGRP_FILTER_MAX];
195 /* Route-map. */
196 struct route_map *routemap[EIGRP_FILTER_MAX];
197 };
198
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)
204 */
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);
212
213 DECLARE_IF_PARAM(char *,
214 auth_keychain); /* Associated keychain with interface*/
215 DECLARE_IF_PARAM(int, auth_type); /* EIGRP authentication type */
216 };
217
218 enum { MEMBER_ALLROUTERS = 0,
219 MEMBER_MAX,
220 };
221
222 struct eigrp_if_info {
223 struct eigrp_if_params *def_params;
224 struct route_table *params;
225 struct route_table *eifs;
226 unsigned int
227 membership_counts[MEMBER_MAX]; /* multicast group refcnts */
228 };
229
230 //------------------------------------------------------------------------------------------------------------------------------------------
231
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
240 };
241
242 /* Neighbor Data Structure */
243 struct eigrp_neighbor {
244 /* This neighbor's parent eigrp interface. */
245 struct eigrp_interface *ei;
246
247 /* EIGRP neighbor Information */
248 u_char state; /* neigbor status. */
249
250 u_int32_t recv_sequence_number; /* Last received sequence Number. */
251 u_int32_t init_sequence_number;
252
253 /*If packet is unacknowledged, we try to send it again 16 times*/
254 u_char retrans_counter;
255
256 struct in_addr src; /* Neighbor Src address. */
257
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
262
263 u_char K1;
264 u_char K2;
265 u_char K3;
266 u_char K4;
267 u_char K5;
268 u_char K6;
269
270 /* Timer values. */
271 u_int16_t v_holddown;
272
273 /* Threads. */
274 struct thread *t_holddown;
275 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
276 chunks */
277
278 struct eigrp_fifo *retrans_queue;
279 struct eigrp_fifo *multicast_queue;
280
281 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
282
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;
289 };
290
291 //---------------------------------------------------------------------------------------------------------------------------------------------
292
293
294 struct eigrp_packet {
295 struct eigrp_packet *next;
296 struct eigrp_packet *previous;
297
298 /* Pointer to data stream. */
299 struct stream *s;
300
301 /* IP destination address. */
302 struct in_addr dst;
303
304 /*Packet retransmission thread*/
305 struct thread *t_retrans_timer;
306
307 /*Packet retransmission counter*/
308 u_char retrans_counter;
309
310 u_int32_t sequence_number;
311
312 /* EIGRP packet length. */
313 u_int16_t length;
314
315 struct eigrp_neighbor *nbr;
316 };
317
318 struct eigrp_fifo {
319 struct eigrp_packet *head;
320 struct eigrp_packet *tail;
321
322 unsigned long count;
323 };
324
325 struct eigrp_header {
326 u_char version;
327 u_char opcode;
328 u_int16_t checksum;
329 u_int32_t flags;
330 u_int32_t sequence;
331 u_int32_t ack;
332 u_int16_t vrid;
333 u_int16_t ASNumber;
334 char *tlv[0];
335
336 } __attribute__((packed));
337
338
339 /**
340 * Generic TLV type used for packet decoding.
341 *
342 * +-----+------------------+
343 * | | | |
344 * | Type| Len | Vector |
345 * | | | |
346 * +-----+------------------+
347 */
348 struct eigrp_tlv_hdr_type {
349 u_int16_t type;
350 u_int16_t length;
351 uint8_t value[0];
352 } __attribute__((packed));
353
354 struct TLV_Parameter_Type {
355 u_int16_t type;
356 u_int16_t length;
357 u_char K1;
358 u_char K2;
359 u_char K3;
360 u_char K4;
361 u_char K5;
362 u_char K6;
363 u_int16_t hold_time;
364 } __attribute__((packed));
365
366 struct TLV_MD5_Authentication_Type {
367 u_int16_t type;
368 u_int16_t length;
369 u_int16_t auth_type;
370 u_int16_t auth_length;
371 u_int32_t key_id;
372 u_int32_t key_sequence;
373 u_char Nullpad[8];
374 u_char digest[EIGRP_AUTH_TYPE_MD5_LEN];
375
376 } __attribute__((packed));
377
378 struct TLV_SHA256_Authentication_Type {
379 u_int16_t type;
380 u_int16_t length;
381 u_int16_t auth_type;
382 u_int16_t auth_length;
383 u_int32_t key_id;
384 u_int32_t key_sequence;
385 u_char Nullpad[8];
386 u_char digest[EIGRP_AUTH_TYPE_SHA256_LEN];
387
388 } __attribute__((packed));
389
390 struct TLV_Sequence_Type {
391 u_int16_t type;
392 u_int16_t length;
393 u_char addr_length;
394 struct in_addr *addresses;
395 } __attribute__((packed));
396
397 struct TLV_Next_Multicast_Sequence {
398 u_int16_t type;
399 u_int16_t length;
400 u_int32_t multicast_sequence;
401 } __attribute__((packed));
402
403 struct TLV_Software_Type {
404 u_int16_t type;
405 u_int16_t length;
406 u_char vender_major;
407 u_char vender_minor;
408 u_char eigrp_major;
409 u_char eigrp_minor;
410 } __attribute__((packed));
411
412 struct TLV_IPv4_Internal_type {
413 u_int16_t type;
414 u_int16_t length;
415 struct in_addr forward;
416
417 /*Metrics*/
418 struct eigrp_metrics metric;
419
420 u_char prefix_length;
421
422 unsigned char destination_part[4];
423 struct in_addr destination;
424 } __attribute__((packed));
425
426 struct TLV_IPv4_External_type {
427 u_int16_t type;
428 u_int16_t length;
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;
434 u_int16_t reserved;
435 u_char external_protocol;
436 u_char external_flags;
437
438 /*Metrics*/
439 struct eigrp_metrics metric;
440
441 u_char prefix_length;
442 unsigned char destination_part[4];
443 struct in_addr destination;
444 } __attribute__((packed));
445
446 /* EIGRP Peer Termination TLV - used for hard restart */
447 struct TLV_Peer_Termination_type {
448 u_int16_t type;
449 u_int16_t length;
450 u_char unknown;
451 u_int32_t neighbor_ip;
452 } __attribute__((packed));
453
454 /* Who executed Graceful restart */
455 enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
456
457 //---------------------------------------------------------------------------------------------------------------------------------------------
458
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
466
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
471
472 struct prefix *destination;
473
474 // If network type is REMOTE_EXTERNAL, pointer will have reference to
475 // its external TLV
476 struct TLV_IPv4_External_type *extTLV;
477
478 uint64_t serno; /*Serial number for this entry. Increased with each
479 change of entry*/
480 };
481
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
488
489 struct eigrp_metrics reported_metric;
490 struct eigrp_metrics total_metric;
491
492 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
493 u_char flags; // used for marking successor and FS
494
495 struct eigrp_interface *ei; // pointer for case of connected entry
496 };
497
498 //---------------------------------------------------------------------------------------------------------------------------------------------
499 typedef enum {
500 EIGRP_CONNECTED,
501 EIGRP_INT,
502 EIGRP_EXT,
503 } msg_data_t;
504
505 /* EIGRP Finite State Machine */
506
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;
515 };
516
517 #endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */