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