]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_structs.h
Merge pull request #2970 from dslicenc/more-bool-use-json
[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. */
d7c0a89a
QY
82 uint32_t router_id; /* Configured automatically. */
83 uint32_t 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
d62a17ae 134 QOBJ_FIELDS
7f57883e
DS
135};
136DECLARE_QOBJ_TYPE(eigrp)
79b30876
DS
137
138struct eigrp_if_params {
d7c0a89a
QY
139 uint8_t passive_interface;
140 uint32_t v_hello;
141 uint16_t v_wait;
142 uint8_t type; /* type of interface */
143 uint32_t bandwidth;
144 uint32_t delay;
145 uint8_t reliability;
146 uint8_t load;
b748db67
DS
147
148 char *auth_keychain; /* Associated keychain with interface*/
996c9314 149 int auth_type; /* EIGRP authentication type */
79b30876
DS
150};
151
152enum { MEMBER_ALLROUTERS = 0,
153 MEMBER_MAX,
154};
7f57883e
DS
155
156/*EIGRP interface structure*/
d62a17ae 157struct eigrp_interface {
b748db67 158 struct eigrp_if_params params;
79b30876
DS
159
160 /*multicast group refcnts */
b748db67 161 bool member_allrouters;
996c9314 162
d62a17ae 163 /* This interface's parent eigrp instance. */
164 struct eigrp *eigrp;
165
166 /* Interface data from zebra. */
167 struct interface *ifp;
168
169 /* Packet send buffer. */
170 struct eigrp_fifo *obuf; /* Output queue */
171
172 /* To which multicast groups do we currently belong? */
173
d62a17ae 174
d7c0a89a 175 uint8_t multicast_memberships;
d62a17ae 176
177 /* EIGRP Network Type. */
d7c0a89a 178 uint8_t type;
d62a17ae 179
180 struct prefix *address; /* Interface prefix */
181 struct connected *connected; /* Pointer to connected */
182
183 /* Neighbor information. */
184 struct list *nbrs; /* EIGRP Neighbor List */
185
186 /* Threads. */
187 struct thread *t_hello; /* timer */
188 struct thread *t_distribute; /* timer for distribute list */
189
190 int on_write_q;
191
192 /* Statistics fields. */
d7c0a89a
QY
193 uint32_t hello_in; /* Hello message input count. */
194 uint32_t update_in; /* Update message input count. */
195 uint32_t query_in; /* Querry message input count. */
196 uint32_t reply_in; /* Reply message input count. */
197 uint32_t hello_out; /* Hello message output count. */
198 uint32_t update_out; /* Update message output count. */
199 uint32_t query_out; /* Query message output count. */
200 uint32_t reply_out; /* Reply message output count. */
201 uint32_t siaQuery_in;
202 uint32_t siaQuery_out;
203 uint32_t siaReply_in;
204 uint32_t siaReply_out;
205 uint32_t ack_out;
206 uint32_t ack_in;
207
208 uint32_t crypt_seqnum; /* Cryptographic Sequence Number */
d62a17ae 209
210 /* Access-list. */
211 struct access_list *list[EIGRP_FILTER_MAX];
212 /* Prefix-list. */
213 struct prefix_list *prefix[EIGRP_FILTER_MAX];
214 /* Route-map. */
215 struct route_map *routemap[EIGRP_FILTER_MAX];
7f57883e
DS
216};
217
7f57883e
DS
218/* Determines if it is first or last packet
219 * when packet consists of multiple packet
220 * chunks because of many route TLV
221 * (all won't fit into one packet) */
d62a17ae 222enum Packet_part_type {
7f57883e
DS
223 EIGRP_PACKET_PART_NA,
224 EIGRP_PACKET_PART_FIRST,
225 EIGRP_PACKET_PART_LAST
226};
227
228/* Neighbor Data Structure */
d62a17ae 229struct eigrp_neighbor {
230 /* This neighbor's parent eigrp interface. */
231 struct eigrp_interface *ei;
7f57883e 232
d62a17ae 233 /* EIGRP neighbor Information */
d7c0a89a 234 uint8_t state; /* neigbor status. */
7f57883e 235
d7c0a89a
QY
236 uint32_t recv_sequence_number; /* Last received sequence Number. */
237 uint32_t init_sequence_number;
7f57883e 238
d62a17ae 239 /*If packet is unacknowledged, we try to send it again 16 times*/
d7c0a89a 240 uint8_t retrans_counter;
7f57883e 241
d62a17ae 242 struct in_addr src; /* Neighbor Src address. */
7f57883e 243
d7c0a89a
QY
244 uint8_t os_rel_major; // system version - just for show
245 uint8_t os_rel_minor; // system version - just for show
246 uint8_t tlv_rel_major; // eigrp version - tells us what TLV format to
247 // use
248 uint8_t tlv_rel_minor; // eigrp version - tells us what TLV format to
249 // use
7f57883e 250
d7c0a89a
QY
251 uint8_t K1;
252 uint8_t K2;
253 uint8_t K3;
254 uint8_t K4;
255 uint8_t K5;
256 uint8_t K6;
7f57883e 257
d62a17ae 258 /* Timer values. */
d7c0a89a 259 uint16_t v_holddown;
7f57883e 260
d62a17ae 261 /* Threads. */
262 struct thread *t_holddown;
263 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
264 chunks */
7f57883e 265
d62a17ae 266 struct eigrp_fifo *retrans_queue;
267 struct eigrp_fifo *multicast_queue;
7f57883e 268
d7c0a89a 269 uint32_t crypt_seqnum; /* Cryptographic Sequence Number. */
7f57883e 270
d62a17ae 271 /* prefixes not received from neighbor during Graceful restart */
272 struct list *nbr_gr_prefixes;
273 /* prefixes not yet send to neighbor during Graceful restart */
274 struct list *nbr_gr_prefixes_send;
275 /* if packet is first or last during Graceful restart */
276 enum Packet_part_type nbr_gr_packet_type;
7f57883e
DS
277};
278
279//---------------------------------------------------------------------------------------------------------------------------------------------
280
281
d62a17ae 282struct eigrp_packet {
283 struct eigrp_packet *next;
284 struct eigrp_packet *previous;
7f57883e 285
d62a17ae 286 /* Pointer to data stream. */
287 struct stream *s;
7f57883e 288
d62a17ae 289 /* IP destination address. */
290 struct in_addr dst;
7f57883e 291
d62a17ae 292 /*Packet retransmission thread*/
293 struct thread *t_retrans_timer;
7f57883e 294
d62a17ae 295 /*Packet retransmission counter*/
d7c0a89a 296 uint8_t retrans_counter;
7f57883e 297
d7c0a89a 298 uint32_t sequence_number;
7f57883e 299
d62a17ae 300 /* EIGRP packet length. */
d7c0a89a 301 uint16_t length;
907b4303
DS
302
303 struct eigrp_neighbor *nbr;
7f57883e
DS
304};
305
d62a17ae 306struct eigrp_fifo {
307 struct eigrp_packet *head;
308 struct eigrp_packet *tail;
7f57883e 309
d62a17ae 310 unsigned long count;
7f57883e
DS
311};
312
d62a17ae 313struct eigrp_header {
d7c0a89a
QY
314 uint8_t version;
315 uint8_t opcode;
316 uint16_t checksum;
317 uint32_t flags;
318 uint32_t sequence;
319 uint32_t ack;
320 uint16_t vrid;
321 uint16_t ASNumber;
d62a17ae 322 char *tlv[0];
7f57883e 323
d62a17ae 324} __attribute__((packed));
7f57883e
DS
325
326
327/**
328 * Generic TLV type used for packet decoding.
329 *
330 * +-----+------------------+
331 * | | | |
332 * | Type| Len | Vector |
333 * | | | |
334 * +-----+------------------+
335 */
d62a17ae 336struct eigrp_tlv_hdr_type {
d7c0a89a
QY
337 uint16_t type;
338 uint16_t length;
d62a17ae 339 uint8_t value[0];
340} __attribute__((packed));
341
342struct TLV_Parameter_Type {
d7c0a89a
QY
343 uint16_t type;
344 uint16_t length;
345 uint8_t K1;
346 uint8_t K2;
347 uint8_t K3;
348 uint8_t K4;
349 uint8_t K5;
350 uint8_t K6;
351 uint16_t hold_time;
d62a17ae 352} __attribute__((packed));
353
354struct TLV_MD5_Authentication_Type {
d7c0a89a
QY
355 uint16_t type;
356 uint16_t length;
357 uint16_t auth_type;
358 uint16_t auth_length;
359 uint32_t key_id;
360 uint32_t key_sequence;
361 uint8_t Nullpad[8];
362 uint8_t digest[EIGRP_AUTH_TYPE_MD5_LEN];
d62a17ae 363
364} __attribute__((packed));
365
366struct TLV_SHA256_Authentication_Type {
d7c0a89a
QY
367 uint16_t type;
368 uint16_t length;
369 uint16_t auth_type;
370 uint16_t auth_length;
371 uint32_t key_id;
372 uint32_t key_sequence;
373 uint8_t Nullpad[8];
374 uint8_t digest[EIGRP_AUTH_TYPE_SHA256_LEN];
d62a17ae 375
376} __attribute__((packed));
377
378struct TLV_Sequence_Type {
d7c0a89a
QY
379 uint16_t type;
380 uint16_t length;
381 uint8_t addr_length;
d62a17ae 382 struct in_addr *addresses;
383} __attribute__((packed));
384
385struct TLV_Next_Multicast_Sequence {
d7c0a89a
QY
386 uint16_t type;
387 uint16_t length;
388 uint32_t multicast_sequence;
d62a17ae 389} __attribute__((packed));
390
391struct TLV_Software_Type {
d7c0a89a
QY
392 uint16_t type;
393 uint16_t length;
394 uint8_t vender_major;
395 uint8_t vender_minor;
396 uint8_t eigrp_major;
397 uint8_t eigrp_minor;
d62a17ae 398} __attribute__((packed));
399
400struct TLV_IPv4_Internal_type {
d7c0a89a
QY
401 uint16_t type;
402 uint16_t length;
d62a17ae 403 struct in_addr forward;
404
405 /*Metrics*/
406 struct eigrp_metrics metric;
407
d7c0a89a 408 uint8_t prefix_length;
d62a17ae 409
410 unsigned char destination_part[4];
411 struct in_addr destination;
412} __attribute__((packed));
413
414struct TLV_IPv4_External_type {
d7c0a89a
QY
415 uint16_t type;
416 uint16_t length;
d62a17ae 417 struct in_addr next_hop;
418 struct in_addr originating_router;
d7c0a89a
QY
419 uint32_t originating_as;
420 uint32_t administrative_tag;
421 uint32_t external_metric;
422 uint16_t reserved;
423 uint8_t external_protocol;
424 uint8_t external_flags;
d62a17ae 425
426 /*Metrics*/
427 struct eigrp_metrics metric;
428
d7c0a89a 429 uint8_t prefix_length;
d62a17ae 430 unsigned char destination_part[4];
431 struct in_addr destination;
432} __attribute__((packed));
7f57883e
DS
433
434/* EIGRP Peer Termination TLV - used for hard restart */
d62a17ae 435struct TLV_Peer_Termination_type {
d7c0a89a
QY
436 uint16_t type;
437 uint16_t length;
438 uint8_t unknown;
439 uint32_t neighbor_ip;
7f57883e
DS
440} __attribute__((packed));
441
442/* Who executed Graceful restart */
d62a17ae 443enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
7f57883e
DS
444
445//---------------------------------------------------------------------------------------------------------------------------------------------
446
447/* EIGRP Topology table node structure */
d62a17ae 448struct eigrp_prefix_entry {
449 struct list *entries, *rij;
d7c0a89a
QY
450 uint32_t fdistance; // FD
451 uint32_t rdistance; // RD
452 uint32_t distance; // D
d62a17ae 453 struct eigrp_metrics reported_metric; // RD for sending
454
d7c0a89a
QY
455 uint8_t nt; // network type
456 uint8_t state; // route fsm state
457 uint8_t af; // address family
458 uint8_t req_action; // required action
d62a17ae 459
02b45998 460 struct prefix *destination;
d62a17ae 461
462 // If network type is REMOTE_EXTERNAL, pointer will have reference to
463 // its external TLV
464 struct TLV_IPv4_External_type *extTLV;
465
466 uint64_t serno; /*Serial number for this entry. Increased with each
467 change of entry*/
7f57883e
DS
468};
469
470/* EIGRP Topology table record structure */
255ab940 471struct eigrp_nexthop_entry {
d62a17ae 472 struct eigrp_prefix_entry *prefix;
d7c0a89a
QY
473 uint32_t reported_distance; // distance reported by neighbor
474 uint32_t distance; // sum of reported distance and link cost to
475 // advertised neighbor
7f57883e 476
d62a17ae 477 struct eigrp_metrics reported_metric;
478 struct eigrp_metrics total_metric;
7f57883e 479
d62a17ae 480 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
d7c0a89a 481 uint8_t flags; // used for marking successor and FS
7f57883e 482
d62a17ae 483 struct eigrp_interface *ei; // pointer for case of connected entry
7f57883e
DS
484};
485
486//---------------------------------------------------------------------------------------------------------------------------------------------
7cfa4322
DS
487typedef enum {
488 EIGRP_CONNECTED,
489 EIGRP_INT,
490 EIGRP_EXT,
491} msg_data_t;
7f57883e
DS
492
493/* EIGRP Finite State Machine */
494
d62a17ae 495struct eigrp_fsm_action_message {
d7c0a89a 496 uint8_t packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY
d62a17ae 497 struct eigrp *eigrp; // which thread sent mesg
498 struct eigrp_neighbor *adv_router; // advertising neighbor
255ab940 499 struct eigrp_nexthop_entry *entry;
d62a17ae 500 struct eigrp_prefix_entry *prefix;
7cfa4322 501 msg_data_t data_type; // internal or external tlv type
db6ec9ff 502 struct eigrp_metrics metrics;
377f30c3 503 enum metric_change change;
7f57883e
DS
504};
505
506#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */