blob: 5742b462c33710eb3dd3544361b08bb3f1231a82 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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;
Joakim Tjernlunda8ba8472009-07-27 12:42:34 +020042 unsigned int ifindex;
paul718e3742002-12-13 20:15:29 +000043};
44
45/* Below is the structure linked to every
46 route node. Note that for Network routing
47 entries a single ospf_route is kept, while
48 for ABRs and ASBRs (Router routing entries),
49 we link an instance of ospf_router_route
50 where a list of paths is maintained, so
51
52 nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
53 but
54 nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
55*/
56
57struct route_standard
58{
59 /* Link Sate Origin. */
60 struct lsa_header *origin;
61
62 /* Associated Area. */
63 struct in_addr area_id; /* The area the route belongs to */
64
paul718e3742002-12-13 20:15:29 +000065 /* Area Type */
66 int external_routing;
paul718e3742002-12-13 20:15:29 +000067
68 /* Optional Capability. */
69 u_char options; /* Get from LSA header. */
70
71 /* */
72 u_char flags; /* From router-LSA */
73};
74
75struct route_external
76{
77 /* Link State Origin. */
78 struct ospf_lsa *origin;
79
80 /* Link State Cost Type2. */
81 u_int32_t type2_cost;
82
83 /* Tag value. */
84 u_int32_t tag;
85
86 /* ASBR route. */
87 struct ospf_route *asbr;
88};
89
90struct ospf_route
91{
92 /* Create time. */
93 time_t ctime;
94
95 /* Modified time. */
96 time_t mtime;
97
98 /* Destination Type. */
99 u_char type;
100
101 /* Destination ID. */ /* i.e. Link State ID. */
102 struct in_addr id;
103
104 /* Address Mask. */
105 struct in_addr mask; /* Only valid for networks. */
106
107 /* Path Type. */
108 u_char path_type;
109
110 /* List of Paths. */
hasso52dc7ee2004-09-23 19:18:23 +0000111 struct list *paths;
paul718e3742002-12-13 20:15:29 +0000112
113 /* Link State Cost. */
114 u_int32_t cost; /* i.e. metric. */
115
116 /* Route specific info. */
117 union
118 {
119 struct route_standard std;
120 struct route_external ext;
121 } u;
122};
123
paul4dadc292005-05-06 21:37:42 +0000124extern struct ospf_path *ospf_path_new (void);
125extern void ospf_path_free (struct ospf_path *);
126extern struct ospf_path *ospf_path_lookup (struct list *, struct ospf_path *);
127extern struct ospf_route *ospf_route_new (void);
128extern void ospf_route_free (struct ospf_route *);
129extern void ospf_route_delete (struct route_table *);
130extern void ospf_route_table_free (struct route_table *);
paul718e3742002-12-13 20:15:29 +0000131
paul4dadc292005-05-06 21:37:42 +0000132extern void ospf_route_install (struct ospf *, struct route_table *);
133extern void ospf_route_table_dump (struct route_table *);
paul718e3742002-12-13 20:15:29 +0000134
paul4dadc292005-05-06 21:37:42 +0000135extern void ospf_intra_add_router (struct route_table *, struct vertex *,
136 struct ospf_area *);
paul718e3742002-12-13 20:15:29 +0000137
paul4dadc292005-05-06 21:37:42 +0000138extern void ospf_intra_add_transit (struct route_table *, struct vertex *,
139 struct ospf_area *);
paul718e3742002-12-13 20:15:29 +0000140
paul4dadc292005-05-06 21:37:42 +0000141extern void ospf_intra_add_stub (struct route_table *,
142 struct router_lsa_link *, struct vertex *,
Paul Jakmab3bc68e2008-09-04 13:52:07 +0100143 struct ospf_area *,
Joakim Tjernlund57c639f2012-07-07 17:06:12 +0200144 int parent_is_root, int);
paul718e3742002-12-13 20:15:29 +0000145
paul4dadc292005-05-06 21:37:42 +0000146extern int ospf_route_cmp (struct ospf *, struct ospf_route *,
paul718e3742002-12-13 20:15:29 +0000147 struct ospf_route *);
paul4dadc292005-05-06 21:37:42 +0000148extern void ospf_route_copy_nexthops (struct ospf_route *, struct list *);
149extern void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
150 struct vertex *);
151
152extern void ospf_route_subst (struct route_node *, struct ospf_route *,
153 struct ospf_route *);
154extern void ospf_route_add (struct route_table *, struct prefix_ipv4 *,
155 struct ospf_route *, struct ospf_route *);
156
157extern void ospf_route_subst_nexthops (struct ospf_route *, struct list *);
158extern void ospf_prune_unreachable_networks (struct route_table *);
159extern void ospf_prune_unreachable_routers (struct route_table *);
160extern int ospf_add_discard_route (struct route_table *, struct ospf_area *,
161 struct prefix_ipv4 *);
162extern void ospf_delete_discard_route (struct prefix_ipv4 *);
163extern int ospf_route_match_same (struct route_table *, struct prefix_ipv4 *,
164 struct ospf_route *);
paul718e3742002-12-13 20:15:29 +0000165
166#endif /* _ZEBRA_OSPF_ROUTE_H */