]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_structs.h
eigrp: Initial Commit
[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 *
27 * You should have received a copy of the GNU General Public License
28 * along with GNU Zebra; see the file COPYING. If not, write to the Free
29 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30 * 02111-1307, USA.
31 */
32
33#ifndef _ZEBRA_EIGRP_STRUCTS_H_
34#define _ZEBRA_EIGRP_STRUCTS_H_
35
36#include "filter.h"
37
38#include "eigrpd/eigrp_const.h"
39#include "eigrpd/eigrp_macros.h"
40
41/* EIGRP master for system wide configuration and variables. */
42struct eigrp_master
43{
44 /* EIGRP instance. */
45 struct list *eigrp;
46
47 /* EIGRP thread master. */
48 struct thread_master *master;
49
50 /* Zebra interface list. */
51 struct list *iflist;
52
53 /* EIGRP start time. */
54 time_t start_time;
55
56 /* Various EIGRP global configuration. */
57 u_char options;
58
59#define EIGRP_MASTER_SHUTDOWN (1 << 0) /* deferred-shutdown */
60};
61
62struct eigrp_metrics
63{
64 u_int32_t delay;
65 u_int32_t bandwith;
66 unsigned char mtu[3];
67 u_char hop_count;
68 u_char reliability;
69 u_char load;
70 u_char tag;
71 u_char flags;
72};
73
74struct eigrp
75{
76 u_int16_t AS; /* Autonomous system number */
77 u_int16_t vrid; /* Virtual Router ID */
78 u_char k_values[6]; /*Array for K values configuration*/
79 u_char variance; /*Metric variance multiplier*/
80 u_char max_paths; /*Maximum allowed paths for 1 prefix*/
81
82 /*Name of this EIGRP instance*/
83 char *name;
84
85 /* EIGRP Router ID. */
86 u_int32_t router_id; /* Configured automatically. */
87 u_int32_t router_id_static; /* Configured manually. */
88
89 struct list *eiflist; /* eigrp interfaces */
90 u_char passive_interface_default; /* passive-interface default */
91
92 unsigned int fd;
93 unsigned int maxsndbuflen;
94
95 u_int32_t sequence_number; /*Global EIGRP sequence number*/
96
97 struct stream *ibuf;
98 struct list *oi_write_q;
99
100 /*Threads*/
101 struct thread *t_write;
102 struct thread *t_read;
103 struct thread *t_distribute; /* timer for distribute list */
104
105 struct route_table *networks; /* EIGRP config networks. */
106
107 struct list *topology_table;
108
109 u_int64_t serno; /* Global serial number counter for topology entry changes*/
110 u_int64_t serno_last_update; /* Highest serial number of information send by last update*/
111 struct list *topology_changes_internalIPV4;
112 struct list *topology_changes_externalIPV4;
113
114 /*Neighbor self*/
115 struct eigrp_neighbor *neighbor_self;
116
117 /*Configured metric for redistributed routes*/
118 struct eigrp_metrics dmetric[ZEBRA_ROUTE_MAX + 1];
119 int redistribute; /* Num of redistributed protocols. */
120
121 /* Access-list. */
122 struct access_list *list[EIGRP_FILTER_MAX];
123 /* Prefix-list. */
124 struct prefix_list *prefix[EIGRP_FILTER_MAX];
125 /* Route-map. */
126 struct route_map *routemap[EIGRP_FILTER_MAX];
127
128 /* For redistribute route map. */
129 struct
130 {
131 char *name;
132 struct route_map *map;
133 int metric_config;
134 u_int32_t metric;
135 } route_map[ZEBRA_ROUTE_MAX];
136
137 QOBJ_FIELDS
138};
139DECLARE_QOBJ_TYPE(eigrp)
140//------------------------------------------------------------------------------------------------------------------------------------------
141
142/*EIGRP interface structure*/
143struct eigrp_interface
144{
145 /* This interface's parent eigrp instance. */
146 struct eigrp *eigrp;
147
148 /* Interface data from zebra. */
149 struct interface *ifp;
150
151 /* Packet send buffer. */
152 struct eigrp_fifo *obuf; /* Output queue */
153
154 /* To which multicast groups do we currently belong? */
155
156 /* Configured varables. */
157 struct eigrp_if_params *params;
158
159 u_char multicast_memberships;
160
161 /* EIGRP Network Type. */
162 u_char type;
163
164 struct prefix *address; /* Interface prefix */
165 struct connected *connected; /* Pointer to connected */
166
167 /* Neighbor information. */
168 struct list *nbrs; /* EIGRP Neighbor List */
169
170 /* Threads. */
171 struct thread *t_hello; /* timer */
172 struct thread *t_distribute; /* timer for distribute list */
173
174 int on_write_q;
175
176 /* Statistics fields. */
177 u_int32_t hello_in; /* Hello message input count. */
178 u_int32_t update_in; /* Update message input count. */
179 u_int32_t query_in; /* Querry message input count. */
180 u_int32_t reply_in; /* Reply message input count. */
181 u_int32_t hello_out; /* Hello message output count. */
182 u_int32_t update_out; /* Update message output count. */
183 u_int32_t query_out; /* Query message output count. */
184 u_int32_t reply_out; /* Reply message output count. */
185 u_int32_t siaQuery_in;
186 u_int32_t siaQuery_out;
187 u_int32_t siaReply_in;
188 u_int32_t siaReply_out;
189 u_int32_t ack_out;
190 u_int32_t ack_in;
191
192 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
193
194 /* Access-list. */
195 struct access_list *list[EIGRP_FILTER_MAX];
196 /* Prefix-list. */
197 struct prefix_list *prefix[EIGRP_FILTER_MAX];
198 /* Route-map. */
199 struct route_map *routemap[EIGRP_FILTER_MAX];
200};
201
202struct eigrp_if_params
203{
204 DECLARE_IF_PARAM (u_char, passive_interface); /* EIGRP Interface is passive: no sending or receiving (no need to join multicast groups) */
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 *, auth_keychain ); /* Associated keychain with interface*/
214 DECLARE_IF_PARAM (int, auth_type); /* EIGRP authentication type */
215};
216
217enum
218{
219 MEMBER_ALLROUTERS = 0, MEMBER_MAX,
220};
221
222struct eigrp_if_info
223{
224 struct eigrp_if_params *def_params;
225 struct route_table *params;
226 struct route_table *eifs;
227 unsigned int membership_counts[MEMBER_MAX]; /* multicast group refcnts */
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) */
236enum Packet_part_type
237{
238 EIGRP_PACKET_PART_NA,
239 EIGRP_PACKET_PART_FIRST,
240 EIGRP_PACKET_PART_LAST
241};
242
243/* Neighbor Data Structure */
244struct eigrp_neighbor
245{
246 /* This neighbor's parent eigrp interface. */
247 struct eigrp_interface *ei;
248
249 /* EIGRP neighbor Information */
250 u_char state; /* neigbor status. */
251
252 u_int32_t recv_sequence_number; /* Last received sequence Number. */
253 u_int32_t init_sequence_number;
254
255 /*If packet is unacknowledged, we try to send it again 16 times*/
256 u_char retrans_counter;
257
258 struct in_addr src; /* Neighbor Src address. */
259
260 u_char os_rel_major; // system version - just for show
261 u_char os_rel_minor; // system version - just for show
262 u_char tlv_rel_major; // eigrp version - tells us what TLV format to use
263 u_char tlv_rel_minor; // eigrp version - tells us what TLV format to use
264
265 u_char K1;
266 u_char K2;
267 u_char K3;
268 u_char K4;
269 u_char K5;
270 u_char K6;
271
272 /* Timer values. */
273 u_int16_t v_holddown;
274
275 /* Threads. */
276 struct thread *t_holddown;
277 struct thread *t_nbr_send_gr; /* thread for sending multiple GR packet chunks */
278
279 struct eigrp_fifo *retrans_queue;
280 struct eigrp_fifo *multicast_queue;
281
282 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
283
284 /* prefixes not received from neighbor during Graceful restart */
285 struct list *nbr_gr_prefixes;
286 /* prefixes not yet send to neighbor during Graceful restart */
287 struct list *nbr_gr_prefixes_send;
288 /* if packet is first or last during Graceful restart */
289 enum Packet_part_type nbr_gr_packet_type;
290};
291
292//---------------------------------------------------------------------------------------------------------------------------------------------
293
294
295struct eigrp_packet
296{
297 struct eigrp_packet *next;
298 struct eigrp_packet *previous;
299
300 /* Pointer to data stream. */
301 struct stream *s;
302
303 /* IP destination address. */
304 struct in_addr dst;
305
306 /*Packet retransmission thread*/
307 struct thread *t_retrans_timer;
308
309 /*Packet retransmission counter*/
310 u_char retrans_counter;
311
312 u_int32_t sequence_number;
313
314 /* EIGRP packet length. */
315 u_int16_t length;
316};
317
318struct eigrp_fifo
319{
320 struct eigrp_packet *head;
321 struct eigrp_packet *tail;
322
323 unsigned long count;
324};
325
326struct eigrp_header
327{
328 u_char version;
329 u_char opcode;
330 u_int16_t checksum;
331 u_int32_t flags;
332 u_int32_t sequence;
333 u_int32_t ack;
334 u_int16_t vrid;
335 u_int16_t ASNumber;
336 char *tlv[0];
337
338}__attribute__((packed));
339
340
341/**
342 * Generic TLV type used for packet decoding.
343 *
344 * +-----+------------------+
345 * | | | |
346 * | Type| Len | Vector |
347 * | | | |
348 * +-----+------------------+
349 */
350struct eigrp_tlv_hdr_type
351{
352 u_int16_t type;
353 u_int16_t length;
354 uint8_t value[0];
355}__attribute__((packed));
356
357struct TLV_Parameter_Type
358{
359 u_int16_t type;
360 u_int16_t length;
361 u_char K1;
362 u_char K2;
363 u_char K3;
364 u_char K4;
365 u_char K5;
366 u_char K6;
367 u_int16_t hold_time;
368}__attribute__((packed));
369
370struct TLV_MD5_Authentication_Type
371{
372 u_int16_t type;
373 u_int16_t length;
374 u_int16_t auth_type;
375 u_int16_t auth_length;
376 u_int32_t key_id;
377 u_int32_t key_sequence;
378 u_char Nullpad[8];
379 u_char digest[EIGRP_AUTH_TYPE_MD5_LEN];
380
381}__attribute__((packed));
382
383struct TLV_SHA256_Authentication_Type
384{
385 u_int16_t type;
386 u_int16_t length;
387 u_int16_t auth_type;
388 u_int16_t auth_length;
389 u_int32_t key_id;
390 u_int32_t key_sequence;
391 u_char Nullpad[8];
392 u_char digest[EIGRP_AUTH_TYPE_SHA256_LEN];
393
394}__attribute__((packed));
395
396struct TLV_Sequence_Type
397{
398 u_int16_t type;
399 u_int16_t length;
400 u_char addr_length;
401 struct in_addr *addresses;
402}__attribute__((packed));
403
404struct TLV_Next_Multicast_Sequence
405{
406 u_int16_t type;
407 u_int16_t length;
408 u_int32_t multicast_sequence;
409}__attribute__((packed));
410
411struct TLV_Software_Type
412{
413 u_int16_t type;
414 u_int16_t length;
415 u_char vender_major;
416 u_char vender_minor;
417 u_char eigrp_major;
418 u_char eigrp_minor;
419}__attribute__((packed));
420
421struct TLV_IPv4_Internal_type
422{
423 u_int16_t type;
424 u_int16_t length;
425 struct in_addr forward;
426
427 /*Metrics*/
428 struct eigrp_metrics metric;
429
430 u_char prefix_length;
431
432 unsigned char destination_part[4];
433 struct in_addr destination;
434}__attribute__((packed));
435
436struct TLV_IPv4_External_type
437{
438 u_int16_t type;
439 u_int16_t length;
440 struct in_addr next_hop;
441 struct in_addr originating_router;
442 u_int32_t originating_as;
443 u_int32_t administrative_tag;
444 u_int32_t external_metric;
445 u_int16_t reserved;
446 u_char external_protocol;
447 u_char external_flags;
448
449 /*Metrics*/
450 struct eigrp_metrics metric;
451
452 u_char prefix_length;
453 unsigned char destination_part[4];
454 struct in_addr destination;
455}__attribute__((packed));
456
457/* EIGRP Peer Termination TLV - used for hard restart */
458struct TLV_Peer_Termination_type
459{
460 u_int16_t type;
461 u_int16_t length;
462 u_char unknown;
463 u_int32_t neighbor_ip;
464} __attribute__((packed));
465
466/* Who executed Graceful restart */
467enum GR_type
468{
469 EIGRP_GR_MANUAL,
470 EIGRP_GR_FILTER
471};
472
473//---------------------------------------------------------------------------------------------------------------------------------------------
474
475/* EIGRP Topology table node structure */
476struct eigrp_prefix_entry
477{
478 struct list *entries, *rij;
479 u_int32_t fdistance; // FD
480 u_int32_t rdistance; // RD
481 u_int32_t distance; // D
482 struct eigrp_metrics reported_metric; // RD for sending
483
484 u_char nt; //network type
485 u_char state; //route fsm state
486 u_char af; // address family
487 u_char req_action; // required action
488
489 struct prefix_ipv4 *destination_ipv4; // pointer to struct with ipv4 address
490 struct prefix_ipv6 *destination_ipv6; // pointer to struct with ipv6 address
491
492 //If network type is REMOTE_EXTERNAL, pointer will have reference to its external TLV
493 struct TLV_IPv4_External_type *extTLV;
494
495 u_int64_t serno; /*Serial number for this entry. Increased with each change of entry*/
496};
497
498/* EIGRP Topology table record structure */
499struct eigrp_neighbor_entry
500{
501 struct eigrp_prefix_entry *prefix;
502 u_int32_t reported_distance; //distance reported by neighbor
503 u_int32_t distance; //sum of reported distance and link cost to advertised neighbor
504
505 struct eigrp_metrics reported_metric;
506 struct eigrp_metrics total_metric;
507
508 struct eigrp_neighbor *adv_router; //ip address of advertising neighbor
509 u_char flags; //used for marking successor and FS
510
511 struct eigrp_interface *ei; //pointer for case of connected entry
512
513};
514
515//---------------------------------------------------------------------------------------------------------------------------------------------
516
517/* EIGRP Finite State Machine */
518
519struct eigrp_fsm_action_message
520{
521 u_char packet_type; //UPDATE, QUERY, SIAQUERY, SIAREPLY
522 struct eigrp *eigrp; // which thread sent mesg
523 struct eigrp_neighbor *adv_router; //advertising neighbor
524 struct eigrp_neighbor_entry *entry;
525 struct eigrp_prefix_entry *prefix;
526 int data_type; // internal or external tlv type
527 union{
528 struct TLV_IPv4_External_type *ipv4_ext_data;
529 struct TLV_IPv4_Internal_type *ipv4_int_type;
530 }data;
531};
532
533#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */