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