-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheigrp_structs.h
443 lines (358 loc) · 10.5 KB
/
eigrp_structs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* EIGRP Definition of Data Structures.
* Copyright (C) 2013-2016
* Authors:
* Donnie Savage
* Jan Janovic
* Matej Perina
* Peter Orsag
* Peter Paluch
* Frantisek Gazo
* Tomas Hvorkovy
* Martin Kontsek
* Lukas Koribsky
*
*/
#ifndef _ZEBRA_EIGRP_STRUCTS_H_
#define _ZEBRA_EIGRP_STRUCTS_H_
#include "eigrpd/eigrp_const.h"
#include "eigrpd/eigrp_types.h"
#include "eigrpd/eigrp_macros.h"
typedef struct eigrp_addr {
uint8_t afi; // ipv4 or ipv6
union {
struct in_addr v4;
struct in6_addr v6;
} ip;
} eigrp_addr_t;
typedef struct eigrp_metrics {
eigrp_delay_t delay;
eigrp_bandwidth_t bandwidth;
unsigned char mtu[3];
uint8_t hop_count;
uint8_t reliability;
uint8_t load;
uint8_t tag;
uint8_t flags;
} eigrp_metrics_t;
typedef struct eigrp_extdata {
uint32_t orig;
uint32_t as;
uint32_t tag;
uint32_t metric;
uint16_t reserved;
uint8_t protocol;
uint8_t flags;
} eigrp_extdata_t;
/*
*DVS: this stuct is a mess of a dumping ground for any and everythign.
* will be cleaned up as it exposes to much to functions that do not need
*it.
*
*/
struct eigrp_instance {
vrf_id_t vrf_id;
uint16_t AS; /* Autonomous system number */
uint16_t vrid; /* Virtual Router ID */
uint8_t k_values[6]; /*Array for K values configuration*/
uint8_t variance; /*Metric variance multiplier*/
uint8_t max_paths; /*Maximum allowed paths for 1 prefix*/
/*Name of this EIGRP instance*/
char *name;
/* EIGRP Router ID. */
struct in_addr router_id; /* Configured automatically. */
struct in_addr router_id_static; /* Configured manually. */
struct list *eiflist; /* eigrp interfaces */
uint8_t passive_interface_default; /* passive-interface default */
int fd;
unsigned int maxsndbuflen;
uint32_t sequence_number; /*Global EIGRP sequence number*/
struct stream *ibuf;
struct list *oi_write_q;
/*Events*/
struct event *t_write;
struct event *t_read;
struct event *t_distribute; /* timer for distribute list */
struct route_table *networks; /* EIGRP config networks. */
struct route_table *topology_table;
uint64_t serno; /* Global serial number counter for topology entry
changes*/
uint64_t serno_last_update; /* Highest serial number of information send
by last update*/
struct list *topology_changes;
/*Neighbor self*/
eigrp_neighbor_t *neighbor_self;
/*Configured metric for redistributed routes*/
eigrp_metrics_t dmetric[ZEBRA_ROUTE_MAX + 1];
int redistribute; /* Num of redistributed protocols. */
/* Access-list. */
struct access_list *list[EIGRP_FILTER_MAX];
/* Prefix-list. */
struct prefix_list *prefix[EIGRP_FILTER_MAX];
/* Route-map. */
struct route_map *routemap[EIGRP_FILTER_MAX];
/* For redistribute route map. */
struct {
char *name;
struct route_map *map;
int metric_config;
uint32_t metric;
} route_map[ZEBRA_ROUTE_MAX];
/* distribute_ctx */
struct distribute_ctx *distribute_ctx;
QOBJ_FIELDS;
};
DECLARE_QOBJ_TYPE(eigrp);
typedef struct eigrp_packet_queue {
eigrp_packet_t *head;
eigrp_packet_t *tail;
unsigned long count;
} eigrp_packet_queue_t;
typedef struct eigrp_intf_params {
uint8_t passive_interface;
uint32_t v_hello;
uint16_t v_wait;
uint8_t type; /* type of interface */
uint32_t bandwidth;
uint32_t delay;
uint8_t reliability;
uint8_t load;
char *auth_keychain; /* Associated keychain with interface*/
int auth_type; /* EIGRP authentication type */
} eigrp_intf_params_t;
enum { MEMBER_ALLROUTERS = 0,
MEMBER_MAX,
};
typedef struct eigrp_intf_stats {
struct {
int ack;
int hello; /* Hello message input count. */
int query; /* Query message input count. */
int reply; /* Reply message input count. */
int update; /* Update message input count. */
int siaQuery;
int siaReply;
} rcvd;
struct {
int ack;
int hello; /* Hello message output count. */
int query; /* Query message output count. */
int reply; /* Reply message output count. */
int update; /* Update message output count. */
int siaQuery;
int siaReply;
} sent;
} eigrp_intf_stats_t;
/*EIGRP interface structure*/
typedef struct eigrp_interface {
/* This interface's parent eigrp instance. */
eigrp_instance_t *eigrp;
/* Zebra Interface Properties */
struct interface *ifp; //Interface data from zebra
uint8_t type; // P2P, LOOP, BCAST
struct prefix address; // Interface prefix
uint32_t curr_bandwidth;
uint32_t curr_mtu;
/* Multicat Properties */
bool member_allrouters; // multicast group refcnts
uint8_t multicast_memberships; // multicast groups we belong
/* EIGRP Interface Properties */
eigrp_intf_params_t params;
struct {
bool mixed;
uint8_t v1;
uint8_t v2;
} version;
/* Neighbor information. */
struct list *nbrs; /* EIGRP Neighbor List */
/* Events. */
struct event *t_hello; /* timer */
struct event *t_distribute; /* timer for distribute list */
/* Packet send buffer. */
eigrp_packet_queue_t *obuf; /* Output queue */
int on_write_q;
uint32_t crypt_seqnum; /* Cryptographic Sequence Number */
/* Statistics fields. */
eigrp_intf_stats_t stats; // Statistics fields
/* Access-list. */
struct access_list *list[EIGRP_FILTER_MAX];
/* Prefix-list. */
struct prefix_list *prefix[EIGRP_FILTER_MAX];
/* Route-map. */
struct route_map *routemap[EIGRP_FILTER_MAX];
} eigrp_interface_t;
/* Determines if it is first or last packet
* when packet consists of multiple packet
* chunks because of many route TLV
* (all won't fit into one packet) */
enum Packet_part_type {
EIGRP_PACKET_PART_NA,
EIGRP_PACKET_PART_FIRST,
EIGRP_PACKET_PART_LAST
};
//---------------------------------------------------------------------------------------------------------------------------------------------
typedef struct eigrp_packet {
eigrp_packet_t *next;
eigrp_packet_t *previous;
/* Pointer to data stream. */
struct stream *s;
/* IP destination address. */
eigrp_addr_t dst;
/*Packet retransmission event and counter*/
struct event *t_retrans_timer;
uint8_t retrans_counter;
/*neighbor details for sendng packet*/
eigrp_neighbor_t *nbr;
uint32_t sequence_number;
/* EIGRP packet length. */
uint16_t length;
} eigrp_packet_t;
struct eigrp_header {
uint8_t version;
uint8_t opcode;
uint16_t checksum;
uint32_t flags;
uint32_t sequence;
uint32_t ack;
uint16_t vrid;
uint16_t ASNumber;
char *tlv[0];
} __attribute__((packed));
typedef struct eigrp_header eigrp_header_t;
/**
* Generic TLV type used for packet decoding.
*
* +-----+------------------+
* | | | |
* | Type| Len | Vector |
* | | | |
* +-----+------------------+
*/
struct eigrp_tlv_hdr_type {
uint16_t type;
uint16_t length;
uint8_t value[0];
} __attribute__((packed));
struct TLV_Parameter_Type {
uint16_t type;
uint16_t length;
uint8_t K1;
uint8_t K2;
uint8_t K3;
uint8_t K4;
uint8_t K5;
uint8_t K6;
uint16_t hold_time;
} __attribute__((packed));
struct TLV_MD5_Authentication_Type {
uint16_t type;
uint16_t length;
uint16_t auth_type;
uint16_t auth_length;
uint32_t key_id;
uint32_t key_sequence;
uint8_t Nullpad[8];
uint8_t digest[EIGRP_AUTH_TYPE_MD5_LEN];
} __attribute__((packed));
struct TLV_SHA256_Authentication_Type {
uint16_t type;
uint16_t length;
uint16_t auth_type;
uint16_t auth_length;
uint32_t key_id;
uint32_t key_sequence;
uint8_t Nullpad[8];
uint8_t digest[EIGRP_AUTH_TYPE_SHA256_LEN];
} __attribute__((packed));
struct TLV_Sequence_Type {
uint16_t type;
uint16_t length;
uint8_t addr_length;
struct in_addr *addresses;
} __attribute__((packed));
struct TLV_Next_Multicast_Sequence {
uint16_t type;
uint16_t length;
uint32_t multicast_sequence;
} __attribute__((packed));
struct TLV_Software_Type {
uint16_t type;
uint16_t length;
uint8_t vender_major;
uint8_t vender_minor;
uint8_t eigrp_major;
uint8_t eigrp_minor;
} __attribute__((packed));
struct TLV_IPv4_Internal_type {
uint16_t type;
uint16_t length;
struct in_addr forward;
/*Metrics*/
struct eigrp_metrics metric;
uint8_t prefix_length;
struct in_addr destination;
} __attribute__((packed));
struct TLV_IPv4_External_type {
uint16_t type;
uint16_t length;
struct in_addr next_hop;
struct in_addr originating_router;
uint32_t originating_as;
uint32_t administrative_tag;
uint32_t external_metric;
uint16_t reserved;
uint8_t external_protocol;
uint8_t external_flags;
/*Metrics*/
struct eigrp_metrics metric;
uint8_t prefix_length;
unsigned char destination_part[4];
struct in_addr destination;
} __attribute__((packed));
/* EIGRP Peer Termination TLV - used for hard restart */
struct TLV_Peer_Termination_type {
uint16_t type;
uint16_t length;
uint8_t unknown;
uint32_t neighbor_ip;
} __attribute__((packed));
/* Who executed Graceful restart */
enum GR_type { EIGRP_GR_MANUAL, EIGRP_GR_FILTER };
//---------------------------------------------------------------------------------------------------------------------------------------------
/* EIGRP Topology table node structure */
typedef struct eigrp_prefix_descriptor {
struct list *entries, *rij;
struct prefix *destination;
eigrp_metrics_t reported_metric; // RD for sending
uint32_t fdistance; // FD
uint32_t rdistance; // RD
uint32_t distance; // D
uint8_t nt; // network type
uint8_t state; // route FSM state
uint8_t req_action; // required action
// If network type is REMOTE_EXTERNAL, pointer will have reference to
// its external TLV
// uint8_t af; // address family
struct TLV_IPv4_External_type *extTLV;
uint64_t serno; /*Serial number for this entry. Increased with each
change of entry*/
} eigrp_prefix_descriptor_t;
/* EIGRP Topology table record structure */
typedef struct eigrp_route_descriptor {
uint16_t type;
struct prefix dest; // destination address
eigrp_addr_t nexthop; // address of advertised by peer
eigrp_prefix_descriptor_t *prefix; // prefix this route is part of
eigrp_neighbor_t *adv_router; // peer who sent me the route
eigrp_metrics_t reported_metric; // neighbors vector metrics
uint32_t reported_distance; // neighbors distance (RD)
eigrp_metrics_t total_metric; // calculated vector metrics
uint32_t distance; // calculatd distance (RD + link cost)
eigrp_metrics_t metric;
eigrp_extdata_t extdata;
uint8_t flags; // used for marking successor and FS
eigrp_interface_t *ei; // pointer for case of connected entry
} eigrp_route_descriptor_t;
//---------------------------------------------------------------------------------------------------------------------------------------------
#endif /* _ZEBRA_EIGRP_STRUCTURES_H_ */