]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_structs.h
bgpd: fix large route-distinguisher's format
[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
40/* EIGRP master for system wide configuration and variables. */
d62a17ae 41struct eigrp_master {
42 /* EIGRP instance. */
43 struct list *eigrp;
7f57883e 44
d62a17ae 45 /* EIGRP thread master. */
46 struct thread_master *master;
7f57883e 47
d62a17ae 48 /* Zebra interface list. */
49 struct list *iflist;
7f57883e 50
d62a17ae 51 /* EIGRP start time. */
52 time_t start_time;
7f57883e 53
d62a17ae 54 /* Various EIGRP global configuration. */
d7c0a89a 55 uint8_t options;
7f57883e
DS
56
57#define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
58};
59
d62a17ae 60struct eigrp_metrics {
d7c0a89a
QY
61 uint32_t delay;
62 uint32_t bandwidth;
d62a17ae 63 unsigned char mtu[3];
d7c0a89a
QY
64 uint8_t hop_count;
65 uint8_t reliability;
66 uint8_t load;
67 uint8_t tag;
68 uint8_t flags;
7f57883e
DS
69};
70
d62a17ae 71struct eigrp {
d7c0a89a
QY
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*/
7f57883e 77
d62a17ae 78 /*Name of this EIGRP instance*/
79 char *name;
7f57883e 80
d62a17ae 81 /* EIGRP Router ID. */
900e2d42
DS
82 struct in_addr router_id; /* Configured automatically. */
83 struct in_addr router_id_static; /* Configured manually. */
7f57883e 84
d62a17ae 85 struct list *eiflist; /* eigrp interfaces */
d7c0a89a 86 uint8_t passive_interface_default; /* passive-interface default */
7f57883e 87
d62a17ae 88 unsigned int fd;
89 unsigned int maxsndbuflen;
7f57883e 90
d7c0a89a 91 uint32_t sequence_number; /*Global EIGRP sequence number*/
7f57883e 92
d62a17ae 93 struct stream *ibuf;
94 struct list *oi_write_q;
7f57883e 95
d62a17ae 96 /*Threads*/
97 struct thread *t_write;
98 struct thread *t_read;
99 struct thread *t_distribute; /* timer for distribute list */
7f57883e 100
d62a17ae 101 struct route_table *networks; /* EIGRP config networks. */
7f57883e 102
9ca66cc7 103 struct route_table *topology_table;
7f57883e 104
d62a17ae 105 uint64_t serno; /* Global serial number counter for topology entry
106 changes*/
996c9314
LB
107 uint64_t serno_last_update; /* Highest serial number of information send
108 by last update*/
d62a17ae 109 struct list *topology_changes_internalIPV4;
110 struct list *topology_changes_externalIPV4;
7f57883e 111
d62a17ae 112 /*Neighbor self*/
113 struct eigrp_neighbor *neighbor_self;
7f57883e 114
d62a17ae 115 /*Configured metric for redistributed routes*/
116 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
117 int redistribute; /* Num of redistributed protocols. */
7f57883e 118
d62a17ae 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];
7f57883e 125
d62a17ae 126 /* For redistribute route map. */
127 struct {
128 char *name;
129 struct route_map *map;
130 int metric_config;
d7c0a89a 131 uint32_t metric;
d62a17ae 132 } route_map[ZEBRA_ROUTE_MAX];
7f57883e 133
03a38493
PG
134 /* distribute_ctx */
135 struct distribute_ctx *distribute_ctx;
136
d62a17ae 137 QOBJ_FIELDS
7f57883e
DS
138};
139DECLARE_QOBJ_TYPE(eigrp)
79b30876
DS
140
141struct eigrp_if_params {
d7c0a89a
QY
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;
b748db67
DS
150
151 char *auth_keychain; /* Associated keychain with interface*/
996c9314 152 int auth_type; /* EIGRP authentication type */
79b30876
DS
153};
154
155enum { MEMBER_ALLROUTERS = 0,
156 MEMBER_MAX,
157};
7f57883e
DS
158
159/*EIGRP interface structure*/
d62a17ae 160struct eigrp_interface {
b748db67 161 struct eigrp_if_params params;
79b30876
DS
162
163 /*multicast group refcnts */
b748db67 164 bool member_allrouters;
996c9314 165
d62a17ae 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
d62a17ae 177
d7c0a89a 178 uint8_t multicast_memberships;
d62a17ae 179
180 /* EIGRP Network Type. */
d7c0a89a 181 uint8_t type;
d62a17ae 182
b245781a 183 struct prefix address; /* Interface prefix */
d62a17ae 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. */
d7c0a89a
QY
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 */
d62a17ae 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];
7f57883e
DS
218};
219
7f57883e
DS
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) */
d62a17ae 224enum Packet_part_type {
7f57883e
DS
225 EIGRP_PACKET_PART_NA,
226 EIGRP_PACKET_PART_FIRST,
227 EIGRP_PACKET_PART_LAST
228};
229
230/* Neighbor Data Structure */
d62a17ae 231struct eigrp_neighbor {
232 /* This neighbor's parent eigrp interface. */
233 struct eigrp_interface *ei;
7f57883e 234
d62a17ae 235 /* EIGRP neighbor Information */
d7c0a89a 236 uint8_t state; /* neigbor status. */
7f57883e 237
d7c0a89a
QY
238 uint32_t recv_sequence_number; /* Last received sequence Number. */
239 uint32_t init_sequence_number;
7f57883e 240
d62a17ae 241 /*If packet is unacknowledged, we try to send it again 16 times*/
d7c0a89a 242 uint8_t retrans_counter;
7f57883e 243
d62a17ae 244 struct in_addr src; /* Neighbor Src address. */
7f57883e 245
d7c0a89a
QY
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
7f57883e 252
d7c0a89a
QY
253 uint8_t K1;
254 uint8_t K2;
255 uint8_t K3;
256 uint8_t K4;
257 uint8_t K5;
258 uint8_t K6;
7f57883e 259
d62a17ae 260 /* Timer values. */
d7c0a89a 261 uint16_t v_holddown;
7f57883e 262
d62a17ae 263 /* Threads. */
264 struct thread *t_holddown;
265 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
266 chunks */
7f57883e 267
d62a17ae 268 struct eigrp_fifo *retrans_queue;
269 struct eigrp_fifo *multicast_queue;
7f57883e 270
d7c0a89a 271 uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */
7f57883e 272
d62a17ae 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;
7f57883e
DS
279};
280
281//---------------------------------------------------------------------------------------------------------------------------------------------
282
283
d62a17ae 284struct eigrp_packet {
285 struct eigrp_packet *next;
286 struct eigrp_packet *previous;
7f57883e 287
d62a17ae 288 /* Pointer to data stream. */
289 struct stream *s;
7f57883e 290
d62a17ae 291 /* IP destination address. */
292 struct in_addr dst;
7f57883e 293
d62a17ae 294 /*Packet retransmission thread*/
295 struct thread *t_retrans_timer;
7f57883e 296
d62a17ae 297 /*Packet retransmission counter*/
d7c0a89a 298 uint8_t retrans_counter;
7f57883e 299
d7c0a89a 300 uint32_t sequence_number;
7f57883e 301
d62a17ae 302 /* EIGRP packet length. */
d7c0a89a 303 uint16_t length;
907b4303
DS
304
305 struct eigrp_neighbor *nbr;
7f57883e
DS
306};
307
d62a17ae 308struct eigrp_fifo {
309 struct eigrp_packet *head;
310 struct eigrp_packet *tail;
7f57883e 311
d62a17ae 312 unsigned long count;
7f57883e
DS
313};
314
d62a17ae 315struct eigrp_header {
d7c0a89a
QY
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;
d62a17ae 324 char *tlv[0];
7f57883e 325
d62a17ae 326} __attribute__((packed));
7f57883e
DS
327
328
329/**
330 * Generic TLV type used for packet decoding.
331 *
332 * +-----+------------------+
333 * | | | |
334 * | Type| Len | Vector |
335 * | | | |
336 * +-----+------------------+
337 */
d62a17ae 338struct eigrp_tlv_hdr_type {
d7c0a89a
QY
339 uint16_t type;
340 uint16_t length;
d62a17ae 341 uint8_t value[0];
342} __attribute__((packed));
343
344struct TLV_Parameter_Type {
d7c0a89a
QY
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;
d62a17ae 354} __attribute__((packed));
355
356struct TLV_MD5_Authentication_Type {
d7c0a89a
QY
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];
d62a17ae 365
366} __attribute__((packed));
367
368struct TLV_SHA256_Authentication_Type {
d7c0a89a
QY
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];
d62a17ae 377
378} __attribute__((packed));
379
380struct TLV_Sequence_Type {
d7c0a89a
QY
381 uint16_t type;
382 uint16_t length;
383 uint8_t addr_length;
d62a17ae 384 struct in_addr *addresses;
385} __attribute__((packed));
386
387struct TLV_Next_Multicast_Sequence {
d7c0a89a
QY
388 uint16_t type;
389 uint16_t length;
390 uint32_t multicast_sequence;
d62a17ae 391} __attribute__((packed));
392
393struct TLV_Software_Type {
d7c0a89a
QY
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;
d62a17ae 400} __attribute__((packed));
401
402struct TLV_IPv4_Internal_type {
d7c0a89a
QY
403 uint16_t type;
404 uint16_t length;
d62a17ae 405 struct in_addr forward;
406
407 /*Metrics*/
408 struct eigrp_metrics metric;
409
d7c0a89a 410 uint8_t prefix_length;
d62a17ae 411
412 unsigned char destination_part[4];
413 struct in_addr destination;
414} __attribute__((packed));
415
416struct TLV_IPv4_External_type {
d7c0a89a
QY
417 uint16_t type;
418 uint16_t length;
d62a17ae 419 struct in_addr next_hop;
420 struct in_addr originating_router;
d7c0a89a
QY
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;
d62a17ae 427
428 /*Metrics*/
429 struct eigrp_metrics metric;
430
d7c0a89a 431 uint8_t prefix_length;
d62a17ae 432 unsigned char destination_part[4];
433 struct in_addr destination;
434} __attribute__((packed));
7f57883e
DS
435
436/* EIGRP Peer Termination TLV - used for hard restart */
d62a17ae 437struct TLV_Peer_Termination_type {
d7c0a89a
QY
438 uint16_t type;
439 uint16_t length;
440 uint8_t unknown;
441 uint32_t neighbor_ip;
7f57883e
DS
442} __attribute__((packed));
443
444/* Who executed Graceful restart */
d62a17ae 445enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
7f57883e
DS
446
447//---------------------------------------------------------------------------------------------------------------------------------------------
448
449/* EIGRP Topology table node structure */
d62a17ae 450struct eigrp_prefix_entry {
451 struct list *entries, *rij;
d7c0a89a
QY
452 uint32_t fdistance; // FD
453 uint32_t rdistance; // RD
454 uint32_t distance; // D
d62a17ae 455 struct eigrp_metrics reported_metric; // RD for sending
456
d7c0a89a
QY
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
d62a17ae 461
02b45998 462 struct prefix *destination;
d62a17ae 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*/
7f57883e
DS
470};
471
472/* EIGRP Topology table record structure */
255ab940 473struct eigrp_nexthop_entry {
d62a17ae 474 struct eigrp_prefix_entry *prefix;
d7c0a89a
QY
475 uint32_t reported_distance; // distance reported by neighbor
476 uint32_t distance; // sum of reported distance and link cost to
477 // advertised neighbor
7f57883e 478
d62a17ae 479 struct eigrp_metrics reported_metric;
480 struct eigrp_metrics total_metric;
7f57883e 481
d62a17ae 482 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
d7c0a89a 483 uint8_t flags; // used for marking successor and FS
7f57883e 484
d62a17ae 485 struct eigrp_interface *ei; // pointer for case of connected entry
7f57883e
DS
486};
487
488//---------------------------------------------------------------------------------------------------------------------------------------------
7cfa4322
DS
489typedef enum {
490 EIGRP_CONNECTED,
491 EIGRP_INT,
492 EIGRP_EXT,
493} msg_data_t;
7f57883e
DS
494
495/* EIGRP Finite State Machine */
496
d62a17ae 497struct eigrp_fsm_action_message {
d7c0a89a 498 uint8_t packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY
d62a17ae 499 struct eigrp *eigrp; // which thread sent mesg
500 struct eigrp_neighbor *adv_router; // advertising neighbor
255ab940 501 struct eigrp_nexthop_entry *entry;
d62a17ae 502 struct eigrp_prefix_entry *prefix;
7cfa4322 503 msg_data_t data_type; // internal or external tlv type
db6ec9ff 504 struct eigrp_metrics metrics;
377f30c3 505 enum metric_change change;
7f57883e
DS
506};
507
508#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */