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