]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_asbr.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / ospfd / ospf_asbr.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * OSPF AS Boundary Router functions.
4 * Copyright (C) 1999, 2000 Kunihiro Ishiguro, Toshiaki Takada
5 */
6
7 #ifndef _ZEBRA_OSPF_ASBR_H
8 #define _ZEBRA_OSPF_ASBR_H
9
10 struct route_map_set_values {
11 int32_t metric;
12 int32_t metric_type;
13 };
14
15 /* Redistributed external information. */
16 struct external_info {
17 struct ospf *ospf;
18
19 /* Type of source protocol. */
20 uint8_t type;
21
22 unsigned short instance;
23
24 /* Prefix. */
25 struct prefix_ipv4 p;
26
27 /* Interface index. */
28 ifindex_t ifindex;
29
30 /* Nexthop address. */
31 struct in_addr nexthop;
32
33 /* Additional Route tag. */
34 route_tag_t tag;
35
36 /* Actual tag received from zebra*/
37 route_tag_t orig_tag;
38
39 uint32_t metric;
40 uint32_t min_metric;
41 uint32_t max_metric;
42
43 struct route_map_set_values route_map_set;
44 #define ROUTEMAP_METRIC(E) (E)->route_map_set.metric
45 #define ROUTEMAP_METRIC_TYPE(E) (E)->route_map_set.metric_type
46
47 /* Back pointer to summary address */
48 struct ospf_external_aggr_rt *aggr_route;
49
50 /* To identify the routes to be originated
51 * after a summary address deletion.
52 */
53 bool to_be_processed;
54 };
55
56 #define OSPF_EXTL_AGGR_DEFAULT_DELAY 5
57
58 #define OSPF_EXTERNAL_RT_COUNT(aggr) \
59 (((struct ospf_external_aggr_rt *)aggr)->match_extnl_hash->count)
60
61 enum ospf_aggr_action_t {
62 OSPF_ROUTE_AGGR_NONE = 0,
63 OSPF_ROUTE_AGGR_ADD,
64 OSPF_ROUTE_AGGR_DEL,
65 OSPF_ROUTE_AGGR_MODIFY
66 };
67
68 #define OSPF_SUCCESS 1
69 #define OSPF_FAILURE 0
70 #define OSPF_INVALID -1
71
72 #define OSPF_EXTERNAL_AGGRT_NO_ADVERTISE 0x1
73 #define OSPF_EXTERNAL_AGGRT_ORIGINATED 0x2
74
75 /* Data structures for external route aggregator */
76 struct ospf_external_aggr_rt {
77 /* Prefix. */
78 struct prefix_ipv4 p;
79
80 /* Bit 1 : Dont advertise.
81 * Bit 2 : Originated as Type-5
82 */
83 uint8_t flags;
84
85 /* Tag for summary route */
86 route_tag_t tag;
87
88 /* Action to be done at the delay
89 * timer expairy.
90 */
91 enum ospf_aggr_action_t action;
92
93 /* Hash Table of external routes */
94 struct hash *match_extnl_hash;
95 };
96
97 #define OSPF_ASBR_CHECK_DELAY 30
98 #define OSPF_ASBR_NSSA_REDIST_UPDATE_DELAY 9
99
100 extern void ospf_external_route_remove(struct ospf *, struct prefix_ipv4 *);
101 extern struct external_info *ospf_external_info_new(struct ospf *, uint8_t,
102 unsigned short);
103 extern void ospf_reset_route_map_set_values(struct route_map_set_values *);
104 extern int ospf_route_map_set_compare(struct route_map_set_values *,
105 struct route_map_set_values *);
106 extern struct external_info *
107 ospf_external_info_add(struct ospf *, uint8_t, unsigned short,
108 struct prefix_ipv4, ifindex_t, struct in_addr,
109 route_tag_t, uint32_t metric);
110 extern void ospf_external_info_delete(struct ospf *, uint8_t, unsigned short,
111 struct prefix_ipv4);
112 extern struct external_info *ospf_external_info_lookup(struct ospf *, uint8_t,
113 unsigned short,
114 struct prefix_ipv4 *);
115 extern void ospf_asbr_status_update(struct ospf *, uint8_t);
116 extern void ospf_schedule_asbr_nssa_redist_update(struct ospf *ospf);
117
118 extern void ospf_redistribute_withdraw(struct ospf *, uint8_t, unsigned short);
119 extern void ospf_asbr_check(void);
120 extern void ospf_schedule_asbr_check(void);
121 extern void ospf_asbr_route_install_lsa(struct ospf_lsa *);
122 extern struct ospf_lsa *ospf_external_info_find_lsa(struct ospf *,
123 struct prefix_ipv4 *p);
124
125 /* External Route Aggregator */
126 extern void ospf_asbr_external_aggregator_init(struct ospf *instance);
127 extern void ospf_external_aggregator_free(struct ospf_external_aggr_rt *aggr);
128 extern bool is_valid_summary_addr(struct prefix_ipv4 *p);
129 extern struct ospf_external_aggr_rt *
130 ospf_external_aggr_match(struct ospf *ospf, struct prefix_ipv4 *p);
131 extern void ospf_unlink_ei_from_aggr(struct ospf *ospf,
132 struct ospf_external_aggr_rt *aggr,
133 struct external_info *ei);
134 extern struct ospf_lsa *
135 ospf_originate_summary_lsa(struct ospf *ospf,
136 struct ospf_external_aggr_rt *aggr,
137 struct external_info *ei);
138 extern int ospf_external_aggregator_timer_set(struct ospf *ospf,
139 uint16_t interval);
140 extern void ospf_external_aggrigator_free(struct ospf_external_aggr_rt *aggr);
141
142 extern struct ospf_external_aggr_rt *
143 ospf_extrenal_aggregator_lookup(struct ospf *ospf, struct prefix_ipv4 *p);
144
145 void ospf_unset_all_aggr_flag(struct ospf *ospf);
146
147 extern int ospf_asbr_external_aggregator_set(struct ospf *ospf,
148 struct prefix_ipv4 *p,
149 route_tag_t tag);
150 extern int ospf_asbr_external_aggregator_unset(struct ospf *ospf,
151 struct prefix_ipv4 *p,
152 route_tag_t tag);
153 extern int ospf_asbr_external_rt_no_advertise(struct ospf *ospf,
154 struct prefix_ipv4 *p);
155 extern int ospf_asbr_external_rt_advertise(struct ospf *ospf,
156 struct prefix_ipv4 *p);
157 #endif /* _ZEBRA_OSPF_ASBR_H */