3 * Copyright (C) 1998, 99, 2000 Kunihiro Ishiguro, Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
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
23 #ifndef _ZEBRA_OSPFD_H
24 #define _ZEBRA_OSPFD_H
29 #define OSPF_VERSION 2
31 /* Default protocol, port number. */
32 #ifndef IPPROTO_OSPFIGP
33 #define IPPROTO_OSPFIGP 89
34 #endif /* IPPROTO_OSPFIGP */
37 #ifndef IPTOS_PREC_INTERNETCONTROL
38 #define IPTOS_PREC_INTERNETCONTROL 0xC0
39 #endif /* IPTOS_PREC_INTERNETCONTROL */
41 /* VTY port number. */
42 #define OSPF_VTY_PORT 2604
44 /* IP TTL for OSPF protocol. */
46 #define OSPF_VL_IP_TTL 100
48 /* Default configuration file name for ospfd. */
49 #define OSPF_DEFAULT_CONFIG "ospfd.conf"
51 /* Architectual Constants */
53 #define OSPF_LS_REFRESH_TIME 60
55 #define OSPF_LS_REFRESH_TIME 1800
57 #define OSPF_MIN_LS_INTERVAL 5
58 #define OSPF_MIN_LS_ARRIVAL 1
59 #define OSPF_LSA_MAXAGE 3600
60 #define OSPF_CHECK_AGE 300
61 #define OSPF_LSA_MAXAGE_DIFF 900
62 #define OSPF_LS_INFINITY 0xffffff
63 #define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
64 #define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
65 #define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
67 #define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
68 #define OSPF_NSSA_TRANS_STABLE_DEFAULT 40
70 #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
71 #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
73 /* XXX Where is this used? And why it was used only if compiled with
75 #define OSPF_LOOPer 0x7f000000 /* 127.0.0.0 */
77 #define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
79 /* OSPF Authentication Type. */
80 #define OSPF_AUTH_NULL 0
81 #define OSPF_AUTH_SIMPLE 1
82 #define OSPF_AUTH_CRYPTOGRAPHIC 2
83 /* For Interface authentication setting default */
84 #define OSPF_AUTH_NOTSET -1
85 /* For the consumption and sanity of the command handler */
86 /* DO NIOT REMOVE!!! Need to detect whether a value has
87 been given or not in VLink command handlers */
88 #define OSPF_AUTH_CMD_NOTSEEN -2
90 /* OSPF SPF timer values. */
91 #define OSPF_SPF_DELAY_DEFAULT 1
92 #define OSPF_SPF_HOLDTIME_DEFAULT 1
94 /* OSPF interface default values. */
95 #define OSPF_OUTPUT_COST_DEFAULT 10
96 #define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
97 #define OSPF_HELLO_INTERVAL_DEFAULT 10
98 #define OSPF_ROUTER_PRIORITY_DEFAULT 1
99 #define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
100 #define OSPF_TRANSMIT_DELAY_DEFAULT 1
101 #define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
103 #define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
105 #define OSPF_POLL_INTERVAL_DEFAULT 60
106 #define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
108 #define OSPF_MTU_IGNORE_DEFAULT 0
111 #define OSPF_OPTION_T 0x01 /* TOS. */
112 #define OSPF_OPTION_E 0x02
113 #define OSPF_OPTION_MC 0x04
114 #define OSPF_OPTION_NP 0x08
115 #define OSPF_OPTION_EA 0x10
116 #define OSPF_OPTION_DC 0x20
117 #define OSPF_OPTION_O 0x40
119 /* OSPF Database Description flags. */
120 #define OSPF_DD_FLAG_MS 0x01
121 #define OSPF_DD_FLAG_M 0x02
122 #define OSPF_DD_FLAG_I 0x04
123 #define OSPF_DD_FLAG_ALL 0x07
126 #define OSPF_ROUTER_ID_UPDATE_DELAY 1
128 #define OSPF_LS_REFRESH_SHIFT (60 * 15)
129 #define OSPF_LS_REFRESH_JITTER 60
131 /* OSPF master for system wide configuration and variables. */
137 /* OSPF thread master. */
138 struct thread_master
*master
;
140 /* Zebra interface list. */
143 /* Redistributed external information. */
144 struct route_table
*external_info
[ZEBRA_ROUTE_MAX
+ 1];
145 #define EXTERNAL_INFO(T) om->external_info[T]
147 /* OSPF start time. */
150 /* Various OSPF global configuration. */
154 /* OSPF instance structure. */
157 /* OSPF Router ID. */
158 struct in_addr router_id
; /* Configured automatically. */
159 struct in_addr router_id_static
; /* Configured manually. */
161 /* ABR/ASBR internal flags. */
163 #define OSPF_FLAG_ABR 0x0001
164 #define OSPF_FLAG_ASBR 0x0002
168 #define OSPF_ABR_UNKNOWN 0
169 #define OSPF_ABR_STAND 1
170 #define OSPF_ABR_IBM 2
171 #define OSPF_ABR_CISCO 3
172 #define OSPF_ABR_SHORTCUT 4
173 #define OSPF_ABR_DEFAULT OSPF_ABR_CISCO
176 u_char anyNSSA
; /* Bump for every NSSA attached. */
178 /* Configured variables. */
180 #define OSPF_RFC1583_COMPATIBLE (1 << 0)
181 #define OSPF_OPAQUE_CAPABLE (1 << 2)
183 #ifdef HAVE_OPAQUE_LSA
184 /* Opaque-LSA administrative flags. */
186 #define OPAQUE_OPERATION_READY_BIT (1 << 0)
187 #define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1)
188 #define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2)
189 #define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3)
190 #endif /* HAVE_OPAQUE_LSA */
192 int spf_delay
; /* SPF delay time. */
193 int spf_holdtime
; /* SPF hold time. */
194 int default_originate
; /* Default information originate. */
195 #define DEFAULT_ORIGINATE_NONE 0
196 #define DEFAULT_ORIGINATE_ZEBRA 1
197 #define DEFAULT_ORIGINATE_ALWAYS 2
198 u_int32_t ref_bandwidth
; /* Reference Bandwidth (Kbps). */
199 struct route_table
*networks
; /* OSPF config networks. */
200 struct list
*vlinks
; /* Configured Virtual-Links. */
201 struct list
*areas
; /* OSPF areas. */
202 struct route_table
*nbr_nbma
;
203 struct ospf_area
*backbone
; /* Pointer to the Backbone Area. */
205 struct list
*oiflist
; /* ospf interfaces */
207 /* LSDB of AS-external-LSAs. */
208 struct ospf_lsdb
*lsdb
;
211 int external_origin
; /* AS-external-LSA origin flag. */
212 int ase_calc
; /* ASE calculation flag. */
214 #ifdef HAVE_OPAQUE_LSA
215 struct list
*opaque_lsa_self
; /* Type-11 Opaque-LSAs */
216 #endif /* HAVE_OPAQUE_LSA */
218 /* Routing tables. */
219 struct route_table
*old_table
; /* Old routing table. */
220 struct route_table
*new_table
; /* Current routing table. */
222 struct route_table
*old_rtrs
; /* Old ABR/ASBR RT. */
223 struct route_table
*new_rtrs
; /* New ABR/ASBR RT. */
225 struct route_table
*new_external_route
; /* New External Route. */
226 struct route_table
*old_external_route
; /* Old External Route. */
228 struct route_table
*external_lsas
; /* Database of external LSAs,
229 prefix is LSA's adv. network*/
232 time_t ts_spf
; /* SPF calculation time stamp. */
234 struct list
*maxage_lsa
; /* List of MaxAge LSA for deletion. */
235 int redistribute
; /* Num of redistributed protocols. */
238 struct thread
*t_router_id_update
; /* Router ID update timer. */
239 struct thread
*t_router_lsa_update
; /* router-LSA update timer. */
240 struct thread
*t_abr_task
; /* ABR task timer. */
241 struct thread
*t_asbr_check
; /* ASBR check timer. */
242 struct thread
*t_distribute_update
; /* Distirbute list update timer. */
243 struct thread
*t_spf_calc
; /* SPF calculation timer. */
244 struct thread
*t_ase_calc
; /* ASE calculation timer. */
245 struct thread
*t_external_lsa
; /* AS-external-LSA origin timer. */
246 #ifdef HAVE_OPAQUE_LSA
247 struct thread
*t_opaque_lsa_self
; /* Type-11 Opaque-LSAs origin event. */
248 #endif /* HAVE_OPAQUE_LSA */
249 struct thread
*t_maxage
; /* MaxAge LSA remover timer. */
250 struct thread
*t_maxage_walker
; /* MaxAge LSA checking timer. */
252 struct thread
*t_write
;
253 struct thread
*t_read
;
256 struct list
*oi_write_q
;
258 /* Distribute lists out of other route sources. */
262 struct access_list
*list
;
263 } dlist
[ZEBRA_ROUTE_MAX
];
264 #define DISTRIBUTE_NAME(O,T) (O)->dlist[T].name
265 #define DISTRIBUTE_LIST(O,T) (O)->dlist[T].list
267 /* Redistribute metric info. */
270 int type
; /* External metric type (E1 or E2). */
271 int value
; /* Value for static metric (24-bit).
272 -1 means metric value is not set. */
273 } dmetric
[ZEBRA_ROUTE_MAX
+ 1];
275 /* For redistribute route map. */
279 struct route_map
*map
;
280 } route_map
[ZEBRA_ROUTE_MAX
+ 1]; /* +1 is for default-information */
281 #define ROUTEMAP_NAME(O,T) (O)->route_map[T].name
282 #define ROUTEMAP(O,T) (O)->route_map[T].map
284 int default_metric
; /* Default metric for redistribute. */
286 #define OSPF_LSA_REFRESHER_GRANULARITY 10
287 #define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
288 OSPF_LS_REFRESH_SHIFT)/10 + 1)
292 struct list
*qs
[OSPF_LSA_REFRESHER_SLOTS
];
295 struct thread
*t_lsa_refresher
;
296 time_t lsa_refresher_started
;
297 #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
298 u_int16_t lsa_refresh_interval
;
300 /* Distance parameter. */
302 u_char distance_intra
;
303 u_char distance_inter
;
304 u_char distance_external
;
306 /* Statistics for LSA origination. */
307 u_int32_t lsa_originate_count
;
309 /* Statistics for LSA used for new instantiation. */
310 u_int32_t rx_lsa_count
;
312 struct route_table
*distance_table
;
315 /* OSPF area structure. */
321 /* Zebra interface list belonging to the area. */
322 struct list
*oiflist
;
325 struct in_addr area_id
;
327 /* Area ID format. */
329 #define OSPF_AREA_ID_FORMAT_ADDRESS 1
330 #define OSPF_AREA_ID_FORMAT_DECIMAL 2
333 struct list
*address_range
;
335 /* Configured variables. */
336 int external_routing
; /* ExternalRoutingCapability. */
337 #define OSPF_AREA_DEFAULT 0
338 #define OSPF_AREA_STUB 1
339 #define OSPF_AREA_NSSA 2
340 #define OSPF_AREA_TYPE_MAX 3
341 int no_summary
; /* Don't inject summaries into stub.*/
342 int shortcut_configured
; /* Area configured as shortcut. */
343 #define OSPF_SHORTCUT_DEFAULT 0
344 #define OSPF_SHORTCUT_ENABLE 1
345 #define OSPF_SHORTCUT_DISABLE 2
346 int shortcut_capability
; /* Other ABRs agree on S-bit */
347 u_int32_t default_cost
; /* StubDefaultCost. */
348 int auth_type
; /* Authentication type. */
350 u_char NSSATranslatorRole
; /* NSSA configured role */
351 #define OSPF_NSSA_ROLE_NEVER 0
352 #define OSPF_NSSA_ROLE_CANDIDATE 1
353 #define OSPF_NSSA_ROLE_ALWAYS 2
354 u_char NSSATranslatorState
; /* NSSA operational role */
355 #define OSPF_NSSA_TRANSLATE_DISABLED 0
356 #define OSPF_NSSA_TRANSLATE_ENABLED 1
357 int NSSATranslatorStabilityInterval
;
359 u_char transit
; /* TransitCapability. */
360 #define OSPF_TRANSIT_FALSE 0
361 #define OSPF_TRANSIT_TRUE 1
362 struct route_table
*ranges
; /* Configured Area Ranges. */
364 /* Area related LSDBs[Type1-4]. */
365 struct ospf_lsdb
*lsdb
;
367 /* Self-originated LSAs. */
368 struct ospf_lsa
*router_lsa_self
;
369 #ifdef HAVE_OPAQUE_LSA
370 struct list
*opaque_lsa_self
; /* Type-10 Opaque-LSAs */
371 #endif /* HAVE_OPAQUE_LSA */
373 /* Area announce list. */
377 struct access_list
*list
;
379 #define EXPORT_NAME(A) (A)->export.name
380 #define EXPORT_LIST(A) (A)->export.list
382 /* Area acceptance list. */
386 struct access_list
*list
;
388 #define IMPORT_NAME(A) (A)->import.name
389 #define IMPORT_LIST(A) (A)->import.list
391 /* Type 3 LSA Area prefix-list. */
395 struct prefix_list
*list
;
397 #define PREFIX_LIST_IN(A) (A)->plist_in.list
398 #define PREFIX_NAME_IN(A) (A)->plist_in.name
403 struct prefix_list
*list
;
405 #define PREFIX_LIST_OUT(A) (A)->plist_out.list
406 #define PREFIX_NAME_OUT(A) (A)->plist_out.name
408 /* Shortest Path Tree. */
412 struct thread
*t_router_lsa_self
;/* Self-originated router-LSA timer. */
413 #ifdef HAVE_OPAQUE_LSA
414 struct thread
*t_opaque_lsa_self
; /* Type-10 Opaque-LSAs origin. */
415 #endif /* HAVE_OPAQUE_LSA */
417 /* Statistics field. */
418 u_int32_t spf_calculation
; /* SPF Calculation Count. */
421 u_int32_t abr_count
; /* ABR router in this area. */
422 u_int32_t asbr_count
; /* ASBR router in this area. */
425 u_int32_t act_ints
; /* Active interfaces. */
426 u_int32_t full_nbrs
; /* Fully adjacent neighbors. */
427 u_int32_t full_vls
; /* Fully adjacent virtual neighbors. */
430 /* OSPF config network structure. */
434 struct in_addr area_id
;
438 /* OSPF NBMA neighbor structure. */
441 /* Neighbor IP address. */
444 /* OSPF interface. */
445 struct ospf_interface
*oi
;
447 /* OSPF neighbor structure. */
448 struct ospf_neighbor
*nbr
;
450 /* Neighbor priority. */
453 /* Poll timer value. */
456 /* Poll timer thread. */
457 struct thread
*t_poll
;
460 u_int32_t state_change
;
464 #define OSPF_AREA_SAME(X,Y) \
465 (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
467 #define IS_OSPF_ABR(O) ((O)->flags & OSPF_FLAG_ABR)
468 #define IS_OSPF_ASBR(O) ((O)->flags & OSPF_FLAG_ASBR)
470 #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
471 #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
474 # define ROUNDUP(val, gran) roundup(val, gran)
476 # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
479 #define LSA_OPTIONS_GET(area) \
480 (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
481 #define LSA_OPTIONS_NSSA_GET(area) \
482 (((area)->external_routing == OSPF_AREA_NSSA) ? OSPF_OPTION_NP : 0)
484 #define OSPF_TIMER_ON(T,F,V) \
487 (T) = thread_add_timer (master, (F), ospf, (V)); \
490 #define OSPF_AREA_TIMER_ON(T,F,V) \
493 (T) = thread_add_timer (master, (F), area, (V)); \
496 #define OSPF_POLL_TIMER_ON(T,F,V) \
499 (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
502 #define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
504 #define OSPF_TIMER_OFF(X) \
513 /* Extern variables. */
514 extern struct ospf_master
*om
;
515 extern struct message ospf_ism_state_msg
[];
516 extern struct message ospf_nsm_state_msg
[];
517 extern struct message ospf_lsa_type_msg
[];
518 extern struct message ospf_link_state_id_type_msg
[];
519 extern struct message ospf_network_type_msg
[];
520 extern int ospf_ism_state_msg_max
;
521 extern int ospf_nsm_state_msg_max
;
522 extern int ospf_lsa_type_msg_max
;
523 extern int ospf_link_state_id_type_msg_max
;
524 extern int ospf_redistributed_proto_max
;
525 extern int ospf_network_type_msg_max
;
526 extern struct zclient
*zclient
;
527 extern struct thread_master
*master
;
528 extern int ospf_zlog
;
531 extern const char *ospf_redist_string(u_int route_type
);
532 extern struct ospf
*ospf_lookup (void);
533 extern struct ospf
*ospf_get (void);
534 extern void ospf_finish (struct ospf
*);
535 extern int ospf_router_id_update_timer (struct thread
*);
536 extern void ospf_router_id_update (struct ospf
*ospf
);
537 extern int ospf_network_match_iface (struct connected
*, struct prefix
*);
538 extern int ospf_network_set (struct ospf
*, struct prefix_ipv4
*,
540 extern int ospf_network_unset (struct ospf
*, struct prefix_ipv4
*,
542 extern int ospf_area_stub_set (struct ospf
*, struct in_addr
);
543 extern int ospf_area_stub_unset (struct ospf
*, struct in_addr
);
544 extern int ospf_area_no_summary_set (struct ospf
*, struct in_addr
);
545 extern int ospf_area_no_summary_unset (struct ospf
*, struct in_addr
);
546 extern int ospf_area_nssa_set (struct ospf
*, struct in_addr
);
547 extern int ospf_area_nssa_unset (struct ospf
*, struct in_addr
);
548 extern int ospf_area_nssa_translator_role_set (struct ospf
*, struct in_addr
,
550 extern int ospf_area_export_list_set (struct ospf
*, struct ospf_area
*,
552 extern int ospf_area_export_list_unset (struct ospf
*, struct ospf_area
*);
553 extern int ospf_area_import_list_set (struct ospf
*, struct ospf_area
*,
555 extern int ospf_area_import_list_unset (struct ospf
*, struct ospf_area
*);
556 extern int ospf_area_shortcut_set (struct ospf
*, struct ospf_area
*, int);
557 extern int ospf_area_shortcut_unset (struct ospf
*, struct ospf_area
*);
558 extern int ospf_timers_spf_set (struct ospf
*, u_int32_t
, u_int32_t
);
559 extern int ospf_timers_spf_unset (struct ospf
*);
560 extern int ospf_timers_refresh_set (struct ospf
*, int);
561 extern int ospf_timers_refresh_unset (struct ospf
*);
562 extern int ospf_nbr_nbma_set (struct ospf
*, struct in_addr
);
563 extern int ospf_nbr_nbma_unset (struct ospf
*, struct in_addr
);
564 extern int ospf_nbr_nbma_priority_set (struct ospf
*, struct in_addr
, u_char
);
565 extern int ospf_nbr_nbma_priority_unset (struct ospf
*, struct in_addr
);
566 extern int ospf_nbr_nbma_poll_interval_set (struct ospf
*, struct in_addr
,
568 extern int ospf_nbr_nbma_poll_interval_unset (struct ospf
*, struct in_addr
);
569 extern void ospf_prefix_list_update (struct prefix_list
*);
570 extern void ospf_init (void);
571 extern void ospf_if_update (struct ospf
*);
572 extern void ospf_ls_upd_queue_empty (struct ospf_interface
*);
573 extern void ospf_terminate (void);
574 extern void ospf_nbr_nbma_if_update (struct ospf
*, struct ospf_interface
*);
575 extern struct ospf_nbr_nbma
*ospf_nbr_nbma_lookup (struct ospf
*,
577 extern struct ospf_nbr_nbma
*ospf_nbr_nbma_lookup_next (struct ospf
*,
580 extern int ospf_oi_count (struct interface
*);
582 extern struct ospf_area
*ospf_area_get (struct ospf
*, struct in_addr
, int);
583 extern void ospf_area_check_free (struct ospf
*, struct in_addr
);
584 extern struct ospf_area
*ospf_area_lookup_by_area_id (struct ospf
*,
586 extern void ospf_area_add_if (struct ospf_area
*, struct ospf_interface
*);
587 extern void ospf_area_del_if (struct ospf_area
*, struct ospf_interface
*);
589 extern void ospf_route_map_init (void);
590 extern void ospf_snmp_init (void);
592 extern void ospf_master_init (void);
594 #endif /* _ZEBRA_OSPFD_H */