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