]> git.proxmox.com Git - mirror_frr.git/blame - eigrpd/eigrp_interface.c
doc: sample code-doc in .rst+sphinx
[mirror_frr.git] / eigrpd / eigrp_interface.c
CommitLineData
7f57883e
DS
1/*
2 * EIGRP Interface Functions.
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#include <zebra.h>
33
34#include "thread.h"
35#include "linklist.h"
36#include "prefix.h"
37#include "if.h"
38#include "table.h"
39#include "memory.h"
40#include "command.h"
41#include "stream.h"
42#include "log.h"
43#include "keychain.h"
44#include "vrf.h"
45
46#include "eigrpd/eigrp_structs.h"
47#include "eigrpd/eigrpd.h"
48#include "eigrpd/eigrp_interface.h"
49#include "eigrpd/eigrp_neighbor.h"
50#include "eigrpd/eigrp_packet.h"
51#include "eigrpd/eigrp_zebra.h"
52#include "eigrpd/eigrp_vty.h"
53#include "eigrpd/eigrp_network.h"
54#include "eigrpd/eigrp_topology.h"
55#include "eigrpd/eigrp_memory.h"
56
d62a17ae 57static void eigrp_delete_from_if(struct interface *, struct eigrp_interface *);
7f57883e 58
d62a17ae 59static void eigrp_add_to_if(struct interface *ifp, struct eigrp_interface *ei)
7f57883e 60{
d62a17ae 61 struct route_node *rn;
62 struct prefix p;
63
64 p = *ei->address;
65 p.prefixlen = IPV4_MAX_PREFIXLEN;
66
67 rn = route_node_get(IF_OIFS(ifp), &p);
68 /* rn->info should either be NULL or equal to this ei
69 * as route_node_get may return an existing node
70 */
71 assert(!rn->info || rn->info == ei);
72 rn->info = ei;
7f57883e
DS
73}
74
d62a17ae 75struct eigrp_interface *eigrp_if_new(struct eigrp *eigrp, struct interface *ifp,
76 struct prefix *p)
7f57883e 77{
d62a17ae 78 struct eigrp_interface *ei;
79 int i;
7f57883e 80
d62a17ae 81 if ((ei = eigrp_if_table_lookup(ifp, p)) == NULL) {
82 ei = XCALLOC(MTYPE_EIGRP_IF, sizeof(struct eigrp_interface));
83 memset(ei, 0, sizeof(struct eigrp_interface));
84 } else
85 return ei;
7f57883e 86
d62a17ae 87 /* Set zebra interface pointer. */
88 ei->ifp = ifp;
89 ei->address = p;
7f57883e 90
d62a17ae 91 eigrp_add_to_if(ifp, ei);
92 listnode_add(eigrp->eiflist, ei);
7f57883e 93
d62a17ae 94 ei->type = EIGRP_IFTYPE_BROADCAST;
7f57883e 95
d62a17ae 96 /* Initialize neighbor list. */
97 ei->nbrs = list_new();
7f57883e 98
d62a17ae 99 ei->crypt_seqnum = time(NULL);
7f57883e 100
d62a17ae 101 /* Initialize lists */
102 for (i = 0; i < EIGRP_FILTER_MAX; i++) {
103 ei->list[i] = NULL;
104 ei->prefix[i] = NULL;
105 ei->routemap[i] = NULL;
106 }
7f57883e 107
d62a17ae 108 return ei;
7f57883e
DS
109}
110
111/* lookup ei for specified prefix/ifp */
d62a17ae 112struct eigrp_interface *eigrp_if_table_lookup(struct interface *ifp,
113 struct prefix *prefix)
7f57883e 114{
d62a17ae 115 struct prefix p;
116 struct route_node *rn;
117 struct eigrp_interface *rninfo = NULL;
7f57883e 118
d62a17ae 119 p = *prefix;
120 p.prefixlen = IPV4_MAX_PREFIXLEN;
7f57883e 121
d62a17ae 122 /* route_node_get implicitly locks */
123 if ((rn = route_node_lookup(IF_OIFS(ifp), &p))) {
124 rninfo = (struct eigrp_interface *)rn->info;
125 route_unlock_node(rn);
126 }
7f57883e 127
d62a17ae 128 return rninfo;
7f57883e
DS
129}
130
d62a17ae 131int eigrp_if_delete_hook(struct interface *ifp)
7f57883e 132{
d62a17ae 133 struct route_node *rn;
7f57883e 134
d62a17ae 135 route_table_finish(IF_OIFS(ifp));
7f57883e 136
d62a17ae 137 for (rn = route_top(IF_OIFS_PARAMS(ifp)); rn; rn = route_next(rn))
138 if (rn->info)
139 eigrp_del_if_params(rn->info);
140 route_table_finish(IF_OIFS_PARAMS(ifp));
7f57883e 141
d62a17ae 142 XFREE(MTYPE_EIGRP_IF_INFO, ifp->info);
143 ifp->info = NULL;
7f57883e 144
d62a17ae 145 return 0;
7f57883e
DS
146}
147
148struct list *eigrp_iflist;
149
d62a17ae 150void eigrp_if_init()
7f57883e 151{
d62a17ae 152 /* Initialize Zebra interface data structure. */
153 if_add_hook(IF_NEW_HOOK, eigrp_if_new_hook);
154 if_add_hook(IF_DELETE_HOOK, eigrp_if_delete_hook);
7f57883e
DS
155}
156
d62a17ae 157int eigrp_if_new_hook(struct interface *ifp)
7f57883e 158{
d62a17ae 159 int rc = 0;
7f57883e 160
d62a17ae 161 ifp->info = XCALLOC(MTYPE_EIGRP_IF_INFO, sizeof(struct eigrp_if_info));
7f57883e 162
d62a17ae 163 IF_OIFS(ifp) = route_table_init();
164 IF_OIFS_PARAMS(ifp) = route_table_init();
7f57883e 165
d62a17ae 166 IF_DEF_PARAMS(ifp) = eigrp_new_if_params();
7f57883e 167
d62a17ae 168 SET_IF_PARAM(IF_DEF_PARAMS(ifp), v_hello);
169 IF_DEF_PARAMS(ifp)->v_hello = (u_int32_t)EIGRP_HELLO_INTERVAL_DEFAULT;
7f57883e 170
d62a17ae 171 SET_IF_PARAM(IF_DEF_PARAMS(ifp), v_wait);
172 IF_DEF_PARAMS(ifp)->v_wait = (u_int16_t)EIGRP_HOLD_INTERVAL_DEFAULT;
7f57883e 173
d62a17ae 174 SET_IF_PARAM(IF_DEF_PARAMS(ifp), bandwidth);
175 IF_DEF_PARAMS(ifp)->bandwidth = (u_int32_t)EIGRP_BANDWIDTH_DEFAULT;
7f57883e 176
d62a17ae 177 SET_IF_PARAM(IF_DEF_PARAMS(ifp), delay);
178 IF_DEF_PARAMS(ifp)->delay = (u_int32_t)EIGRP_DELAY_DEFAULT;
7f57883e 179
d62a17ae 180 SET_IF_PARAM(IF_DEF_PARAMS(ifp), reliability);
181 IF_DEF_PARAMS(ifp)->reliability = (u_char)EIGRP_RELIABILITY_DEFAULT;
7f57883e 182
d62a17ae 183 SET_IF_PARAM(IF_DEF_PARAMS(ifp), load);
184 IF_DEF_PARAMS(ifp)->load = (u_char)EIGRP_LOAD_DEFAULT;
7f57883e 185
d62a17ae 186 SET_IF_PARAM(IF_DEF_PARAMS(ifp), auth_type);
187 IF_DEF_PARAMS(ifp)->auth_type = EIGRP_AUTH_TYPE_NONE;
7f57883e 188
d62a17ae 189 SET_IF_PARAM(IF_DEF_PARAMS(ifp), auth_keychain);
190 IF_DEF_PARAMS(ifp)->auth_keychain = NULL;
7f57883e 191
d62a17ae 192 return rc;
7f57883e
DS
193}
194
d62a17ae 195struct eigrp_if_params *eigrp_new_if_params(void)
7f57883e 196{
d62a17ae 197 struct eigrp_if_params *eip;
198
199 eip = XCALLOC(MTYPE_EIGRP_IF_PARAMS, sizeof(struct eigrp_if_params));
200 if (!eip)
201 return NULL;
202
203 UNSET_IF_PARAM(eip, passive_interface);
204 UNSET_IF_PARAM(eip, v_hello);
205 UNSET_IF_PARAM(eip, v_wait);
206 UNSET_IF_PARAM(eip, bandwidth);
207 UNSET_IF_PARAM(eip, delay);
208 UNSET_IF_PARAM(eip, reliability);
209 UNSET_IF_PARAM(eip, load);
210 UNSET_IF_PARAM(eip, auth_keychain);
211 UNSET_IF_PARAM(eip, auth_type);
212
213 return eip;
7f57883e
DS
214}
215
d62a17ae 216void eigrp_del_if_params(struct eigrp_if_params *eip)
7f57883e 217{
d62a17ae 218 if (eip->auth_keychain)
219 free(eip->auth_keychain);
7f57883e 220
d62a17ae 221 XFREE(MTYPE_EIGRP_IF_PARAMS, eip);
7f57883e
DS
222}
223
d62a17ae 224struct eigrp_if_params *eigrp_lookup_if_params(struct interface *ifp,
225 struct in_addr addr)
7f57883e 226{
d62a17ae 227 struct prefix_ipv4 p;
228 struct route_node *rn;
7f57883e 229
d62a17ae 230 p.family = AF_INET;
231 p.prefixlen = IPV4_MAX_PREFIXLEN;
232 p.prefix = addr;
7f57883e 233
d62a17ae 234 rn = route_node_lookup(IF_OIFS_PARAMS(ifp), (struct prefix *)&p);
7f57883e 235
d62a17ae 236 if (rn) {
237 route_unlock_node(rn);
238 return rn->info;
239 }
7f57883e 240
d62a17ae 241 return NULL;
7f57883e
DS
242}
243
d62a17ae 244int eigrp_if_up(struct eigrp_interface *ei)
7f57883e 245{
d62a17ae 246 struct eigrp_prefix_entry *pe;
247 struct eigrp_neighbor_entry *ne;
248 struct eigrp_metrics metric;
249 struct eigrp_interface *ei2;
250 struct listnode *node, *nnode;
251 struct eigrp *eigrp = eigrp_lookup();
252
253 if (ei == NULL)
254 return 0;
255
256 if (eigrp != NULL)
257 eigrp_adjust_sndbuflen(eigrp, ei->ifp->mtu);
258 else
259 zlog_warn("%s: eigrp_lookup () returned NULL", __func__);
260 eigrp_if_stream_set(ei);
261
262 /* Set multicast memberships appropriately for new state. */
263 eigrp_if_set_multicast(ei);
264
265 thread_add_event(master, eigrp_hello_timer, ei, (1), NULL);
266
267 /*Prepare metrics*/
b1968f83 268 metric.bandwidth =
d62a17ae 269 eigrp_bandwidth_to_scaled(EIGRP_IF_PARAM(ei, bandwidth));
270 metric.delay = eigrp_delay_to_scaled(EIGRP_IF_PARAM(ei, delay));
271 metric.load = EIGRP_IF_PARAM(ei, load);
272 metric.reliability = EIGRP_IF_PARAM(ei, reliability);
273 metric.mtu[0] = 0xDC;
274 metric.mtu[1] = 0x05;
275 metric.mtu[2] = 0x00;
276 metric.hop_count = 0;
277 metric.flags = 0;
278 metric.tag = 0;
279
280 /*Add connected entry to topology table*/
281
282 struct prefix_ipv4 dest_addr;
283
284 dest_addr.family = AF_INET;
285 dest_addr.prefix = ei->connected->address->u.prefix4;
286 dest_addr.prefixlen = ei->connected->address->prefixlen;
287 apply_mask_ipv4(&dest_addr);
288 pe = eigrp_topology_table_lookup_ipv4(eigrp->topology_table,
289 &dest_addr);
290
291 if (pe == NULL) {
292 pe = eigrp_prefix_entry_new();
293 pe->serno = eigrp->serno;
294 pe->destination_ipv4 = prefix_ipv4_new();
295 prefix_copy((struct prefix *)pe->destination_ipv4,
296 (struct prefix *)&dest_addr);
297 pe->af = AF_INET;
298 pe->nt = EIGRP_TOPOLOGY_TYPE_CONNECTED;
299
300 pe->state = EIGRP_FSM_STATE_PASSIVE;
301 pe->fdistance = eigrp_calculate_metrics(eigrp, metric);
302 pe->req_action |= EIGRP_FSM_NEED_UPDATE;
303 eigrp_prefix_entry_add(eigrp->topology_table, pe);
304 listnode_add(eigrp->topology_changes_internalIPV4, pe);
305 }
306 ne = eigrp_neighbor_entry_new();
307 ne->ei = ei;
308 ne->reported_metric = metric;
309 ne->total_metric = metric;
310 ne->distance = eigrp_calculate_metrics(eigrp, metric);
311 ne->reported_distance = 0;
312 ne->prefix = pe;
313 ne->adv_router = eigrp->neighbor_self;
314 ne->flags = EIGRP_NEIGHBOR_ENTRY_SUCCESSOR_FLAG;
315 eigrp_neighbor_entry_add(pe, ne);
316
317 for (ALL_LIST_ELEMENTS(eigrp->eiflist, node, nnode, ei2)) {
318 if (ei2->nbrs->count != 0) {
319 eigrp_update_send(ei2);
320 }
321 }
322
323 pe->req_action &= ~EIGRP_FSM_NEED_UPDATE;
324 listnode_delete(eigrp->topology_changes_internalIPV4, pe);
325
326 return 1;
7f57883e
DS
327}
328
d62a17ae 329int eigrp_if_down(struct eigrp_interface *ei)
7f57883e 330{
d62a17ae 331 struct listnode *node, *nnode;
332 struct eigrp_neighbor *nbr;
7f57883e 333
d62a17ae 334 if (ei == NULL)
335 return 0;
7f57883e 336
d62a17ae 337 /* Shutdown packet reception and sending */
338 if (ei->t_hello)
339 THREAD_OFF(ei->t_hello);
7f57883e 340
d62a17ae 341 eigrp_if_stream_unset(ei);
7f57883e 342
d62a17ae 343 /*Set infinite metrics to routes learned by this interface and start
344 * query process*/
345 for (ALL_LIST_ELEMENTS(ei->nbrs, node, nnode, nbr)) {
346 eigrp_nbr_delete(nbr);
347 }
7f57883e 348
d62a17ae 349 return 1;
7f57883e
DS
350}
351
d62a17ae 352void eigrp_if_stream_set(struct eigrp_interface *ei)
7f57883e 353{
d62a17ae 354 /* set output fifo queue. */
355 if (ei->obuf == NULL)
356 ei->obuf = eigrp_fifo_new();
7f57883e
DS
357}
358
d62a17ae 359void eigrp_if_stream_unset(struct eigrp_interface *ei)
7f57883e 360{
d62a17ae 361 struct eigrp *eigrp = ei->eigrp;
362
363 if (ei->obuf) {
364 eigrp_fifo_free(ei->obuf);
365 ei->obuf = NULL;
366
367 if (ei->on_write_q) {
368 listnode_delete(eigrp->oi_write_q, ei);
369 if (list_isempty(eigrp->oi_write_q))
370 thread_cancel(eigrp->t_write);
371 ei->on_write_q = 0;
372 }
373 }
7f57883e
DS
374}
375
d62a17ae 376void eigrp_if_set_multicast(struct eigrp_interface *ei)
7f57883e 377{
d62a17ae 378 if ((EIGRP_IF_PASSIVE_STATUS(ei) == EIGRP_IF_ACTIVE)) {
379 /* The interface should belong to the EIGRP-all-routers group.
380 */
381 if (!EI_MEMBER_CHECK(ei, MEMBER_ALLROUTERS)
382 && (eigrp_if_add_allspfrouters(ei->eigrp, ei->address,
383 ei->ifp->ifindex)
384 >= 0))
385 /* Set the flag only if the system call to join
386 * succeeded. */
387 EI_MEMBER_JOINED(ei, MEMBER_ALLROUTERS);
388 } else {
389 /* The interface should NOT belong to the EIGRP-all-routers
390 * group. */
391 if (EI_MEMBER_CHECK(ei, MEMBER_ALLROUTERS)) {
392 /* Only actually drop if this is the last reference */
393 if (EI_MEMBER_COUNT(ei, MEMBER_ALLROUTERS) == 1)
394 eigrp_if_drop_allspfrouters(ei->eigrp,
395 ei->address,
396 ei->ifp->ifindex);
397 /* Unset the flag regardless of whether the system call
398 to leave
399 the group succeeded, since it's much safer to assume
400 that
401 we are not a member. */
402 EI_MEMBER_LEFT(ei, MEMBER_ALLROUTERS);
403 }
404 }
7f57883e
DS
405}
406
d62a17ae 407u_char eigrp_default_iftype(struct interface *ifp)
7f57883e 408{
d62a17ae 409 if (if_is_pointopoint(ifp))
410 return EIGRP_IFTYPE_POINTOPOINT;
411 else if (if_is_loopback(ifp))
412 return EIGRP_IFTYPE_LOOPBACK;
413 else
414 return EIGRP_IFTYPE_BROADCAST;
7f57883e
DS
415}
416
d62a17ae 417void eigrp_if_free(struct eigrp_interface *ei, int source)
7f57883e 418{
d62a17ae 419 struct prefix_ipv4 dest_addr;
420 struct eigrp_prefix_entry *pe;
421 struct eigrp *eigrp = eigrp_lookup();
422
423 if (source == INTERFACE_DOWN_BY_VTY) {
424 THREAD_OFF(ei->t_hello);
425 eigrp_hello_send(ei, EIGRP_HELLO_GRACEFUL_SHUTDOWN, NULL);
426 }
427
428 dest_addr.family = AF_INET;
429 dest_addr.prefix = ei->connected->address->u.prefix4;
430 dest_addr.prefixlen = ei->connected->address->prefixlen;
431 apply_mask_ipv4(&dest_addr);
432 pe = eigrp_topology_table_lookup_ipv4(eigrp->topology_table,
433 &dest_addr);
434 if (pe)
435 eigrp_prefix_entry_delete(eigrp->topology_table, pe);
436
437 eigrp_if_down(ei);
438
439 list_delete(ei->nbrs);
440 eigrp_delete_from_if(ei->ifp, ei);
441 listnode_delete(ei->eigrp->eiflist, ei);
442
443 thread_cancel_event(master, ei);
444
445 memset(ei, 0, sizeof(*ei));
446 XFREE(MTYPE_EIGRP_IF, ei);
7f57883e
DS
447}
448
d62a17ae 449static void eigrp_delete_from_if(struct interface *ifp,
450 struct eigrp_interface *ei)
7f57883e 451{
d62a17ae 452 struct route_node *rn;
453 struct prefix p;
454
455 p = *ei->address;
456 p.prefixlen = IPV4_MAX_PREFIXLEN;
457
458 rn = route_node_lookup(IF_OIFS(ei->ifp), &p);
459 assert(rn);
460 assert(rn->info);
461 rn->info = NULL;
462 route_unlock_node(rn);
463 route_unlock_node(rn);
7f57883e
DS
464}
465
466/* Simulate down/up on the interface. This is needed, for example, when
f9e5c9ca 467 the MTU changes. */
d62a17ae 468void eigrp_if_reset(struct interface *ifp)
7f57883e 469{
d62a17ae 470 struct route_node *rn;
7f57883e 471
d62a17ae 472 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
473 struct eigrp_interface *ei;
7f57883e 474
d62a17ae 475 if ((ei = rn->info) == NULL)
476 continue;
7f57883e 477
d62a17ae 478 eigrp_if_down(ei);
479 eigrp_if_up(ei);
480 }
7f57883e
DS
481}
482
d62a17ae 483struct eigrp_interface *eigrp_if_lookup_by_local_addr(struct eigrp *eigrp,
484 struct interface *ifp,
485 struct in_addr address)
7f57883e 486{
d62a17ae 487 struct listnode *node;
488 struct eigrp_interface *ei;
7f57883e 489
d62a17ae 490 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
491 if (ifp && ei->ifp != ifp)
492 continue;
7f57883e 493
d62a17ae 494 if (IPV4_ADDR_SAME(&address, &ei->address->u.prefix4))
495 return ei;
496 }
7f57883e 497
d62a17ae 498 return NULL;
7f57883e
DS
499}
500
501/**
502 * @fn eigrp_if_lookup_by_name
503 *
504 * @param[in] eigrp EIGRP process
505 * @param[in] if_name Name of the interface
506 *
507 * @return struct eigrp_interface *
508 *
509 * @par
510 * Function is used for lookup interface by name.
511 */
d62a17ae 512struct eigrp_interface *eigrp_if_lookup_by_name(struct eigrp *eigrp,
513 const char *if_name)
7f57883e 514{
d62a17ae 515 struct eigrp_interface *ei;
516 struct listnode *node;
517
518 /* iterate over all eigrp interfaces */
519 for (ALL_LIST_ELEMENTS_RO(eigrp->eiflist, node, ei)) {
520 /* compare int name with eigrp interface's name */
521 if (strcmp(ei->ifp->name, if_name) == 0) {
522 return ei;
523 }
524 }
525
526 return NULL;
7f57883e
DS
527}
528
529/* determine receiving interface by ifp and source address */
d62a17ae 530struct eigrp_interface *eigrp_if_lookup_recv_if(struct eigrp *eigrp,
531 struct in_addr src,
532 struct interface *ifp)
7f57883e 533{
d62a17ae 534 struct route_node *rn;
535 struct prefix_ipv4 addr;
536 struct eigrp_interface *ei, *match;
7f57883e 537
d62a17ae 538 addr.family = AF_INET;
539 addr.prefix = src;
540 addr.prefixlen = IPV4_MAX_BITLEN;
7f57883e 541
d62a17ae 542 match = NULL;
7f57883e 543
d62a17ae 544 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next(rn)) {
545 ei = rn->info;
7f57883e 546
d62a17ae 547 if (!ei) /* oi can be NULL for PtP aliases */
548 continue;
7f57883e 549
d62a17ae 550 if (if_is_loopback(ei->ifp))
551 continue;
7f57883e 552
d62a17ae 553 if (prefix_match(CONNECTED_PREFIX(ei->connected),
554 (struct prefix *)&addr)) {
9d303b37
DL
555 if ((match == NULL) || (match->address->prefixlen
556 < ei->address->prefixlen))
d62a17ae 557 match = ei;
558 }
559 }
7f57883e 560
d62a17ae 561 return match;
7f57883e
DS
562}
563
d62a17ae 564u_int32_t eigrp_bandwidth_to_scaled(u_int32_t bandwidth)
7f57883e 565{
d62a17ae 566 uint64_t temp_bandwidth = (256ull * 10000000) / bandwidth;
7f57883e 567
d62a17ae 568 temp_bandwidth = temp_bandwidth < EIGRP_MAX_METRIC ? temp_bandwidth
569 : EIGRP_MAX_METRIC;
7f57883e 570
d62a17ae 571 return (u_int32_t)temp_bandwidth;
7f57883e
DS
572}
573
d62a17ae 574u_int32_t eigrp_scaled_to_bandwidth(u_int32_t scaled)
7f57883e 575{
d62a17ae 576 uint64_t temp_scaled = scaled * (256ull * 10000000);
7f57883e 577
d62a17ae 578 temp_scaled =
579 temp_scaled < EIGRP_MAX_METRIC ? temp_scaled : EIGRP_MAX_METRIC;
7f57883e 580
d62a17ae 581 return (u_int32_t)temp_scaled;
7f57883e
DS
582}
583
d62a17ae 584u_int32_t eigrp_delay_to_scaled(u_int32_t delay)
7f57883e 585{
d62a17ae 586 return delay * 256;
7f57883e
DS
587}
588
d62a17ae 589u_int32_t eigrp_scaled_to_delay(u_int32_t scaled)
7f57883e 590{
d62a17ae 591 return scaled / 256;
7f57883e 592}