]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_structs.h
Merge pull request #10590 from donaldsharp/bgp_error_codes
[mirror_frr.git] / eigrpd / eigrp_structs.h
CommitLineData
7f57883e
DS
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 *
896014f4
DL
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
7f57883e
DS
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
d62a17ae 40struct eigrp_metrics {
d7c0a89a
QY
41 uint32_t delay;
42 uint32_t bandwidth;
7c6ff2c5 43 uint8_t mtu[3];
d7c0a89a
QY
44 uint8_t hop_count;
45 uint8_t reliability;
46 uint8_t load;
47 uint8_t tag;
48 uint8_t flags;
7f57883e
DS
49};
50
dc4accdd
DS
51struct 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
d62a17ae 61struct eigrp {
c371cd6b
DS
62 vrf_id_t vrf_id;
63
d7c0a89a
QY
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*/
7f57883e 69
d62a17ae 70 /*Name of this EIGRP instance*/
71 char *name;
7f57883e 72
d62a17ae 73 /* EIGRP Router ID. */
900e2d42
DS
74 struct in_addr router_id; /* Configured automatically. */
75 struct in_addr router_id_static; /* Configured manually. */
7f57883e 76
d62a17ae 77 struct list *eiflist; /* eigrp interfaces */
d7c0a89a 78 uint8_t passive_interface_default; /* passive-interface default */
7f57883e 79
128ed760 80 int fd;
d62a17ae 81 unsigned int maxsndbuflen;
7f57883e 82
d7c0a89a 83 uint32_t sequence_number; /*Global EIGRP sequence number*/
7f57883e 84
d62a17ae 85 struct stream *ibuf;
86 struct list *oi_write_q;
7f57883e 87
d62a17ae 88 /*Threads*/
89 struct thread *t_write;
90 struct thread *t_read;
91 struct thread *t_distribute; /* timer for distribute list */
7f57883e 92
d62a17ae 93 struct route_table *networks; /* EIGRP config networks. */
7f57883e 94
9ca66cc7 95 struct route_table *topology_table;
7f57883e 96
d62a17ae 97 uint64_t serno; /* Global serial number counter for topology entry
98 changes*/
996c9314
LB
99 uint64_t serno_last_update; /* Highest serial number of information send
100 by last update*/
d62a17ae 101 struct list *topology_changes_internalIPV4;
102 struct list *topology_changes_externalIPV4;
7f57883e 103
d62a17ae 104 /*Neighbor self*/
105 struct eigrp_neighbor *neighbor_self;
7f57883e 106
d62a17ae 107 /*Configured metric for redistributed routes*/
108 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
109 int redistribute; /* Num of redistributed protocols. */
7f57883e 110
d62a17ae 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];
7f57883e 117
d62a17ae 118 /* For redistribute route map. */
119 struct {
120 char *name;
121 struct route_map *map;
122 int metric_config;
d7c0a89a 123 uint32_t metric;
d62a17ae 124 } route_map[ZEBRA_ROUTE_MAX];
7f57883e 125
03a38493
PG
126 /* distribute_ctx */
127 struct distribute_ctx *distribute_ctx;
128
96244aca 129 QOBJ_FIELDS;
7f57883e 130};
96244aca 131DECLARE_QOBJ_TYPE(eigrp);
79b30876
DS
132
133struct eigrp_if_params {
d7c0a89a
QY
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;
b748db67
DS
142
143 char *auth_keychain; /* Associated keychain with interface*/
996c9314 144 int auth_type; /* EIGRP authentication type */
79b30876
DS
145};
146
147enum { MEMBER_ALLROUTERS = 0,
148 MEMBER_MAX,
149};
7f57883e
DS
150
151/*EIGRP interface structure*/
d62a17ae 152struct eigrp_interface {
b748db67 153 struct eigrp_if_params params;
79b30876
DS
154
155 /*multicast group refcnts */
b748db67 156 bool member_allrouters;
996c9314 157
d62a17ae 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
85d25587
DS
169 uint32_t curr_bandwidth;
170 uint32_t curr_mtu;
d62a17ae 171
d7c0a89a 172 uint8_t multicast_memberships;
d62a17ae 173
174 /* EIGRP Network Type. */
d7c0a89a 175 uint8_t type;
d62a17ae 176
b245781a 177 struct prefix address; /* Interface prefix */
d62a17ae 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. */
d7c0a89a
QY
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 */
d62a17ae 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];
7f57883e
DS
212};
213
7f57883e
DS
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) */
d62a17ae 218enum Packet_part_type {
7f57883e
DS
219 EIGRP_PACKET_PART_NA,
220 EIGRP_PACKET_PART_FIRST,
221 EIGRP_PACKET_PART_LAST
222};
223
224/* Neighbor Data Structure */
d62a17ae 225struct eigrp_neighbor {
226 /* This neighbor's parent eigrp interface. */
227 struct eigrp_interface *ei;
7f57883e 228
d62a17ae 229 /* EIGRP neighbor Information */
d7c0a89a 230 uint8_t state; /* neigbor status. */
7f57883e 231
d7c0a89a
QY
232 uint32_t recv_sequence_number; /* Last received sequence Number. */
233 uint32_t init_sequence_number;
7f57883e 234
d62a17ae 235 /*If packet is unacknowledged, we try to send it again 16 times*/
d7c0a89a 236 uint8_t retrans_counter;
7f57883e 237
d62a17ae 238 struct in_addr src; /* Neighbor Src address. */
7f57883e 239
d7c0a89a
QY
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
7f57883e 246
d7c0a89a
QY
247 uint8_t K1;
248 uint8_t K2;
249 uint8_t K3;
250 uint8_t K4;
251 uint8_t K5;
252 uint8_t K6;
7f57883e 253
d62a17ae 254 /* Timer values. */
d7c0a89a 255 uint16_t v_holddown;
7f57883e 256
d62a17ae 257 /* Threads. */
258 struct thread *t_holddown;
259 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
260 chunks */
7f57883e 261
d62a17ae 262 struct eigrp_fifo *retrans_queue;
263 struct eigrp_fifo *multicast_queue;
7f57883e 264
d7c0a89a 265 uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */
7f57883e 266
d62a17ae 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;
7f57883e
DS
273};
274
275//---------------------------------------------------------------------------------------------------------------------------------------------
276
277
d62a17ae 278struct eigrp_packet {
279 struct eigrp_packet *next;
280 struct eigrp_packet *previous;
7f57883e 281
d62a17ae 282 /* Pointer to data stream. */
283 struct stream *s;
7f57883e 284
d62a17ae 285 /* IP destination address. */
286 struct in_addr dst;
7f57883e 287
d62a17ae 288 /*Packet retransmission thread*/
289 struct thread *t_retrans_timer;
7f57883e 290
d62a17ae 291 /*Packet retransmission counter*/
d7c0a89a 292 uint8_t retrans_counter;
7f57883e 293
d7c0a89a 294 uint32_t sequence_number;
7f57883e 295
d62a17ae 296 /* EIGRP packet length. */
d7c0a89a 297 uint16_t length;
907b4303
DS
298
299 struct eigrp_neighbor *nbr;
7f57883e
DS
300};
301
d62a17ae 302struct eigrp_fifo {
303 struct eigrp_packet *head;
304 struct eigrp_packet *tail;
7f57883e 305
d62a17ae 306 unsigned long count;
7f57883e
DS
307};
308
d62a17ae 309struct eigrp_header {
d7c0a89a
QY
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;
d62a17ae 318 char *tlv[0];
7f57883e 319
d62a17ae 320} __attribute__((packed));
7f57883e
DS
321
322
323/**
324 * Generic TLV type used for packet decoding.
325 *
326 * +-----+------------------+
327 * | | | |
328 * | Type| Len | Vector |
329 * | | | |
330 * +-----+------------------+
331 */
d62a17ae 332struct eigrp_tlv_hdr_type {
d7c0a89a
QY
333 uint16_t type;
334 uint16_t length;
d62a17ae 335 uint8_t value[0];
336} __attribute__((packed));
337
338struct TLV_Parameter_Type {
d7c0a89a
QY
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;
d62a17ae 348} __attribute__((packed));
349
350struct TLV_MD5_Authentication_Type {
d7c0a89a
QY
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];
d62a17ae 359
360} __attribute__((packed));
361
362struct TLV_SHA256_Authentication_Type {
d7c0a89a
QY
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];
d62a17ae 371
372} __attribute__((packed));
373
374struct TLV_Sequence_Type {
d7c0a89a
QY
375 uint16_t type;
376 uint16_t length;
377 uint8_t addr_length;
d62a17ae 378 struct in_addr *addresses;
379} __attribute__((packed));
380
381struct TLV_Next_Multicast_Sequence {
d7c0a89a
QY
382 uint16_t type;
383 uint16_t length;
384 uint32_t multicast_sequence;
d62a17ae 385} __attribute__((packed));
386
387struct TLV_Software_Type {
d7c0a89a
QY
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;
d62a17ae 394} __attribute__((packed));
395
396struct TLV_IPv4_Internal_type {
d7c0a89a
QY
397 uint16_t type;
398 uint16_t length;
d62a17ae 399 struct in_addr forward;
400
401 /*Metrics*/
402 struct eigrp_metrics metric;
403
d7c0a89a 404 uint8_t prefix_length;
d62a17ae 405
d62a17ae 406 struct in_addr destination;
407} __attribute__((packed));
408
409struct TLV_IPv4_External_type {
d7c0a89a
QY
410 uint16_t type;
411 uint16_t length;
d62a17ae 412 struct in_addr next_hop;
413 struct in_addr originating_router;
d7c0a89a
QY
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;
d62a17ae 420
421 /*Metrics*/
422 struct eigrp_metrics metric;
423
d7c0a89a 424 uint8_t prefix_length;
d62a17ae 425 unsigned char destination_part[4];
426 struct in_addr destination;
427} __attribute__((packed));
7f57883e
DS
428
429/* EIGRP Peer Termination TLV - used for hard restart */
d62a17ae 430struct TLV_Peer_Termination_type {
d7c0a89a
QY
431 uint16_t type;
432 uint16_t length;
433 uint8_t unknown;
434 uint32_t neighbor_ip;
7f57883e
DS
435} __attribute__((packed));
436
437/* Who executed Graceful restart */
d62a17ae 438enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
7f57883e
DS
439
440//---------------------------------------------------------------------------------------------------------------------------------------------
441
442/* EIGRP Topology table node structure */
dc4accdd 443struct eigrp_prefix_descriptor {
d62a17ae 444 struct list *entries, *rij;
d7c0a89a
QY
445 uint32_t fdistance; // FD
446 uint32_t rdistance; // RD
447 uint32_t distance; // D
d62a17ae 448 struct eigrp_metrics reported_metric; // RD for sending
449
d7c0a89a
QY
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
d62a17ae 454
02b45998 455 struct prefix *destination;
d62a17ae 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*/
7f57883e
DS
463};
464
465/* EIGRP Topology table record structure */
dc4accdd
DS
466struct 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
d7c0a89a
QY
474 uint32_t reported_distance; // distance reported by neighbor
475 uint32_t distance; // sum of reported distance and link cost to
476 // advertised neighbor
7f57883e 477
d62a17ae 478 struct eigrp_metrics reported_metric;
479 struct eigrp_metrics total_metric;
7f57883e 480
dc4accdd
DS
481 struct eigrp_metrics metric;
482 struct eigrp_extdata extdata;
483
d7c0a89a 484 uint8_t flags; // used for marking successor and FS
7f57883e 485
d62a17ae 486 struct eigrp_interface *ei; // pointer for case of connected entry
7f57883e
DS
487};
488
489//---------------------------------------------------------------------------------------------------------------------------------------------
7cfa4322
DS
490typedef enum {
491 EIGRP_CONNECTED,
492 EIGRP_INT,
493 EIGRP_EXT,
494} msg_data_t;
7f57883e
DS
495
496/* EIGRP Finite State Machine */
497
d62a17ae 498struct eigrp_fsm_action_message {
d7c0a89a 499 uint8_t packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY
d62a17ae 500 struct eigrp *eigrp; // which thread sent mesg
501 struct eigrp_neighbor *adv_router; // advertising neighbor
dc4accdd
DS
502 struct eigrp_route_descriptor *entry;
503 struct eigrp_prefix_descriptor *prefix;
7cfa4322 504 msg_data_t data_type; // internal or external tlv type
db6ec9ff 505 struct eigrp_metrics metrics;
377f30c3 506 enum metric_change change;
7f57883e
DS
507};
508
509#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */