]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_asbr.h
*: auto-convert to SPDX License IDs
[mirror_frr.git] / ospf6d / ospf6_asbr.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (C) 2001 Yasuhiro Ohara
4 */
5
6 #ifndef OSPF6_ASBR_H
7 #define OSPF6_ASBR_H
8
9 /* for struct ospf6_prefix */
10 #include "ospf6_proto.h"
11 /* for struct ospf6_lsa */
12 #include "ospf6_lsa.h"
13 /* for struct ospf6_route */
14 #include "ospf6_route.h"
15
16 /* Debug option */
17 extern unsigned char conf_debug_ospf6_asbr;
18 #define OSPF6_DEBUG_ASBR_ON() (conf_debug_ospf6_asbr = 1)
19 #define OSPF6_DEBUG_ASBR_OFF() (conf_debug_ospf6_asbr = 0)
20 #define IS_OSPF6_DEBUG_ASBR (conf_debug_ospf6_asbr)
21
22 struct ospf6_external_info {
23 /* External route type */
24 int type;
25
26 /* Originating Link State ID */
27 uint32_t id;
28
29 struct in6_addr forwarding;
30
31 route_tag_t tag;
32
33 ifindex_t ifindex;
34
35 };
36
37 /* OSPF6 ASBR Summarisation */
38 typedef enum {
39 OSPF6_ROUTE_AGGR_NONE = 0,
40 OSPF6_ROUTE_AGGR_ADD,
41 OSPF6_ROUTE_AGGR_DEL,
42 OSPF6_ROUTE_AGGR_MODIFY
43 } ospf6_aggr_action_t;
44
45 #define OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE 0x1
46 #define OSPF6_EXTERNAL_AGGRT_ORIGINATED 0x2
47
48 #define OSPF6_EXTERNAL_RT_COUNT(aggr) \
49 (((struct ospf6_external_aggr_rt *)aggr)->match_extnl_hash->count)
50
51 struct ospf6_external_aggr_rt {
52 /* range address and masklen */
53 struct prefix p;
54
55 /* use bits for OSPF6_EXTERNAL_AGGRT_NO_ADVERTISE and
56 * OSPF6_EXTERNAL_AGGRT_ORIGINATED
57 */
58 uint16_t aggrflags;
59
60 /* To store external metric-type */
61 uint8_t mtype;
62
63 /* Route tag for summary address */
64 route_tag_t tag;
65
66 /* To store aggregated metric config */
67 int metric;
68
69 /* To Store the LS ID when LSA is originated */
70 uint32_t id;
71
72 /* Action to be done after delay timer expiry */
73 int action;
74
75 /* OSPFv3 route generated by summary address. */
76 struct ospf6_route *route;
77
78 /* Hash table of matching external routes */
79 struct hash *match_extnl_hash;
80 };
81
82 /* AS-External-LSA */
83 #define OSPF6_AS_EXTERNAL_LSA_MIN_SIZE 4U /* w/o IPv6 prefix */
84 struct ospf6_as_external_lsa {
85 uint32_t bits_metric;
86
87 struct ospf6_prefix prefix;
88 /* followed by none or one forwarding address */
89 /* followed by none or one external route tag */
90 /* followed by none or one referenced LS-ID */
91 };
92
93 #define OSPF6_ASBR_BIT_T ntohl (0x01000000)
94 #define OSPF6_ASBR_BIT_F ntohl (0x02000000)
95 #define OSPF6_ASBR_BIT_E ntohl (0x04000000)
96
97 #define OSPF6_ASBR_METRIC(E) (ntohl ((E)->bits_metric & htonl (0x00ffffff)))
98 #define OSPF6_ASBR_METRIC_SET(E, C) \
99 { \
100 (E)->bits_metric &= htonl(0xff000000); \
101 (E)->bits_metric |= htonl(0x00ffffff) & htonl(C); \
102 }
103
104 extern void ospf6_asbr_lsa_add(struct ospf6_lsa *lsa);
105
106 extern void ospf6_asbr_lsa_remove(struct ospf6_lsa *lsa,
107 struct ospf6_route *asbr_entry);
108 extern void ospf6_asbr_lsentry_add(struct ospf6_route *asbr_entry,
109 struct ospf6 *ospf6);
110 extern void ospf6_asbr_lsentry_remove(struct ospf6_route *asbr_entry,
111 struct ospf6 *ospf6);
112
113 extern int ospf6_asbr_is_asbr(struct ospf6 *o);
114 extern void ospf6_asbr_redistribute_add(int type, ifindex_t ifindex,
115 struct prefix *prefix,
116 unsigned int nexthop_num,
117 struct in6_addr *nexthop,
118 route_tag_t tag, struct ospf6 *ospf6);
119 extern void ospf6_asbr_redistribute_remove(int type, ifindex_t ifindex,
120 struct prefix *prefix,
121 struct ospf6 *ospf6);
122
123 extern int ospf6_redistribute_config_write(struct vty *vty,
124 struct ospf6 *ospf6);
125
126 extern void ospf6_asbr_init(void);
127 extern void ospf6_asbr_redistribute_disable(struct ospf6 *ospf6);
128 extern void ospf6_asbr_redistribute_reset(struct ospf6 *ospf6);
129 extern void ospf6_asbr_terminate(void);
130 extern void ospf6_asbr_send_externals_to_area(struct ospf6_area *);
131 extern void ospf6_asbr_remove_externals_from_area(struct ospf6_area *oa);
132
133 extern int config_write_ospf6_debug_asbr(struct vty *vty);
134 extern int ospf6_distribute_config_write(struct vty *vty, struct ospf6 *ospf6);
135 extern void install_element_ospf6_debug_asbr(void);
136 extern void ospf6_asbr_update_route_ecmp_path(struct ospf6_route *old,
137 struct ospf6_route *route,
138 struct ospf6 *ospf6);
139 extern void ospf6_asbr_distribute_list_update(struct ospf6 *ospf6,
140 struct ospf6_redist *red);
141 struct ospf6_redist *ospf6_redist_lookup(struct ospf6 *ospf6, int type,
142 unsigned short instance);
143 extern void ospf6_asbr_routemap_update(const char *mapname);
144 extern struct ospf6_lsa *
145 ospf6_as_external_lsa_originate(struct ospf6_route *route,
146 struct ospf6 *ospf6);
147 extern void ospf6_asbr_status_update(struct ospf6 *ospf6, int status);
148
149 int ospf6_asbr_external_rt_advertise(struct ospf6 *ospf6,
150 struct prefix *p);
151 int ospf6_external_aggr_delay_timer_set(struct ospf6 *ospf6, uint16_t interval);
152 int ospf6_asbr_external_rt_no_advertise(struct ospf6 *ospf6,
153 struct prefix *p);
154
155 struct ospf6_external_aggr_rt *
156 ospf6_external_aggr_config_lookup(struct ospf6 *ospf6, struct prefix *p);
157
158 int ospf6_external_aggr_config_set(struct ospf6 *ospf6, struct prefix *p,
159 route_tag_t tag, int metric, int mtype);
160
161 int ospf6_external_aggr_config_unset(struct ospf6 *ospf6,
162 struct prefix *p);
163 void ospf6_handle_external_lsa_origination(struct ospf6 *ospf6,
164 struct ospf6_route *rt,
165 struct prefix *p);
166 void ospf6_external_aggregator_free(struct ospf6_external_aggr_rt *aggr);
167 void ospf6_unset_all_aggr_flag(struct ospf6 *ospf6);
168 void ospf6_fill_aggr_route_details(struct ospf6 *ospf6,
169 struct ospf6_external_aggr_rt *aggr);
170 void ospf6_asbr_summary_config_delete(struct ospf6 *ospf6,
171 struct route_node *rn);
172 #endif /* OSPF6_ASBR_H */