]>
git.proxmox.com Git - mirror_frr.git/blob - lib/nexthop_group.c
2 * Nexthop Group structure definition.
3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include <nexthop_group.h>
25 /* Add nexthop to the end of a nexthop list. */
26 void nexthop_add(struct nexthop
**target
, struct nexthop
*nexthop
)
30 for (last
= *target
; last
&& last
->next
; last
= last
->next
)
39 void copy_nexthops(struct nexthop
**tnh
, struct nexthop
*nh
,
40 struct nexthop
*rparent
)
42 struct nexthop
*nexthop
;
45 for (nh1
= nh
; nh1
; nh1
= nh1
->next
) {
46 nexthop
= nexthop_new();
47 nexthop
->vrf_id
= nh1
->vrf_id
;
48 nexthop
->ifindex
= nh1
->ifindex
;
49 nexthop
->type
= nh1
->type
;
50 nexthop
->flags
= nh1
->flags
;
51 memcpy(&nexthop
->gate
, &nh1
->gate
, sizeof(nh1
->gate
));
52 memcpy(&nexthop
->src
, &nh1
->src
, sizeof(nh1
->src
));
53 memcpy(&nexthop
->rmap_src
, &nh1
->rmap_src
,
54 sizeof(nh1
->rmap_src
));
55 nexthop
->rparent
= rparent
;
57 nexthop_add_labels(nexthop
, nh1
->nh_label_type
,
58 nh1
->nh_label
->num_labels
,
59 &nh1
->nh_label
->label
[0]);
60 nexthop_add(tnh
, nexthop
);
62 if (CHECK_FLAG(nh1
->flags
, NEXTHOP_FLAG_RECURSIVE
))
63 copy_nexthops(&nexthop
->resolved
, nh1
->resolved
,