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
28 #define OSPF_VERSION 2
30 /* Default protocol, port number. */
31 #ifndef IPPROTO_OSPFIGP
32 #define IPPROTO_OSPFIGP 89
33 #endif /* IPPROTO_OSPFIGP */
35 /* VTY port number. */
36 #define OSPF_VTY_PORT 2604
37 #define OSPF_VTYSH_PATH "/tmp/.ospfd"
39 /* IP TTL for OSPF protocol. */
41 #define OSPF_VL_IP_TTL 100
43 /* Default configuration file name for ospfd. */
44 #define OSPF_DEFAULT_CONFIG "ospfd.conf"
46 /* Architectual Constants */
48 #define OSPF_LS_REFRESH_TIME 60
50 #define OSPF_LS_REFRESH_TIME 1800
52 #define OSPF_MIN_LS_INTERVAL 5
53 #define OSPF_MIN_LS_ARRIVAL 1
54 #define OSPF_LSA_MAXAGE 3600
55 #define OSPF_CHECK_AGE 300
56 #define OSPF_LSA_MAXAGE_DIFF 900
57 #define OSPF_LS_INFINITY 0xffffff
58 #define OSPF_DEFAULT_DESTINATION 0x00000000 /* 0.0.0.0 */
59 #define OSPF_INITIAL_SEQUENCE_NUMBER 0x80000001
60 #define OSPF_MAX_SEQUENCE_NUMBER 0x7fffffff
62 #define OSPF_LSA_MAXAGE_CHECK_INTERVAL 30
64 #define OSPF_ALLSPFROUTERS 0xe0000005 /* 224.0.0.5 */
65 #define OSPF_ALLDROUTERS 0xe0000006 /* 224.0.0.6 */
68 #define OSPF_LOOPer 0x7f000000 /* 127.0.0.0 */
69 #endif /* HAVE_NSSA */
71 #define OSPF_AREA_BACKBONE 0x00000000 /* 0.0.0.0 */
73 /* OSPF Authentication Type. */
74 #define OSPF_AUTH_NULL 0
75 #define OSPF_AUTH_SIMPLE 1
76 #define OSPF_AUTH_CRYPTOGRAPHIC 2
77 /* For Interface authentication setting default */
78 #define OSPF_AUTH_NOTSET -1
79 /* For the consumption and sanity of the command handler */
80 /* DO NIOT REMOVE!!! Need to detect whether a value has
81 been given or not in VLink command handlers */
82 #define OSPF_AUTH_CMD_NOTSEEN -2
84 /* OSPF SPF timer values. */
85 #define OSPF_SPF_DELAY_DEFAULT 5
86 #define OSPF_SPF_HOLDTIME_DEFAULT 10
88 /* OSPF interface default values. */
89 #define OSPF_OUTPUT_COST_DEFAULT 10
90 #define OSPF_ROUTER_DEAD_INTERVAL_DEFAULT 40
91 #define OSPF_HELLO_INTERVAL_DEFAULT 10
92 #define OSPF_ROUTER_PRIORITY_DEFAULT 1
93 #define OSPF_RETRANSMIT_INTERVAL_DEFAULT 5
94 #define OSPF_TRANSMIT_DELAY_DEFAULT 1
95 #define OSPF_DEFAULT_BANDWIDTH 10000 /* Kbps */
97 #define OSPF_DEFAULT_REF_BANDWIDTH 100000 /* Kbps */
99 #define OSPF_POLL_INTERVAL_DEFAULT 60
100 #define OSPF_NEIGHBOR_PRIORITY_DEFAULT 0
103 #define OSPF_OPTION_T 0x01 /* TOS. */
104 #define OSPF_OPTION_E 0x02
105 #define OSPF_OPTION_MC 0x04
106 #define OSPF_OPTION_NP 0x08
107 #define OSPF_OPTION_EA 0x10
108 #define OSPF_OPTION_DC 0x20
109 #define OSPF_OPTION_O 0x40
111 /* OSPF Database Description flags. */
112 #define OSPF_DD_FLAG_MS 0x01
113 #define OSPF_DD_FLAG_M 0x02
114 #define OSPF_DD_FLAG_I 0x04
115 #define OSPF_DD_FLAG_ALL 0x07
118 #define OSPF_ROUTER_ID_UPDATE_DELAY 1
120 #define OSPF_LS_REFRESH_SHIFT (60 * 15)
121 #define OSPF_LS_REFRESH_JITTER 60
123 /* OSPF instance structure. */
126 /* OSPF Router ID. */
127 struct in_addr router_id
; /* Configured automatically. */
128 struct in_addr router_id_static
; /* Configured manually. */
130 /* ABR/ASBR internal flags. */
132 #define OSPF_FLAG_ABR 0x0001
133 #define OSPF_FLAG_ASBR 0x0002
137 #define OSPF_ABR_UNKNOWN 0
138 #define OSPF_ABR_STAND 1
139 #define OSPF_ABR_IBM 2
140 #define OSPF_ABR_CISCO 3
141 #define OSPF_ABR_SHORTCUT 4
144 u_char anyNSSA
; /* Bump for every NSSA attached. */
146 /* Configured variables. */
148 #define OSPF_RFC1583_COMPATIBLE (1 << 0)
149 #define OSPF_OPAQUE_CAPABLE (1 << 2)
151 #ifdef HAVE_OPAQUE_LSA
152 /* Opaque-LSA administrative flags. */
154 #define OPAQUE_OPERATION_READY_BIT (1 << 0)
155 #define OPAQUE_BLOCK_TYPE_09_LSA_BIT (1 << 1)
156 #define OPAQUE_BLOCK_TYPE_10_LSA_BIT (1 << 2)
157 #define OPAQUE_BLOCK_TYPE_11_LSA_BIT (1 << 3)
158 #endif /* HAVE_OPAQUE_LSA */
160 int spf_delay
; /* SPF delay time. */
161 int spf_holdtime
; /* SPF hold time. */
162 int default_originate
; /* Default information originate. */
163 #define DEFAULT_ORIGINATE_NONE 0
164 #define DEFAULT_ORIGINATE_ZEBRA 1
165 #define DEFAULT_ORIGINATE_ALWAYS 2
166 u_int32_t ref_bandwidth
; /* Reference Bandwidth (Kbps). */
167 struct route_table
*networks
; /* OSPF config networks. */
168 list vlinks
; /* Configured Virtual-Links. */
169 list areas
; /* OSPF areas. */
170 struct route_table
*nbr_nbma
;
171 struct ospf_area
*backbone
; /* Pointer to the Backbone Area. */
173 list iflist
; /* Zebra derived interfaces. */
174 list oiflist
; /* ospf interfaces */
176 /* LSDB of AS-external-LSAs. */
177 struct ospf_lsdb
*lsdb
;
179 /* Redistributed external information. */
180 struct route_table
*external_info
[ZEBRA_ROUTE_MAX
+ 1];
181 #define EXTERNAL_INFO(T) ospf_top->external_info[T]
184 int external_origin
; /* AS-external-LSA origin flag. */
185 int ase_calc
; /* ASE calculation flag. */
187 #ifdef HAVE_OPAQUE_LSA
188 list opaque_lsa_self
; /* Type-11 Opaque-LSAs */
189 #endif /* HAVE_OPAQUE_LSA */
191 /* Routing tables. */
192 struct route_table
*old_table
; /* Old routing table. */
193 struct route_table
*new_table
; /* Current routing table. */
195 struct route_table
*old_rtrs
; /* Old ABR/ASBR RT. */
196 struct route_table
*new_rtrs
; /* New ABR/ASBR RT. */
198 struct route_table
*new_external_route
; /* New External Route. */
199 struct route_table
*old_external_route
; /* Old External Route. */
201 struct route_table
*external_lsas
; /* Database of external LSAs,
202 prefix is LSA's adv. network*/
205 time_t ts_spf
; /* SPF calculation time stamp. */
207 list maxage_lsa
; /* List of MaxAge LSA for deletion. */
208 int redistribute
; /* Num of redistributed protocols. */
211 struct thread
*t_router_id_update
; /* Router ID update timer. */
212 struct thread
*t_router_lsa_update
; /* router-LSA update timer. */
213 struct thread
*t_abr_task
; /* ABR task timer. */
214 struct thread
*t_asbr_check
; /* ASBR check timer. */
215 struct thread
*t_distribute_update
; /* Distirbute list update timer. */
216 struct thread
*t_spf_calc
; /* SPF calculation timer. */
217 struct thread
*t_ase_calc
; /* ASE calculation timer. */
218 struct thread
*t_external_lsa
; /* AS-external-LSA origin timer. */
219 #ifdef HAVE_OPAQUE_LSA
220 struct thread
*t_opaque_lsa_self
; /* Type-11 Opaque-LSAs origin event. */
221 #endif /* HAVE_OPAQUE_LSA */
222 struct thread
*t_maxage
; /* MaxAge LSA remover timer. */
223 struct thread
*t_maxage_walker
; /* MaxAge LSA checking timer. */
225 struct thread
*t_write
;
226 struct thread
*t_read
;
230 /* Distribute lists out of other route sources. */
234 struct access_list
*list
;
235 } dlist
[ZEBRA_ROUTE_MAX
];
236 #define DISTRIBUTE_NAME(T) ospf_top->dlist[T].name
237 #define DISTRIBUTE_LIST(T) ospf_top->dlist[T].list
239 /* Redistribute metric info. */
242 int type
; /* External metric type (E1 or E2). */
243 int value
; /* Value for static metric (24-bit).
244 -1 means metric value is not set. */
245 } dmetric
[ZEBRA_ROUTE_MAX
+ 1];
247 /* For redistribute route map. */
251 struct route_map
*map
;
252 } route_map
[ZEBRA_ROUTE_MAX
+ 1]; /* +1 is for default-information */
253 #define ROUTEMAP_NAME(T) ospf_top->route_map[T].name
254 #define ROUTEMAP(T) ospf_top->route_map[T].map
256 int default_metric
; /* Default metric for redistribute. */
258 #define OSPF_LSA_REFRESHER_GRANULARITY 10
259 #define OSPF_LSA_REFRESHER_SLOTS ((OSPF_LS_REFRESH_TIME + \
260 OSPF_LS_REFRESH_SHIFT)/10 + 1)
264 list qs
[OSPF_LSA_REFRESHER_SLOTS
];
267 struct thread
*t_lsa_refresher
;
268 time_t lsa_refresher_started
;
269 #define OSPF_LSA_REFRESH_INTERVAL_DEFAULT 10
270 u_int16_t lsa_refresh_interval
;
272 /* Distance parameter. */
274 u_char distance_intra
;
275 u_char distance_inter
;
276 u_char distance_external
;
278 /* Statistics for LSA origination. */
279 u_int32_t lsa_originate_count
;
281 /* Statistics for LSA used for new instantiation. */
282 u_int32_t rx_lsa_count
;
284 struct route_table
*distance_table
;
287 /* OSPF area structure. */
293 /* Zebra interface list belonging to the area. */
297 struct in_addr area_id
;
299 /* Area ID format. */
301 #define OSPF_AREA_ID_FORMAT_ADDRESS 1
302 #define OSPF_AREA_ID_FORMAT_DECIMAL 2
307 /* Configured variables. */
308 int external_routing
; /* ExternalRoutingCapability. */
309 #define OSPF_AREA_DEFAULT 0
310 #define OSPF_AREA_STUB 1
311 #define OSPF_AREA_NSSA 2
312 #define OSPF_AREA_TYPE_MAX 3
313 int no_summary
; /* Don't inject summaries into stub.*/
314 int shortcut_configured
; /* Area configured as shortcut. */
315 #define OSPF_SHORTCUT_DEFAULT 0
316 #define OSPF_SHORTCUT_ENABLE 1
317 #define OSPF_SHORTCUT_DISABLE 2
318 int shortcut_capability
; /* Other ABRs agree on S-bit */
319 u_int32_t default_cost
; /* StubDefaultCost. */
320 int auth_type
; /* Authentication type. */
322 u_char NSSATranslatorRole
; /* NSSA Role during configuration */
323 #define OSPF_NSSA_ROLE_NEVER 0
324 #define OSPF_NSSA_ROLE_ALWAYS 1
325 #define OSPF_NSSA_ROLE_CANDIDATE 2
326 u_char NSSATranslator
; /* NSSA Role after election process */
328 u_char transit
; /* TransitCapability. */
329 #define OSPF_TRANSIT_FALSE 0
330 #define OSPF_TRANSIT_TRUE 1
331 struct route_table
*ranges
; /* Configured Area Ranges. */
333 /* Area related LSDBs[Type1-4]. */
334 struct ospf_lsdb
*lsdb
;
336 /* Self-originated LSAs. */
337 struct ospf_lsa
*router_lsa_self
;
338 #ifdef HAVE_OPAQUE_LSA
339 list opaque_lsa_self
; /* Type-10 Opaque-LSAs */
340 #endif /* HAVE_OPAQUE_LSA */
342 /* Area announce list. */
346 struct access_list
*list
;
348 #define EXPORT_NAME(A) (A)->export.name
349 #define EXPORT_LIST(A) (A)->export.list
351 /* Area acceptance list. */
355 struct access_list
*list
;
357 #define IMPORT_NAME(A) (A)->import.name
358 #define IMPORT_LIST(A) (A)->import.list
360 /* Type 3 LSA Area prefix-list. */
364 struct prefix_list
*list
;
366 #define PREFIX_LIST_IN(A) (A)->plist_in.list
367 #define PREFIX_NAME_IN(A) (A)->plist_in.name
372 struct prefix_list
*list
;
374 #define PREFIX_LIST_OUT(A) (A)->plist_out.list
375 #define PREFIX_NAME_OUT(A) (A)->plist_out.name
377 /* Shortest Path Tree. */
381 struct thread
*t_router_lsa_self
;/* Self-originated router-LSA timer. */
382 #ifdef HAVE_OPAQUE_LSA
383 struct thread
*t_opaque_lsa_self
; /* Type-10 Opaque-LSAs origin. */
384 #endif /* HAVE_OPAQUE_LSA */
386 /* Statistics field. */
387 u_int32_t spf_calculation
; /* SPF Calculation Count. */
390 u_int32_t abr_count
; /* ABR router in this area. */
391 u_int32_t asbr_count
; /* ASBR router in this area. */
394 u_int32_t act_ints
; /* Active interfaces. */
395 u_int32_t full_nbrs
; /* Fully adjacent neighbors. */
396 u_int32_t full_vls
; /* Fully adjacent virtual neighbors. */
399 /* OSPF config network structure. */
403 struct in_addr area_id
;
407 /* OSPF NBMA neighbor structure. */
410 /* Neighbor IP address. */
413 /* OSPF interface. */
414 struct ospf_interface
*oi
;
416 /* OSPF neighbor structure. */
417 struct ospf_neighbor
*nbr
;
419 /* Neighbor priority. */
422 /* Poll timer value. */
425 /* Poll timer thread. */
426 struct thread
*t_poll
;
429 u_int32_t state_change
;
433 #define OSPF_AREA_SAME(X,Y) \
434 (memcmp ((X->area_id), (Y->area_id), IPV4_MAX_BYTELEN) == 0)
436 #define OSPF_IS_ABR (ospf_top->flags & OSPF_FLAG_ABR)
437 #define OSPF_IS_ASBR (ospf_top->flags & OSPF_FLAG_ASBR)
439 #define OSPF_IS_AREA_ID_BACKBONE(I) ((I).s_addr == OSPF_AREA_BACKBONE)
440 #define OSPF_IS_AREA_BACKBONE(A) OSPF_IS_AREA_ID_BACKBONE ((A)->area_id)
443 # define ROUNDUP(val, gran) roundup(val, gran)
445 # define ROUNDUP(val, gran) (((val) - 1 | (gran) - 1) + 1)
448 #define LSA_OPTIONS_GET(area) \
449 (((area)->external_routing == OSPF_AREA_DEFAULT) ? OSPF_OPTION_E : 0)
451 #define LSA_NSSA_GET(area) \
452 (((area)->external_routing == OSPF_AREA_NSSA) ? \
453 (area)->NSSATranslator : 0)
454 #endif /* HAVE_NSSA */
456 #define OSPF_TIMER_ON(T,F,V) \
459 (T) = thread_add_timer (master, (F), NULL, (V)); \
462 #define OSPF_AREA_TIMER_ON(T,F,V) \
465 (T) = thread_add_timer (master, (F), area, (V)); \
468 #define OSPF_POLL_TIMER_ON(T,F,V) \
471 (T) = thread_add_timer (master, (F), nbr_nbma, (V)); \
474 #define OSPF_POLL_TIMER_OFF(X) OSPF_TIMER_OFF((X))
476 #define OSPF_TIMER_OFF(X) \
485 #define OSPF_SCHEDULE_MAXAGE(T, F) \
488 (T) = thread_add_timer (master, (F), 0, 2); \
492 extern struct message ospf_ism_state_msg
[];
493 extern struct message ospf_nsm_state_msg
[];
494 extern struct message ospf_lsa_type_msg
[];
495 extern struct message ospf_link_state_id_type_msg
[];
496 extern struct message ospf_redistributed_proto
[];
497 extern struct message ospf_network_type_msg
[];
498 extern int ospf_ism_state_msg_max
;
499 extern int ospf_nsm_state_msg_max
;
500 extern int ospf_lsa_type_msg_max
;
501 extern int ospf_link_state_id_type_msg_max
;
502 extern int ospf_redistributed_proto_max
;
503 extern int ospf_network_type_msg_max
;
504 extern struct zclient
*zclient
;
505 extern struct thread_master
*master
;
506 extern struct ospf
*ospf_top
;
507 extern int ospf_zlog
;
510 struct ospf
*ospf_get ();
511 void ospf_finish (struct ospf
*);
512 int ospf_router_id_update_timer (struct thread
*);
513 void ospf_router_id_update ();
514 int ospf_network_set (struct ospf
*, struct prefix_ipv4
*, struct in_addr
);
515 int ospf_network_unset (struct ospf
*, struct prefix_ipv4
*, struct in_addr
);
516 int ospf_area_stub_set (struct ospf
*, struct in_addr
);
517 int ospf_area_stub_unset (struct ospf
*, struct in_addr
);
518 int ospf_area_no_summary_set (struct ospf
*, struct in_addr
);
519 int ospf_area_no_summary_unset (struct ospf
*, struct in_addr
);
520 int ospf_area_nssa_set (struct ospf
*, struct in_addr
);
521 int ospf_area_nssa_unset (struct ospf
*, struct in_addr
);
522 int ospf_area_nssa_translator_role_set (struct ospf
*, struct in_addr
, int);
523 int ospf_area_export_list_set (struct ospf_area
*, char *);
524 int ospf_area_export_list_unset (struct ospf_area
*);
525 int ospf_area_import_list_set (struct ospf_area
*, char *);
526 int ospf_area_import_list_unset (struct ospf_area
*);
527 int ospf_area_shortcut_set (struct ospf_area
*, int);
528 int ospf_area_shortcut_unset (struct ospf_area
*);
529 int ospf_timers_spf_set (struct ospf
*, u_int32_t
, u_int32_t
);
530 int ospf_timers_spf_unset (struct ospf
*);
531 int ospf_timers_refresh_set (struct ospf
*, int);
532 int ospf_timers_refresh_unset (struct ospf
*);
533 int ospf_nbr_nbma_set (struct ospf
*, struct in_addr
);
534 int ospf_nbr_nbma_unset (struct ospf
*, struct in_addr
);
535 int ospf_nbr_nbma_priority_set (struct ospf
*, struct in_addr
, u_char
);
536 int ospf_nbr_nbma_priority_unset (struct ospf
*, struct in_addr
);
537 int ospf_nbr_nbma_poll_interval_set (struct ospf
*, struct in_addr
, int);
538 int ospf_nbr_nbma_poll_interval_unset (struct ospf
*, struct in_addr
);
539 void ospf_prefix_list_update (struct prefix_list
*);
541 void ospf_if_update ();
542 void ospf_ls_upd_queue_empty (struct ospf_interface
*);
543 void ospf_terminate ();
544 void ospf_nbr_nbma_if_update (struct ospf_interface
*);
545 struct ospf_nbr_nbma
*ospf_nbr_nbma_lookup (struct ospf
*, struct in_addr
);
546 struct ospf_nbr_nbma
*ospf_nbr_nbma_lookup_next (struct in_addr
*, int);
547 int ospf_oi_count (struct interface
*);
549 struct ospf_area
*ospf_area_new (struct in_addr
);
550 struct ospf_area
*ospf_area_get (struct in_addr
, int);
551 void ospf_area_check_free (struct in_addr
);
552 struct ospf_area
*ospf_area_lookup_by_area_id (struct in_addr
);
553 void ospf_area_add_if (struct ospf_area
*, struct ospf_interface
*);
554 void ospf_area_del_if (struct ospf_area
*, struct ospf_interface
*);
556 void ospf_route_map_init ();
557 void ospf_snmp_init ();
559 #endif /* _ZEBRA_OSPFD_H */