2 * RIPng routes function.
3 * Copyright (C) 1998 Kunihiro Ishiguro
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
31 #include "ripngd/ripngd.h"
32 #include "ripngd/ripng_route.h"
34 struct ripng_aggregate
*
35 ripng_aggregate_new ()
37 struct ripng_aggregate
*new;
39 new = XCALLOC (MTYPE_RIPNG_AGGREGATE
, sizeof (struct ripng_aggregate
));
44 ripng_aggregate_free (struct ripng_aggregate
*aggregate
)
46 XFREE (MTYPE_RIPNG_AGGREGATE
, aggregate
);
49 /* Aggregate count increment check. */
51 ripng_aggregate_increment (struct route_node
*child
, struct ripng_info
*rinfo
)
53 struct route_node
*np
;
54 struct ripng_aggregate
*aggregate
;
56 for (np
= child
; np
; np
= np
->parent
)
57 if ((aggregate
= np
->aggregate
) != NULL
)
64 /* Aggregate count decrement check. */
66 ripng_aggregate_decrement (struct route_node
*child
, struct ripng_info
*rinfo
)
68 struct route_node
*np
;
69 struct ripng_aggregate
*aggregate
;
71 for (np
= child
; np
; np
= np
->parent
)
72 if ((aggregate
= np
->aggregate
) != NULL
)
79 /* RIPng routes treatment. */
81 ripng_aggregate_add (struct prefix
*p
)
83 struct route_node
*top
;
84 struct route_node
*rp
;
85 struct ripng_info
*rinfo
;
86 struct ripng_aggregate
*aggregate
;
87 struct ripng_aggregate
*sub
;
89 /* Get top node for aggregation. */
90 top
= route_node_get (ripng
->table
, p
);
92 /* Allocate new aggregate. */
93 aggregate
= ripng_aggregate_new ();
94 aggregate
->metric
= 1;
96 top
->aggregate
= aggregate
;
98 /* Suppress routes match to the aggregate. */
99 for (rp
= route_lock_node (top
); rp
; rp
= route_next_until (rp
, top
))
101 /* Suppress normal route. */
102 if ((rinfo
= rp
->info
) != NULL
)
107 /* Suppress aggregate route. This may not need. */
108 if (rp
!= top
&& (sub
= rp
->aggregate
) != NULL
)
118 /* Delete RIPng static route. */
120 ripng_aggregate_delete (struct prefix
*p
)
122 struct route_node
*top
;
123 struct route_node
*rp
;
124 struct ripng_info
*rinfo
;
125 struct ripng_aggregate
*aggregate
;
126 struct ripng_aggregate
*sub
;
128 /* Get top node for aggregation. */
129 top
= route_node_get (ripng
->table
, p
);
131 /* Allocate new aggregate. */
132 aggregate
= top
->aggregate
;
134 /* Suppress routes match to the aggregate. */
135 for (rp
= route_lock_node (top
); rp
; rp
= route_next_until (rp
, top
))
137 /* Suppress normal route. */
138 if ((rinfo
= rp
->info
) != NULL
)
144 if (rp
!= top
&& (sub
= rp
->aggregate
) != NULL
)
151 top
->aggregate
= NULL
;
152 ripng_aggregate_free (aggregate
);
154 route_unlock_node (top
);
155 route_unlock_node (top
);