]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_route.h
Merge pull request #531 from qlyoung/fix-stack-ref
[mirror_frr.git] / ospfd / ospf_route.h
CommitLineData
718e3744 1/*
2 * OSPF routing table.
3 * Copyright (C) 1999, 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
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
10 * later version.
11 *
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.
16 *
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
20 * 02111-1307, USA.
21 */
22
23#ifndef _ZEBRA_OSPF_ROUTE_H
24#define _ZEBRA_OSPF_ROUTE_H
25
26#define OSPF_DESTINATION_ROUTER 1
27#define OSPF_DESTINATION_NETWORK 2
28#define OSPF_DESTINATION_DISCARD 3
29
30#define OSPF_PATH_MIN 0
31#define OSPF_PATH_INTRA_AREA 1
32#define OSPF_PATH_INTER_AREA 2
33#define OSPF_PATH_TYPE1_EXTERNAL 3
34#define OSPF_PATH_TYPE2_EXTERNAL 4
35#define OSPF_PATH_MAX 5
36
37/* OSPF Path. */
38struct ospf_path
39{
40 struct in_addr nexthop;
41 struct in_addr adv_router;
b892f1dd 42 ifindex_t ifindex;
525c1839 43 unsigned char unnumbered;
718e3744 44};
45
46/* Below is the structure linked to every
47 route node. Note that for Network routing
48 entries a single ospf_route is kept, while
49 for ABRs and ASBRs (Router routing entries),
50 we link an instance of ospf_router_route
51 where a list of paths is maintained, so
52
53 nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
54 but
55 nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
56*/
57
58struct route_standard
59{
60 /* Link Sate Origin. */
61 struct lsa_header *origin;
62
63 /* Associated Area. */
64 struct in_addr area_id; /* The area the route belongs to */
65
718e3744 66 /* Area Type */
67 int external_routing;
718e3744 68
69 /* Optional Capability. */
70 u_char options; /* Get from LSA header. */
71
72 /* */
73 u_char flags; /* From router-LSA */
74};
75
76struct route_external
77{
78 /* Link State Origin. */
79 struct ospf_lsa *origin;
80
81 /* Link State Cost Type2. */
82 u_int32_t type2_cost;
83
84 /* Tag value. */
85 u_int32_t tag;
86
87 /* ASBR route. */
88 struct ospf_route *asbr;
89};
90
91struct ospf_route
92{
718e3744 93 /* Destination Type. */
94 u_char type;
95
96 /* Destination ID. */ /* i.e. Link State ID. */
97 struct in_addr id;
98
99 /* Address Mask. */
100 struct in_addr mask; /* Only valid for networks. */
101
102 /* Path Type. */
103 u_char path_type;
104
105 /* List of Paths. */
52dc7ee6 106 struct list *paths;
718e3744 107
108 /* Link State Cost. */
109 u_int32_t cost; /* i.e. metric. */
110
111 /* Route specific info. */
112 union
113 {
114 struct route_standard std;
115 struct route_external ext;
116 } u;
117};
118
4dadc291 119extern struct ospf_path *ospf_path_new (void);
120extern void ospf_path_free (struct ospf_path *);
121extern struct ospf_path *ospf_path_lookup (struct list *, struct ospf_path *);
122extern struct ospf_route *ospf_route_new (void);
123extern void ospf_route_free (struct ospf_route *);
124extern void ospf_route_delete (struct route_table *);
125extern void ospf_route_table_free (struct route_table *);
126
127extern void ospf_route_install (struct ospf *, struct route_table *);
128extern void ospf_route_table_dump (struct route_table *);
129
130extern void ospf_intra_add_router (struct route_table *, struct vertex *,
131 struct ospf_area *);
132
133extern void ospf_intra_add_transit (struct route_table *, struct vertex *,
134 struct ospf_area *);
135
136extern void ospf_intra_add_stub (struct route_table *,
137 struct router_lsa_link *, struct vertex *,
b3bc68e5 138 struct ospf_area *,
57c639f0 139 int parent_is_root, int);
4dadc291 140
141extern int ospf_route_cmp (struct ospf *, struct ospf_route *,
718e3744 142 struct ospf_route *);
4dadc291 143extern void ospf_route_copy_nexthops (struct ospf_route *, struct list *);
144extern void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
145 struct vertex *);
146
147extern void ospf_route_subst (struct route_node *, struct ospf_route *,
148 struct ospf_route *);
149extern void ospf_route_add (struct route_table *, struct prefix_ipv4 *,
150 struct ospf_route *, struct ospf_route *);
151
152extern void ospf_route_subst_nexthops (struct ospf_route *, struct list *);
153extern void ospf_prune_unreachable_networks (struct route_table *);
154extern void ospf_prune_unreachable_routers (struct route_table *);
155extern int ospf_add_discard_route (struct route_table *, struct ospf_area *,
156 struct prefix_ipv4 *);
8fc9e007 157extern void ospf_delete_discard_route (struct route_table *, struct prefix_ipv4 *);
4dadc291 158extern int ospf_route_match_same (struct route_table *, struct prefix_ipv4 *,
159 struct ospf_route *);
718e3744 160
161#endif /* _ZEBRA_OSPF_ROUTE_H */