blob: e909da23db340863bb5f8d5bc4723d9449228240 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#ifndef OSPF6_INTRA_H
23#define OSPF6_INTRA_H
24
Paul Jakmacb4b8842006-05-15 10:39:30 +000025/* Debug option */
26extern unsigned char conf_debug_ospf6_brouter;
27extern u_int32_t conf_debug_ospf6_brouter_specific_router_id;
28extern u_int32_t conf_debug_ospf6_brouter_specific_area_id;
29#define OSPF6_DEBUG_BROUTER_SUMMARY 0x01
30#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER 0x02
31#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA 0x04
32#define OSPF6_DEBUG_BROUTER_ON() \
33 (conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SUMMARY)
34#define OSPF6_DEBUG_BROUTER_OFF() \
35 (conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SUMMARY)
36#define IS_OSPF6_DEBUG_BROUTER \
37 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SUMMARY)
38
39#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ON(router_id) \
40 do { \
41 conf_debug_ospf6_brouter_specific_router_id = (router_id); \
42 conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
43 } while (0)
44#define OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_OFF() \
45 do { \
46 conf_debug_ospf6_brouter_specific_router_id = 0; \
47 conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER; \
48 } while (0)
49#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER \
50 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER)
51#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER_ID(router_id) \
52 (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_ROUTER && \
53 conf_debug_ospf6_brouter_specific_router_id == (router_id))
54
55#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ON(area_id) \
56 do { \
57 conf_debug_ospf6_brouter_specific_area_id = (area_id); \
58 conf_debug_ospf6_brouter |= OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
59 } while (0)
60#define OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_OFF() \
61 do { \
62 conf_debug_ospf6_brouter_specific_area_id = 0; \
63 conf_debug_ospf6_brouter &= ~OSPF6_DEBUG_BROUTER_SPECIFIC_AREA; \
64 } while (0)
65#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA \
66 (conf_debug_ospf6_brouter & OSPF6_DEBUG_BROUTER_SPECIFIC_AREA)
67#define IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA_ID(area_id) \
68 (IS_OSPF6_DEBUG_BROUTER_SPECIFIC_AREA && \
69 conf_debug_ospf6_brouter_specific_area_id == (area_id))
70
hasso508e53e2004-05-18 18:57:06 +000071/* Router-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +040072#define OSPF6_ROUTER_LSA_MIN_SIZE 4U
hasso508e53e2004-05-18 18:57:06 +000073struct ospf6_router_lsa
74{
75 u_char bits;
76 u_char options[3];
77 /* followed by ospf6_router_lsdesc(s) */
78};
79
80/* Link State Description in Router-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +040081#define OSPF6_ROUTER_LSDESC_FIX_SIZE 16U
hasso508e53e2004-05-18 18:57:06 +000082struct ospf6_router_lsdesc
83{
84 u_char type;
85 u_char reserved;
86 u_int16_t metric; /* output cost */
87 u_int32_t interface_id;
88 u_int32_t neighbor_interface_id;
89 u_int32_t neighbor_router_id;
90};
91
92#define OSPF6_ROUTER_LSDESC_POINTTOPOINT 1
93#define OSPF6_ROUTER_LSDESC_TRANSIT_NETWORK 2
94#define OSPF6_ROUTER_LSDESC_STUB_NETWORK 3
95#define OSPF6_ROUTER_LSDESC_VIRTUAL_LINK 4
96
Dinesh Duttf41b4a02013-08-24 08:00:37 +000097enum stub_router_mode
98 {
99 OSPF6_NOT_STUB_ROUTER,
100 OSPF6_IS_STUB_ROUTER,
101 OSPF6_IS_STUB_ROUTER_V6,
102 };
103
hasso508e53e2004-05-18 18:57:06 +0000104#define ROUTER_LSDESC_IS_TYPE(t,x) \
105 ((((struct ospf6_router_lsdesc *)(x))->type == \
106 OSPF6_ROUTER_LSDESC_ ## t) ? 1 : 0)
107#define ROUTER_LSDESC_GET_METRIC(x) \
108 (ntohs (((struct ospf6_router_lsdesc *)(x))->metric))
109#define ROUTER_LSDESC_GET_IFID(x) \
110 (ntohl (((struct ospf6_router_lsdesc *)(x))->interface_id))
111#define ROUTER_LSDESC_GET_NBR_IFID(x) \
112 (ntohl (((struct ospf6_router_lsdesc *)(x))->neighbor_interface_id))
113#define ROUTER_LSDESC_GET_NBR_ROUTERID(x) \
114 (((struct ospf6_router_lsdesc *)(x))->neighbor_router_id)
115
116/* Network-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +0400117#define OSPF6_NETWORK_LSA_MIN_SIZE 4U
hasso508e53e2004-05-18 18:57:06 +0000118struct ospf6_network_lsa
119{
120 u_char reserved;
121 u_char options[3];
122 /* followed by ospf6_netowrk_lsd(s) */
123};
124
125/* Link State Description in Router-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +0400126#define OSPF6_NETWORK_LSDESC_FIX_SIZE 4U
hasso508e53e2004-05-18 18:57:06 +0000127struct ospf6_network_lsdesc
128{
129 u_int32_t router_id;
130};
131#define NETWORK_LSDESC_GET_NBR_ROUTERID(x) \
132 (((struct ospf6_network_lsdesc *)(x))->router_id)
133
134/* Link-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +0400135#define OSPF6_LINK_LSA_MIN_SIZE 24U /* w/o 1st IPv6 prefix */
hasso508e53e2004-05-18 18:57:06 +0000136struct ospf6_link_lsa
137{
138 u_char priority;
139 u_char options[3];
140 struct in6_addr linklocal_addr;
141 u_int32_t prefix_num;
142 /* followed by ospf6 prefix(es) */
143};
144
145/* Intra-Area-Prefix-LSA */
Denis Ovsienkoabc7ef42011-09-26 13:18:51 +0400146#define OSPF6_INTRA_PREFIX_LSA_MIN_SIZE 12U /* w/o 1st IPv6 prefix */
hasso508e53e2004-05-18 18:57:06 +0000147struct ospf6_intra_prefix_lsa
148{
149 u_int16_t prefix_num;
150 u_int16_t ref_type;
151 u_int32_t ref_id;
152 u_int32_t ref_adv_router;
153 /* followed by ospf6 prefix(es) */
154};
155
156
157#define OSPF6_ROUTER_LSA_SCHEDULE(oa) \
158 do { \
Christian Franked9628722013-03-08 21:47:35 +0100159 if (! (oa)->thread_router_lsa \
160 && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
hasso508e53e2004-05-18 18:57:06 +0000161 (oa)->thread_router_lsa = \
162 thread_add_event (master, ospf6_router_lsa_originate, oa, 0); \
163 } while (0)
164#define OSPF6_NETWORK_LSA_SCHEDULE(oi) \
165 do { \
Christian Franked9628722013-03-08 21:47:35 +0100166 if (! (oi)->thread_network_lsa \
167 && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
hasso508e53e2004-05-18 18:57:06 +0000168 (oi)->thread_network_lsa = \
169 thread_add_event (master, ospf6_network_lsa_originate, oi, 0); \
170 } while (0)
171#define OSPF6_LINK_LSA_SCHEDULE(oi) \
172 do { \
Christian Franked9628722013-03-08 21:47:35 +0100173 if (! (oi)->thread_link_lsa \
174 && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
hasso508e53e2004-05-18 18:57:06 +0000175 (oi)->thread_link_lsa = \
176 thread_add_event (master, ospf6_link_lsa_originate, oi, 0); \
177 } while (0)
178#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_STUB(oa) \
179 do { \
Christian Franked9628722013-03-08 21:47:35 +0100180 if (! (oa)->thread_intra_prefix_lsa \
181 && CHECK_FLAG((oa)->flag, OSPF6_AREA_ENABLE)) \
hasso508e53e2004-05-18 18:57:06 +0000182 (oa)->thread_intra_prefix_lsa = \
183 thread_add_event (master, ospf6_intra_prefix_lsa_originate_stub, \
184 oa, 0); \
185 } while (0)
186#define OSPF6_INTRA_PREFIX_LSA_SCHEDULE_TRANSIT(oi) \
187 do { \
Christian Franked9628722013-03-08 21:47:35 +0100188 if (! (oi)->thread_intra_prefix_lsa \
189 && ! CHECK_FLAG((oi)->flag, OSPF6_INTERFACE_DISABLE)) \
hasso508e53e2004-05-18 18:57:06 +0000190 (oi)->thread_intra_prefix_lsa = \
191 thread_add_event (master, ospf6_intra_prefix_lsa_originate_transit, \
192 oi, 0); \
193 } while (0)
194
hasso6452df02004-08-15 05:52:07 +0000195#define OSPF6_NETWORK_LSA_EXECUTE(oi) \
196 do { \
197 THREAD_OFF ((oi)->thread_network_lsa); \
198 thread_execute (master, ospf6_network_lsa_originate, oi, 0); \
199 } while (0)
200#define OSPF6_INTRA_PREFIX_LSA_EXECUTE_TRANSIT(oi) \
201 do { \
202 THREAD_OFF ((oi)->thread_intra_prefix_lsa); \
203 thread_execute (master, ospf6_intra_prefix_lsa_originate_transit, oi, 0); \
204 } while (0)
205
206
hasso508e53e2004-05-18 18:57:06 +0000207/* Function Prototypes */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100208extern char *ospf6_router_lsdesc_lookup (u_char type, u_int32_t interface_id,
209 u_int32_t neighbor_interface_id,
210 u_int32_t neighbor_router_id,
211 struct ospf6_lsa *lsa);
212extern char *ospf6_network_lsdesc_lookup (u_int32_t router_id,
213 struct ospf6_lsa *lsa);
hasso508e53e2004-05-18 18:57:06 +0000214
Dinesh Duttf41b4a02013-08-24 08:00:37 +0000215extern int ospf6_router_is_stub_router (struct ospf6_lsa *lsa);
Paul Jakma6ac29a52008-08-15 13:45:30 +0100216extern int ospf6_router_lsa_originate (struct thread *);
217extern int ospf6_network_lsa_originate (struct thread *);
218extern int ospf6_link_lsa_originate (struct thread *);
219extern int ospf6_intra_prefix_lsa_originate_transit (struct thread *);
220extern int ospf6_intra_prefix_lsa_originate_stub (struct thread *);
221extern void ospf6_intra_prefix_lsa_add (struct ospf6_lsa *lsa);
222extern void ospf6_intra_prefix_lsa_remove (struct ospf6_lsa *lsa);
hasso508e53e2004-05-18 18:57:06 +0000223
Paul Jakma6ac29a52008-08-15 13:45:30 +0100224extern void ospf6_intra_route_calculation (struct ospf6_area *oa);
225extern void ospf6_intra_brouter_calculation (struct ospf6_area *oa);
paul718e3742002-12-13 20:15:29 +0000226
Paul Jakma6ac29a52008-08-15 13:45:30 +0100227extern void ospf6_intra_init (void);
paul718e3742002-12-13 20:15:29 +0000228
Paul Jakma6ac29a52008-08-15 13:45:30 +0100229extern int config_write_ospf6_debug_brouter (struct vty *vty);
230extern void install_element_ospf6_debug_brouter (void);
Paul Jakmacb4b8842006-05-15 10:39:30 +0000231
hasso508e53e2004-05-18 18:57:06 +0000232#endif /* OSPF6_LSA_H */
paul718e3742002-12-13 20:15:29 +0000233