]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_structs.h
eigrpd: Remove extra newline in debug
[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. */
55 u_char options;
7f57883e
DS
56
57#define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
58};
59
d62a17ae 60struct eigrp_metrics {
61 u_int32_t delay;
b1968f83 62 u_int32_t bandwidth;
d62a17ae 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;
7f57883e
DS
69};
70
d62a17ae 71struct 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*/
7f57883e 77
d62a17ae 78 /*Name of this EIGRP instance*/
79 char *name;
7f57883e 80
d62a17ae 81 /* EIGRP Router ID. */
82 u_int32_t router_id; /* Configured automatically. */
83 u_int32_t router_id_static; /* Configured manually. */
7f57883e 84
d62a17ae 85 struct list *eiflist; /* eigrp interfaces */
86 u_char passive_interface_default; /* passive-interface default */
7f57883e 87
d62a17ae 88 unsigned int fd;
89 unsigned int maxsndbuflen;
7f57883e 90
d62a17ae 91 u_int32_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
d62a17ae 103 struct list *topology_table;
7f57883e 104
d62a17ae 105 uint64_t serno; /* Global serial number counter for topology entry
106 changes*/
9d303b37
DL
107 uint64_t
108 serno_last_update; /* Highest serial number of information send
109 by last update*/
d62a17ae 110 struct list *topology_changes_internalIPV4;
111 struct list *topology_changes_externalIPV4;
7f57883e 112
d62a17ae 113 /*Neighbor self*/
114 struct eigrp_neighbor *neighbor_self;
7f57883e 115
d62a17ae 116 /*Configured metric for redistributed routes*/
117 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
118 int redistribute; /* Num of redistributed protocols. */
7f57883e 119
d62a17ae 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];
7f57883e 126
d62a17ae 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];
7f57883e 134
d62a17ae 135 QOBJ_FIELDS
7f57883e
DS
136};
137DECLARE_QOBJ_TYPE(eigrp)
138//------------------------------------------------------------------------------------------------------------------------------------------
139
140/*EIGRP interface structure*/
d62a17ae 141struct 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];
7f57883e
DS
197};
198
d62a17ae 199struct 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 */
7f57883e
DS
216};
217
d62a17ae 218enum { MEMBER_ALLROUTERS = 0,
219 MEMBER_MAX,
7f57883e
DS
220};
221
d62a17ae 222struct 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 */
7f57883e
DS
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) */
d62a17ae 236enum Packet_part_type {
7f57883e
DS
237 EIGRP_PACKET_PART_NA,
238 EIGRP_PACKET_PART_FIRST,
239 EIGRP_PACKET_PART_LAST
240};
241
242/* Neighbor Data Structure */
d62a17ae 243struct eigrp_neighbor {
244 /* This neighbor's parent eigrp interface. */
245 struct eigrp_interface *ei;
7f57883e 246
d62a17ae 247 /* EIGRP neighbor Information */
248 u_char state; /* neigbor status. */
7f57883e 249
d62a17ae 250 u_int32_t recv_sequence_number; /* Last received sequence Number. */
251 u_int32_t init_sequence_number;
7f57883e 252
d62a17ae 253 /*If packet is unacknowledged, we try to send it again 16 times*/
254 u_char retrans_counter;
7f57883e 255
d62a17ae 256 struct in_addr src; /* Neighbor Src address. */
7f57883e 257
d62a17ae 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
7f57883e 262
d62a17ae 263 u_char K1;
264 u_char K2;
265 u_char K3;
266 u_char K4;
267 u_char K5;
268 u_char K6;
7f57883e 269
d62a17ae 270 /* Timer values. */
271 u_int16_t v_holddown;
7f57883e 272
d62a17ae 273 /* Threads. */
274 struct thread *t_holddown;
275 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet
276 chunks */
7f57883e 277
d62a17ae 278 struct eigrp_fifo *retrans_queue;
279 struct eigrp_fifo *multicast_queue;
7f57883e 280
d62a17ae 281 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
7f57883e 282
d62a17ae 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;
7f57883e
DS
289};
290
291//---------------------------------------------------------------------------------------------------------------------------------------------
292
293
d62a17ae 294struct eigrp_packet {
295 struct eigrp_packet *next;
296 struct eigrp_packet *previous;
7f57883e 297
d62a17ae 298 /* Pointer to data stream. */
299 struct stream *s;
7f57883e 300
d62a17ae 301 /* IP destination address. */
302 struct in_addr dst;
7f57883e 303
d62a17ae 304 /*Packet retransmission thread*/
305 struct thread *t_retrans_timer;
7f57883e 306
d62a17ae 307 /*Packet retransmission counter*/
308 u_char retrans_counter;
7f57883e 309
d62a17ae 310 u_int32_t sequence_number;
7f57883e 311
d62a17ae 312 /* EIGRP packet length. */
313 u_int16_t length;
7f57883e
DS
314};
315
d62a17ae 316struct eigrp_fifo {
317 struct eigrp_packet *head;
318 struct eigrp_packet *tail;
7f57883e 319
d62a17ae 320 unsigned long count;
7f57883e
DS
321};
322
d62a17ae 323struct eigrp_header {
324 u_char version;
325 u_char opcode;
326 u_int16_t checksum;
327 u_int32_t flags;
328 u_int32_t sequence;
329 u_int32_t ack;
330 u_int16_t vrid;
331 u_int16_t ASNumber;
332 char *tlv[0];
7f57883e 333
d62a17ae 334} __attribute__((packed));
7f57883e
DS
335
336
337/**
338 * Generic TLV type used for packet decoding.
339 *
340 * +-----+------------------+
341 * | | | |
342 * | Type| Len | Vector |
343 * | | | |
344 * +-----+------------------+
345 */
d62a17ae 346struct eigrp_tlv_hdr_type {
347 u_int16_t type;
348 u_int16_t length;
349 uint8_t value[0];
350} __attribute__((packed));
351
352struct TLV_Parameter_Type {
353 u_int16_t type;
354 u_int16_t length;
355 u_char K1;
356 u_char K2;
357 u_char K3;
358 u_char K4;
359 u_char K5;
360 u_char K6;
361 u_int16_t hold_time;
362} __attribute__((packed));
363
364struct TLV_MD5_Authentication_Type {
365 u_int16_t type;
366 u_int16_t length;
367 u_int16_t auth_type;
368 u_int16_t auth_length;
369 u_int32_t key_id;
370 u_int32_t key_sequence;
371 u_char Nullpad[8];
372 u_char digest[EIGRP_AUTH_TYPE_MD5_LEN];
373
374} __attribute__((packed));
375
376struct TLV_SHA256_Authentication_Type {
377 u_int16_t type;
378 u_int16_t length;
379 u_int16_t auth_type;
380 u_int16_t auth_length;
381 u_int32_t key_id;
382 u_int32_t key_sequence;
383 u_char Nullpad[8];
384 u_char digest[EIGRP_AUTH_TYPE_SHA256_LEN];
385
386} __attribute__((packed));
387
388struct TLV_Sequence_Type {
389 u_int16_t type;
390 u_int16_t length;
391 u_char addr_length;
392 struct in_addr *addresses;
393} __attribute__((packed));
394
395struct TLV_Next_Multicast_Sequence {
396 u_int16_t type;
397 u_int16_t length;
398 u_int32_t multicast_sequence;
399} __attribute__((packed));
400
401struct TLV_Software_Type {
402 u_int16_t type;
403 u_int16_t length;
404 u_char vender_major;
405 u_char vender_minor;
406 u_char eigrp_major;
407 u_char eigrp_minor;
408} __attribute__((packed));
409
410struct TLV_IPv4_Internal_type {
411 u_int16_t type;
412 u_int16_t length;
413 struct in_addr forward;
414
415 /*Metrics*/
416 struct eigrp_metrics metric;
417
418 u_char prefix_length;
419
420 unsigned char destination_part[4];
421 struct in_addr destination;
422} __attribute__((packed));
423
424struct TLV_IPv4_External_type {
425 u_int16_t type;
426 u_int16_t length;
427 struct in_addr next_hop;
428 struct in_addr originating_router;
429 u_int32_t originating_as;
430 u_int32_t administrative_tag;
431 u_int32_t external_metric;
432 u_int16_t reserved;
433 u_char external_protocol;
434 u_char external_flags;
435
436 /*Metrics*/
437 struct eigrp_metrics metric;
438
439 u_char prefix_length;
440 unsigned char destination_part[4];
441 struct in_addr destination;
442} __attribute__((packed));
7f57883e
DS
443
444/* EIGRP Peer Termination TLV - used for hard restart */
d62a17ae 445struct TLV_Peer_Termination_type {
446 u_int16_t type;
447 u_int16_t length;
448 u_char unknown;
449 u_int32_t neighbor_ip;
7f57883e
DS
450} __attribute__((packed));
451
452/* Who executed Graceful restart */
d62a17ae 453enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
7f57883e
DS
454
455//---------------------------------------------------------------------------------------------------------------------------------------------
456
457/* EIGRP Topology table node structure */
d62a17ae 458struct eigrp_prefix_entry {
459 struct list *entries, *rij;
460 u_int32_t fdistance; // FD
461 u_int32_t rdistance; // RD
462 u_int32_t distance; // D
463 struct eigrp_metrics reported_metric; // RD for sending
464
465 u_char nt; // network type
466 u_char state; // route fsm state
467 u_char af; // address family
468 u_char req_action; // required action
469
470 struct prefix_ipv4
471 *destination_ipv4; // pointer to struct with ipv4 address
472 struct prefix_ipv6
473 *destination_ipv6; // pointer to struct with ipv6 address
474
475 // If network type is REMOTE_EXTERNAL, pointer will have reference to
476 // its external TLV
477 struct TLV_IPv4_External_type *extTLV;
478
479 uint64_t serno; /*Serial number for this entry. Increased with each
480 change of entry*/
7f57883e
DS
481};
482
483/* EIGRP Topology table record structure */
d62a17ae 484struct eigrp_neighbor_entry {
485 struct eigrp_prefix_entry *prefix;
486 u_int32_t reported_distance; // distance reported by neighbor
487 u_int32_t distance; // sum of reported distance and link cost to
488 // advertised neighbor
7f57883e 489
d62a17ae 490 struct eigrp_metrics reported_metric;
491 struct eigrp_metrics total_metric;
7f57883e 492
d62a17ae 493 struct eigrp_neighbor *adv_router; // ip address of advertising neighbor
494 u_char flags; // used for marking successor and FS
7f57883e 495
d62a17ae 496 struct eigrp_interface *ei; // pointer for case of connected entry
7f57883e
DS
497};
498
499//---------------------------------------------------------------------------------------------------------------------------------------------
500
501/* EIGRP Finite State Machine */
502
d62a17ae 503struct eigrp_fsm_action_message {
504 u_char packet_type; // UPDATE, QUERY, SIAQUERY, SIAREPLY
505 struct eigrp *eigrp; // which thread sent mesg
506 struct eigrp_neighbor *adv_router; // advertising neighbor
507 struct eigrp_neighbor_entry *entry;
508 struct eigrp_prefix_entry *prefix;
509 int data_type; // internal or external tlv type
510 union {
511 struct TLV_IPv4_External_type *ipv4_ext_data;
512 struct TLV_IPv4_Internal_type *ipv4_int_type;
513 } data;
7f57883e
DS
514};
515
516#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */