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